RE: Composition vs. Deriviation in Gtkmm
- From: "Gavin Lambert" <gavinl compacsort com>
- To: <kenton wilson gmail com>
- Cc: 'José Alburquerque' <jaalburquerque gmail com>, gtkmm-list gnome org
- Subject: RE: Composition vs. Deriviation in Gtkmm
- Date: Thu, 8 Nov 2012 18:34:37 +1300
Quoth José Alburquerque:
> On Wed, 2012-11-07 at 13:34 -0600, kenton wilson gmail com wrote:
> > in the context of Gtkmm, is there a rationale for preferring derivation
> > over composition (or vice-versa).
>
> From memory, I think the examples use a combination of inheritance and
> composition. For example, a lot of the examples have their own window
> class that derives from Gtk::Window. That's inheritance. However,
> whenever a widget class in the examples includes a declaration of a
> widget that it uses in some way (maybe to form part of its own
> presentation), composition is being used in that case. Both methods
> have their usefulness depending on what you want to accomplish and gtkmm
> supports both.
In other words, it's just figuring out whether a given object IS a thing or HAS a thing. If it IS a window, then derive from Window. If it HAS a helper widget, then it contains it.
It's not limited to gtkmm, it's standard practice in object-oriented design.
[
Date Prev][
Date Next] [
Thread Prev][
Thread Next]
[
Thread Index]
[
Date Index]
[
Author Index]