aimthiazz / eMach

Open Source Machine Modeling Framework. X Mach Speed.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

eMach

An open source framework for modeling [electric] machinery.

MATLAB Style Guidelines

All contributors to eMach are asked to use specific MATLAB code style, use MATLAB's object oriented programming (OOP) capabilities, and follow the SOLIDD design principles—all of which are now outlined.

Code Style

Using a consist writing style makes shared code more maintainable, useful, and understandable. Contributors to eMach should follow the guidelines provided here.

A brief summary of guidelines for names includes:

  • Avoid using excessively short names: instead, favor full words to convey meaning
  • Function and variable names: start lower case and then move to camel case, i.e. toInch()
  • Class names: start upper case and then move to camel case, i.e. MaterialGeneric

Follow the MATLAB editor's guidelines on maximum line length. Wrapping to multiple lines is preferred over code that has excessively wide lines. This is for readibility and printability reasons.

Object-Oriented Programming

The reference manual for MATLAB OOP can be found here.

Those looking to quickly grasp the key concepts of Matlab's implementation of OOP are referred to Kevin Murphy's Object Oriented Programming in Matlab: basics guide and the official MATLAB class syntax guide. MATLAB's instructions for creating help documentation of classes can be found here.

SOLIDD Approach to Object Oriented Code Design

SOLIDD is an acronymn for the following code design guidelines:

These guidelines come out of the Agile community (specifically, Robert C. Martin) and are intended to make code flexible and maintainable. They are subtle and require close study to grasp their full implications.

Note that MATLAB is a dynamically typed language and therefore does not impose type restrictions on variables. This can make adherence to the SOLIDD princples challenging. eMach enforces typing manually enforced by calling validateattributes like this:

  • validateattributes(obj.dim_depth,{'dimLinear'},{'nonnegative', 'nonempty'})
  • validateattributes(compArcObj,{'compArc'},{'nonempty'})

For example, see the MATLAB DimLinear class.

Several useful resources on the SOLIDD guidelines are assembled here:

About

Open Source Machine Modeling Framework. X Mach Speed.

License:BSD 3-Clause "New" or "Revised" License


Languages

Language:MATLAB 98.6%Language:TeX 1.4%