1 - General Principles
Published online by Cambridge University Press: 03 May 2011
Summary
Good software gets the immediate job done. But great software, written with a consistent and readable style, is predictable, robust, maintainable, supportable, and extensible. A few general principles provide the foundation for great software.
Avoid Causing Confusion
Avoid doing things that would be an unpleasant surprise to other software developers. The interfaces and the behavior exhibited by your software must be predictable and consistent. If they are not, then the documentation must clearly identify and justify any unusual instances of use or behavior.
To minimize the chances that anyone would encounter something surprising in your software, you should emphasize the following characteristics in its design, implementation, packaging, and documentation:
Simplicity Meet the expectations of your users with simple functions, classes, and methods.
Clarity Ensure that each variable, function, class, and method has a clear purpose.
Completeness Provide at least the minimum functionality that any reasonable user would expect to find and use.
Consistency Design similar entities with a similar look and behavior. Create and apply consistent standards whenever possible.
Robustness Provide predictable, documented behavior in response to errors and exceptions. Do not hide errors, and do not force users to detect errors.
Avoid Throw-Away Code
Apply these rules to any code you write, not just code destined for production. All too often, some piece of prototype or experimental code will make its way into a finished product. Even if your code never makes it into production, someone else may still have to read it.
- Type
- Chapter
- Information
- The Elements of MATLAB Style , pp. 4 - 6Publisher: Cambridge University PressPrint publication year: 2010