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.GetManag er 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. 4 1196
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.GetManag er 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
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.GetUse r()
.Director.GetUs er()
.AsstManager.Ge tUser()
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,
"Chris" <no@spam.com> wrote in message
news:uB******** ******@tk2msftn gp13.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.GetManag er 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
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.
Thanks for the info Alan.
I'll be leaving well enough alone. :)
Regards,
<al*******@user s.com> wrote in message
news:11******** **************@ z14g2000cwz.goo glegroups.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. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: Casper B |
last post by:
Since I am only able to pass simple beans around using my Web Service
framework, I wonder how to incorporate business logic around these beans.
My idea was to let my Beans be the base class and simply extend these
with more sophisticated classes with the nessesary business logic
inside. However, when I do a cast from MyObjectBean to MyObject I get a
ClassCastException. Is it not possible to cast in this direction?
public class...
|
by: David MacQuigg |
last post by:
Seems like we need a simple way to extend Python syntax that doesn't
break existing syntax or clash with any other syntax in Python, is
easy to type, easy to read, and is clearly distinct from the "base"
syntax. Seems like we could put the @ symbol to good use in these
situations. Examples:
print @(separator = None) x, y, z
@x,y:x*x+y*y -- anonymous function
|
by: cwdjrxyz |
last post by:
Javascript has a very small math function list. However there is no
reason that this list can not be extended greatly. Speed is not an
issue, unless you nest complicated calculations several levels deep. In
that case you need much more ram than a PC has to store functions
calculated in loops so that you do not have to recalculate every time
you cycle through the nest of loops. Using a HD for storage to extend
ram is much too slow for many...
|
by: Tim Jarvis |
last post by:
Hi,
I have an object that I am binding to a text box, this object exposes a
boolean field, and I have implemented a format event handler and a
parse event handler for the binding object, where I convert the bool
value to some meaningful text.
i.e.
Binding b = new
|
by: Flip |
last post by:
I'm looking at the O'Reilly Programming C# book and I have a question about
extending and combining interfaces syntax. It just looks a bit odd to me,
the two syntaxes look identical, but how does C# know which is extending and
which is combining?
interface IStorable{
void Read();
void Write(object o);
}
| |
by: A Traveler |
last post by:
Hello all,
i was just curious if anyone whos been playing with VS2005 could tell me...
In javascript (and java??) you can alter the prototypes for an object in
your project. I dont remember the syntax exactly, but basically you do
something like:
function String.prototype.mySplit(myArgs){...do something...}
|
by: Ian Richardson |
last post by:
Hi,
The function I've put together below is a rough idea to extend a SELECT
list, starting from:
<body>
<form name="bambam">
<select id="fred">
<option value="1">1</option>
<option value="2">2</option>
|
by: Tom C |
last post by:
Hi all,
In an N-tier app, what is the DOT NET approach for extending an
application at all levels (i.e. DAL, Business Object, Client) for a
customer or module specific deviation without changing the base code.
Inheritance does not seem to be the answer here as the core
application could/should be the same for all customers. Does
extensibility play a role here? Events? How do I add a class to a
namespace in a separate dll that my...
|
by: Tim Spens |
last post by:
--- On Fri, 6/27/08, Tim Spens <t_spens@yahoo.comwrote:
I think I know where the problem is but I'm unsure how to fix it. When I call Register_Handler(...) from python via callback.setHandler1(callback1) this only seems to affect pythons ability to trigger an "event" in c. PyObject *Handler is always NULL even after I call Register_Handler(...). I thought there was some magic here that was assigning the pointer *Handler to my python...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |