260 likes | 432 Views
Design Patterns. Satzinger, Jackson, and Burd Object-Orieneted Analysis & Design. Summary Slide. Importance of Design Patterns Basic Design Patterns Designing Enterprise-level Systems Differences between client/server and Internet systems UML Notation for Deployment Diagrams
E N D
Design Patterns Satzinger, Jackson, and Burd Object-Orieneted Analysis & Design
Summary Slide • Importance of Design Patterns • Basic Design Patterns • Designing Enterprise-level Systems • Differences between client/server and Internet systems • UML Notation for Deployment Diagrams • Simple Internet Architecture • Two-layer Architecture • Three-layer Architecture • Web Services
Importance of Design Patterns • Standard design templates can speed OO design • Patterns can exist at different levels of abstraction • At the most concrete level, a class definition with code • At the most abstract level, an approach to a problem • Patterns should contain five main elements • Pattern name, problem, solution, example, benefits and consequences
Basic Design Patterns • The authors of Elements of Reusable Object-Oriented Software (referred to as the Gang of Four) developed a basic classification scheme for patterns • The 23 GoF patterns are some of the most fundamental and important patterns in use • Scores of other patterns have been defined • For example, both Java and .NET have sets of enterprise patterns
Singleton Pattern • For classes that must have only one instance, but need to be invoked from several classes and locations within the system • The class itself controls the creation of only one instance • A static variable of the class refers to the object that is created • A class method instantiates the object on the first call, and returns a reference to the object on subsequent calls
Adaptor Pattern • Plugs an external class into a system • Converts the method calls from within the system to match the method names in the external class • A standard solution for protection from variations • Insulates the system from frequently changing classes • An interface is frequently used to specify and enforce the use of correct method names
Observer pattern • Used to handle event-processing and reduce coupling • The domain class • Allows other classes to “subscribe” as listeners • “Publishes” the changes to the listeners • The windows class • Sends a reference of itself to subscribe as a listener • Implements the method to be invoked when notified Inherits the method from the listener interface
Figure 9-11 Three classes in the Create new order use case
Figure 9-12 Implementation of the observer pattern
Designing Enterprise-level Systems • Enterprise-level systems share components among multiple people or groups in an organization • Enterprise-level systems almost always use multiple tiers of computers • Can be client/server network-based or Internet based • Designed with deployment diagrams • A type of implementation diagram that shows physical components across different locations
UML Notation for Deployment Diagrams • Component • Executable module or program • Has an application program interface (API) that is available to the outside world • Node • A physical entity at a specific location • Frameset • A high-level object that holds items to be displayed by a browser
UML node notation UML extension for frameset
Simple Internet Architecture • Used for viewing static information • The browser component executes on the client computer • The Internet server component executes on the server computer • Pages reside on the server and are sent to the browser for display • Program logic is inserted through scripting languages, applets, or other controls
Two-layer Architecture • Primarily captures information from the user and updates the database • The domain layer and data access layer are usually combined • Input data is sent to a CGI or an application server • The user-interface classes often contain the business logic and data access • Processing takes place with servlets (Java) or code behind classes (.NET)
Three-layer Architecture • Separates domain layer and data access layers • Necessary for systems with complex business logic or multiple user interfaces • Using CGI • Provide a use case controller for each form • Using an application server • Java tools: Java Server Pages and servlets • .NET tools: Common Runtime Language and code behind classes
Three-layer Internet architecture
Web Services • A program that provides a service via the Internet • The service is posted in a directory so that systems can find it • Requests for information go to the UDDI directory • UDDI provides the Internet address of a program offering that service • The application then requests the information • All communication is based on XML to allow for generic data exchange