312 lines
4.7 KiB
Plaintext
312 lines
4.7 KiB
Plaintext
Application
|
||
Programming
|
||
Hend Alkittawi
|
||
|
||
MVC Architectural Pattern
|
||
Model-View-Controller Architectural
|
||
Pattern
|
||
|
||
CODE DEMO
|
||
-
|
||
|
||
Discuss the design of
|
||
a bank management app
|
||
|
||
MODEL-VIEW-CONTROLLER
|
||
Welcome to UTSA Bank Management System
|
||
What would you like to do?
|
||
1. Display Accounts
|
||
2. Add Account
|
||
3. Remove Account
|
||
4. Exit
|
||
1
|
||
Name: UTSA Bank
|
||
Account - name: Ash type: checking
|
||
Account - name: Sam type: saving
|
||
Account - name: Jen type: checking
|
||
Account - name: Mia type: saving
|
||
What would you like to do?
|
||
1. Display Accounts
|
||
2. Add Account
|
||
3. Remove Account
|
||
4. Exit
|
||
3
|
||
Enter account name:
|
||
Mia
|
||
What would you like to do?
|
||
1. Display Accounts
|
||
2. Add Account
|
||
3. Remove Account
|
||
4. Exit
|
||
2
|
||
Enter name and type:
|
||
Jim checking
|
||
|
||
What would you like to do?
|
||
1. Display Accounts
|
||
2. Add Account
|
||
3. Remove Account
|
||
4. Exit
|
||
1
|
||
Name: UTSA Bank
|
||
Account - name: Ash type: checking
|
||
Account - name: Sam type: saving
|
||
Account - name: Jen type: checking
|
||
Account - name: Jim type: checking
|
||
What would you like to do?
|
||
1. Display Accounts
|
||
2. Add Account
|
||
3. Remove Account
|
||
4. Exit
|
||
4
|
||
|
||
MODEL-VIEW-CONTROLLER
|
||
|
||
Welcome to UTSA Bank
|
||
Management System
|
||
|
||
What would you like to do?
|
||
View Accounts
|
||
|
||
Welcome to UTSA Bank
|
||
Management System
|
||
|
||
Welcome to UTSA Bank
|
||
Management System
|
||
|
||
Welcome to UTSA Bank
|
||
Management System
|
||
|
||
Here is a list of
|
||
accounts …
|
||
|
||
Enter Account Name
|
||
|
||
Enter Account Name
|
||
|
||
Select Account type
|
||
|
||
Add Account
|
||
Remove an Account
|
||
|
||
Add Account
|
||
|
||
Remove Account
|
||
|
||
Welcome to UTSA BankManagement System
|
||
What would you like to do?
|
||
1. Display Accounts
|
||
2. Add Account
|
||
3. Remove Account
|
||
4. Exit
|
||
1
|
||
Name: UTSA Bank
|
||
Account - name: Ash type: checking
|
||
Account - name: Sam type: saving
|
||
Account - name: Jen type: checking
|
||
Account - name: Mia type: saving
|
||
What would you like to do?
|
||
1. Display Accounts
|
||
2. Add Account
|
||
3. Remove Account
|
||
4. Exit
|
||
3
|
||
Enter account name:
|
||
Mia
|
||
What would you like to do?
|
||
1. Display Accounts
|
||
2. Add Account
|
||
3. Remove Account
|
||
4. Exit
|
||
2
|
||
Enter name and type:
|
||
Jim checking
|
||
|
||
Welcome to UTSA Bank
|
||
Management System
|
||
|
||
What would you like to do?
|
||
View Accounts
|
||
Add Account
|
||
Remove an Account
|
||
|
||
Welcome to UTSA Bank
|
||
Management System
|
||
|
||
Here is a list of
|
||
accounts …
|
||
|
||
Welcome to UTSA Bank
|
||
Management System
|
||
|
||
Welcome to UTSA Bank
|
||
Management System
|
||
|
||
What would you like to do?
|
||
|
||
Enter Account Name
|
||
|
||
View Accounts
|
||
|
||
Select Account type
|
||
|
||
Add Account
|
||
Remove an Account
|
||
|
||
Add Account
|
||
|
||
Welcome to UTSA Bank
|
||
Management System
|
||
|
||
What would you like to do?
|
||
|
||
Welcome to UTSA Bank
|
||
Management System
|
||
|
||
Enter Account Name
|
||
|
||
View Accounts
|
||
Add Account
|
||
Remove an Account
|
||
|
||
Remove Account
|
||
|
||
MODEL-VIEW-CONTROLLER
|
||
-
|
||
|
||
An architectural pattern captures the design structures of
|
||
various systems and elements of software so that they can be
|
||
reused.
|
||
|
||
-
|
||
|
||
Android applications can be designed around an architecture
|
||
called model-view-controller or MVC.
|
||
|
||
-
|
||
|
||
In MVC, all objects in your application must be a model
|
||
object, a view object, or a controller object.
|
||
|
||
-
|
||
|
||
MVC helps you design and understand an application, and makes
|
||
classes easier to reuse.
|
||
|
||
MODEL-VIEW-CONTROLLER
|
||
-
|
||
|
||
MVC is an architectural pattern which helps separate
|
||
-
|
||
|
||
the application logic from the user interface
|
||
|
||
-
|
||
|
||
the control between the user interface and the application
|
||
logic
|
||
|
||
model
|
||
data storage,
|
||
integrity, consistency,
|
||
queries & mutations
|
||
|
||
controller
|
||
view
|
||
receive, interpret &
|
||
validate input, create &
|
||
update views, query and
|
||
modify models
|
||
|
||
presentation assets &
|
||
code
|
||
|
||
user
|
||
|
||
MODEL
|
||
-
|
||
|
||
The model represents the data and the rules that govern access
|
||
to and updates of this data, and the business logic
|
||
|
||
-
|
||
|
||
A model often serves as a software approximation of a
|
||
real-world process
|
||
|
||
-
|
||
|
||
Designed and implemented as one or more classes
|
||
-
|
||
|
||
typically model the things your app is concerned with such as
|
||
a user, a product, a photo, at television show, … etc.
|
||
|
||
-
|
||
|
||
Model objects have no knowledge of the UI; its purpose is
|
||
holding and managing data.
|
||
|
||
VIEW
|
||
-
|
||
|
||
View objects know how to draw themselves on the screen
|
||
|
||
-
|
||
|
||
The view renders the contents of a model
|
||
|
||
-
|
||
|
||
The view specifies exactly how the model data should be
|
||
presented
|
||
|
||
-
|
||
|
||
If the model data changes, the view must update its
|
||
presentation as needed
|
||
|
||
-
|
||
|
||
Android provides a wealth of configurable view classes. You
|
||
can also create custom view classes.
|
||
|
||
CONTROLLER
|
||
-
|
||
|
||
Controller objects tie the View and Model objects together.
|
||
They contain application logic.
|
||
|
||
-
|
||
|
||
Controllers are designed to respond to various events
|
||
triggered by view objects and to manage the flow of data
|
||
between the model layer and the view layer.
|
||
-
|
||
|
||
The controller translates the user's interactions with the
|
||
view into actions that the model will perform
|
||
|
||
-
|
||
|
||
In Android, a controller is typically a subclass of Activity,
|
||
Fragment, or Service.
|
||
|
||
-
|
||
|
||
Implemented as one or more classes
|
||
|
||
DO YOU HAVE ANY
|
||
QUESTIONS?
|
||
|
||
THANK
|
||
YOU!
|
||
|
||
@
|
||
|
||
hend.alkittawi@utsa.edu
|
||
|
||
By Appointment
|
||
Online
|
||
|
||
|