-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathPrototype.cs
More file actions
20 lines (18 loc) · 830 Bytes
/
Prototype.cs
File metadata and controls
20 lines (18 loc) · 830 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
namespace DesignPatterns.Creational.Prototype;
/// <summary>
/// Prototype Pattern
///
/// Intent: Specify the kinds of objects to create using a prototypical instance,
/// and create new objects by copying this prototype.
///
/// When to use:
/// - When a system should be independent of how its products are created, composed, and represented
/// - When the classes to instantiate are specified at run-time (e.g., dynamic loading)
/// - When instances of a class can have only a few different combinations of state
///
/// Real-world analogy: Cell division — a cell splits to create an identical copy of itself.
/// </summary>
// TODO: Implement Prototype
// 1. Prototype interface with Clone() method
// 2. Concrete prototype with deep/shallow copy logic
// 3. Client that clones objects instead of creating new ones