Tutorial: Software Development Method
Overview
Once you have learned many of the key NI LabVIEW software programming concepts, the next step is to create your own program. One of the most important aspects of software engineering is using an effective method to develop a program. Before you start developing applications, you need to determine all of the different project stages and plan accordingly. The first step in becoming an effective programmer is learning an efficient and reusable process to develop an application from start to finish.
Defining the Problem
Before you start planning a project, you have to clearly define the problems. Complex projects likely involve many different problems. For example, imagine a program in a machine that sells train tickets. The program must account for several factors such as how much different train tickets cost, types of discounts, methods of payment, and the schedule for all of the train lines.
One effective way many computer scientists organize their thoughts is by using a whiteboard or chalkboard to brainstorm. By using one of these, all of the thoughts and ideas you have are illustrated in a form that others can work with. If a project involves other people, group brainstorm sessions are also an effective way to organize every group member’s ideas. During this phase, it is important to write down on the whiteboard whatever comes to mind, no matter how unfeasible the idea seems. An example can be seen in the figure below.

Obviously this is just a small example, but it gives you an idea of how to get started with the brainstorming stage. By writing out all of the ideas in your head, you establish a better understanding of what exactly a project entails. Notice that the coffee idea is a little extreme, but it shows how the user should not hold back his ideas during this stage. Some of the best ideas for a project can spawn from ideas that may not seem realistic at first. Every computer scientist has a different method for brainstorming, so you should feel free to do whatever necessary to illustrate your ideas.
Identifying Inputs/Outputs
Every program has a certain number of inputs and outputs. Without these, a program has no functionality. The inputs of a program are all of the different elements used to make calculations and process data to produce the end results, or outputs, of a program. The ticket machine example above features multiple inputs and outputs. Some of the inputs include ticket type, discount type, and amount of money given to the machine. Some of the outputs or final products of the ticket machine are the printed ticket, the amount of change dispensed, and the receipt. It would be a good idea to use a whiteboard again to illustrate all of these parameters.
As you can see in the figure above, the purpose of the actual program is to manipulate the inputs to create the outputs. Therefore, it is crucial that a programmer has a clear understanding of the inputs and outputs before the actual programming begins.
Flowcharts
Flowcharts are essential in any type of software project. They basically illustrate the sequential steps and decisions made throughout the execution of the program and show every possible action and decision for a given algorithm. For the ticket machine example, a simple flowchart for when a customer buys a ticket is shown in the figure below.
There are a few items in the flowchart to note. The rectangular boxes represent action symbols. These actions can be anything from reading user input to displaying information to the customer. Two action symbols that should appear in every flowchart are the start and stop symbols. These symbols tell where a program begins execution and where a program halts execution. The start symbol should have one arrow only coming out of it while the stop symbol should have arrows only going into it. Each action symbol should have a maximum of one arrow coming out of it.
The other main component of the flowchart is the decision symbol. This symbol determines the actual flow of the flowchart. Once execution reaches these symbols, the specified condition inside the symbol is checked. The new path of execution from the decision symbol depends on whether the condition is met. In the example, the first decision symbol reads “A≥P?” When the execution reaches this symbol, it should check whether “A≥P,” or whether the money that the customer gave was greater than or equal to the ticket price. If the customer did not pay enough money, the execution goes back to the “Read A” action symbol. If the customer did pay enough money and the condition was met, the ticket prints and the execution continues.
Implementing the Code
Now that you have completed the planning stages, you need to start writing code. One common mistake is not using all of the resources gathered during the planning stages. You can significantly expedite the programming process by carefully following all of the charts and diagrams you created.
As far as the actual implementation goes, you should follow these widely accepted programming practices:
1. Document any code very thoroughly
2. Give variables and functions relevant names
3. Make code spacing readable and clean
Documentation is very critical, especially in group projects. If thorough documentation accompanies your code, other programmers can look at the code and understand the task you were trying to implement. This saves time down the line when others are working with the code. As far as naming conventions go, by giving all the functions and variables names related to their purposes, you can drastically increase the legibility your code. Consider the following code in the figure below that was written in LabVIEW.

You can see that the code is not very legible, and the program’s purpose is not clear. Below is the same program written in a much more legible and linear style.

Because of the detailed documentation, the program’s intent is clear. Even a person with minimal programming experience is able to easily read this code and understand each component. The spacing and placement of components are aesthetically pleasing and very intuitive.
Programming in a Group
Complex projects require the attention of multiple team members. It is important to know how to effectively split up portions of code so that everyone is programming efficiently and not producing any redundant code. The first step of splitting up the work is defining different sections of the project to assign each team member.
Obviously with different people programming different sections, communication is essential. It is important for all of the programmers to make sure that their code can work together effectively. You also need to select team’s integrator. The integrator is responsible for combining all of the finished code written by the other team members into one complete program. The block diagram of this concept for the ticket machine example is shown below.

Make sure that each team member’s workload is realistic. Ideally, you should distribute the workload evenly among all of the group members; however, in reality, this rarely happens. Certain portions of the project are inevitably going to require more work than others. Typically, the team member responsible for integration is going to have a higher workload than the other members. It is also important that you set realistic deadlines and clearly communicate them to all of the team members. By planning out specific deadlines for project milestones, you can measure progress more effectively.
Verification
The last stage for any software project is the verification stage. During this stage, you must complete extensive testing to make sure the final product is error- and bug-free. At the start of this stage, you should define and execute many different tests and use cases to ensure the highest-quality final product. You need to account and test for every single possibility and state. You also need to implement and test the error handling that tests invalid inputs.
A few examples of tests for the ticket machine example are:
1. Buying a ticket with insufficient money
2. Purchasing a ticket for a train that has already left
3. Paying more money than the amount due to test if the correct change is dispensed
Testing all of these use cases is one of the most important aspects of a project. To illustrate the importance of this, consider a standard vending machine that sells snacks and candy. Many of these vending machines are notorious for getting the snack stuck on the hook of the dispenser and, in effect, ripping off the customer. Errors like these are the direct result of improper testing and verification. Therefore, it is essential in any type of software project to allocate adequate time for extensive testing and verification.
Video Exercise Software Development Method Modules Home FIRST Community
Reader Comments | Submit a comment »
Legal
This tutorial (this "tutorial") was developed by National Instruments ("NI"). Although technical support of this tutorial may be made available by National Instruments, the content in this tutorial may not be completely tested and verified, and NI does not guarantee its quality in any way or that NI will continue to support this content with each new revision of related products and drivers. THIS TUTORIAL IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND AND SUBJECT TO CERTAIN RESTRICTIONS AS MORE SPECIFICALLY SET FORTH IN NI.COM'S TERMS OF USE (http://ni.com/legal/termsofuse/unitedstates/us/).
