Apr
27

Object-flow Programming – Merging Dataflow and Object-Oriented Programming

by Tomi Maila, Apr 27, 2007 at 4:45 pm
1 Star2 Stars3 Stars4 Stars5 Stars (No Ratings Yet)
Loading ... Loading ...

I was giving a talk on LabVIEW object-oriented programming a few week ago in the local LabVIEW user group in Helsinki. For the talk I did some research on the roots of dataflow programming and the roots of object-oriented programming. According to a Wikipedia article I found, dataflow programming was introduced in Bert Sutherland‘s Ph.D. thesis, The On-line Graphical Specification of Computer Procedures in 1966. Coincidentially the first object-oriented programming language Simula 67 was introduced around the same time.

History of Dataflow, LabVIEW and Object-Oriented Programming

Now these two different programming paradigms are merging and giving birth to a new paradigm object-oriented visual programming or should I call it object-flow programming. I believe this to be just the beginning of a new phase in the evolution of visual programming; we’ll see a lot of innovation in this field for the years to come.

Multi-core processors force the software industry to seek solutions to the development of parallel application. Object-flow programming makes developing parallel programs easy. Text based programming languages are bug-prone; visual software development is much less so. Object-flow programming has all the means of doing the same for programming as what Microsoft Windows did for operating systems -making programming so easy and intuitive that it’s no longer a privilege of few.

What do you think? Do you agree with me on the future opportunities of object-flow programming? What do you see to be the greatest obstacles? Could National Instruments get object-flow programming to Forbes cover page or do we need some other company to take the lead? I’d love to hear you comments!

Print This Post Print This Post

Apr
23

Streamlined Software Development with Virtualization

by Tomi Maila, Apr 23, 2007 at 7:42 am
1 Star2 Stars3 Stars4 Stars5 Stars (1 votes, average: 4.00 out of 5)
Loading ... Loading ...

Would you like to test your software on multiple different operating systems? Do you have multiple development branches of your software you would like to isolate on separate computers to avoid unwanted interactions? Is the software you are developing a client-server system that requires multiple computers to run? Do you need to debug your crashing software?

If you answered yes to any of the above questions, virtualized development environment may be the solution to your challenges. Virtualization is currently a hot topic in IT-industry. The word virtualization has multiple meanings and the most common meaning is running multiple operating systems simultaneously on one physical computer by virtualizing the hardware layer. Practically this means that you can run multiple operating system installations in parallel on your computer.

There are a few ways to implement virtualization. One way is to run a virtualization software such as VMWare Server (Windows, Linux), VMWare Workstation (Windows, Linux), VMWare Fusion (OS X), Parallels (OS X), Xen (Linux) or XenSource (Linux) on top of the currently installed operating system or host operating system (the supported host operating systems are in parenthesis). These virtualization systems then allow setting up multiple operating system installations of top the host operating system. The operating systems run as if they were installed on bare metal but they are really running on top of virtual hardware environment provided by the virtualization software. Click the image below to see what it looks like to run LabVIEW on virtual Fedora Core 6 linux on VMWare Server on Windows XP host operating system.

Virtual Desktop

Virtual hardware environment

The isolated virtual computers are called virtual machines. From the operating system point of view virtual machines are exactly like real computers. They provide a processor, memory, hard drive, network interface, a monitor, a CD/DVD-drive, mouse, keyboard and may even support some USB-devices. The user of the virtualization software may define how much system resources such as memory and hard drive space each virtual machine may consume. The user may start and stop virtual machines by pressing start and stop buttons.

The virtual hard drive of each virtual machine is really a large file in the host operating system. The file may either be of a fixed size or gradually resizing up to some upper limit specified by the user. The memory is shared with the host operating system but the user may specify how much memory the virtual machine may consume. The host CD/DVD drive can be used with the virtual machines or alternatively a CD/DVD image can be mounted as a virtual CD/DVD drive. The host mouse and keyboard can be used to control the virtual machines. The virtual machine monitor is a window on the host operating system desktop.

The benefits of virtualization in software development

As indicated by the question in the beginning of the article there are multiple ways virtualization can benefit in the software development process. Virtualization allows isolating multiple software development environments on a same physical computer so that each branch is totally unaware of the other brances and cannot have any interactions with one another. This is a nice thing when you want to develop multiple different versions of the same software and don’t want the development of the different versions to interact and to cause problems in this way. You may also want to test your software with multiple different version of your development tool such as LabVIEW and keep all different version of the development tools isolated from one another. The ability to set multiple isolated development environments on a single computers makes the development process easier and saves your money and nerves.

Another issue where virtualization is a great benefit is when you want to test your software on different operating systems or different versions of the same operating system. Virtualization software allows you to set up multiple different operating systems on a single computer and run them all in parallel. Consider for example that you are developing a LabVIEW application and want to test that it runs properly on Windows XP, Windows Vista, different versions of Linux and OS X. With virtualization software you can run all these operating systems on one computer, although running OS X requires this computer to be a Mac.

Third benefit is when you develop a networked application and need to have multiple computers set up to run the application. Instead of really setting up multiple physical computers you may set up multiple virtual machines that run the different components of the software and interact with one another via the network.

A fourth task where virtual machines show their power is debugging your software. Virtualization technology allows you to make snapshots of your entire virtual machine. The snapshot stores the state of the virtual machine including the memory state and hard disk state to a file. Later you can roll back to this snapshot and repeat what ever you were doing. This is a nice tool when you are for example dubugging a crash. It allows you to roll back to the moment just before the crash and see what really was going on when the crash happened.

Conclusions

Virtualization and virtual machines are a great tool for software development. In this article I covered some general benefits of virtualization in the software development process. I’ll write a follow-up article where I talk about setting up a superb free virtualization software, VMWare Server for Windows. Subscribe to the feed not to miss the next article.

I’d also like to cover LabVIEW licensing issues related to running LabVIEW in virtual machines. I’ve emailed twice National Instruments media relations within the last month telling them that I’m writing an article on LabVIEW virtualization and asking them to comment LabVIEW licensing under virtual machines but they don’t seem to bother responding me. I guess blogging is still not considered a real media.

Print This Post Print This Post

Apr
14

Reusing Code by Inheritance

by Tomi Maila, Apr 14, 2007 at 8:45 pm
1 Star2 Stars3 Stars4 Stars5 Stars (2 votes, average: 4.50 out of 5)
Loading ... Loading ...

In our last topic in article series Introduction to Object-Oriented Programming in LabVIEW I explained how real world objects form conceptual hierarchies. This concept of hierarchies is also present in object-oriented programming where building block can have hierarchical relationships. This concept of hierarchical relationships of software modules in object-oriented programming is called inheritance, as explained last time.

Inheritance in practice

So what does inheritance practically mean in the context of object-oriented programming? Why would we like to define class hierarchies?

Let’s first define some concepts. When a class inherits from another class we call the class upper in the hierarchy a parent class and the class lower in the hierarchy a child class. Further we call parent, parent’s parent and all other classes up in the inheritance chain ancestor classes. Likewise we call all classes down the inheritance chain descendant classes. In the picture below these concepts are visualized for the class Car.

Terminology in LabVIEW object-oriented programming

As we explained earlier a class in object-oriented programming is a user defined datatype that encapsulates both data and functionality. In comparison conventional LabVIEW data types only carry data. As classes are types in object-oriented programming, wires of class types are called objects.

Each class in object-oriented programming specifies some functionality. To implement this functionality the class developer writes a set of method VIs. The method VIs are an integral part of the class. In addition the class developer specifies some internal or private data type for the class. This data type is a cluster. Note that the unlike conventional clusters, this cluster can also be empty.

Reusing ancestor methods

So what’s all the fuss about inheritance? Inheritance allows a developer of the descendant class to reuse much of the code in any of the ancestor classes. If an ancestor class has a method public method VI, this method is available also in any of the descendant classes. Furthermore if objects of ancestor class carry data of certain type, then all the descendent classes carry similar data of the same type.

Let’s take an example. Consider a land vehicle class. As each land vehicle has wheels, we decide to specify that a land vehicle class cluster of private data is an array of wheels. Cluster of private data is a place where the developer specifies the data type that is carried by the wire. Now our all objects of Land Vehicle class as well as all objects of any of the descendant classes of Land Vehicle would carry array of wheels as private data. In addition descendant of Land Vehicle can carry other private data as well but they would always carry at least an array of Wheels.

We cannot fix the number of wheels as some vehicles such as bicycle has only few wheels and others such as a train have more wheels. Further we cannot add an engine to cluster of private data as not all land vehicles have engines. The picture below illustrates the private data of our Land Vehicle class.

Private data of Land Vehicle class

Now we define a public method VI Add Wheel.vi to Land Vehicle class. This method would add a wheel to a vehicle. Now each descendant class of class Land Vehicle would also have these two methods automatically. Land Vehicle would be a kind of a template or a starting point from which we can now build different kinds of land vehicles such as a car or a bicycle.

VI interface of Add Wheel.vi


Class Land Vehicle is a parent class of classes Car, Bicycle and Motorcycle. Now comes the interesting part. All these three classes can call the Add Wheel.vi method as if it was their own. The picture below illustrates this ability.

Add Wheel

So by inheriting classes Car, Bicycle and Motorcycle form a common parent class Land Vehicle, we can share code related to adding wheels to different kind of vehicles between these three classes. The same generality cannot be achieved in classic dataflow programming with such an elegant way.

Passing descendant classes as arguments

Consider you want to travel from Paris to Berlin. Unless you want to walk, you would need a vehicle to take you to Berlin. However it could be an aircraft, a land vehicle or even a watercraft. So generally you could say that any vehicle could be used to travel from Paris to Berlin.

Similar way thinking can be applied to object-oriented programming. When any VI expects an input of general class type then any of its descendants can be passed as an argument as well. So should you have a VI Travel by Land.vi that expects an object of class Land Vehicle as an input, you can pass any object of any descendant class of class Land Vehicle as an argument. This is illustrated by the following picture. The VI expects a Land Vehicle (right) and we pass a Car which is a child of Land Vehicle (left).

Travel by Land

In the previous example we showed how we can reuse ancestor method VIs in descendant classes. However this is not the only benefit of inheritance and class hierarchies. In addition to reusing ancestor class code, we can also pass descendent classes as arguments where ancestor class is expected. Alternatively we can create an array of different kinds of Land Vehicles as select one of the items in an array using index array.

Travel by Land with array of objects

Conclusions

In LabVIEW object-oriented programming or LabVOOP for short we developers can share parent or other ancestor class code between all the decedents of that class. This is a great benefit when software components with shared properties are needed. In my next article in this series I’ll talk about class interfaces, how the interfaces can be shared between classes in the hierarchy and how this greatly enhances software development process. Subscribe to the RSS feed of this blog not miss it.

Print This Post Print This Post

Apr
02

Inheritance and Class Hierarchies in Object-Oriented Programming

by Tomi Maila, Apr 2, 2007 at 12:56 pm
1 Star2 Stars3 Stars4 Stars5 Stars (7 votes, average: 4.29 out of 5)
Loading ... Loading ...

As the third topic in my article series Introduction to Object-Oriented Programming in LabVIEW I’ll talk about inheritance and conceptual hierarchies in object oriented programming.

Hierarchies of real-world objects

Object of the real world often form conceptual hierarchies. For example a bicycle, a motorcycle and a car are all examples of different kinds of vehicles. A bus, a truck and an SUV are examples of different kinds of cars. These relationships between similar objects can be visualized using diagrams similar to one below.

Hierarchy of Vehicles

 

All vehicles share common properties and common functionality. For example all vehicles have one or more wheels and they are designed for transportation purposes. We can also fairly safely say that all vehicles have some sort of steering method.

All cars share even more common properties and common functionality. A steering wheel is used for steering the cars. An engine is used as a power source. All cars have at least four wheels and the wheels are symmetrically distributed on both sides of the car.

We can say that the word vehicle defines a class of real-world objects for transportation and so does the words car, bicycle and motorcycle. As cars, bicycles and motorcycles are all special kinds of vehicles as well we can say that words car, bicycle and motorcycle all define subclasses of class vehicle. In a similar way bus, truck and SUV can all be considered subclasses of class car as they are special kinds of cars.

Class hierarchies in object-oriented programming

It’s often the case that the building blocks of a software project form similar conceptual relationship hierarchies. Consider for example the following build-in LabVIEW types.

Numeric Types in LabVIEW

All of these build-in types are numeric types. Furthermore EXT, DBL, SGL, CXT, CDB and CSG are floating point numbers whereas I64, I32, I16, I8, U64, U32, U16 and U8 are integer numbers. We can divide integers to signed and unsigned integers and floating point numbers to real and complex numers. Indeed these numeric types can be considered to form a conceptual hierarchy similar to one below.

Hierarchy of Numeric Types

Object-oriented programming allows the developer to specify this kind of conceptual hierarchies in software architecture. Each box in the above image can be considered to be a class. Remember from my last article that classes are building blocks in object-oriented programming that encapsulate both data and functionality.

This concept of hierarchies is called inheritance in object-oriented programming. The word inheritance comes from the fact that the classes in the hierarchy inherit properties, functionality and interfaces of their parents and all other ancestors. The diagram itself is called a class diagram as it represents the relations between different classes.

Conclusions

In object-oriented programming developers can define class hierarchies that define the relations of classes. Decedent classes inherit the functionality, the interface and the data type of all the ancestor classes. Although it didn’t yet become clear, class hierarchies and inheritance is one of the key substances in object-oriented programming. Class hierarchies greatly enhance code reuse and allow creating more intuitive software architectures.

In my next article I’ll go into more detail what are the benefits of inheritance. Subscribe to the RSS feed so you will not miss it.

Print This Post Print This Post

Get Adobe Flash playerPlugin by wpburn.com wordpress themes