Less APIs or more encapsulation?
newptcai at gmail.com
Wed Sep 9 17:08:47 CEST 2009
2 class, B contains C. When user want to use some service of C,
there are two choice:
First, more encapsulation:
Sencond : Call seice of f c directly:
Generally, what I learned from books told me that 1st choice is
But when C has many many methods to expose to outer user, 2nd choice
seems to be more reasonable I In the first design, B.newMethod did
nothing really useful.
ctaully, , there are D/E/F, etc. in B we methodhod has to be exposed
to user code, which makes encapsulation more tedious.
In fact, these classes, C/D/E/F all have different jobs, but they all
belongs to a real world object "B", B is only a container of C/D/E/F.
What do you think about it?
More information about the Python-list