Of Portfolio, LabVIEW and Stock Ticker…

Recently I was asked by a company to provide samples of LabVIEW code I previously wrote.

It shouldn’t have been a problem. I have used LabVIEW for a long time (since version 5 I believe). I learned it during my master’s and carried on using it throughout my career. The latest version is 11 (or LabVIEW 2011).

Some of you may ask: “What is LabVIEW?”

    • LabVIEW is a proprietary graphical cross-platform (Mac, Windows and Linux/Unix) development environment (using the G programming language) developed by National Instruments.
    • LabVIEW is particularly well suited for instrument/process control/measurement/automation and used in universities, research labs and manufactures.
    • LabView relies on something called a VI (for Virtual Instrument). A VI is an object with both a front panel and a block diagram. The interaction/connectivity with the outside world and with other VIs is provided by controls and indicators located on the front panel. The diagram is used to connect controls, indicators and other VIs. See an example here.
    • LabVIEW follows a data flow paradigm and may be the element that causes the most confusion with programmers new to the language.
    • LabVIEW is well suited for parallel execution.
    • More info available on LabVIEWWikiWikipedia and Lava.

Back to the initial request from that company… It is not unheard for companies to ask for a portfolio of applications/sources but I must admit I was unprepared for that. All the LabVIEW code I wrote (apart for the code written during my master’s), was written for the companies I worked for or their clients. I do not have ownership of that code and it was created under NDA. I realised that I never wrote something ‘personal’ in LabVIEW… Not even to control my toaster… And I started regretting it. I have used LabVIEW primarily for tests automation (interfacing with a wide range of electrical/optical test instruments and products) but this didn’t seem a practical solution for the portfolio (“It works you know… But you only need the $150000 piece of test equipment to try it!!!”). I ended up going for something where LabVIEW might not be best suited (there is the challenge): A stock ticker (an application displaying selected stock market quotes).

Initial specs:

    • Displays a number of stock tickers.
    • Data displayed: Symbol, name, change, change %, volume.
    • Stock tickers can be added/deleted.
    • Refresh rate can be selected.

I came up with a first version that I sent to the company. I later substantially refactored the code. The main reason for refactoring (other than fixing a few bugs) was a limitation with one of the UI objects I had created. In the original design, the object containing the list of stock tickers was an array of clusters. The clusters contained an indicator for each piece of data I wanted to display (symbol, price, change, …). Something I couldn’t do with this design was to individually control the colour of each cluster object (green/red for positive/negative change). If you modify the attribute of an array element (other than the value of the element), this modification will affect all array elements. The solution I chose was to use the Table object as it allows the attributes to be changed for each cell. Something else I did was to refactor the code using TDD with JKI’s VI Tester for LabVIEW. I cheated a bit with the unit testing as the HTTP tests are done with with the GET command and not with a mock/simulated data. Finally, I added a few more items to the specifications.

Additional specs:

    • Allow “change” and “change %” to change colour.
    • Select data source between Google/Yahoo.

I uploaded the refactored code to my GitHub account. The first GitHub submit of many I hope. I am planning to add another LabVIEW project to allow for stock data viewing. Obviously, LabVIEW is not the best choice for this kind of application (that is if we want a finished product) but it allows RAD and is good enough for prototyping.

Lesson learnt:

    • If you are in a creative job, don’t wait to long before building a portfolio!
Posted in Business/Finance/Management, Hardware, Other, Technology | Leave a comment