-
Notifications
You must be signed in to change notification settings - Fork 1
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Facade Pattern and The I in SOLID #211
Comments
My understanding is that the Facade pattern and ISP are addressing two separate issues. Facade pattern provides a solution to the issue where a client does not want to have extensive awareness about the internal pieces of some component - this is solved via the intermediary "facade". ISP is solving the problems that can occur if a class has to implement useless / redundant behaviour, because it implements an interface that is too broad. This is solved by breaking up the single interface into more modular interfaces - such that each smaller interface contains only related behaviour. That's what I understand from some online reading - one article is here |
@anubh-v is correct |
Thanks for the clarification (and the online article)! Correct me if I miss out anything, in essence a facade hides internal details (may be useful) from a client, ISP aims to hide non-essential methods/services from a client. |
@damithc I understand that facade pattern has something to do with hiding internal details of a component from the client. Is it only meant to describe the relation between different components at a higher level? Is it still relevant to describe relation between classes? More specifically, given the scenario below, is it an example of facade pattern being demonstrated? (I can very well argue that the internal details of |
@jhengy no, I don't think this case is an example of the Facade pattern. |
@iamjackslayer I think ISP is not about hiding anything, it seems to be about creating appropriate interfaces (a more "cohesive" interface is preferred over one that is too broad) |
@anubh-v I see, much thanks! |
In facade pattern, a facade component is introduced to prevent internal details from being exposed to the clients.
On the other hand, according to the Interface Segregation Principle, an interface (abstraction) is introduced so as to prevent a client from being forced to use methods it does not use.
Since software design patterns are more concrete than software principles, can I treat facade pattern as a direct application of ISP?
Thanks for reading and I appreciate any inputs.
The text was updated successfully, but these errors were encountered: