Re: object orientation question

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance

From: Big D (a_at_a.com)
Date: 03/13/04


Date: Fri, 12 Mar 2004 21:45:05 -0700

Yes, they are two different constructors, but they are the same class, so if
foo.Item2 is readOnly, then what is the appropriate method to create a foo
and define item2? A "wrapper" method that just modifies the private member
that the property reads from, a constructor that takes in item2, or a shared
method that returns an instance of foo, or is it all just personal taste?

Thanks for the response!

-D
"Tom Leylan" <gee@iamtiredofspam.com> wrote in message
news:OagYpcKCEHA.3568@tk2msftngp13.phx.gbl...
> "Big D" <a@a.com> wrote...
>
> This example of an existing Foo:
>
> > Dim myFoo as new Foo(433)
>
> And this example of a new Foo:
>
> > Dim myFoo as new Foo()
> > myFoo.Item1 = 3
> > myFoo.Item2 = 4
> > myFoo.insert()
>
> would access two different constructors... so you can assume that if you
are
> using the first constructor that the object has not just been created. If
> you set a flag to indicate if the object is new you can set it to True in
> the second constructor and False in the first one. If you have a "write
> once" property like Item2 you check the flag and permit it to be assigned
so
> long as the flag is set.
>
> Tom Leylan
>
>



Relevant Pages

  • Re: C++ design question
    ... so anyone can instantiate it without ... > default constructor in the class header rather that allowing it to be ... > separately and initialize a pointer to it in Foo: ... fooDeriveN::DoStuffWithBarBase() at all because we have a Bar* in Foo*. ...
    (comp.object)
  • Re: Need help designing some JUnit tests
    ... Given a hypothetical class named Foo where the constructor is: ... if (!myFoo instanceof Foo) fail; ... private Fuzz() { ...
    (comp.lang.java.programmer)
  • Re: object orientation question
    ... your example Foothis would make the Item2 property readonly. ... You would set it to True when the Foo() constructor was ... You have a private member variable named mItem2 and you have a read/write ...
    (microsoft.public.dotnet.languages.vb)
  • Re: C++ design question
    ... The default constructor is implied in the initialization list. ... One wants to access Bar at the superclass level to avoid static typing ... Usually that would be done by whoever instantiates a Foo subclass ...
    (comp.object)
  • Re: "x.constructor == Foo" vs "x instanceof Foo"
    ... (x instanceof Foo) ... by examining the value of its first argument's the constructor ... as giving the object graph: ...
    (comp.lang.javascript)