Consider Liskov’s substition principle for inheritance — Medium
We’ve talked about the open/closed principle and how it can be useful to achieve a flexible system. But when extending a class, we need to be careful.
For example: We have a request and according to request, if the state is in edit mode, make the background always white. We’ve created a custom view by extending View class and luckily the base class already had setBackgroundColor method available to change. We simply put a condition to make sure if the system is in edit mode, make the background always white. This worked flawlessly. Since we love reusable components, we used this view in some other places too.
Read full article from Consider Liskov’s substition principle for inheritance — Medium
No comments:
Post a Comment