samedi 30 janvier 2016

Best way of handling object composed of two other objects in terms of hiding implementation details?

For instance, I have a class named Car which contains of two fields of type AdminPart and PassengerPart correspondingly.

For client code using my code I want the client code to be able to do car.getLicense() and not car.getAdminPart().getlicense() . This of course is implemented as getlicense() in Car which in turn calls the relevant getter. Same for setters.

Is there a best practice for this? Something I've overlooked ? Thanks :-)

Aucun commentaire:

Enregistrer un commentaire