Thursday, May 16, 2019

Design Patterns - Behavioral, Creational, Structural Research Paper

Design Patterns - Behavioral, Creational, Structural - Research Paper Example there atomic number 18 several mannequinifications of design models - this essay focus on three designs, including souvenir for behavioral praxiss, singleton for creational patterns and at long last facade for structural patterns. keepsake Pattern This is a software design pattern that has the capability of take back an object to its initial severalize. As a pattern, it allows the initial state of an object to be restored without in use(p) with the rules of encapsulation. This means that the arising object can be designed appropriately, though it can be restored to its original state. Therefore, memento pattern has the ability of restoring the internal state of an object without breaking the encapsulation rules. As a behavioral pattern, Memento indicates the manner through which communication between entities or classes is achieved (Schmidt, 1997). Basically, the design pattern is popular in applic ations with turn functionality. Memento pattern has two participants the caretaker and the originator. The originator restores memento to its internal state while the caretaker guarantees memento safekeeping. agree to Gamma et al. (1995), memento does not allow access to other objects other than originator. It has two portholes, including narrow and liberal interface. Caretakers only find the narrow interface and pass memento to other objects while the originator finds the wider interface through which it allows access to data that enabling restoration of the initial state. Benefits and drawbacks Memento pattern has chain of responsibilities that offers capacious flexibility especially when processing an application. In this case, it manages complex events by dividing the responsibilities into simpler elements that allows a set of classes to behave as a whole. However, the flexibility of this pattern is hard to develop, debug and test. This is because the chain becomes extremel y complex. In addition, failure to purpose for varied forwarding possibilities could result to messages that lack a handler, hence failing to attract any response. Singleton pattern Singleton is a creation design pattern that ensures only one object of a given class is created. It has only one class that is accessible by clients from identifiable access points. The single class must(prenominal) be extensible and the clients should easily use extended instances without alteration to their codes. Therefore, this pattern is particularly useful when a single object is needed to manage actions across a system. Singleton ensures efficiency when creating numerous identical objects and it uses a particular algorithm that requires a single point of control to interact with a resource that cannot be shared. Benefits and drawbacks The singleton pattern exerts control over the instantiation process and therefore this class has the flexibility to change the instantiation process. In addition, singleton pattern ensures that every object accesses the singleton object and preventing other objects from instantiating their own copies. However, weaknesses associated with singleton pattern includes introduction a global state into the program. It allows uncontrolled access to the program hence being one of the most used patterns. In this regard, programs that are heavily used are difficult to test. This is because it is not possible to test it without testing other

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.