Developing Robust MATLAB Code - mathworks.com · 7. Mocking. Develop Test Integrate Share. Mock....
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](https://reader030.fdocuments.in/reader030/viewer/2022041205/5d56747188c9933d168bd8af/html5/thumbnails/1.jpg)
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](https://reader030.fdocuments.in/reader030/viewer/2022041205/5d56747188c9933d168bd8af/html5/thumbnails/2.jpg)
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](https://reader030.fdocuments.in/reader030/viewer/2022041205/5d56747188c9933d168bd8af/html5/thumbnails/3.jpg)
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](https://reader030.fdocuments.in/reader030/viewer/2022041205/5d56747188c9933d168bd8af/html5/thumbnails/4.jpg)
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](https://reader030.fdocuments.in/reader030/viewer/2022041205/5d56747188c9933d168bd8af/html5/thumbnails/5.jpg)
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](https://reader030.fdocuments.in/reader030/viewer/2022041205/5d56747188c9933d168bd8af/html5/thumbnails/6.jpg)
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](https://reader030.fdocuments.in/reader030/viewer/2022041205/5d56747188c9933d168bd8af/html5/thumbnails/7.jpg)
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](https://reader030.fdocuments.in/reader030/viewer/2022041205/5d56747188c9933d168bd8af/html5/thumbnails/8.jpg)
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](https://reader030.fdocuments.in/reader030/viewer/2022041205/5d56747188c9933d168bd8af/html5/thumbnails/9.jpg)
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](https://reader030.fdocuments.in/reader030/viewer/2022041205/5d56747188c9933d168bd8af/html5/thumbnails/10.jpg)
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](https://reader030.fdocuments.in/reader030/viewer/2022041205/5d56747188c9933d168bd8af/html5/thumbnails/11.jpg)
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](https://reader030.fdocuments.in/reader030/viewer/2022041205/5d56747188c9933d168bd8af/html5/thumbnails/12.jpg)
12
Distribution Develop Test
Integrate ShareStore front-end
Ratings
Comments
Metrics
Repository
• Shared folder
• SharePoint
• Maven
displays
supplies