Presentation is loading. Please wait.

Presentation is loading. Please wait.

Programmeerimine Delphi keskkonnas MTAT.03.214 Programmeerimine Delphi keskkonnas MTAT.03.214 Jelena Zaitseva

Similar presentations


Presentation on theme: "Programmeerimine Delphi keskkonnas MTAT.03.214 Programmeerimine Delphi keskkonnas MTAT.03.214 Jelena Zaitseva"— Presentation transcript:

1 Programmeerimine Delphi keskkonnas MTAT.03.214 Programmeerimine Delphi keskkonnas MTAT.03.214 Jelena Zaitseva jellen@ut.ee

2 Design patterns – frequently recurring structures and relationships in object- oriented design. Design patterns – frequently recurring structures and relationships in object- oriented design.

3 adapter adapter singleton singleton template method template method factory factory observer observer

4 adapter PROBLEM: How to resolve incompatible interfaces, or provide a stable interface to similar components with different interfaces? SOLUTION: Convert the original interface of a component into another interface, through an intermediate adapter object.

5 singleton PROBLEM: Exactly one instance of a class is allowed – it is a “singleton”. Objects need a global and single point of access. SOLUTION: Define a static method of a class that returns the singleton.

6 singleton Benefits: Benefits: –controlled access to sole instance –reduced name space –permits refinement of operations and representations –permits a variable number of instances

7 template method template method – “define the skeleton of an algorithm in an operation, deferring some steps to subclasses” template method – “define the skeleton of an algorithm in an operation, deferring some steps to subclasses” Template Method lets subclasses redefine certain steps of an algorithm without changing the algorithm's structure.

8 template method The pattern is essentially an extension of abstract methods to more complex algorithms. The pattern is essentially an extension of abstract methods to more complex algorithms.

9 factory PROBLEM: Who should be responsible for creating objects when there are special considerations, such as complex creation logic, a desire to separate the creation responsibilities for better cohesion, and so forth? SOLUTION: Create an object called a Factory that handles the creation.

10 Observer PROBLEM: Different kinds of subscriber objects are interested in the state changes or events of a publisher object, and want to react in their own unique way when the publisher generates an event. Moreover, the publisher wants to maintain low coupling to the subscribers. What to do? SOLUTION: Define a “subscriber” or “listener” interface. Subscribers implement this interface. The publisher can dynamically register subscribers who are interested in an event, and notify them when an event occurs.


Download ppt "Programmeerimine Delphi keskkonnas MTAT.03.214 Programmeerimine Delphi keskkonnas MTAT.03.214 Jelena Zaitseva"

Similar presentations


Ads by Google