Re: Holub on getters/setters again
From: Daniel Parker (danielaparker_at_spam?nothanks.windupbird.com)
Date: 01/25/04
- Next message: Avner Ben: "Re: UML question"
- Previous message: Daniel T.: "Re: Holub on getters/setters again"
- In reply to: Daniel T.: "Re: Holub on getters/setters again"
- Next in thread: Ron Jeffries: "Re: Holub on getters/setters again"
- Reply: Ron Jeffries: "Re: Holub on getters/setters again"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Date: Sun, 25 Jan 2004 02:19:40 -0500
"Daniel T." <postmaster@eathlink.net> wrote in message
news:postmaster-889604.01461125012004@news05.east.earthlink.net...
> "Daniel Parker" <danielaparker@spam?nothanks.windupbird.com> wrote:
>
> > Note that even if we return a clone of an array list, if the entries in
the
> > array list are mutable, the client code may still be able to violate
> > conditions for the set, by making member wise changes such that two
entries
> > now evaluate as equal. The tradition in Java and C# seems to be not to
> > worry about these things too much. We don't see deep copies very much.
>
> I guess the question here is how do we decide what should go in the set?
> The code as origionally presented would certanly allow two object with
> the same state (ie two different but equal object) to be contained in
> the set,
I'm not so sure about that.
> so I don't think that is much of an issue.
The code for Add is
public void Add(object o) {
if (this.Includes(o)) return;
contents.Add(o);
}
I don't see the source for Includes, but presumably it would do equality
comparisons for each element in the array, until it found a match. C#
allows overloading of the equality operator, which can depend on state
rather than reference identity, string comparison, for example, is
overloaded to comparing the content of the two strings. So in particular I
don't think the Add method would allow two strings with the same state.
Regards,
Daniel Parker
- Next message: Avner Ben: "Re: UML question"
- Previous message: Daniel T.: "Re: Holub on getters/setters again"
- In reply to: Daniel T.: "Re: Holub on getters/setters again"
- Next in thread: Ron Jeffries: "Re: Holub on getters/setters again"
- Reply: Ron Jeffries: "Re: Holub on getters/setters again"
- Messages sorted by: [ date ] [ thread ] [ subject ] [ author ]
Relevant Pages
|