Modeling
-
CompositeModeling/DesignPattern 2020. 2. 29. 19:09
1. Overview Composite pattern is a partitioning design pattern. The composite pattern describes a group of objects that are treated the same way as a single instance of the same type of object. We have a part-whole relationship or hierarchy of objects and we want to be able to treat all objects in this hierarchy uniformly. This is not a simple composition concept from object-oriented programming..
-
Chain of responsibilityModeling/DesignPattern 2020. 2. 29. 19:06
1. Overview We need to avoid coupling the code which sends a request to the code which handles that request. Typically the code which wants some request handled calls the exact method on an exact object to processing it, thus the tight coupling. Chain of responsibility solves this problem by giving more than one object, chance to process the request. We create objects which are chained together ..
-
VisitorModeling/DesignPattern 2020. 2. 29. 19:02
1. Overview Visitor pattern allows us to define new operations that can be performed on an object without changing the class definition of the object Think of this pattern as an object visitor that visits all nodes in an object structure. Each time our visitor visits a particular object from the object structure, that object calls a specific method on a visitor, passing itself as an argument. Ea..
-
IteratorModeling/DesignPattern 2020. 2. 29. 19:01
1. Overview Iterator allows a way to access elements/children of an aggregate object in sequence while hiding the actual internal data structure used. In Java language, iterators are an integral part of collection frameworks and they are implementations of this design pattern. Iterators are stateful, meaning an iterator object remembers its position while iterating Iterators can become out of sy..
-
CommandModeling/DesignPattern 2020. 2. 29. 16:29
1. Overview We want to represent a request or a method call as an object. Information about parameters passed and the actual operation is encapsulated in an object called command. The advantage of a command pattern is that what would have been a method call is now an object which can be stored for later execution or sent to other parts of code. We can now even queue our command objects and execu..
-
FlyweightModeling/DesignPattern 2020. 2. 28. 23:13
1. Overview Our system needs a large number of objects of a particular class and maintaining these instances is a performance concern. Flyweight allows us to share an object in multiple contexts. But instead of sharing the entire object, which may not be feasible, we divide the object state into two parts. intrinsic (the state that is shared in every context) and extrinsic state (context-specifi..
-
Dependency Inversion Principle (DIP)Modeling/DesignPattern 2020. 2. 28. 11:16
1. Overview High-level modules should not depend upon low-level modules. Both should depend upon abstractions. Abstractions should not depend upon details. Details should depend upon abstractions. 2. Description 2.1 Dependency public void printMe() { System.out.println("Hello"); } printMe() method depends on out object defined in System Class. public void writeReport() { Report report = new Repo..
-
Interface Segregation Principle (ISP)Modeling/DesignPattern 2020. 2. 28. 11:14
1. Overview A client should not be forced to depend upon an interface that they do not use. 2. Description 2.1 Intuition 2.1.1 Interface Pollution Large Interfaces Unrelated Methods Classes have empty method implementations Method implementations throw UnsupportedOperationsException or similar Method implementations return null default/dummy values 3. Example 3.1 Violate ISP interface Persistenc..