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
0 nhận xét:
Đăng nhận xét