Thứ Bảy, 16 tháng 5, 2020

Design Pattern

How is the Builder Pattern useful?


Can you give an example of the Strategy Pattern?

The Strategy Pattern enables you to easily swap specific implementation details of an algorithm without requiring a complete rewrite. You can even swap implementations at run time. The Strategy Pattern is often used in conjunction with dependency injection to allow implementations to be swapped out for test-specific code, or to allow mocked implementations to be used instead.
Implementing a logger with the Strategy Pattern

-> bạn có thể dùng ConsoleLogging để test,
FileLogging cho production
sau này muốn thêm kiểu logging khác thì interface vẫn ko thay đổi


Happy coding

thelam92

0 nhận xét:

Đăng nhận xét