In this post, a demonstration on how to perform unit testing in Microsoft Visual Studio is covered. The demo is structured as follows:
- create a console app with accompanying c sharp classes, and
- perform unit testing on the methods used in the created classes.
In writing a program, implementing unit testing is a key step. The unit test project can be thought of as a document which can be used to understand the functionality and expected outcomes of the code. It is good practice to test the methods used in a program to check that the program delivers the expected results, and in performing the tests errors in the code can be picked up and corrected.
It often occurs that in the production process, a program needs to be extended. In extending the program, the results from one method should not alter the functioning/outcome of other methods. When unit testing is in place, errors can easily be picked up if it were the case that adding new code altered the outcome of existing working code. In this way, the existing working code is validated again when new code is added to the project. Using unit testing therefore serves as an important quality check of a program in the production process. Continue reading →
Introduction to Hierarchy
This blog is part 2 on the object oriented programming in Matlab. Consider reading out previous blog first.
In classifying objects, hierarchy in the objects is a common occurrence, where subclasses and super-classes can be defined. In the example of a rectangle class, a superclass namely Shape can be defined, where the superclass provides a more broadly defined class for a shape, and rectangle a more narrowly defined class for a specific type of shape. We can extend our example, by including the creation of Triangle and Circle classes, which are also subclasses of the superclass Shape.
Continue reading →
In this post, a demonstration on how to create objects using object oriented programming (OOP) in MATLAB is covered using easy to follow steps, and the basic MATLAB syntax. The demo is structured as follows:
- creating objects using the basic MATLAB syntax,
- hierarchy in objects (including Abstract method functions), and
- initialising and validating property values.
OOP is an approach to programming, where focus is put on design patterns and classification systems. It forms a consistent framework which is recognisable, and can be easily reused and extended by others. OOP is ideal to use when designing complex models, because of the flexibility and extensibility of the code, where a simple model can easily be extended to cover a more complex model. Continue reading →