Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Latest commit

 

History

History
History
23 lines (23 loc) · 1.48 KB

File metadata and controls

23 lines (23 loc) · 1.48 KB
Copy raw file
Download raw file
Open symbols panel
Edit and raw actions
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
/**
* Prototype pattern comes into creational design pattern. As the name suggest
* As the name state prototype meaning creating object from some reference which we already have.
* It is mainly useful when we have Object which is already created with costly operations at that time we keep that object after creation whenever we need
* new object we simply clone object and tweak or do slight modification in the object and use it.
* In addition to this it is useful when we want to hide the creation of object.
* Here when we say cost of creation which means lets say your object got created by some database operations or io operation.
*
* In cloning its totally upto implementor whether we want to have shallow copy or depp copy while cloning.
*
* There are mainly three components involved in simple Prototype design pattern.
* 1. Prototype : Type of class which has clone method and a super class of all prototypes.
* 2. Sub-Classes - Which implements cloning.
* 3. Client which uses this subclass and clone
* In this additionally you can maintain registry which helps to give you specific prototype.
* In our example lets say we have vehicle and which different types of vehicle , so you can store in
* vehicle registry with different type of vehicles.
* https://simpletechtalks.com/prototype-design-pattern/
* http://www.jasondeoliveira.com/2011/05/tutorial-common-design-patterns-in-c-40_07.html
* https://reactiveprogramming.io/blog/en/design-patterns/prototype
*/
public class Main {
}
Morty Proxy This is a proxified and sanitized view of the page, visit original site.