Reputation: 33
One of the important advantages of the facade pattern is that it decreases the dependencies between classes, which is not clear to me as I don't know any example that implements this pattern. Also, I know that we use the abstraction occurrence pattern so that we make one class that hold the common information between related objects and we make another class that holds the occurrences of these objects , but I still can't figure out what is the advantage of doing so, because we still can make a single class that can create these related objects ? So please someone clarify these two points.
Upvotes: 2
Views: 1465
Reputation: 9927
You are right about unclear or meaningless example about these patterns. For clarifying these patterns I am going to explain them with two proper example.
Façade
As you can see in following pictures, the first one has many relation between clients and order system whereas the second one has better design and it decreases dependency between external entities and internal entities.
Abstraction-Occurrence
For implementing our projects, you can do everything but patterns help us to do it properly. So Abstraction-Occurrence pattern should be followed if you want to avoid duplicating data. For example, in library, items (objects) have common properties such as name, author, and so on, but these items has different properties like barCodeNumber
and if we incorporate all of properties to a single class, we can’t use common properties separately. For example, another entity may need to Title properties and different properties, but with a single class, we can’t do it. Abstraction-Occurrence pattern helps us to handle these situations.
Upvotes: 3