> So I assume that you use session.currentUser to hold EITHER a > manager object OR a worker object. > > This may be a stupid question since I don't have a lot of oop > experience, but is it bad form to use the same variable name > to store two different types of objects? That seems so > create the problem you have now, because you don't know what > class you used to instantiate that object.
Actually, being able to use one variable to store different objects can be very useful, and is commonly done in OO languages. However, these tend not to be just any two different objects, but objects that either inherit from the same base class or implement the same interface. For example, you might have a bunch of objects that are sortable. You might write a single interface, ISortable, then write functionality in each class to implement how ISortable works for that specific object type. Then, if you have an array of objects, all of which implement ISortable, you could sort them without worrying about what kind of objects they are exactly. This is a big deal in C# now, with the addition of generics - type-safe collections of various kinds. Dave Watts, CTO, Fig Leaf Software http://www.figleaf.com/ Fig Leaf Software provides the highest caliber vendor-authorized instruction at our training centers in Washington DC, Atlanta, Chicago, Baltimore, Northern Virginia, or on-site at your location. Visit http://training.figleaf.com/ for more information! ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~| Message: http://www.houseoffusion.com/lists.cfm/link=i:4:239830 Archives: http://www.houseoffusion.com/cf_lists/threads.cfm/4 Subscription: http://www.houseoffusion.com/lists.cfm/link=s:4 Unsubscribe: http://www.houseoffusion.com/cf_lists/unsubscribe.cfm?user=89.70.4 Donations & Support: http://www.houseoffusion.com/tiny.cfm/54