Open GoogleCodeExporter opened 8 years ago
Why do you have to do this via subclassing? Why not use object composition.
Simply write a class that has a factory method that creates a chart with the
styles you want. I was inspired by Josh Bloch's Effective Java when I wrote
this library. In short, inheritance breaks encapsulation.
Original comment by Julien.C...@gmail.com
on 15 Oct 2011 at 10:44
In fact, an inheritance sometimes breaks encapsulation. So I was tried to
implement my specialized charts by not inheritance but composition.
At that time, I realized that my charts have hierarchical structure and "is-a"
relations each other. The formal solution for this situation is composition.
I know I should build my own class structure same as tree of GCharts. However,
as a design decision, I may select inheritance to prevent a complexity more
than needed. I think that it would be a better not to inhibit potential to
select inheritance.
Humm... I have also read Effective Java. So I know the risk of subclassing
abuse and think you may be right. I'll try to composy my hierarchical
structure again.
Thank you.
Original comment by dai.0...@gmail.com
on 15 Oct 2011 at 1:28
Original issue reported on code.google.com by
dai.0...@gmail.com
on 15 Oct 2011 at 6:01