Skip to content
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

Open
jackedelic opened this issue Dec 3, 2018 · 7 comments
Open

Facade Pattern and The I in SOLID #211

jackedelic opened this issue Dec 3, 2018 · 7 comments

Comments

@jackedelic
Copy link

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.

@anubh-v
Copy link

anubh-v commented Dec 3, 2018

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

@damithc
Copy link
Contributor

damithc commented Dec 3, 2018

@anubh-v is correct

@jackedelic
Copy link
Author

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.

@jhengy
Copy link

jhengy commented Dec 3, 2018

@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 AdminStaff are hidden from Payroll via the use of the interface SalariedStaff(acts as facade))

image

@damithc
Copy link
Contributor

damithc commented Dec 3, 2018

@jhengy no, I don't think this case is an example of the Facade pattern.

@anubh-v
Copy link

anubh-v commented Dec 4, 2018

@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)

@jackedelic
Copy link
Author

@anubh-v I see, much thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants