LabVIEW

cancel
Showing results for 
Search instead for 
Did you mean: 

OOP architecture for device driver

Solved!
Go to solution

@Yamaeda wrote:

@seb_bd wrote:

my main issue here is that if I needed to implement this "CheckCRC" in all the "Read" methods of my devices, I would need to wire it in all the children VIs (since all children have to override the parent/interface methods).


Well ... yes. Sooner or later you have to code. 🙂

/Y


I would argue that in general, if you find yourself in a situation where a requirement change may require you to make the same code changes in many places, you may want to rethink your design. 

 

You have different classes for different libraries/different devices. Keep those libraries for low level interfacing to the device based on the ActiveX library type. If you need to need to implement and check CRCs for the data you are sending to the device, regardless of the ActiveX library type, then maybe the 'data' should be in its own class? What about creating a 'device interface' class (not an 'i' interface class) that contains several classes used to communicate with the device, including a device library wrapper class, and a device data class. In your device interface.lvclass 'read from device' method you call the device library.lvclass 'read' method, and pass the output into the device data.lvclass 'parse response' method. Implement your CRC check there - if it changes, you just update that class, and dont need to update your ActiveX classes. 

 

 

Message 11 of 15
(216 Views)

I would argue that in general, if you find yourself in a situation where a requirement change may require you to make the same code changes in many places, you may want to rethink your design.  


I completely agree. I'll keep my low-level as simple as possible and only implement the higher-level stuff  in the interface. Your answer makes it clearer to me, thanks.

 

0 Kudos
Message 12 of 15
(211 Views)

@seb_bd wrote:

I would argue that in general, if you find yourself in a situation where a requirement change may require you to make the same code changes in many places, you may want to rethink your design.  


I completely agree. I'll keep my low-level as simple as possible and only implement the higher-level stuff  in the interface. Your answer makes it clearer to me, thanks.

 


Just to be clear, I dont mean to implement the higher level stuff in your 'i' interface class - keep that class empty. Rather, create a new class that as a part of its class data, has the above interface class. It also has as part of its class data interface classes for doing the other things you need to do to interact with your device (like building/parsing CRCs) 

 

So maybe calling this new class a device interface was a bad name - rather its a device interaction class.

0 Kudos
Message 13 of 15
(209 Views)

As this is an old discussion thread, I would like to inquire about updating the subject matter - in keeping with the following paradigm:

 

https://www.digitalocean.com/community/conceptual_articles/s-o-l-i-d-the-first-five-principles-of-ob...

 

Thank you,

 

johnkgeo1

0 Kudos
Message 14 of 15
(61 Views)