RAGHU<br /> <br />"When the going gets tough, the tough get going"
Betty Rubble? Well, I would go with Betty... but I'd be thinking of Wilma.
Originally posted by Aaron Shaw:
With the interface you can simply cast the object to that interface type, while the different object classes are completely unrelated, except that they all implement that interface.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
João Bispo wrote:I could use some dynamic casting... I'm writing this more for Chris Beckey, which was curious about a use.
I have an object "library" in some programs which act as a repository of Objects (it's no more than a table with objects, with Strings as keys). It receives objects which represent information from various sources (configuration files, intermediate results from other objects). This way, the information becomes readly avaliable in any part of the program. Because I didn't want the "working" objects to be dependent on a Singleton, there is a loading object/methods which does this job: it uses the "library" object to load information into the working objects. Usually, there is a "Controller" with the main control flow of the program which calls these methods.
It doesn't need dynamic casting to work, but for each entry in the table, I need to write code, and great part of that code could be automated (i.e.: not needed to be written) if I added information about the types of the objects, in String format for example. So, the dynamic casting would not be necesary for the program to work, but would turn the class "library" more usable.
I wanted to decouple the parsing and loading of information, from the objects that use that information, and that was what I came about with. If you know better/different approaches, I'm very interested =)
“Everything should be as simple as it is, but not simpler.” Albert Einstein
with the "Quote" button, then people can see the old discussion.quotes
I didn't like the taste of tongue and it didn't like the taste of me. I will now try this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
|