design patterns and components prepared by : mehmet bilsay karadenİz

22
Design Patterns and Components Prepared by : Mehmet Bilsay KARADENİZ

Post on 20-Dec-2015

221 views

Category:

Documents


1 download

TRANSCRIPT

Page 1: Design Patterns and Components Prepared by : Mehmet Bilsay KARADENİZ

Design Patterns and Components

Prepared by : Mehmet Bilsay KARADENİZ

Page 2: Design Patterns and Components Prepared by : Mehmet Bilsay KARADENİZ

Design PatternsDesign Patterns

• Reusable solutions to recurring design problems in OO systems.

• It describes the problem, the solution, when to apply the solution, and its consequences.

• It also gives implementation hints and examples.• The solution is a general arrangement of objects

and classes that solve the problem.

Page 3: Design Patterns and Components Prepared by : Mehmet Bilsay KARADENİZ

OthersOthers

• Anti-Patterns:

Things you souldn’t do.• AbstractionInversion(From less to more

complex)• Analysis Paralysis (Too much analyse)• ...

Page 4: Design Patterns and Components Prepared by : Mehmet Bilsay KARADENİZ

Desing PatternsDesing Patterns

DesignPatterns:

CreationalPatterns StructuralPatterns BehavioralPatterns

Page 5: Design Patterns and Components Prepared by : Mehmet Bilsay KARADENİZ

CreationalPatterns

Patterns that parameterize the behavior of a system based on the classes of objects it creates.

•AbstractFactoryPattern •BuilderPattern •FactoryMethodPattern •PrototypePattern •SingletonPattern •MonostatePattern

Page 6: Design Patterns and Components Prepared by : Mehmet Bilsay KARADENİZ

StructuralPatterns

Patterns that use various language mechanisms for structuring code and assembling objects .

•AdapterPattern •BridgePattern •CompositePattern •DecoratorPattern •FacadePattern •FlyweightPattern •IteratorPattern •ProxyPattern •RetrofitInterfacePattern

•BeanPattern •EngineCollectionClass •EnvelopeLetter •ExternalizeTheStack •ProtocolStack •TombStone •WeakReferencePattern

Page 7: Design Patterns and Components Prepared by : Mehmet Bilsay KARADENİZ

Behavioral Patterns Behavioral Patterns

•BindingProperties •ChainOfResponsibilityPattern •CommandPattern •InterpreterPattern •IteratorPattern •MediatorPattern

•MementoPattern •ObserverPattern •StatePattern •StrategyPattern •TemplateMethodPattern •VisitorPattern

Describe how a group of objects collaborate to perform some task that no single object can perform alone.

Page 8: Design Patterns and Components Prepared by : Mehmet Bilsay KARADENİZ

SingletonSingleton

• If a system only needs one instance of a class, and that instance needs to be accessible in many different parts of a system, you control both instantiation and access by making that class a singleton.

• Impementation:Static GetInstancePrivate Constructor

• Monostate : All functions are static

Page 9: Design Patterns and Components Prepared by : Mehmet Bilsay KARADENİZ

SingletonSingleton

Page 10: Design Patterns and Components Prepared by : Mehmet Bilsay KARADENİZ

AbstractFactoryAbstractFactory

•A class that exists to create instances of another class.•Implementation:Implement a class for creating instances of classes.GetInstance(TYPE_ID)

Page 11: Design Patterns and Components Prepared by : Mehmet Bilsay KARADENİZ

AbstractFactoryAbstractFactory

Page 12: Design Patterns and Components Prepared by : Mehmet Bilsay KARADENİZ

AdapterAdapter

•Lets classes with incompatible interfaces work together.•Convert the interface of some class b into an interface a that some client class c understands.•Implementation:

Create a class that has the desired interface from some other class.

Page 13: Design Patterns and Components Prepared by : Mehmet Bilsay KARADENİZ

AdapterAdapter

Page 14: Design Patterns and Components Prepared by : Mehmet Bilsay KARADENİZ

FacadeFacade

• Defines a higher-level interface that makes the subsystem easier to use.

• Provide a unified interface to a set of interfaces in a subsystem.

• Hides complexity.• Implementation :

Create a class that has the desired simple interface from more complicated classes that has more detailed interfaces.

Page 15: Design Patterns and Components Prepared by : Mehmet Bilsay KARADENİZ

FacadeFacade

Page 16: Design Patterns and Components Prepared by : Mehmet Bilsay KARADENİZ

Other Practices Other Practices

• Implement according to interfaces.• Don’t use inheritance. It breaks abstraction.

• Use delegation instead of inheritance.• Generics are hard to understand use with caution.

• Applications are hard to design, toolkits (class libraries) are harder, and frameworks are the hardest to design.

Page 17: Design Patterns and Components Prepared by : Mehmet Bilsay KARADENİZ

Design Patterns CriticismDesign Patterns Criticism

•Don’t let enoug code reuse.

•In practise it is not always efficient.

•Most of them are missing language features (16 of 23).

•Do not solve a problems, gives tools.

Page 18: Design Patterns and Components Prepared by : Mehmet Bilsay KARADENİZ

Component OrientationComponent Orientation

•Uses most core practises of design patterns.

•Adresses most of the drawbacks.•ClassFactory, Adapter, ... etc can be widely used in component oeriented software design.

•Component Design Patterns. Not meature enough.

Page 19: Design Patterns and Components Prepared by : Mehmet Bilsay KARADENİZ

Component Design PatternsComponent Design Patterns• Distribution Patterns • DistributionOfComponents • LayeredComponentFramewor

k • BypassableAbstraction • LocationAbstraction • ReplicatedObject • FacadeAtTheDistributionBoun

dary • ChokePoint

• Connection Patterns • InterfaceDiscovery • ConnectionSingleton • ConnectionFlyweight • ConnectionObserver

• Interaction Patterns • AbstractInteractions • ThirdPartyBinding • ComponentGlue • ComponentBus • ConsumerProducer

• Behavior Patterns • ContainerIndependence • EnvironmentalAcquisition• ContainerManagedBehavior• ComponentManagedBehavior• DistributedCommand• InterruptibleCommand • TransactionalCommand• CommandConcurrency

• Deployment Patterns • IndividualPackaging • GroupPackaging • PrebuiltFunctionality • AutomatedAssembly

Page 20: Design Patterns and Components Prepared by : Mehmet Bilsay KARADENİZ

Component Orientation CriticismComponent Orientation Criticism

•Dependency to other firms.(interface and strategy)

•Development of components are harder.•Non-Standart (and possibly incompatible) component protocols.

(COM,XPCOM,CORBA,...)•High learning delta.(coupled with big projects)

Page 21: Design Patterns and Components Prepared by : Mehmet Bilsay KARADENİZ

Component Orientation and PatternsComponent Orientation and Patterns

•High learning delta and dependecy to other firms and component technologies can be reduced with adapter and bridge.

•Design what you need or design with what you have ?

•Which direction should we take ?

Page 22: Design Patterns and Components Prepared by : Mehmet Bilsay KARADENİZ

Thank youThank you

Questions ?Questions ?

Prepared by: Mehmet Bilsay KARADENİZPrepared by: Mehmet Bilsay KARADENİZ

Referances:Referances:

http://www.c2.com/cgi/wiki?AreDesignPatternsMissingLanguageFeatures

http://en.wikipedia.org/wiki/Design_pattern_(computer_science)

Gamma, Erich, Richard Helm, Ralph Johnson, and John Vlissides (1995). Design Patterns: Elements of Reusable Object-Oriented Software, Addison-Wesley. ISBN 0-201-63361-2.

http://www.dofactory.com/Patterns/Patterns.aspx