Structural design patterns online tutorials

20
www.quontrasolutions.c om [email protected] om info@quontrasolutions .com uctural Design Patterns Online Training Clas

description

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

Transcript of Structural design patterns online tutorials

Page 1: Structural design patterns online tutorials

www.quontrasolutions.com [email protected]

[email protected]

Structural Design Patterns Online Training Classes

Page 2: Structural design patterns online tutorials

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.

www.quontrasolutions.com [email protected]

[email protected]

Page 3: Structural design patterns online tutorials

• 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.

www.quontrasolutions.com [email protected]

[email protected]

Page 4: Structural design patterns online tutorials

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.

www.quontrasolutions.com [email protected]

[email protected]

Page 5: Structural design patterns online tutorials

• 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.

www.quontrasolutions.com [email protected]

[email protected]

Page 6: Structural design patterns online tutorials

Decorator Patternwww.quontrasolutions.com [email protected]

[email protected]

Page 7: Structural design patterns online tutorials

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.

www.quontrasolutions.com [email protected]

[email protected]

Page 8: Structural design patterns online tutorials

• 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.

www.quontrasolutions.com [email protected]

[email protected]

Page 9: Structural design patterns online tutorials

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.

www.quontrasolutions.com [email protected]

Page 10: Structural design patterns online tutorials

Command Patternwww.quontrasolutions.com [email protected]

[email protected]

Page 11: Structural design patterns online tutorials

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.

www.quontrasolutions.com [email protected]

[email protected]

Page 12: Structural design patterns online tutorials

• 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.

Page 13: Structural design patterns online tutorials

Factory Patternwww.quontrasolutions.com [email protected]

[email protected]

Page 14: Structural design patterns online tutorials

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.

Page 15: Structural design patterns online tutorials

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.

www.quontrasolutions.com [email protected]

[email protected]

Page 16: Structural design patterns online tutorials

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.

www.quontrasolutions.com [email protected]

Page 17: Structural design patterns online tutorials

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.

www.quontrasolutions.com [email protected]

[email protected]

Page 18: Structural design patterns online tutorials

• 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 nique it should be implemented as a singleton, thus avoiding to instantiate the class before using it.

Page 19: Structural design patterns online tutorials

Singleton Patternwww.quontrasolutions.com [email protected]

[email protected]

Page 20: Structural design patterns online tutorials

www.quontrasolutions.com

For More Details Contact us

Quontra Solutions

[email protected]

[email protected]

Visit: http://Www.quontrasolutions.com

Email: [email protected]

Call Now : (404) 900-9988