Elijah Kerry, Certified LabVIEW Architect (CLA) Senior Product Manager for LabVIEW, National...

Preview:

Citation preview

Elijah Kerry, Certified LabVIEW Architect (CLA)Senior Product Manager for LabVIEW, National Instruments

Software Engineering Best Practices

2

3

5

Examples of Software Engineering Debt(just some of the most common LabVIEW development mistakes)

No source code control (or Project) Flat file hierarchy ‘Stop’ isn’t tested regularly Wait until the ‘end’ of a project to build an application Few specifications / documentation / requirements No ‘buddying’ or code reviews Poor planning (Lack of consideration for SMoRES) No test plans Poor error handling No consistent style Tight coupling, poor cohesion

6

The Cost of a Software Defect

Development Phase Cost RatioRequirements 1

Design 3-6xImplementation 10x

Development Testing 15-40xAcceptance Testing 30-70x

Post Release 40-1000x

Based on an analysis of 63 software development projects at companies including IBM, GTE and TRW

Avionics ApplicationsRobotics and Mechatronics Large Physics Applications

High-Volume Production Test Structural Health Monitoring Medical Devices

Large System Development

Powered by LabVIEW

8

Topics • Configuration Management• Requirements Tracking• Architecture and Design• Coding Styles and Standards• Testing and Debugging• Documentation

ni.com/largeapps

9

Requirements Gathering

Application Architecture

Deployment

Unit Testing

System Testing

Integration Testing

Module Architecture

Review and Test

Software Engineering V-Model

Development Verif

icatio

n

Prototyping Service

14

Size of LabVIEW Applications

0 to 100 VIs 100 to 250 VIs 250 to 1000 VIs 1000 to 3000 VIs

3000 to 5000 VIs

Greater than 5000

0

2

4

6

8

10

12

14

16

Source: 2010 ni.com/largeapps survey

15

Average Number of Developers Per Project

> 10 5 to 10 3 to 5 2 10

5

10

15

20

25

Source: NIWeek 2008 Software Engineering Survey

16

Source Code Control

Developer 1

Developer 2

Merger

Code Revision

Code Repository

Locked for edit

Requirements Gathering

Application Architecture Development Debugging &

Testing Deployment

Software Configuration Management

Checked Out Checked In

Checked Out Checked In

Checked InChecked Out

Get Latest Version

17

SCC Options for Integration within LabVIEW

Native LabVIEW Integration• Perforce Integration Through Standard API• Microsoft Visual SourceSafe • Microsoft Team System • Rational ClearCase • PCVS (Serena) Version Manager • MKS Source Integrity • Seapine Surround SCM • Borland StarTeam • Telelogic Synergy • ionForge Evolution

Support through additional add-ons• Subversion• Mecurial

18

Development TrunkFeature-Team

Repository

Feature-TeamRepository

Feature-TeamRepository

Individual’s LocalRepositories

NI Configuration Management

• Different trunk for each LabVIEW version

• Teams of 3 to 7 developers work in smaller repositories

• Individuals may have their own repositories

• New features and changes are regularly merged in

Popularity of SCC Options Amongst LabVIEW Programmers

Perforce Subversion ClearCase Git VSS Mecurial none0

10

20

30

40

50

60

10

48

1 1 14 3

Source: 2010 ni.com/largeapps survey

20

DEMOConfiguration Management

21

Graphical Differencing

•Provides a checklist of changes•Useful for peer reviews•Available via command-line

22

Separate Compiled Code From Source FileImproved Source Code Control Integration

Eliminate the need to re-save and re-submit files to source code control unless the graphical source code has been changed by the developer

*this feature is not on by default and needs to be enabled from the VI Properties dialog

2009.vi file format

2010.vi file format*

Front Panel Block Diagram

Connector Pane Icon

Compiled Code

Inplaceness Info

Compiled Code

Inplaceness Info

Front Panel Block Diagram

Connector Pane Icon

A separate object file is created to store and retain this information

TopLevel.vi

SubVI2.vi

SubVI1.vi

Source Code Control Scenario: Today

In SCC

TopLevel.vi

SubVI2.vi

Local Machine

EditSave

Check-inSubVI1.viSubVI1.vi SubVI1.vi

Source Code Control Scenario: 2010

In SCC

TopLevel.vi

SubVI2.vi

Local Machine

EditRun/SaveSubVI1.vi

Check-in

local .viobj cache

TopLevel.viobj

SubVI1.viobj

SubVI2.viobj

TopLevel.viobj

SubVI1.viobj

SubVI1.vi

TopLevel.vi

SubVI2.vi

SubVI1.viSub VI1.vi SubVI1.vi

25

VI Package Manager

Build and manage packages of LabVIEW code

26

Structured Error Handler

GXML Library

Install and Manage VI Packages

27

Easily Upgrade and Downgrade Versions

28

Structured Error Handler

GXML Library

Create VI Configuration Files

AMC Library G Library

A single file that contains multiple packages. Easily share and distribute code that depends upon multiple libraries.

Structured Error Handler Config

33

Track Changes

Manage Reuse Libraries

Integrate with SCC

Merge Graphical Code Manage Files and Links

System Level View

Software Configuration Management for LabVIEW

34

The Software Engineering Process

Now Included with DevSuite

NI Requirements Gateway

Requirements Gathering

Application Architecture Development Testing and

Validation Deployment

LabVIEWVI Analyzer

LabVIEW Desktop Execution Trace

LabVIEW Unit Test Framework

Application Builder

LabVIEW Statechart

Improve quality. Reduce risk. Save time. Prove it works.

Object Orientation

Real Time

FPGA

EmbeddedNI TestStand

Dataflow

MathScript

Statechart

Simulation

35

The Software Engineering Process

NI Requirements Gateway

Requirements Gathering

Application Architecture Development Testing and

Validation Deployment

LabVIEWVI Analyzer

LabVIEW Desktop Execution Trace

LabVIEW Unit Test Framework

Application Builder

LabVIEW Statechart

Improve quality. Reduce risk. Save time. Prove it works.

Object Orientation

Real Time

FPGA

EmbeddedNI TestStand

Dataflow

MathScript

Statechart

Simulation

37

Requirements Traceability Solution from NI

38

Requirements Gathering

Application Architecture Development Debugging &

Testing Deployment

Requirements Coverage and Project Tracking Traceability and Documentation

Generation

39

DEMORequirements Tracking

40

Documentation

• Labeled objects• In-line comments• Distinct Icon• Description and Tip• HTML Print-Out• Requirements Coverage

41

Tools for Debugging and Testing

High RiskLow Risk

Debugging & Testing

Dynamic Code AnalysisReal Time Execution Trace

Static Code Analysis

Functional Validation of Code

Unit Test Framework

Adv

ance

dSi

mpl

eAppl

icatio

n Co

mpl

exity

Application Criticality

Desktop Execution Trace

VI Analyzer Toolkit

42

Performing a LabVIEW Code Review

• Walk someone through your code• Questions to consider:

Is the code easy to maintain, and has it been documented? What happens if the code returns an error?

(… or if it receives an error?) Is too much functionality located in a single VI? Are there any race conditions? Is the memory usage within acceptable limits?

• Perform code reviews frequently

43

Establish or Adopt Development GuidelinesFront Panel Style

Fonts and Text Characteristics Colors Graphics and Custom Controls Layout Sizing and Positioning Labels Paths versus Strings Enumerated Type Controls versus Ring Controls Default Values and Ranges Property Nodes Key Navigation Dialog Boxes

Style Checklist VI Checklist Front Panel Checklist Block Diagram Checklist

Block Diagram Style Wiring Techniques Memory and Speed Optimization Sizing and Positioning Left-to-Right Layouts Block Diagram Comments Call Library Function Nodes and Code Interface

Nodes Type Definitions Sequence Structures

Icon and Connector Pane Style Icons Example of Intuitive Icons Connector Panes

NI Style Guideline: ni.com/largeapps

44

Preparing for a Code Review with VI Analyzer

• Automate code analysis with 80+ configurable tests Performance Style Complexity

• Interactively inspect failures• Generate custom reports• Code complexity metrics• Write your own tests with VI

Scripting LabVIEW 2010

45

VI Analyzer Code Complexity MetricsTests for Industry Standard Metric Calculations

True

False

Case 1

Case 2

Case 3

Edges = 5 Nodes = 3 Paths = 1

Cyclomatic complexity: 5 – 3 + 2 (1) = 4

48

DEMOVI Analyzer for Peer Reviews

49

Tools for Debugging and Testing

High RiskLow Risk

Debugging & Testing

Dynamic Code AnalysisReal Time Execution Trace

Static Code Analysis

Functional Validation of Code

Unit Test Framework

Adv

ance

dSi

mpl

eAppl

icatio

n Co

mpl

exity

Application Criticality

Desktop Execution Trace

VI Analyzer Toolkit

51

Trace Production Systems Remotely

Run-Time Execution Information

Run-Time Execution Information

Network

Network

Deployed Real-Time Applications

VIs and Debuggable Executables

LabVIEW Desktop Execution Trace Toolkit

LabVIEW Real-Time Execution Trace Toolkit

52

Desktop Execution Trace ToolkitTrace During Run-Time:• Event Structures• Memory Allocation• Queues / Notifiers• Reference Leaks• Thread ID• Unhandled Errors• Dynamic / Static SubVIs• Custom User Strings

53

Desktop Execution Trace ToolkitTrace During Run-Time:• Event Structures• Memory Allocation• Queues / Notifiers• Reference Leaks• Thread ID• Unhandled Errors• Dynamic / Static SubVIs• Custom User Strings

54

DEMODynamic Code Analysis with Desktop Execution Trace Toolkit

55

Remote Debugging of Executables

• Include block diagrams with an executable• Remotely troubleshoot using LabVIEW debug tools

56

Tools for Debugging and Testing

High RiskLow Risk

Debugging & Testing

Dynamic Code AnalysisReal Time Execution Trace

Static Code Analysis

Functional Validation of Code

Unit Test Framework

Adv

ance

dSi

mpl

eAppl

icatio

n Co

mpl

exity

Application Criticality

Desktop Execution Trace

VI Analyzer Toolkit

57

Data Science Automation

Developed Long-term testing solution for artificial hearts

"The Unit Test Framework’s flexibility and ease of use certainly enabled much faster and reliable completion of this portion of the project potentially saving hundreds of hours and thousands of dollars over the life of the project."

58

LabVIEW Unit Test Framework

VI Under Test

Input Values Output

Expected OutputUnit Test Framework Automated

Report Generation

Test vector = Input value(s) + Expected output(s)

59

Windows Desktop

LabVIEW Unit Test Framework

VI Under Test

Input Values Output

Expected OutputUnit Test Framework Automated

Report Generation

Test vector = Input value(s) + Expected output(s)

60

Real Time

LabVIEW Unit Test Framework

VI Under Test

Input Values Output

Expected OutputUnit Test Framework Automated

Report Generation

Test vector = Input value(s) + Expected output(s)

61

DEMOUnit Testing

63

Code Coverage Example

6 Diagrams. 3 Diagrams Executed. 50% Code Coverage

64

Code Coverage Example

2nd Test Vector (aggregates covered code from 1st pass)Block diagram, 5 Case diagrams executed. ( 4 + 1 ) / 6 = 83.33% Code Coverage

1ST Test Vector:Block diagram, 2 Case diagrams executed. ( 2 + 1 ) / 6 = 50% Code Coverage

65

Programmatic Unit Testing

• Programmatically invoke testing and report generation

66

Unit Tests

Implementation

Software Requirements

Test Results

Integration with Requirements Gateway

69

Application Builder API New in LabVIEW 2011Automate build and deployment processes

70

App Builder Log-File GenerationDocument version, date and time of Vis included in buildAvailable in LabVIEW 2009

LabVIEWCore 1

LabVIEWCore 2 LabVIEW Core 3

Certified LabVIEW Developer

Advanced Architecturesin LabVIEW Certified

LabVIEW Architect

Certified LabVIEW Associate Developer

NI LabVIEW Certifications Align with Training

Managing Software

Engineering in LabVIEWLabVIEW

Connectivity

LabVIEW Performance

Object-Oriented Design &

Programming in LabVIEW

Recommended course

Optional course

Optional certification

Developer Senior Developer Software Architect/ Project Manager

"Certification is an absolute must for anyone serious about calling himself a LabVIEW expert... At our organization, we require that every LabVIEW developer be on a professional path to become a Certified LabVIEW Architect."

- President, JKI Software, Inc.

More Information on Architectures and ProcessDedicated to LabVIEW Development and Software Engineering Practices

Technical White Paper Series

ni.com/largeapps

Online Community Dedicated to Development Best Practices

ni.com/community/largeapps

Follow My Blog on Software Engineering with LabVIEW

ekerry.wordpress.com

Follow me on Twitter

elijah286