분류 전체보기
-
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..
-
Liskov Substitution Principle (LSP)Modeling/DesignPattern 2020. 2. 28. 00:51
1. Overview We should be to substitute base class objects with child class objects and this should not alter behavior/characteristics of the program. 2. Description For example, Java what we are also talking about behavioral subtypes. That means if the base class object was providing a specific behavior and if that base class object is now substituted with a child class object that behavior shou..
-
Parallel Algorithms and Sequential AlgorithmsModeling/TheoremParadigm 2020. 2. 27. 21:22
1. Overview In the case of Sequential algorithms, It should execute the tasks one after each other. In the case of Parallel algorithms, we execute different tasks with different processors then combine the results. Some problems are easy to parallelizable, other problems are completely sequential. 2. Description 2.1 Parallel algorithms Checking prime numbers in a range. We have to make subsets. ..