프로그래밍/디자인패턴
-
Adapter Pattern프로그래밍/디자인패턴 2012. 12. 8. 21:16
Motivation The adapter pattern is adapting between classes and objects. Like any adapter in the real world it is used to be an interface, a bridge between two objects. In real world we have adapters for power supplies, adapters for camera memory cards, and so on. Probably everyone have seen some adapters for memory cards. If you can not plug in the camera memory in your laptop you can use and ad..
-
Command Pattern프로그래밍/디자인패턴 2012. 12. 8. 21:13
“An object that contains a symbol, name or key that represents a list of commands, actions or keystrokes”. This is the definition of a macro, one that should be familiar to any computer user. From this idea the Command design pattern was given birth. The Macro represents, at some extent, a command that is built from the reunion of a set of other commands, in a given order. Just as a macro, the C..
-
Singleton Pattern프로그래밍/디자인패턴 2012. 12. 8. 21:10
Motivation Sometimes it's important to have only one instance for a class. For example, in a system there should be only one window manager (or only a file system or only a print spooler). Usually singletons are used for centralized management of internal or external resources and they provide a global point of access to themselves. The singleton pattern is one of the simplest design patterns: i..
-
Factory Method Pattern프로그래밍/디자인패턴 2012. 12. 8. 21:07
Motivation 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. One type of responsibility is creating such objects. The library knows when an object needs to be created, but not what kind of object it should create, this being specific to the application using..
-
Abstract Factory프로그래밍/디자인패턴 2012. 12. 8. 21:04
Motivation Modularization is a big issue in today's programming. Programmers all over the world are trying to avoid the idea of adding code to existing classes in order to make them support encapsulating more general information. Take the case of a information manager which manages phone number. Phone numbers have a particular rule on which they get generated depending on areas and countries. If..
-
Factory Pattern프로그래밍/디자인패턴 2012. 12. 8. 20:58
Motivation The Factory Design Pattern is probably the most used design pattern in modern programming languages like Java and C#. It comes in different variants and implementations. If you are searching for it, most likely, you'll find references about the GoF patterns: Factory Method and Abstract Factory. In this article we'll describe a flavor of factory pattern commonly used nowdays. You can a..
-
Decorator Pattern프로그래밍/디자인패턴 2012. 12. 8. 20:53
Motivation Extending an objects functionality can be done statically (at compile time) by using inheritance however it might be necessary to extend an objects functionality dynamically (at runtime) as an object is used. Consider the typical example of a graphical window. To extend the functionality of the graphical window for example by adding a frame to the window, would require extending the w..
-
Observer Pattern프로그래밍/디자인패턴 2012. 11. 20. 16:07
Motivation We can not talk about Object Oriented Programming without considering the state of the objects. After all object oriented programming is about objects and their interaction. The cases when certain objects need to be informed about the changes occured in other objects are frequent. To have a good design means to decouple as much as possible and to reduce the dependencies. The Observer ..