architectural design&patterns
TRANSCRIPT
![Page 1: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/1.jpg)
Architectural Design&
PatternsMembers:
Abdul Manan 1420 Areeba Riaz 1439
Junaid Majeed 1428 Allah Ditta 1419
![Page 2: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/2.jpg)
Architectural Pattern
• An architectural pattern is a general, reusable solution to acommonly occurring problem in software architecture.
• Architectural patterns are similar to software design pattern buthave a broader scope.
• Design patterns are medium-scale tactics that flesh out some of thestructure and behavior of entities and their relationships.
• Architectural patterns are high-level strategies that concerns large-scale components, the global properties and mechanisms of asystem.
• The architectural patterns address various issues in softwareengineering, such as computer hardware performancelimitations, high availability and minimization of a business risk.
![Page 3: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/3.jpg)
Architectural patterns 3
Categories of architectural patterns
• From mud to structure
• Patterns: Layers, “Pipes and filters”
• Distributed systems
• Patterns: Broker, Master-Slave
• Interactive systems
• Patterns: Model-View-Controller (MVC) ,MVP,MVVM
![Page 4: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/4.jpg)
Architectural patterns 4
Architectural Pattern - Layers
• Decompose overall system task into cooperating subtasks Examples
• TCP/IP, and other protocol stacks
• Java application, JVM, OS, physical machine
• Upper layer asks lower layer for service
![Page 5: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/5.jpg)
5
Architectural Pattern - Pipes and
filters
• System process a stream of data.
• Each processing step is encapsulated in a filter component.
• Examples
• A shell in an operating system, like Linux/UNIX or MS-DOS
• find “a” data.txt | sort | more
• Find all lines with “a” in data.txt | sort the lines | show the lines, one screen at a time
• Compilation of a Java program
• Lexical analysis | syntax analysis | semantic analysis | code generation
• Reuse of filter components
![Page 6: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/6.jpg)
6
Distributed systems
• A layered system can be distributed
• Each layer running on a separate computer
• Called “multi-tiered” system
• A “pipes and filters” system can be distributed
• Each filter running on a separate computer
• Pipes are network connections
![Page 7: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/7.jpg)
7
Architectural Pattern - Broker
• Coordinates communication between distributed components
• Broker features• Locate servers
• Forward messages
• Examples• CORBA
• Common Object Request Broker Architecture
• an architecture that enables pieces of programs, called objects, tocommunicate with one another regardless of what programminglanguage they were written in or what operating system they're running on.CORBA was developed by an industry consortium known as the ObjectManagement Group (OMG).
• Some chat / messenger systems
![Page 8: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/8.jpg)
8
Broker, consequences
• Benefits
• Location transparency
• Clients do not need to know where servers are.
• Servers can be moved to other computers.
• Changeability and extensibility
• Servers can be changed
• Keep the same interface
• Reusability
• Components can be reused in other application
• Liabilities
• Efficiency
• Fault tolerance
• Broker is not working => nothing is working
![Page 9: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/9.jpg)
9
Architectural Pattern
– Master-Slave
• Divide and conquer
• Master functions• Split work
• Call slaves
• Combine results
• Examples• Parallel processing
• Fault tolerance
• Computational accuracy
![Page 10: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/10.jpg)
10
Master-Slave, consequences
• Benefits
• Faster computation
• Split the problem over threads and machines.
• Robustness
• Slaves can be duplicated
![Page 11: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/11.jpg)
11
Interactive systems
• Interaction with the user
• Through graphical user interfaces
• System responds to events (user inputs)
• Functional core of the system must be kept independent of the user interface
• You must be able to add a new user interface to the system.
• A single system can have many user interfaces
• PC interface
• Web interface
• Mobil phone interface
![Page 12: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/12.jpg)
Interactive System Architectural
Patterns
• There are the followings architectural patterns:
• MVC – Model View Controller
• MVP – Model View Presenter
• MVVM – Model View View-Model
![Page 13: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/13.jpg)
MVC - Model View Controller
• Model View Controller or MVC as it is popularly called, is a design pattern for developing web applications. A Model View Controller pattern is made up of the following three parts:
• Model - The lowest level of the pattern which is responsible for maintaining data.
• View - This is responsible for displaying all or a portion of the data to the user.
• Controller - Software Code that controls the interactions between the Model and View.
• MVC is popular as it separates the application logic from the user interface layer and supports separation of concerns.
![Page 14: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/14.jpg)
The Model
• The model is responsible for managing the data of the
application.
• It responds to the request from the view and it also responds
to instructions from the controller to update itself.
The View• A presentation of data in a particular format, produced by
a controller's decision to present the data.
• They are script based templating systems like JSP, ASP,PHP and very easy to integrate with AJAX technology.
![Page 15: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/15.jpg)
The Controller
• The controller is responsible for responding to user input and perform interactions on the data model objects.
• The controller receives the input, it validates the input and then performs the business operation that modifies the state of the data model.
• Struts2 is a MVC based framework.
• Apache Struts 2 is an open-source web application framework for developing Java EE web applications. It uses and extends the Java Servlet API to encourage developers to adopt a model–view–controller (MVC) architecture
![Page 16: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/16.jpg)
![Page 17: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/17.jpg)
Implementation
• We are going to create a Student object acting as amodel.StudentView will be a view class which canprint student details on console.
• StudentController is the controller class responsible tostore data in Student object and updateviewStudentView accordingly.
• MVCPatternDemo, our demo class, willuse StudentController to demonstrate use of MVCpattern.
![Page 18: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/18.jpg)
![Page 19: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/19.jpg)
Sequence Diagram
![Page 20: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/20.jpg)
![Page 21: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/21.jpg)
![Page 22: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/22.jpg)
![Page 23: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/23.jpg)
![Page 24: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/24.jpg)
MVP – Model View Presenter
• This pattern is similar to MVC pattern in whichcontroller has been replaced by the presenter.
• This design pattern splits an application into threemain aspects:
• Model
• View
• Presenter
• Model and View are same as MVC.
![Page 25: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/25.jpg)
![Page 26: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/26.jpg)
The Presenter
• The Presenter is responsible for handling all UI events onbehalf of the view.
• This receive input from users via the View, then process theuser's data with the help of Model and passing the results backto the View.
• view and presenter communicate to each other’s by aninterface.
• Also, presenter does not manage the incoming request trafficas controller.
• There is one-to-one relationship between View and Presentermeans one View is mapped to only one Presenter.
![Page 27: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/27.jpg)
Sequence Diagram
![Page 28: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/28.jpg)
MVVM – Model View View-Model
• This design pattern splits an application into three
main aspects:
• Model
• View
• View Model
• Model and View are same as MVC.
![Page 29: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/29.jpg)
![Page 30: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/30.jpg)
The View Model
• The View Model is responsible for showing methods,commands, and other properties that helps to maintainthe state of the view, manipulate the model as the resultof actions on the view, and activate events in the viewitself.
• There is many-to-one relationship between View andViewModel means many View can be mapped to oneViewModel.
• the MVVM pattern allows your code to be consistentlytested through unit testing.
![Page 31: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/31.jpg)
The View Model
• A ViewModel is a model for a view in the application as shownby its name. It has a collection which contain the data from themodel currently needed for the view.
• The view binds to properties on a ViewModel, which, in turn,exposes data contained in model objects and other state specificto the view. The bindings between view and ViewModel aresimple to construct because a ViewModel object is set as theData Context of a view. If property values in the ViewModelchange, those new values automatically propagate to the viewvia data binding. When the user clicks a button in the View, acommand on the ViewModel executes to perform the requestedaction.
![Page 32: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/32.jpg)
Sequence Diagram
![Page 33: Architectural Design&Patterns](https://reader031.vdocuments.us/reader031/viewer/2022013013/5a6513197f8b9aa6218b4a4d/html5/thumbnails/33.jpg)
Summary