- Design Patterns and Best Practices in Java
- Kamalmeet Singh Adrian Ianculescu LUCIAN PAUL TORJE
- 146字
- 2021-06-25 20:52:29
Composition
As the name suggests, a class is a composition of another one. This is somewhat similar to aggregation, with the difference being that the dependent class ceases to exist when the main class ceases to exist. For example, a House is made up of a Room, but the Room ceases to exist if the House is destroyed, as shown in the following diagram:

In practice, especially in languages such as Java that have garbage collectors, the boundary between composition and aggregation is not so well defined. Objects are not destroyed manually; when they are no longer referenced, they are automatically destroyed by the garbage collector. For this reason, from a coding point of view, we should not really be concerned if we deal with a composition or an aggregation relationship, but it's important if we want to have a well-defined model in UML.
- VMware View Security Essentials
- SpringMVC+MyBatis快速開發與項目實戰
- 微服務設計原理與架構
- 秒懂設計模式
- 征服RIA
- C#應用程序設計教程
- PHP+Ajax+jQuery網站開發項目式教程
- Fast Data Processing with Spark(Second Edition)
- Learning Modular Java Programming
- C++編程兵書
- Illustrator CS6設計與應用任務教程
- Android系統下Java編程詳解
- ASP.NET 4.0 Web程序設計
- Python預測分析與機器學習
- 官方 Scratch 3.0 編程趣味卡:讓孩子們愛上編程(全彩)