Does the Bridge Pattern decouples an abstraction from implementation?

BridgePattern decouples an abstraction from its implementation. Abstraction and Implementation can vary independently since the concrete class does not directly implement Abstraction ( interface) Implementation never refers Abstraction. Abstraction contains Implementation interface as a member (through composition). Coming back to your question regarding the example code in [journaldev][4] article : Shape is Abstraction Triangle is … Read more

When should I return the Interface and when the concrete class?

Return the appropriate interface to hide implementation details. Your clients should only care about what your object offers, not how you implemented it. If you start with a private ArrayList, and decide later on that something else (e.g., LinkedLisk, skip list, etc.) is more appropriate you can change the implementation without affecting clients if you … Read more

Should I use public or private variables?

private data members are generally considered good because they provide encapsulation. Providing getters and setters for them breaks that encapsulation, but it’s still better than public data members because there’s only once access point to that data. You’ll notice this during debugging. If it’s private, you know you can only modify the variable inside the … Read more

What does the quote “An extra level of indirection solves every problem” mean? [closed]

Generally it means that by increasing the level of abstraction one can make the problem easier to understand/resolve. Be careful with your abstractions though, the full quote at least as I heard it is, “You can solve every problem with another level of indirection, except for the problem of too many levels of indirection”.