04-21-2016 11:20 AM
Hi all,
Relatively new to OOP still and have been working on an OOP project. My basic architecture is an OOP state machine, each class represents a different test. I have one test that will run through all the tests, so i figured i could just pass a new class into a for loop and have it run through all the tests. Problem with that of course is i connect to a device and the resource is lost with every new object. One solution ive come up with for this problem is to have a class that composes of the test class and the device resource and i could bundle a new class every time i switched tests and carry the same resource on the wire.
Any comments welcome, if my overall plan for this program is off please say so.
Thank you,
Matt
Solved! Go to Solution.
04-21-2016 11:54 AM
Use a shift register to store your device and have each of your Run Test methods have an input for the device object. You will probably need a couple of tests for Initialize Device and Close Device. These should be the only two cases that open or close your device. So no composition is needed.
04-21-2016 11:59 AM
Hi Crossrulz,
That actually makes a lot of sense, i was hoping to be able to carry it on the same wire as the class, but i think it probably just makes more sense to have it in the for loop. I suppose i should have one parent method for configure and open device and one for close device, beofre and after the loop?
Matt
04-21-2016 12:22 PM
matt198717 wrote: I suppose i should have one parent method for configure and open device and one for close device, beofre and after the loop?
That would make sense to me.