1 / 19

Introduction to Design Patterns

Introduction to Design Patterns. Questions. What is a design pattern? Who needs design patterns? How different are classes and objects in APL compared to the rest of the world? How different are patterns in APL?. What are design patterns?.

rrafferty
Télécharger la présentation

Introduction to Design Patterns

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. Introduction to Design Patterns

  2. Questions • What is a design pattern? • Who needs design patterns? • How different are classes and objects in APL compared to the rest of the world? • How different are patterns in APL?

  3. What are design patterns? • Design patterns are solution templates for frequently occurring problems. This term is widely applied to the design of Objects and their relations with each other.

  4. Who needs design patterns? • The only classes in my first application using Object Oriented programming where static classes. If you are in the same boat why do we need Object Orientation at all.

  5. How different are classes and objects in APL? • Type less nature of variables/objects – Type of variable is defined at the runtime.. • State full nature of workspace – workspace at every point in time has preexisting state. • Something else …

  6. Effect of type-less nature on classes/objects • Strong typing of results helps resolving data type compatibility problems at a time of compilation. • Absence of strong typing gives flexibility for developers at implementation time, but may cause type compatibility issues at a runtime. • Properties/fields and method’s results of classes are not strongly typed. • As we will see it may be good or bad

  7. Effect of state full workspace on classes • State of class is defined by static members (fields, properties) of class (State of object is defined by dynamic members) • State full nature of workspace may be described as the fact that at every point in time workspace is continuation of previous work rather then start from scratch. Static members are assigned at the time of class initialization. And may already change several times during test run before workspace will be saved. So application will start with static members which comes not from class definition but from intermediate state prior workspace saving.

  8. Creational patterns • Singleton • Abstract Factory • Factory Method • Prototype • Builder

  9. Structural Patterns • Adapter • Bridge • Composite • Decorator • Façade • Flyweight • Proxy

  10. Behavioral patterns • Chain of Responsibility. • Command • Interpreter • Iterator • Mediator • Memento • Observer • State • Strategy • Template Method • Visitor

  11. Singleton Definition: Singleton is a class of which only a single instance may exist at every given time. Features: • Provide alternative mechanism for object creation. • Prevent regular object creation.

  12. Singleton Possible use: • Load Balancers • Configuration class • Access to the object pool • Iterators • …

  13. Prototype Definition: Create an object by copying existing rather then using []NEW. Features: • Utilize cloning of objects as alternative way to create instance instead of regular object creation. • No need to prevent regular object creation.

  14. Prototype Possible use: • Classes with time and resource consuming initialization process

  15. Abstract Factory Definition: Creates a series of objects without specifying object class. Features: • Need for interface structure defined. • Need for multiple interface implementations

  16. Abstract Factory Note: It is more relevant to the strongly typed world as strong typing puts limitations, which this pattern trying to resolve. Possible use: 1. Tools which operate/generate different classes with the same interface

  17. Adapter Definition: Creates an interface representing another interface/class. Features: • Need for interface structure defined. • Need for multiple interface implementations

  18. Adapter Definition: Creates an interface to represent another interface/class. Features: • Allows encapsulation of class behavior.

  19. Proxy Definition: Creates an interface representing another interface/class. Features: • Need for interface structure defined. • Need for multiple interface implementations

More Related