1 / 20

Structural design patterns by quontra solutions

Quontra Solutions is leading provider of IT career advice, Training and consulting services for IT Professional and corporates across USA. We train individuals or Corporate via online or class Room training in all IT tools and Technologies. We always strive to bring out innovative methods along with the traditional teaching techniques which enhance the overall experience of the students and teachers to extract the return on Investments, high efficiency and scalability. The company’s architecture is based on the insights from the marketplace, business analytics and strategies keeping intact the fundamental principles in mind, helps us to compete and win in today’s environment without changing any quality in training. The support, service and training provided by Quontra solutions for various customers assures a “stay up to date” easy transition from previous to current in terms of technology. Our advertisers and promoters are none other than the clients you have been associated with us for their training needs. We improve our training programs from the feedback from the students. Email Id : info@quontrasolutions.co.uk Website: http://www.quontrasolutions.co.uk

Télécharger la présentation

Structural design patterns by quontra solutions

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. info@quontrasolutions.co.uk www.quontrasolutions.co.uk Structural Design Patterns Online Training Classes info@quontrasolutions.co.uk

  2. info@quontrasolutions.co.uk www.quontrasolutions.co.uk Decorator Pattern • The Decorator Pattern is used for adding additional functionality to a particular object as opposed to a class of objects. • A Decorator, also known as a Wrapper, is an object that has an interface identical to an object that it contains. info@quontrasolutions.co.uk

  3. info@quontrasolutions.co.uk www.quontrasolutions.co.uk • Any calls that the decorator gets, it relays to the object that it contains, and adds its own functionality along the way, either before or after the call. • This gives you a lot of flexibility, since you can change what the decorator does at runtime, as opposed to having the change be static and determined at compile time by sub classing. info@quontrasolutions.co.uk

  4. info@quontrasolutions.co.uk www.quontrasolutions.co.uk Decorator Pattern • A Decorator is a concrete instance of the abstract class and is indistinguishable from the object that it contains.  • This can be used to great advantage, as you can recursively nest decorators without any other objects being able to tell the difference, allowing a near infinite amount of customization. info@quontrasolutions.co.uk

  5. info@quontrasolutions.co.uk www.quontrasolutions.co.uk • Decorators add the ability to dynamically alter the behavior of an object. • Good idea to use in a situation to change the behavior of an object repeatedly during runtime. • It helps to add behavior or responsibilities to an object. info@quontrasolutions.co.uk

  6. info@quontrasolutions.co.uk www.quontrasolutions.co.uk Decorator Pattern info@quontrasolutions.co.uk

  7. info@quontrasolutions.co.uk www.quontrasolutions.co.uk Command pattern • A Command pattern is an object behavioral pattern used to achieve complete decoupling between the sender and the receiver. • A sender is an object that invokes an operation, and a receiver is an object that receives the request to execute a certain operation. info@quontrasolutions.co.uk

  8. info@quontrasolutions.co.uk www.quontrasolutions.co.uk • With decoupling, the sender has no knowledge of the Receiver's interface. • The term request here refers to the command that is to be executed. • The Command pattern allows to vary when and how a request is fulfilled thus providing flexibility as well as extensibility. info@quontrasolutions.co.uk

  9. info@quontrasolutions.co.uk www.quontrasolutions.co.uk Command Pattern • Intent: • encapsulate a request in an object • allows the parameterization of clients with different requests • allows saving the requests in a queue • Implementation: • The Client asks for a command to be executed. • The Invoker takes the command, encapsulates it and places it in a queue, in case there is something else to do first, and the ConcreteCommand that is in charge of the requested command, sending its result to the Receiver. info@quontrasolutions.co.uk

  10. info@quontrasolutions.co.uk www.quontrasolutions.co.uk Command Pattern info@quontrasolutions.co.uk

  11. info@quontrasolutions.co.uk www.quontrasolutions.co.uk Factory Pattern • Factory Method is a creational pattern which helps to model an interface for creating an object which at creation time can let its subclasses decide which class to instantiate. • Factory Pattern is responsible for "Manufacturing" an Object. • It helps to instantiate the appropriate Subclass by creating the right Object from a group of related classes. info@quontrasolutions.co.uk

  12. The Factory Pattern promotes loose coupling by eliminating the need to bind application-specific classes into the code. • The use of factories gives the programmer the opportunity to abstract the specific attributes of an Object into specific subclasses which create them. • Define an interface for creating an object, but let the subclasses decide which class to instantiate. The Factory method lets a class defer instantiation to subclasses.

  13. info@quontrasolutions.co.uk www.quontrasolutions.co.uk Factory Pattern info@quontrasolutions.co.uk

  14. Singleton Pattern • Singleton involves only one class which is responsible to instantiate itself, to make sure it creates not more than one instance; in the same time it provides a global point of access to that instance. • The same instance can be used from everywhere, being impossible to invoke directly the constructor each time. • Intent: • Ensure that only one instance of a class is created. • Provide a global point of access to the object.

  15. info@quontrasolutions.co.uk www.quontrasolutions.co.uk Singleton Pattern • Implementation: • It involves a static member in the "Singleton" class, a private constructor and a static public method that returns a reference to the static member. • The Singleton Pattern defines a getInstance operation which exposes the unique instance which is accessed by the clients. • Constructor is not accessible from outside of the class. info@quontrasolutions.co.uk

  16. info@quontrasolutions.co.uk www.quontrasolutions.co.uk Singleton: Specific Implementation issues • Thread-safe implementation: Singletons can be used specifically in multi-threaded application to make sure the reads/writes are synchronized. • Lazy instantiation: Synchronization can be very expensive considering the performance. When the singleton object is already created it should be returned without using any synchronized block. • Such optimization consist of checking in an unsynchronized block if the object is null and if not to check again and create it in an syncronized block. This is called double locking mechanism. info@quontrasolutions.co.uk

  17. info@quontrasolutions.co.uk www.quontrasolutions.co.uk Singleton: Specific Implementation issues • Early instantiation using static field: The singleton object is instantiated when the class is loaded and not when it is first used, due to the fact that the instance member is declared static. • Classes loaded by different classloaders: If a class(same name, same package) is loaded by 2 different classloaders they represents 2 different clasess in memory. info@quontrasolutions.co.uk

  18. Serialization: If Singleton class implements java.io.Serializable interface, when a singleton is serialized and then deserialized more than once, there will be multiple instances of Singleton created. It can be avoided by implementing the readResolve method. • Abstract Factory and Factory Methods implemented as singletons: Having 2 factories might have undesired effects when objects are created. Hence, to ensure that a factory is niqueit should be implemented as a singleton, thus avoiding to instantiate the class before using it.

  19. info@quontrasolutions.co.uk www.quontrasolutions.co.uk Singleton Pattern info@quontrasolutions.co.uk

  20. info@quontrasolutions.co.uk www.quontrasolutions.co.uk For More Details Contact us Quontra Solutions Visit: http://www.quontrasolutions.co.uk/ Email: info@quontrasolutions.co.uk Call Now : 20-3734-1498 info@quontrasolutions.co.uk

More Related