LabVIEW AF_11 More details of Interface

2019 ACLA Stephen Loftus Mercer G Interfaces

Learning notes for LabVIEW Interface

An Introduction to G interface

What is an interface type

In General Context:

Software interface = the set of functions that one code module uses to request functionality from another module

In today’s Context:

Interface = a new data type that defines a set of tasks that object can do without specifying how those tasks must be done

Basic Definition

Identity - State - Behavior

Three things go into making a class and decide the inheritance hierarchy as well as how classes related to each other.

  • State is the internal data that a class stores that has the transitions that it moves through
  • Behavior is the presentation that it the things/tasks Class can do
  • Identity is the how the rest of system think of this object

Interface only defines:

  • Identity
  • Behavior

assets/images/LabVIEW Actor Framework/11/Interface.png

  • An interface is a user-defined data type with encapsulation and inheritance
  • An interface has all parts of a class except the private data control and the Call Parent Class Method node
  • Class inherit methods from interfaces and then provide their OWN implementation (very similar to inherited from an abstract Class)

It do not have private data control.

  • A Class defines an object’s existence, behavior and it is a concrete thing that we know how to work/implement
  • An Abstract class is the framework around it, it is a basic structure that the details will be filled later
  • An interface doesn’t even really talk to the structure. It says this is what I can do, this is a list of functionality. When a class has this interface, it can do these things

Why would users want that?

What use is a thing that looks like a crippled class?

There is a problem with inheritance

If we define using Prying Tool to open a box, a Nailer belong to Pounding Tool can not be used to open a box

The flathead screw driver can also be used to open a box although it is not a prying tool.

Furthermore, we can not put Pry() in tool attribute as it is also a bad idea.

We should not piling functionalities into base class in order to support specific cases. Instead we inroduce the Lever Pry() interface

It is not a real “Class”, if we have multiple class inheritance where we bring the classes together, some state that has to somehow be merged.

We can use the interface with unrelated classes.

The Key has its own private method to pry a small battery box instead of load of huge box.

There is no loyalty of an interface to a particular class hierarchy. With the wiring

  • Hardware\ Measurement Abstraction Layers
  • Plug - in Systems
  • Loosely coupled messaging
  • Multiple inheritance
  • Mock Testing

Notes: Class more focus on Identity Interface more focus on Task

Multiple Interface inherit is allowed.

Another example for Interface, interface is the higher level abstract on skills/tasks

No more Abstract Message

  • Interface are essentially classes without data
  • Interface enable a form of multiple inheritance
  • Interface decouple modules and enable dependency inversion
  • Interface make nicer code in may use cases

Comments