CLD Summit Presentations

cancel
Showing results for 
Search instead for 
Did you mean: 

How and Why You Should Use Object-Oriented Programming

Overview

Compare task-based programming with object-oriented programming (OOP) and discover how using OOP can make applications more future proof and improve the developer's experience.

 

Description

 Learn how to convert any task-based application into an OOP application.

 

Hardware and Software Requirements

LabVIEW 

 

Steps to Implement or Execute Code

Open the zip file and open the project and follow the instructions below. Code is in 2016 version.

In this Demo, we are using three approaches to develop the Data logger Application.

1)Task based approach

2)Object Oriented Design (OOD), and

3)Object Oriented Programming (OOP)

Without Added Functionality:

--------------------------------------

1) In task based approach, we have a subVI that is performing the repeated task i.e. logging the data.

2) In OOD approach, we have a module that is performing the specific responsibility i.e. logging the data. We also have subVIs to acquire data and check limit.

3) In OOP approach, we have two classes that are performing the specific responsibilities i.e. using signal and logging the data respectively. In OOD, the acquire data and check limit subVIs were not related which means they can be used independently. But in OOP, Both methods are related with each other as they are part of ‘Signal’ class.  

With Added Functionality:

--------------------------------------

1) In task based approach, we create another subVI that will log the data in .xml file.

2) In OOD approach, we create another module that will log the data in .xml file.

3) In OOP approach, we create another child class to log the data in .xml file. This class inherits from the ‘log data’ parent class. First doing so protects the data of the object. Next we can override the dynamic dispatch VIs means both child classes can use the same log data.vi of the parent class. The code inside the override VI is dynamically dispatched during runtime.

These properties makes OOP code more robust, secure, and extensible than other methods.

Demo instruction is also included in the file

 

Additional Information or References

  • OOP Design Patterns
  • Hardware Abstraction Layers
  • Actor Oriented Design
  • NI Instructor Led Training: Object-Oriented Design and Programming in LabVIEW (

    https://goo.gl/2gD2tQ)

  • Online Resource: LabVIEW Object Oriented Programming Resource Directory (

    https://goo.gl/DydQm7)

157+ CLDs & 9 CLA Trained
LabVIEW Training resources
Download All
Contributors