Re: Software design patterns: encapsulation & object identity
From: Daniel Parker (danielaparker_at_spam?nothanks.windupbird.com)
Date: 12/08/04
- Next message: Dagfinn Reiersol: "Re: agile/xp question (formal analysis)"
- Previous message: AB: "Software design patterns: encapsulation & object identity"
- In reply to: AB: "Software design patterns: encapsulation & object identity"
- Next in thread: Mark Nicholls: "Re: Software design patterns: encapsulation & object identity"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Tue, 7 Dec 2004 23:47:42 -0800
"AB" <apqs43@dsl.pipex.com> wrote in message
news:1102467125.026213.290220@z14g2000cwz.googlegroups.com...
> Please consider a GOF Factory class (C++ implementation) that
> constructs, maintains, and issues GOF Singleton instances of a Widget.
> Clients of the Factory instance obtain the Widget Singleton instance
> from the Factory.
>
> 1. Is it important for the Factory to publish (e.g. document on public
> APIs) the fact that the instances issued to clients are Singletons?
Are the instances immutable? If so, no.
>
> 2. Similarly, might clients justifiably require unique non-Singleton
> instances from a Factory for some particular type of Widget, or would
> such a requirement represent an implementation constraint that the
> client is not entitled to impose on the Factory?
>
The primary reason the client would want a unique instance would be if it
wanted to change the state of the instance. But I think you would want a
separate factory method to return a mutable instance.
> 3. What would be the most appropriate public API names(s) for the
> Factory interface(s)? What would constitute a bad API name? Starter
> candidates include GetWidget(), MakeWidget(), WidgetInstance(). I
> anticipate the answer being partially related to 1 & 2.
>
WigetInstance or (better) GetWidget connote the idea of a singleton.
MakeWidget, CreateWidget or NewWidget connote the idea of a factory.
Depends on what you want to convey.
Regards,
Daniel Parker
- Next message: Dagfinn Reiersol: "Re: agile/xp question (formal analysis)"
- Previous message: AB: "Software design patterns: encapsulation & object identity"
- In reply to: AB: "Software design patterns: encapsulation & object identity"
- Next in thread: Mark Nicholls: "Re: Software design patterns: encapsulation & object identity"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|