Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.python > #29041 > unrolled thread

Re: main and dependent objects

Started byJean-Michel Pichavant <jeanmichel@sequans.com>
First post2012-09-13 17:22 +0200
Last post2012-09-13 17:22 +0200
Articles 1 — 1 participant

Back to article view | Back to comp.lang.python


Contents

  Re: main and dependent objects Jean-Michel Pichavant <jeanmichel@sequans.com> - 2012-09-13 17:22 +0200

#29041 — Re: main and dependent objects

FromJean-Michel Pichavant <jeanmichel@sequans.com>
Date2012-09-13 17:22 +0200
SubjectRe: main and dependent objects
Message-ID<mailman.609.1347549751.27098.python-list@python.org>
----- Original Message -----
> 2012/9/13 Jean-Michel Pichavant <jeanmichel@sequans.com>:
> >
> > Nothing shocking right here imo. It looks like a classic
> > parent-child implementation.
> > However it seems the relation between Obj and Dependent are 1-to-1.
> > Since Dependent need to access all Obj attributes, are you sure
> > that Dependent and Obj are not actually the same class ?
> >
> >
> > JM
> 
> Yes well the main class is already big enough, and the relation is
> 1-1
> but the dependent class can be also considered separate to split
> things more nicely..
> 
> So I think it will stay like this for now and see how it goes.
> 

Difficult to say given the meaningless names you provided. Just in case, you can still split things nicely in 2 classes and still get Dependent to be the same thing than Obj : by inheritance. It is a common way to extend one class's features.

class Obj
class Dependent(Obj)

But do it only if Dependent **is** actually an Obj.
If Dependent not an Obj but part of an Obj, then your original implementation is probably the way to go.

JM

[toc] | [standalone]


Back to top | Article view | comp.lang.python


csiph-web