Design Patterns

Design patterns represent the structure of a software projects. The design pattern describes the way the software functions not the details of how it functions. Most design patterns can be described in simple terms that do not require knowledge of computer programming or any particular programming language. Design patterns can be implemented in several languages. The practice of using templates (design patterns) that can be applied to programming situations is the job of a software engineer.

Christopher Alexander is a world renowned building architect whose ideologies are largely responsible for the shift in computer science to the use of design patterns. He has advanced degrees in mathematics, architecture, and later was a professor of architecture at UC Berkley for 38 years. Alexander said of building design patterns that "each pattern describes a problem which occurs over and over again in our environment, and then describes the core of the solution to that problem, in such a way that you can use this solution a million times over, without ever doing it the same way twice." (http://www.patternlanguage.com/leveltwo/caframe.htm?/leveltwo/../bios/designpatterns.htm) This is central to the concept of design patterns in computer science. Patterns in computer science follow the same logic. They solve problems by implementing a general design pattern and modifying code in order to apply specific details to individual situations. Similarly an architect designs the blueprint for a building and an engineer uses the guidelines before implementing the details to specific building project.

One design patten is the Command Pattern. This pattern treats command as objects, which allows commands to contain basic attributes and methods applicable to all subclasses of the command class. Because this pattern treats commands as objects commands can be stored in arraylists and executed in a more organized fashion. Commands can be undone because they can be stored and tracked. For example a command design pattern could be used by a waiter to place an order to the chefs in the kitchen. The command object would store details for several orders (attributes) from several patrons at the restaurant and a method to prepare the order (execute method). The client invokes a command (patron/ waiter), the command (order) is executed, and the results of the command are produced by the receiver (cook). (http://sourcemaking.com/design_patterns/command) In this scenario each command for the order is based on a general template and variation is built in for specific situations.

Comments

Popular Posts