If there is a relationship between those properties, such as with x, y for a
point.

Would it be possible to extract a class and make it immutable?  So the
construtor is always used to validate the creation of the two values.  Also
when setting a property to the containing class it can be done by creating a
new instance, so you implicitly know the values will be correct.

Just an idea,

Duncan
----- Original Message -----
From: "Chris Sells" <[EMAIL PROTECTED]>
To: <[EMAIL PROTECTED]>
Sent: Friday, May 17, 2002 7:26 PM
Subject: Re: [DOTNET] Setting properties


> I ran into this issue just the end day with a start date and an end
> date. I couldn't figure out how to check that the start was always
> before the end without requiring them to set the properties in a certain
> order.
>
> Chris Sells
> http://www.sellsbrothers.com/
>
> > -----Original Message-----
> > From: dotnet discussion [mailto:[EMAIL PROTECTED]] On Behalf
> Of
> > Simon Robinson
> > Sent: Friday, May 17, 2002 11:01 AM
> > To: [EMAIL PROTECTED]
> > Subject: [DOTNET] Setting properties
> >
> > Hi guys
> >
> > I have a class with two integer properties - call them A and B.
> > There is a condition that the value of B should always be greater than
> A,
> > otherwise the class won't function correctly. I'd like the error to be
> > detected and an exception thrown when client code sets the properties,
> > and I'm trying to figure out if there's any way of doing this that's
> > consistent with the normal .NET usage guidelines that it should be
> > acceptable to set
> > properties in any order.
> >
> > Any ideas? Is what I want to do possible?
> >
> > Simon
>
> You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
> subscribe to other DevelopMentor lists at http://discuss.develop.com.

You can read messages from the DOTNET archive, unsubscribe from DOTNET, or
subscribe to other DevelopMentor lists at http://discuss.develop.com.

Reply via email to