Presentation is loading. Please wait.

Presentation is loading. Please wait.

Using Software Design Patterns Bill Anderson. About me Fox developer since 1987 Fox developer since 1987 Program Director, Los Angeles Visual Foxpro Developers.

Similar presentations


Presentation on theme: "Using Software Design Patterns Bill Anderson. About me Fox developer since 1987 Fox developer since 1987 Program Director, Los Angeles Visual Foxpro Developers."— Presentation transcript:

1 Using Software Design Patterns Bill Anderson

2 About me Fox developer since 1987 Fox developer since 1987 Program Director, Los Angeles Visual Foxpro Developers Group (LAFox) Program Director, Los Angeles Visual Foxpro Developers Group (LAFox) Independent Consultant since 1991 Independent Consultant since 1991 SoCal speaker and author SoCal speaker and author

3 Design Patterns What are patterns? What are patterns? A solution to a problem in a context. A solution to a problem in a context. Similarities to architectural design issues. Similarities to architectural design issues.

4 Design Patterns Four elements to a design pattern Four elements to a design pattern Name Name When to apply pattern When to apply pattern Description of elements and responsibilities Description of elements and responsibilities Consequences of usage Consequences of usage You’re familiar with patterns! You’re familiar with patterns!

5 Bridge Pattern Definition: Decouple an abstraction from the implementation so the two can vary independently. Definition: Decouple an abstraction from the implementation so the two can vary independently. Fundamental design pattern Fundamental design pattern Three types of bridges Three types of bridges Reference bridges Reference bridges Multiple bridges Multiple bridges Aggregation bridges Aggregation bridges

6 Decorator Pattern Definition: Attach additional responsibilities to an object dynamically. Definition: Attach additional responsibilities to an object dynamically. Heuristic: Subclass all “black box” objects (VFP base classes, ActiveX controls, etc.) Heuristic: Subclass all “black box” objects (VFP base classes, ActiveX controls, etc.) Subclassed a control and changed its behavior? Then you know the pattern. Subclassed a control and changed its behavior? Then you know the pattern.

7 Adapter Pattern Definition: Convert the interface of a class into another interface clients expect. Definition: Convert the interface of a class into another interface clients expect. Adapters modify interfaces to an object (unlike Decorators, which modify behavior of an object). Makes an object look like another. Adapters modify interfaces to an object (unlike Decorators, which modify behavior of an object). Makes an object look like another.

8 Template Method Definition: Define the skeleton of an algorithm in an operation. Definition: Define the skeleton of an algorithm in an operation. Used to define a common sequence of events Used to define a common sequence of events Template methods contain Template methods contain Abstract operation methods Abstract operation methods Hook operations Hook operations

9 Iterator Pattern Definition: Provide a way to access elements of an aggregate object. Definition: Provide a way to access elements of an aggregate object. Means of traversal handled by iterator object. Means of traversal handled by iterator object. Should be a container. Should be a container. VFP collection class is ideal. VFP collection class is ideal. Similarities to traversing an array. Similarities to traversing an array.

10 Observer Pattern Definition: Define dependency between objects so that if state change, all dependents are notified. Definition: Define dependency between objects so that if state change, all dependents are notified. Two types of Observers Two types of Observers Active (Voyeur) Active (Voyeur) Passive (Publish and Subscribe) Passive (Publish and Subscribe)

11 Mediator Pattern Definition: Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling via one communication point. Definition: Define an object that encapsulates how a set of objects interact. Mediator promotes loose coupling via one communication point. Used to handle event notification. Used to handle event notification. Mediator is a form of a Passive Observer. Mediator is a form of a Passive Observer.

12 Memento Pattern Definition: Capture an object’s internal state so that the object can be restored. Definition: Capture an object’s internal state so that the object can be restored. Use this pattern for VFP housekeeping chores – SET settings, ON settings, work areas, etc. Use this pattern for VFP housekeeping chores – SET settings, ON settings, work areas, etc.

13 Chain of Responsibility Definition: Avoid coupling request sender to the receiver by giving more than one object a chance to handle the request. Chain the receiving objects. Definition: Avoid coupling request sender to the receiver by giving more than one object a chance to handle the request. Chain the receiving objects. Pattern often used in hierarchies – Error handling, processing import data, multi- tier applications, etc. Pattern often used in hierarchies – Error handling, processing import data, multi- tier applications, etc.

14 Chain of Responsibility

15 Abstract Factory Pattern Definition: Provide an interface for creating families of dependent objects without specifying their concrete classes. Definition: Provide an interface for creating families of dependent objects without specifying their concrete classes. Avoid NewObject and CreateObject methods – let Factory handle it. Avoid NewObject and CreateObject methods – let Factory handle it. VFP data access performance is ideal for implementing this pattern. VFP data access performance is ideal for implementing this pattern.

16 Summary Use Software Patterns to keep an application as flexible as possible. Use Software Patterns to keep an application as flexible as possible. Think in Patterns Think in Patterns You’re already familiar with most patterns. You’re already familiar with most patterns. Use pattern heuristics as a guideline. Use pattern heuristics as a guideline. Understand pattern usage. Understand pattern usage. Don’t get lost in formal definitions. Don’t get lost in formal definitions. Fox Wiki is a great resource Fox Wiki is a great resource http://fox.wikis.com http://fox.wikis.com

17 Thank you! Remember to fill out your session evaluation. Session slides, white paper, and code samples will not be updated.


Download ppt "Using Software Design Patterns Bill Anderson. About me Fox developer since 1987 Fox developer since 1987 Program Director, Los Angeles Visual Foxpro Developers."

Similar presentations


Ads by Google