docs: property, prototype, proxy diagrams

This commit is contained in:
Ilkka Seppälä
2025-04-09 21:34:01 +03:00
parent 3abaa83710
commit 23af67c755
6 changed files with 12 additions and 0 deletions
+4
View File
@@ -31,6 +31,10 @@ In plain words
> Define and manage a dynamic set of properties for an object, allowing customization without altering its structure.
Sequence diagram
![Property sequence diagram](./etc/property-sequence-diagram.png)
## Programmatic Example of Property Pattern in Java
The Property design pattern, also known as Prototype inheritance, is a pattern that allows objects to be created from other objects, forming object hierarchies. This pattern is particularly useful when you want to create a new object that is a slight variation of an existing object.
Binary file not shown.

After

Width:  |  Height:  |  Size: 39 KiB

+4
View File
@@ -35,6 +35,10 @@ Wikipedia says
> The prototype pattern is a creational design pattern in software development. It is used when the type of objects to create is determined by a prototypical instance, which is cloned to produce new objects.
Sequence diagram
![Prototype sequence diagram](./etc/prototype-sequence-diagram.png)
## Programmatic Example of Prototype Pattern in Java
In Java, the prototype pattern is recommended to be implemented as follows. First, create an interface with a method for cloning objects. In this example, `Prototype` interface accomplishes this with its `copy` method.
Binary file not shown.

After

Width:  |  Height:  |  Size: 24 KiB

+4
View File
@@ -36,6 +36,10 @@ Wikipedia says
> A proxy, in its most general form, is a class functioning as an interface to something else. A proxy is a wrapper or agent object that is being called by the client to access the real serving object behind the scenes. Use of the proxy can simply be forwarding to the real object, or can provide additional logic. In the proxy extra functionality can be provided, for example caching when operations on the real object are resource intensive, or checking preconditions before operations on the real object are invoked.
Sequence diagram
![Proxy sequence diagram](./etc/proxy-sequence-diagram.png)
## Programmatic Example of Proxy Pattern in Java
Imagine a tower where the local wizards go to study their spells. The ivory tower can only be accessed through a proxy which ensures that only the first three wizards can enter. Here the proxy represents the functionality of the tower and adds access control to it.
Binary file not shown.

After

Width:  |  Height:  |  Size: 25 KiB