Home All Groups Group Topic Archive Search About

Extending Business Object

Author
11 Jan 2006 7:38 PM
Brandon Miller
All,
I have an existing business object (VB.Net) which returns user IDs for our
locations in our regions.
One of the properties objReg.Manager returns the manager's user id (integer)
for a given location.

What I'd like to do is implement something similar to .ToString, so I might
call -
objReg.Manager.GetUser()
This would return a User object (which we already have written) representing
the Manager for that ID.
(There's also VP, Director, etc properties.. so this code would be used for
those properties as well)

We already have a objReg.GetManager property which does this, but I think it
would just be snazzier to implement it in the method above.

Does anyone know how I might pull this off -- or even what I would search
for to get me started?
TIA
Brandon.

Author
11 Jan 2006 7:47 PM
Chris
Brandon Miller wrote:
Show quoteHide quote
> All,
> I have an existing business object (VB.Net) which returns user IDs for our
> locations in our regions.
> One of the properties objReg.Manager returns the manager's user id (integer)
> for a given location.
>
> What I'd like to do is implement something similar to .ToString, so I might
> call -
> objReg.Manager.GetUser()
> This would return a User object (which we already have written) representing
> the Manager for that ID.
> (There's also VP, Director, etc properties.. so this code would be used for
> those properties as well)
>
> We already have a objReg.GetManager property which does this, but I think it
> would just be snazzier to implement it in the method above.
>
> Does anyone know how I might pull this off -- or even what I would search
> for to get me started?
> TIA
> Brandon.
>
>

I may have missed something on what you are looking to do.  If you have
the GetManager method that returns the object, what are you looking for
help on?

Chris
Author
11 Jan 2006 7:56 PM
Brandon Miller
Sorry.. I figured I wasn't explaining myself well.
Rather than have a separate method for each of the positions, (VP, Manager,
Director, AsstManager, etc)
I'd like to have a method at the end of each of those properties which
returns the User object for that account ID.
       .VP.GetUser()
        .Manager.GetUser()
        .Director.GetUser()
        .AsstManager.GetUser()

The guts of GetUser will be the same for any of those properties.
I just don't know how to make GetUser hook into the existing properties.
I think it would be easier to maintain, more intuitive and of course,
intellisense would kick in, making coding faster. :)

Thanks,
Show quoteHide quote
"Chris" <no@spam.com> wrote in message
news:uBRibfuFGHA.2912@tk2msftngp13.phx.gbl...
> Brandon Miller wrote:
>> All,
>> I have an existing business object (VB.Net) which returns user IDs for
>> our locations in our regions.
>> One of the properties objReg.Manager returns the manager's user id
>> (integer) for a given location.
>>
>> What I'd like to do is implement something similar to .ToString, so I
>> might call -
>> objReg.Manager.GetUser()
>> This would return a User object (which we already have written)
>> representing the Manager for that ID.
>> (There's also VP, Director, etc properties.. so this code would be used
>> for those properties as well)
>>
>> We already have a objReg.GetManager property which does this, but I think
>> it would just be snazzier to implement it in the method above.
>>
>> Does anyone know how I might pull this off -- or even what I would search
>> for to get me started?
>> TIA
>> Brandon.
>
> I may have missed something on what you are looking to do.  If you have
> the GetManager method that returns the object, what are you looking for
> help on?
>
> Chris
Author
11 Jan 2006 10:42 PM
alantolan
I'm a bit confused about the ToString() reference but the problem as I
understand it is


You have a business object which includes the 4 methods

  Function VP() as Integer
  Function Manager() as Integer
  Function Director() as Integer
  Function AsstManager() as Integer

where the integer is a userID.

You wish to be able to obtain more details about the user (basically a
User object)


You cannot just use a x.VP.GetUser() with extending the Integer type
(inherit something from Integer and include a GetUser() function). This
starts off as a dodgy idea and gets worse very quickly (how does this
new type (IntegerX ?) know how to look up a user?

Conceptually cleanest but it depends on the implementation of your
existing business object and how much you can change it, is to change
the existing functions to

  Function VP() as User
  Function Manager() as User
  Function Director() as User
  Function AsstManager() as User

where one of the properties on the User is ID() as integer

You then replace all references to .VP or .Manager with .VP.ID or
..Manager.ID, and so on.


If you cannot change the existing business object then you are back to
a more procedural shape of creating a function that takes a UserID and
returns a user object.

If the code for getting the user given the user ID is different for
each user type, well then it depends on how different.
  Very different, then you are probably stuck with different functions
for each.
  Mostly the same but with some small changes - you can create a class
to encapulate the general functionality which has overridable methods
for the specific sections.

Without more details it is hard to be more specific.


Best bet - if you can change the business object that is returning the
user ids to return users instead then I would go with that one.

hth,
Alan.
Author
12 Jan 2006 1:40 PM
Brandon Miller
Thanks for the info Alan.
I'll be leaving well enough alone. :)
Regards,

<alanto***@users.com> wrote in message
Show quoteHide quote
news:1137019360.846910.234440@z14g2000cwz.googlegroups.com...
>
>
> I'm a bit confused about the ToString() reference but the problem as I
> understand it is
>
>
> You have a business object which includes the 4 methods
>
>  Function VP() as Integer
>  Function Manager() as Integer
>  Function Director() as Integer
>  Function AsstManager() as Integer
>
> where the integer is a userID.
>
> You wish to be able to obtain more details about the user (basically a
> User object)
>
>
> You cannot just use a x.VP.GetUser() with extending the Integer type
> (inherit something from Integer and include a GetUser() function). This
> starts off as a dodgy idea and gets worse very quickly (how does this
> new type (IntegerX ?) know how to look up a user?
>
> Conceptually cleanest but it depends on the implementation of your
> existing business object and how much you can change it, is to change
> the existing functions to
>
>  Function VP() as User
>  Function Manager() as User
>  Function Director() as User
>  Function AsstManager() as User
>
> where one of the properties on the User is ID() as integer
>
> You then replace all references to .VP or .Manager with .VP.ID or
> .Manager.ID, and so on.
>
>
> If you cannot change the existing business object then you are back to
> a more procedural shape of creating a function that takes a UserID and
> returns a user object.
>
> If the code for getting the user given the user ID is different for
> each user type, well then it depends on how different.
>  Very different, then you are probably stuck with different functions
> for each.
>  Mostly the same but with some small changes - you can create a class
> to encapulate the general functionality which has overridable methods
> for the specific sections.
>
> Without more details it is hard to be more specific.
>
>
> Best bet - if you can change the business object that is returning the
> user ids to return users instead then I would go with that one.
>
> hth,
> Alan.
>