Đừng học cùng tôi! Head first design patterns - chapter 3 (29/06/2025)
Автор: Cường Mạnh
Загружено: 2025-06-29
Просмотров: 4
Описание:
Tự tóm tắt:
-Thêm nguyên lý thiết kế mới (5):
1 - Encapsulate what varies.
2- Favor composition over inheritance.
3- Program to interfaces, not implementations.
4- Strive for loosely coupled designs between objects that interact.
5 - Classes should be open for extension but closed for modification. (Nguyên lý Open-Closed, code nên có thể dễ mở rộng tính năng(open cho mở rộng) nhưng mà lại không được sửa code cũ (closed cho sửa code gốc)).
/******************/
Định nghĩa Decorator pattern:
Decorator - Attach additional responsibilities to an object dynamically. Decorators provide a flexible alternative to subclassing for extending functionality.
Dịch: Gắn thêm các trách nhiệm bổ sung (nhìn chung là tính năng mới) vào một đối tượng tại thời điểm chạy (runtime). Decorator cung cấp một cách mở rộng chức năng linh hoạt hơn so với việc dùng kế thừa.
Các bullet points:
Inheritance is one form of extension, but not necessarily the best way to achieve flexibility in our designs.
In our designs we should allow behavior to be extended without the need to modify existing code.
Composition and delegation can often be used to add new behaviors at runtime.
The Decorator Pattern provides an alternative to subclassing for extending behavior.
The Decorator Pattern involves a set of decorator classes that are used to wrap concrete components.
Decorator classes mirror the type of the components they decorate. (In fact, they are the same type as the components they decorate, either through inheritance or interface implementation.)
Decorators change the behavior of their components by adding new functionality before and/or after (or even in place of) method calls to the component.
You can wrap a component with any number of decorators.
Decorators are typically transparent to the client of the component—that is, unless the client is relying on the component’s concrete type.
Decorators can result in many small objects in our design, and overuse can be complex.
Повторяем попытку...

Доступные форматы для скачивания:
Скачать видео
-
Информация по загрузке: