You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: composite-entity/README.md
+89-45Lines changed: 89 additions & 45 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -3,53 +3,62 @@ title: Composite Entity
3
3
category: Structural
4
4
language: en
5
5
tag:
6
-
- Enterprise Integration Pattern
6
+
- Client-server
7
+
- Data access
8
+
- Enterprise patterns
7
9
---
8
10
11
+
## Also known as
12
+
13
+
* Coarse-Grained Entity
14
+
9
15
## Intent
10
16
11
-
It is used to model, represent, and manage a set of persistent objects that are interrelated, rather than representing them as individual fine-grained entities.
17
+
The Composite Entity design pattern is aimed at managing a set of interrelated persistent objects as if they were a
18
+
single entity. It is commonly used in the context of Enterprise JavaBeans (EJB) and similar enterprise frameworks to
19
+
represent graph-based data structures within business models, enabling clients to treat them as a single unit.
12
20
13
21
## Explanation
14
22
15
23
Real world example
16
24
17
-
> For a console, there may be many interfaces that need to be managed and controlled. Using the composite entity pattern, dependent objects such as messages and signals can be combined together and controlled using a single object.
25
+
> For a console, there may be many interfaces that need to be managed and controlled. Using the composite entity
26
+
> pattern, dependent objects such as messages and signals can be combined and controlled using a single object.
18
27
19
28
In plain words
20
29
21
30
> Composite entity pattern allows a set of related objects to be represented and managed by a unified object.
22
31
23
32
**Programmatic Example**
24
33
25
-
We need a generic solution for the problem. To achieve this, let's introduce a generic
34
+
We need a generic solution for the problem. To achieve this, let's introduce a generic
Use the Composite Entity Pattern in the following situation:
124
+
* Useful in enterprise applications where business objects are complex and involve various interdependent objects.
125
+
* Ideal for scenarios where clients need to work with a unified interface to a set of objects rather than individual
126
+
entities.
127
+
* Applicable in systems that require a simplified view of a complex data model for external clients or services.
128
+
129
+
## Known Uses
130
+
131
+
* Enterprise applications with complex business models, particularly those using EJB or similar enterprise frameworks.
132
+
* Systems requiring abstraction over complex database schemas to simplify client interactions.
133
+
* Applications that need to enforce consistency or transactions across multiple objects in a business entity.
134
+
135
+
## Consequences
136
+
137
+
Benefits:
138
+
139
+
* Simplifies client interactions with complex entity models by providing a unified interface.
140
+
* Enhances reusability and maintainability of the business layer by decoupling client code from the complex internals of
141
+
business entities.
142
+
* Facilitates easier transaction management and consistency enforcement across a set of related objects.
143
+
144
+
Trade-offs:
145
+
146
+
* May introduce a level of indirection that could impact performance.
147
+
* Can lead to overly coarse-grained interfaces that might not be as flexible for all client needs.
148
+
* Requires careful design to avoid bloated composite entities that are difficult to manage.
149
+
150
+
## Related Patterns
151
+
152
+
*[Decorator](https://java-design-patterns.com/patterns/decorator/): For dynamically adding behavior to individual
153
+
objects within the composite entity without affecting the structure.
154
+
*[Facade](https://java-design-patterns.com/patterns/facade/): Provides a simplified interface to a complex subsystem,
155
+
similar to how a composite entity simplifies access to a set of objects.
156
+
*[Flyweight](https://java-design-patterns.com/patterns/flyweight/): Useful for managing shared objects within a
157
+
composite entity to reduce memory footprint.
116
158
117
-
* You want to manage multiple dependency objects through one object to adjust the degree of granularity between objects. At the same time, the lifetime of dependency objects depends on a coarse-grained object.
118
159
## Credits
119
160
120
161
*[Composite Entity Pattern in wikipedia](https://en.wikipedia.org/wiki/Composite_entity_pattern)
162
+
*[Core J2EE Patterns: Best Practices and Design Strategies](https://amzn.to/4cAbDap)
163
+
*[Enterprise Patterns and MDA: Building Better Software with Archetype Patterns and UML](https://amzn.to/49mslqS)
164
+
*[Patterns of Enterprise Application Architecture](https://amzn.to/3xjKdpe)
0 commit comments