Developing Robust MATLAB Code - mathworks.com · 7. Mocking. Develop Test Integrate Share. Mock....

12
1 © 2018 The MathWorks, Inc. Developing Robust MATLAB Code Paul Peeling MathWorks UK Consulting Services

Transcript of Developing Robust MATLAB Code - mathworks.com · 7. Mocking. Develop Test Integrate Share. Mock....

Page 1: Developing Robust MATLAB Code - mathworks.com · 7. Mocking. Develop Test Integrate Share. Mock. Implements the abstract methods and properties of the specified interface Backed by

1© 2018 The MathWorks, Inc.

Developing Robust MATLAB Code

Paul Peeling

MathWorks UK Consulting Services

Page 2: Developing Robust MATLAB Code - mathworks.com · 7. Mocking. Develop Test Integrate Share. Mock. Implements the abstract methods and properties of the specified interface Backed by

2

MATLAB for Software Development

Develop Test

Integrate Share

Page 3: Developing Robust MATLAB Code - mathworks.com · 7. Mocking. Develop Test Integrate Share. Mock. Implements the abstract methods and properties of the specified interface Backed by

3

Input Validation Develop Test

Integrate Share

Property Validation

narginchk

nargoutchk

validateattributes

validatestringCode Suggestions and Completions

Page 4: Developing Robust MATLAB Code - mathworks.com · 7. Mocking. Develop Test Integrate Share. Mock. Implements the abstract methods and properties of the specified interface Backed by

4

Clean Code Develop Test

Integrate Share All handles are cleaned up after execution

Code executes from a clean MATLAB install

Code does not require changing working

directory

Code does not manipulate MATLAB path

Uses error and warning identifiers

No shadowing of MATLAB functions

Variable names do not conflict with functions

Naming conventions are followed

package.Class

classMethodOrFunction

object.Property

Page 5: Developing Robust MATLAB Code - mathworks.com · 7. Mocking. Develop Test Integrate Share. Mock. Implements the abstract methods and properties of the specified interface Backed by

5

Documentation – Live Functions Develop Test

Integrate Share

Page 6: Developing Robust MATLAB Code - mathworks.com · 7. Mocking. Develop Test Integrate Share. Mock. Implements the abstract methods and properties of the specified interface Backed by

6

Unit Testing Develop Test

Integrate Share

Page 7: Developing Robust MATLAB Code - mathworks.com · 7. Mocking. Develop Test Integrate Share. Mock. Implements the abstract methods and properties of the specified interface Backed by

7

Mocking Develop Test

Integrate Share

Mock

Implements the abstract methods and

properties of the specified interface

Backed by an actual MATLAB class

generated at runtime

Carries out actions

Behavior

Defines the same methods as the mock

Controls the mock behavior

Used to verify interactions with the mock

Page 8: Developing Robust MATLAB Code - mathworks.com · 7. Mocking. Develop Test Integrate Share. Mock. Implements the abstract methods and properties of the specified interface Backed by

8

App Testing Develop Test

Integrate Share

Page 9: Developing Robust MATLAB Code - mathworks.com · 7. Mocking. Develop Test Integrate Share. Mock. Implements the abstract methods and properties of the specified interface Backed by

9

Continuous Integration Pipeline Develop Test

Integrate ShareBeyond source control integration and testing

Code analysis and metrics

Code coverage

Page 10: Developing Robust MATLAB Code - mathworks.com · 7. Mocking. Develop Test Integrate Share. Mock. Implements the abstract methods and properties of the specified interface Backed by

10

MATLAB Interfaces with other languages Develop Test

Integrate ShareLanguage MATLAB Engine MATLAB

Compiler /

Compiler SDK

MATLAB

Production

Server

C/C++ ✓ ✓ ✓

FORTRAN ✓

Python ✓ ✓ ✓

COM ✓

Java ✓ ✓ ✓

.NET ✓ ✓

Page 11: Developing Robust MATLAB Code - mathworks.com · 7. Mocking. Develop Test Integrate Share. Mock. Implements the abstract methods and properties of the specified interface Backed by

11

Packaging Develop Test

Integrate ShareMATLAB Toolbox Packaging:

▪ Manages the MATLAB search path

▪ Picks up file dependencies

▪ Specifies MathWorks product dependencies

▪ Provides registration points for examples

and documentation

See Developer Zone posts

http://blogs.mathworks.com/developer/

Page 12: Developing Robust MATLAB Code - mathworks.com · 7. Mocking. Develop Test Integrate Share. Mock. Implements the abstract methods and properties of the specified interface Backed by

12

Distribution Develop Test

Integrate ShareStore front-end

Ratings

Comments

Metrics

Repository

• Shared folder

• SharePoint

• Maven

displays

supplies