Anda di halaman 1dari 6

Software Engineering Design Patterns Chris Norris CSS422 October 24, 2011 Bhaskar Jonnalagadda

SOFTWARE ENGINEERING DESIGN PATTERNS Software Engineering Design Patterns The intent of this paper is to compare and contrast five different types of design patterns. Design patterns in general are repeatable solutions in software engineering that adhere to common

occurring problems in software design. However, transforming design patterns into code is not an easy task. A design pattern serves as a template with the intention of solving a problem and is useful in numerous different conditions. Design patterns use tested, proven development paradigms that assist in speeding up the development processes. Therefore, the reuse of design patterns aids in the prevention of subtle issues, which can cause problems and improves readability of code for architects and coders familiar with the patterns. Comparison of Design Patterns Different types of design patterns offer flexible solutions in software development. The design patterns that will be discussed are the Model View Controller (MVC), Adapter, Facade, Proxy, and Factory Method. Design patterns consist of three primary uses such as creational design patterns, structural design patterns, and behavioral design patterns. Creational design patterns deal with class instantiation. Structural design patterns deal with class and object composition. Behavioral design patterns deal with classs objects communications (SourceMaking, 2010). Model View Controller (MVC) The Model View Controller (MVC) is a traditional design pattern commonly used by an array of applications that require the capability to uphold numerous views of similar data. What makes the MVC pattern unique is it separates objects into three categories models, views, and controllers. Models are used for data maintenance, managing information, and notifying observers when changes in information occur. Model objects consist of attributes like first name, last name,

SOFTWARE ENGINEERING DESIGN PATTERNS

and date of birth for modeling an employee in a business as an example. Views, for displaying data or mapping graphics on a device that have a one-to-one communication and permits human interaction with the computer system. A good example would be Facebook as it provides information about friends like profiles, status updates, and wall pages. Controllers handle events and user interactions with an application. Again, using Facebook as an example, the designers most likely have controller objects like AddStatusController, UploadPhotosController, and InviteFriendsController to control and coordinate user interaction. According to TechTarget (2010), the MVC pattern has been heralded by many developers as a useful pattern for the reuse of object code and a pattern that allows them to significantly reduce the time it takes to develop applications with user interfaces (para. 2). Adapter Unlike (MVC) Model View Controller, the Adapter is a structural design pattern. The adapter creates go-between construct and translates the old element to the new system. An Adapter is also known as a wrapper. The main purpose of an Adapter is component reuse in implementing a new system. A good analogy would be attaching a PS3 (Playstation) gaming system using an HDMI adapter to an HDTV. The ability to display HD quality video is impossible without the adapter. The Adapter functions using the same concept because without the adapter functionality of incompatible systems would not be possible. This pattern establishes a relationship between the two unrelated interfaces such that they work together (RoseIndia, 2008, p. 1). Facade Facade like the Adapter is a structural design pattern. The facade pattern provides a more

SOFTWARE ENGINEERING DESIGN PATTERNS simple interface to a mass amount of code like a class library. A facade design pattern can

accomplish many aspects like making software libraries easy to understand and use, more readable, and reduce dependencies of outside code, thus allowing more flexibility in system development. In comparison with the Adapter, the facade defines a new interface as opposed to reuse of existing interfaces. Adapters are normally small and do not cause performance issues. The facade defines a unified, higher level interface to a subsystem that makes it easier to use (SourceMaking, 2010, p. 1). Proxy The Proxy design pattern is another type of structural design pattern. As stated by Holobloc, Inc. (2010), The proxy pattern is described as one which decouples clients from their servers by creating a local proxy, or stand-in, for the less accessible server. When the client needs to request a service from the server, such as retrieving a value, it asks its local proxy. The proxy can then marshal a request to the original server (para. 1). The Proxy pattern provides a surrogate object to the client and controls access to another object. A Proxy can implement a valid objects interface; thus, the client thinks the Proxy is the valid object. Therefore, the client is unaware the Proxy uses access to the RealSubjects interface. A good example is a debit card as it serves as a proxy to cash in a bank account. A proxys intent is to add behavior, whereas Facades intent is to make it easier, which may entail removing behavior. In addition, Proxies are not obligatory and Facades on average are not. Factory Method A Factory Method is a creational design pattern. According to OODesign (2010), also known as Virtual Constructor, the Factory Method is related to the idea on which libraries work: a library uses abstract classes for defining and maintaining relations between objects (para. 1). The

SOFTWARE ENGINEERING DESIGN PATTERNS Factory Method is a highly used pattern and is said to be more robust. The purpose for using a Factory Method is separation between applications and family classes, which simplifies extension with minor changes in application code and are common in frameworks and toolkits. The Factory Method is only a bit more complicated, and the design is more customizable. Other types of design patterns involve new classes, as opposed to a new operation such as the Factory Method implements. Conclusion Design patterns serve different purposes and implementation is dependent on software design. Each design pattern whether creational, structural, or behavioral has advantages and disadvantages. Therefore, consideration of the design pattern is critical to successful software

design process and understanding what design pattern to follow can either make or break a project.

References

SOFTWARE ENGINEERING DESIGN PATTERNS Holobloc, Inc. (2010). Design Pattern: Proxy. Retrieved from http://www.holobloc.com/doc/despats/proxy/index.htm OODesign.com. (2010). Factory Method Pattern. Retrieved from http://www.oodesign.com/factory-method-pattern.html RoseIndia. (2008). Adapter Pattern. Retrieved from http://www.roseindia.net/designpattern/adapter-pattern.shtml

SourceMaking. (2010). Design Patterns. Retrieved from http://sourcemaking.com/design_patterns SourceMaking. (2010). Facade Design Pattern. Retrieved from http://sourcemaking.com/design_patterns/Facade TechTarget. (2010). Model-view-controller. Retrieved from http://whatis.techtarget.com/definition/0,,sid9_gci214607,00.html

Anda mungkin juga menyukai