Hello folks,
I "discovered" R4X last Saturday and I've been having so much fun with it. I worked on Basic for more years that I can remember, learning it in mid 80s using GW-Basic, then using Turbo Basic since ~1988 as a hobby. In early 90s I met Visual Basic 1 but it sucked very badly, went back to Turbo Basic. Years later, in 1994, I started working professionally in VB3 for about four years and then jumped to VB6 until 2005 (although managed projects on it till mid 2011.) I've not been related to any basic-based project since then.
All that said, just to mention that R4X brings so much nostalgia to me. Thanks to the developer who made it possible!
Ok.. my question...
=======
I'm trying to create a design similar to the following, but I'm not quite sure what are the best practices, or the best approach, in B4J. Any help will be appreciated!
Let's say I've a main class called Manager.
I also have three different classes called EngineA, EngineB and EngineC. All these classes share the same methods and properties. Let's say "name" and "doSomething()"
I've love to have an "engine" property in the Manager class that can hold any of the different engine classes so I can call manager.engine.doSomething() or manager.engine.name
I know inheritance is not possible and I've found duck typing is the recommended approach.
What I've done so far, is having a run(cmd, Args() as object) method in manager class which makes a CallSubX(cmd [, Args()]) on the appropriate engine, but it looks like so much work.
I'm not sure if this is the best approach possible in B4J. Any hint here?
Thanks in advance,
Will
I "discovered" R4X last Saturday and I've been having so much fun with it. I worked on Basic for more years that I can remember, learning it in mid 80s using GW-Basic, then using Turbo Basic since ~1988 as a hobby. In early 90s I met Visual Basic 1 but it sucked very badly, went back to Turbo Basic. Years later, in 1994, I started working professionally in VB3 for about four years and then jumped to VB6 until 2005 (although managed projects on it till mid 2011.) I've not been related to any basic-based project since then.
All that said, just to mention that R4X brings so much nostalgia to me. Thanks to the developer who made it possible!
Ok.. my question...
=======
I'm trying to create a design similar to the following, but I'm not quite sure what are the best practices, or the best approach, in B4J. Any help will be appreciated!
Let's say I've a main class called Manager.
I also have three different classes called EngineA, EngineB and EngineC. All these classes share the same methods and properties. Let's say "name" and "doSomething()"
I've love to have an "engine" property in the Manager class that can hold any of the different engine classes so I can call manager.engine.doSomething() or manager.engine.name
I know inheritance is not possible and I've found duck typing is the recommended approach.
What I've done so far, is having a run(cmd, Args() as object) method in manager class which makes a CallSubX(cmd [, Args()]) on the appropriate engine, but it looks like so much work.
I'm not sure if this is the best approach possible in B4J. Any hint here?
Thanks in advance,
Will