Design and Programming Patterns Associated with Java Networking by Margaret Toews cs843, Spring 2003
Design Patterns History Benefits Description Examples Conclusion
Design Patterns – History Late 1970’s, book by Christopher Alexander published, domain – architectural design patterns 1987, OOPSLA conference, paper presented on design patterns in Smalltalk 1995, Design Patterns: Elements of Reusable Object-Oriented Software, published
Benefits of Design Patterns Provide a framework for naming solutions – templates provide a framework for description – give developers a vocabulary to use when collaborating Enable developers to document solutions Can build on expertise of others Can use solutions that have worked before –Rule of three
Design Pattern Template (GofF) Name Participants Classification Collaborations Intent Consequences Also Known As Implementation Motivation Sample Code Applicability Known Uses Structure Related Patterns
Template Attributes Name –Name –Classification –Also Known As (optional) –Intent What does this pattern do? Problem –Motivation A scenario that describes the problem –Applicability
Template Attributes (cont) Solution –Structure Can include UML or OMT diagrams –Participants List of classes and objects –Collaborations Other patterns involved –Implementation –Sample Code –Known Uses –Related Patterns
Template Attributes (cont) Consequences –Consequences Trade offs – often in flexibility, portability
Classification of Design Patterns
Problem: High Communication Overhead Solution Request data more efficiently –use Fast Lane Reader Pattern Make fewer remote method calls –use Half-Object Plus Protocol
Fast Lane Reader Pattern Motivation –Using EJB to implement a catalog of services for a financial services company –Customer wants to browse list of available online services Problem –High overhead to use EJB for read-only listing Possible solution –Avoid EJB, use direct access
Fast Lane Reader Pattern
Half-Object Plus Protocol Pattern Motivation –Using RMI to implement a Voting Services application Problem –Part of functionality should execute remotely, part locally Want to avoid using remote method calls for login Possible Solution –Split object and use a proxy to communicate between the two parts
Half-Object Plus Protocol
Conclusion Design patterns enable developers to build on solutions that have already been created. “Each pattern describes a problem that occurs over and over again in our environment and then describes the core of the solution to that problem in such a way that you can use this solutions a million times over without ever doing it the same way twice.” - Christopher Alexander