On 17 Nov, 19:58, Carl Banks <[EMAIL PROTECTED]> wrote:
> Google for Liskov Substitutability if you are interested. I didn't pull
> this idea out of my hat. In fact I learned the term from reading a post
> by GvR himself, though the idea was intuitive to me long before that.
>
> Carl Banks
Inte
On 2007-11-17, Odalrick <[EMAIL PROTECTED]> wrote:
>> But that breaks expectations: a user doesn't expect
>> set_width() to affect the height.
>
> I can't speak for everyone but I certainly expect setting the
> width of a Square to change it's height. In fact, that would
> probably be the reason I
>
> > >Well, you would if you override the two set_* methods to set both
> > > height and width to the same value
> >
> > But that breaks expectations: a user doesn't expect set_width() to
> affect
> > the height.
>
> I can't speak for everyone but I certainly expect setting the width of
> a S
On 16 Nov, 16:35, Carl Banks <[EMAIL PROTECTED]> wrote:
> On Thu, 15 Nov 2007 21:25:16 -0800, Dennis Lee Bieber wrote:
> > On Thu, 15 Nov 2007 16:57:57 -0800 (PST), Carl Banks
> > <[EMAIL PROTECTED]> declaimed the following in comp.lang.python:
>
> >> A source of confusion with "is a" is that it do
[EMAIL PROTECTED] a écrit :
(snip)
> It's hard to apply some of the available
> material's examples to Python since a lot of the documentation I find
> is specific to implementations in lower-level languages and don't
> apply to Python.
Fact is that quite a few design patterns are mostly workarou
[EMAIL PROTECTED] a écrit :
> In learning about design patterns, I've seen discussion about using
> inheritance when an object's relationship to another object is 'is-a'
> and composition when the relationship is 'has-a'.
wrt/ inheritance, it only makes sens with declarative static type
systems w
On 2007-11-16, Dennis Lee Bieber <[EMAIL PROTECTED]> wrote:
> On Thu, 15 Nov 2007 12:28:28 -0800 (PST), "[EMAIL PROTECTED]"
><[EMAIL PROTECTED]> declaimed the following in comp.lang.python:
>
>>
>> As a very simplified example, if I had two classes, Pet and Owner, it
>> seems that I would not have
On 2007-11-15, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
> inheritance when an object's relationship to another object is 'is-a'
> and composition when the relationship is 'has-a'.
>
> Since this is all new and I'm still learning, I was hoping someone can
> give me some pointers on best practice
On Nov 15, 3:28 pm, "[EMAIL PROTECTED]" <[EMAIL PROTECTED]> wrote:
>
My response ended up being pretty long and heavy for a beginner, but
you sound pretty smart.
> In learning about design patterns, I've seen discussion about using
> inheritance when an object's relationship to another object is
> I think my main concern while getting my toes wet on this was to not
> reference the owner object out of "thin air" but to pass it in when
> pet is instantiated. I'm not sure what 'actor-passed' is yet, but it
> gives me something to search for and learn about.
I meant ctor, short-hand for const
On Nov 15, 2007 2:37 PM, Diez B. Roggisch <[EMAIL PROTECTED]> wrote:
>
> > As a very simplified example, if I had two classes, Pet and Owner, it
> > seems that I would not have Pet inherit from Owner, since a pet 'has
> > an' owner, but not 'is an' owner. If this is correct, does my code
> > below
Sorry for the double post
-- Forwarded message --
From: Matthieu Brucher <[EMAIL PROTECTED]>
Date: 15 nov. 2007 23:38
Subject: Re: Python Design Patterns - composition vs. inheritance
To: "[EMAIL PROTECTED]" <[EMAIL PROTECTED]>
2007/11/15, [EMAIL PROTEC
> Yes. Of course there are other ways, establishing the connection later,
> and of course making the Owner know her pets. But your unidirectional,
> ctor-passed implementation is sensible.
I think my main concern while getting my toes wet on this was to not
reference the owner object out of "thin
On Nov 15, 3:37 pm, "Diez B. Roggisch" <[EMAIL PROTECTED]> wrote:
> > Also, I've seen talk that ideally you shouldn't have too many "dots"
> > in your method calls, instead using delegates to the methods and
> > attributes. Can anyone elaborate on this? Ideally, should I be writing
> > getattr() m
> As a very simplified example, if I had two classes, Pet and Owner, it
> seems that I would not have Pet inherit from Owner, since a pet 'has
> an' owner, but not 'is an' owner. If this is correct, does my code
> below reflect this? I passed the owner object into the pet object's
> constructor -
In learning about design patterns, I've seen discussion about using
inheritance when an object's relationship to another object is 'is-a'
and composition when the relationship is 'has-a'.
Since this is all new and I'm still learning, I was hoping someone can
give me some pointers on best practices
16 matches
Mail list logo