behavioral design patterns

PPTX 36 sahifa 1,2 MB Bepul yuklash

Sahifa ko'rinishi (5 sahifa)

Pastga aylantiring 👇
1 / 36
design patterns behavioral design patterns 1 template design pattern have a generic algorithm or task to perform want the code to be reusable but the details differ create an abstract class that performs the task abstract functions code stuff that changes subclass behaviour of these things using polymorphism 2 3 4 or even more detailed templating template pattern advantages separates what changes from what does not bulk of unchanging code can be easily reused detailed differences are all that the subclasses worry about much that might change can also be a no-op this pattern is being used every time in java you extend a class public class myframe extends jframe public class myapplet extends applet 5 template pattern definition the template method defines the skeleton of an operation either not specifying some steps to be performed, or giving them a generic default behaviour the template method lets subclasses redefine these …
2 / 36
in original objects needing a behaviour point at behaviour with behavioural interface in construction assign actual behaviour to object 9 10 avoids explosion in classes ducks have 8 types of quack and 8 styles of flying need 64 types of duck represent this but need only 1 type of duck, 8 types of quack, 8 styles of flying ie. 17 classes using the strategy design pattern easy to create new types of quack or flying easy to add further types of behaviour architecture grows linearly, not exponentially 11 other advantages assignment of behaviour now done at run time can easily increase types of behaviour with no new class definitions code needs to know how to invoke behaviour but not how actual behaviour is implemented behaviours can be shared and reused behaviour can be dynamically changed can modify object without touching behaviour can modify behaviour without impacting object 12 formal description …
3 / 36
to recover from backup 17 one disadvantage can’t easily parameterize an action must add any parameterization to the command as part of its construction but could have a common interface with an object passed containing parameters or actual parameters to execute if can agree on what these should always be 18 command pattern definition the command pattern encapsulates a request as an object (reification), letting you parameterize other objects with different requests, queue or log requests, and supports repeat and undoable operations. 19 state design pattern a specialisation of the strategy pattern consider modelling problem as state changes define a complete list of actions interface represent each state by a class having interface a class defines ∃ state ∀ actions current state is referenced using strategy pattern 20 21 22 23 object pool strategy delegation change state advantages implemented within a object the object appears to have behaviour predicated on …
4 / 36
through structure passes each node seen to visitor actual visitor behaviour determined by templating visitor pattern advantages separate what changes from what does not the parallel visitor class does this classes open for extension; closed for modification the parallel visitor class achieves this each class should have one responsibility each visitor class is designed for one purpose the what to do code is centralised in the visitor class not spread across all of the composite class members 28 visitor pattern definition use the visitor design pattern when you want to add capabilities to a composite of objects and encapsulation within these objects is not important, undesirable, or not possible. 29 chain of responsibility design pattern use the chain of responsibility design pattern when you want to give a sequence of objects in turn a chance to handle a request each object in chain delegates to next object in chain if …
5 / 36
. sso is pourlncup() eath subelass implements its coffee preparerecipel) tea own recipe. brewcoffeegrinds() preparerecioe() js eath subclass overrides addsugarandmik() steepteabag)) the preparerecipel) addlemoni) method and im plements its own vecipe. the methods sr and tea stay ® fie to coffee the subclasses: caf feinebeverage is abstract, just ike im the class design: f “ now, the same preparerecipel method will be used rubia gpsleace chase’ cabteineeverads 1 ke make both tea and coffee preparerecipel) is i ; vecloved final because we don want ow sobelasses sia wsl peseazerscube (ni ¢-—————_to be able to overvide this method and change the beew()? "7 vetipe! we've generalized steps 2 and 4 to brew() pourtncu> of the beverage and addcondiments() addcondiments (); abstract void brew() zo betause coffee and tea handle these methods in different ways, they're going to have to aesinast wolal aslelcomsiimesits (\) 4 be declared as abstract. let the subclasses …

Ko'proq o'qimoqchimisiz?

Barcha 36 sahifani Telegram orqali bepul yuklab oling.

To'liq faylni yuklab olish

"behavioral design patterns" haqida

design patterns behavioral design patterns 1 template design pattern have a generic algorithm or task to perform want the code to be reusable but the details differ create an abstract class that performs the task abstract functions code stuff that changes subclass behaviour of these things using polymorphism 2 3 4 or even more detailed templating template pattern advantages separates what changes from what does not bulk of unchanging code can be easily reused detailed differences are all that the subclasses worry about much that might change can also be a no-op this pattern is being used every time in java you extend a class public class myframe extends jframe public class myapplet extends applet 5 template pattern definition the …

Bu fayl PPTX formatida 36 sahifadan iborat (1,2 MB). "behavioral design patterns"ni yuklab olish uchun chap tomondagi Telegram tugmasini bosing.

Teglar: behavioral design patterns PPTX 36 sahifa Bepul yuklash Telegram