samedi 24 octobre 2015

Hiding implementation to client

I am studying the design patterns and there are some things I don’t get to understand. For instance, I have often come across the idea of hiding the implementation to the client.

For example, with respect to the factory pattern I read that the logics of the application must not know the subclasses of the user interface, not even during the creation.

I don’t get why hiding the implementation to the client is an advantage. The only reason I can think of is that of simplicity. Indeed, I guess in this case the client needs to know only the interface, and not the various subclasses, in order to use the objects, thus making everything easier, since you don’t need to know the whole implementation of the subclasses. Am I right?

However, I think it might happen that you need to call a specific method of a subclass, in which case you are force to cast the subclass in order to call the method.

Having said that, I would like to ask you the following questions:

  1. What does the idea of “hiding concrete classes or hiding the implementation to the client mean? What’s the advantage? Is it just a matter of simplicity and maintenance?

Moreover, I would like you to give me some advice on books and online resources (theory and practice) on software engineering. Indeed, there are several aspects of it which are unclear to me. Namely independent objects and programming to interface.

Thanks for your help

Aucun commentaire:

Enregistrer un commentaire