Prashanth Hs

download Prashanth Hs

of 12

Transcript of Prashanth Hs

  • 7/30/2019 Prashanth Hs

    1/12

    STRUCTURAL DESIGNPATTERNS

    Presentedby

    PRASHANTH HS

  • 7/30/2019 Prashanth Hs

    2/12

    STRUCTURAL DESIGN PATTERN

    Structural design patterns can be used to organize your programgroups. This segregation will provide you clarity and will enable easier maintainability.

  • 7/30/2019 Prashanth Hs

    3/12

    TYPES OF STRUCTURAL DESIGN PATTRENS

    1) FCADE PATTERN

    2) BRIDGE PATTERN

    3) DECORATOR PATTERN

    4) ADAPTER PATTERN

  • 7/30/2019 Prashanth Hs

    4/12

    FCADE PATTERN

    FCADE pattern provide a unified interface to a set of interfacesin a subsystem. Facade Pattern defines a higher-level interfacethat makes the subsystem easier to use.

  • 7/30/2019 Prashanth Hs

    5/12

    EXAMPLE OF FCADE PATTERN

    In the above design Mercides factory creates family car andsports cars and audi factory also creates both family and sportscars. Car factory has family car and sports cars of both factory.Driver drives family car and sports cars of audi factory andmercedes factory. Thus creates unified interface b/w family car

    and sports car classes .this is refferd as FCADE design pattern.

  • 7/30/2019 Prashanth Hs

    6/12

    BRIDGE PATTERN

    Decouple an abstraction from its implementation so that thetwo can vary independently is the intent for bridge designpattern.

    Bridge design pattern is a modified version of the notion

    of prefer composition over inheritance.

    It creates two different hierarchies. One for abstraction andanother for implementation.

  • 7/30/2019 Prashanth Hs

    7/12

    EXAMPLE OF BRIDGE PATTERN

    Workshop can manufacture bike and also car but it violatesfundamental principle of objects:an object should responsible foitself.workshop should know specific information about vehcle(i.e type of vehcle)in order to manufacture them.shapes wouldntneed to know what type of workshop object used because I could

    have vehcles refer to the workshop class. In the above designvehcle uses workshop to manifest its bahavior.

  • 7/30/2019 Prashanth Hs

    8/12

    DECORATOR PATTERN

    To extend or modify the behaviour of an instance at runtimedesign pattern is used. Inheritance is used to extend the abilitiesof a class. Unlike inheritance, you can choose any single object ofa class and modify its behaviour leaving the other instancesunmodified.

  • 7/30/2019 Prashanth Hs

    9/12

    EXAMPLE OF DECORATOR PATTERN

    In the above design SAMPLE ICECREAM is the concretecomponent. HONEY DECORATOR adds honey and NUTTYDECORATOR adds honey. Both are used with ICECREAM . ThenICECREAM is prepared with adding required amount of honeyand nutts. This is reffered as DEECORATOR PATTERN.

  • 7/30/2019 Prashanth Hs

    10/12

    ADAPTER PATTERN

    An adapter helps two incompatible interfaces to work togetheAdapter design pattern is used when you want two differentclasses with incompatible interfaces to work together. The namsays it all. Interfaces may be incompatible but the inner

    functionality should suit the need.

  • 7/30/2019 Prashanth Hs

    11/12

    EXAMPLE OF ADAPTER PATTERN

    player is used to play audio and video songs. The windowsmedia plays .mp4, .mp3 files but not play .vob, .flv . To play thesetypes of files we adopt the vlc media player.

  • 7/30/2019 Prashanth Hs

    12/12

    Thank You..