56
Elijah Kerry, Certified LabVIEW Architect (CLA) Senior Product Manager for LabVIEW, National Instruments Software Engineering Best Practices

Elijah Kerry, Certified LabVIEW Architect (CLA)

Embed Size (px)

DESCRIPTION

Software Engineering Best Practices. Elijah Kerry, Certified LabVIEW Architect (CLA) Senior Product Manager for LabVIEW, National Instruments. 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 - PowerPoint PPT Presentation

Citation preview

Page 1: Elijah Kerry, Certified LabVIEW Architect (CLA)

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

Software Engineering Best Practices

Page 2: Elijah Kerry, Certified LabVIEW Architect (CLA)

2

Page 3: Elijah Kerry, Certified LabVIEW Architect (CLA)

3

Page 4: Elijah Kerry, Certified LabVIEW Architect (CLA)

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

Page 5: Elijah Kerry, Certified LabVIEW Architect (CLA)

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

Page 6: Elijah Kerry, Certified LabVIEW Architect (CLA)

Avionics ApplicationsRobotics and Mechatronics Large Physics Applications

High-Volume Production Test Structural Health Monitoring Medical Devices

Large System Development

Powered by LabVIEW

Page 7: Elijah Kerry, Certified LabVIEW Architect (CLA)

8

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

ni.com/largeapps

Page 8: Elijah Kerry, Certified LabVIEW Architect (CLA)

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

Page 9: Elijah Kerry, Certified LabVIEW Architect (CLA)

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

Page 10: Elijah Kerry, Certified LabVIEW Architect (CLA)

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

Page 11: Elijah Kerry, Certified LabVIEW Architect (CLA)

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

Page 12: Elijah Kerry, Certified LabVIEW Architect (CLA)

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

Page 13: Elijah Kerry, Certified LabVIEW Architect (CLA)

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

Page 14: Elijah Kerry, Certified LabVIEW Architect (CLA)

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

Page 15: Elijah Kerry, Certified LabVIEW Architect (CLA)

20

DEMOConfiguration Management

Page 16: Elijah Kerry, Certified LabVIEW Architect (CLA)

21

Graphical Differencing

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

Page 17: Elijah Kerry, Certified LabVIEW Architect (CLA)

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

Page 18: Elijah Kerry, Certified LabVIEW Architect (CLA)

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

Page 19: Elijah Kerry, Certified LabVIEW Architect (CLA)

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

Page 20: Elijah Kerry, Certified LabVIEW Architect (CLA)

25

VI Package Manager

Build and manage packages of LabVIEW code

Page 21: Elijah Kerry, Certified LabVIEW Architect (CLA)

26

Structured Error Handler

GXML Library

Install and Manage VI Packages

Page 22: Elijah Kerry, Certified LabVIEW Architect (CLA)

27

Easily Upgrade and Downgrade Versions

Page 23: Elijah Kerry, Certified LabVIEW Architect (CLA)

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

Page 24: Elijah Kerry, Certified LabVIEW Architect (CLA)

33

Track Changes

Manage Reuse Libraries

Integrate with SCC

Merge Graphical Code Manage Files and Links

System Level View

Software Configuration Management for LabVIEW

Page 25: Elijah Kerry, Certified LabVIEW Architect (CLA)

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

Page 26: Elijah Kerry, Certified LabVIEW Architect (CLA)

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

Page 27: Elijah Kerry, Certified LabVIEW Architect (CLA)

37

Requirements Traceability Solution from NI

Page 28: Elijah Kerry, Certified LabVIEW Architect (CLA)

38

Requirements Gathering

Application Architecture Development Debugging &

Testing Deployment

Requirements Coverage and Project Tracking Traceability and Documentation

Generation

Page 29: Elijah Kerry, Certified LabVIEW Architect (CLA)

39

DEMORequirements Tracking

Page 30: Elijah Kerry, Certified LabVIEW Architect (CLA)

40

Documentation

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

Page 31: Elijah Kerry, Certified LabVIEW Architect (CLA)

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

Page 32: Elijah Kerry, Certified LabVIEW Architect (CLA)

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

Page 33: Elijah Kerry, Certified LabVIEW Architect (CLA)

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

Page 34: Elijah Kerry, Certified LabVIEW Architect (CLA)

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

Page 35: Elijah Kerry, Certified LabVIEW Architect (CLA)

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

Page 36: Elijah Kerry, Certified LabVIEW Architect (CLA)

48

DEMOVI Analyzer for Peer Reviews

Page 37: Elijah Kerry, Certified LabVIEW Architect (CLA)

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

Page 38: Elijah Kerry, Certified LabVIEW Architect (CLA)

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

Page 39: Elijah Kerry, Certified LabVIEW Architect (CLA)

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

Page 40: Elijah Kerry, Certified LabVIEW Architect (CLA)

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

Page 41: Elijah Kerry, Certified LabVIEW Architect (CLA)

54

DEMODynamic Code Analysis with Desktop Execution Trace Toolkit

Page 42: Elijah Kerry, Certified LabVIEW Architect (CLA)

55

Remote Debugging of Executables

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

Page 43: Elijah Kerry, Certified LabVIEW Architect (CLA)

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

Page 44: Elijah Kerry, Certified LabVIEW Architect (CLA)

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."

Page 45: Elijah Kerry, Certified LabVIEW Architect (CLA)

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)

Page 46: Elijah Kerry, Certified LabVIEW Architect (CLA)

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)

Page 47: Elijah Kerry, Certified LabVIEW Architect (CLA)

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)

Page 48: Elijah Kerry, Certified LabVIEW Architect (CLA)

61

DEMOUnit Testing

Page 49: Elijah Kerry, Certified LabVIEW Architect (CLA)

63

Code Coverage Example

6 Diagrams. 3 Diagrams Executed. 50% Code Coverage

Page 50: Elijah Kerry, Certified LabVIEW Architect (CLA)

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

Page 51: Elijah Kerry, Certified LabVIEW Architect (CLA)

65

Programmatic Unit Testing

• Programmatically invoke testing and report generation

Page 52: Elijah Kerry, Certified LabVIEW Architect (CLA)

66

Unit Tests

Implementation

Software Requirements

Test Results

Integration with Requirements Gateway

Page 53: Elijah Kerry, Certified LabVIEW Architect (CLA)

69

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

Page 54: Elijah Kerry, Certified LabVIEW Architect (CLA)

70

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

Page 55: Elijah Kerry, Certified LabVIEW Architect (CLA)

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.

Page 56: Elijah Kerry, Certified LabVIEW Architect (CLA)

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