Stuart Posted January 11, 2011 Report Share Posted January 11, 2011 I'm teaching an introductory programming course using LabVIEW to 30 college freshmen, as part of a comparison study of text based vs. graphical programming. To match curricula, I need to include two days of object oriented programming. There are lots of great examples of how to do this, but I need to find a compelling example that shows why it is used. Is there some simple application that involves solving a real world problem, that becomes much easier, or much more obvious when OO concepts are applied to the solution? I'm drawing a blank, and have posed the question to several colleagues, and have them puzzled as well. Stuart Quote Link to comment
Aristos Queue Posted January 11, 2011 Report Share Posted January 11, 2011 Using OO to mitigate the problems that arise when hardware is obsoleted before the system that needs that hardware goes obsolete: http://zone.ni.com/devzone/cda/epd/p/id/6307 (There are two examples attached to this document... use hal_version_2.zip, as that's the one that has been recently revised. We're leaving the old one up as reference just for a short while in case people are still using that as a reference example.) You might also hunt around for one of the "creating a framework that 3rd parties can plug into" examples. Quote Link to comment
Mark Balla Posted January 14, 2011 Report Share Posted January 14, 2011 I'm teaching an introductory programming course using LabVIEW to 30 college freshmen, as part of a comparison study of text based vs. graphical programming. To match curricula, I need to include two days of object oriented programming. There are lots of great examples of how to do this, but I need to find a compelling example that shows why it is used. Is there some simple application that involves solving a real world problem, that becomes much easier, or much more obvious when OO concepts are applied to the solution? I'm drawing a blank, and have posed the question to several colleagues, and have them puzzled as well. Stuart The project I am currently working on processes and displays data in specified ways. The User determines what and how data is calculated as well as what will be displayed. Initially the "User" was a person. There for several dialog vis were created to extract the needed information before the application could continue. The project has expanded and the user is not always available to enter in the information. In one case the program will extract the needed information form a file. In another case the information will be queried from a PLC. Extracting data from each of the different sources requires very different methods User: Ask user using dialog vis File: Find Open and read data. PLC: Setup connection read tags To solve this problem I created a parent "Data Source" Class and 3 children User, File, PLC, Later if another data source is requested I simple add another child The "Get Data" method is overwritten by each child using dynamic dispatch. Hope this helps spark and idea for you Mark Quote Link to comment
Stuart Posted January 26, 2011 Author Report Share Posted January 26, 2011 The project I am currently working on processes and displays data in specified ways. The User determines what and how data is calculated as well as what will be displayed. Initially the "User" was a person. There for several dialog vis were created to extract the needed information before the application could continue. The project has expanded and the user is not always available to enter in the information. In one case the program will extract the needed information form a file. In another case the information will be queried from a PLC. Extracting data from each of the different sources requires very different methods User: Ask user using dialog vis File: Find Open and read data. PLC: Setup connection read tags To solve this problem I created a parent "Data Source" Class and 3 children User, File, PLC, Later if another data source is requested I simple add another child The "Get Data" method is overwritten by each child using dynamic dispatch. Hope this helps spark and idea for you Mark Thanks for the good ideas with this. I'd thought of the plug-in architecture myself, but not the obsolete hardware challenge or the multi-access point problem. These are still a bit above the level of non-programmers learning LabVIEW in a 10-week class, although the plug-in and multi access point can probably be simplified enough to work as problems. Thanks again, Stuart Quote Link to comment
jdunham Posted January 26, 2011 Report Share Posted January 26, 2011 Hi Stuart: One use for a plugin/OOP architecture is debugging/logging. I have a VI that I sprinkle around in my code that logs messages and errors to a text file. I think a lot of programmers have something like that, and I think your students can understand the value. So if you make it object oriented, it's much easier to change the way it behaves, like I have a version that emails me when there is an error. You could also use it to post status messages to a web page, or put up certain error codes in dialog boxes. But all the code that calls this logging VI has no need to know how it works. If I distribute the code, I just have to distribute the base class, and the user can ignore it or write their own descendants of the class to meet their own needs. For this implementation, I keep the object in a global, so that I don't have to pass the lvclass wire through all though hundreds of routines that call it. Jason Quote Link to comment
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.