When designing a software there are various principle you should follow
to make the software better in different aspects.
In this article we'll go through some of those principles.
Principle of least astonishment
Basically you should not astonish people when it comes to implementing something. For example if you have a method toString() which returns a string "not implemented", it is breaking of least astonishment principle.
GRASP
Consists of guidelines for assigning responsibility to classes and objects. See this wikipedia article and this.
KISS (Keep it simple stupid)
States most systems works best if they are kept simple rather than complicating. Therefore simplicity should be a key goal in designing a system.
YAGNI (You aren't gonna need it)
It's a principle of Extreme Programming. It states that programmer should not add functionality unless deemed necessary. See wikipedia.
Other
Having a good software design is important to avoid bad design which will cause us very badly. According to Robert martin there a 3 things we must avoid when designing software.
- Ridiglity : It's hard to change because changes affects too many other parts of the system
- every change causes a cascade of subsequent changes in dependent modules. Can grow 2 day work to multiple weeks
- Fragility : When you do a change, unexpected parts of the system breaks. Has a close connection with Ridiglity.
- Immobility: It is hard to reuse component in another area of the application.
- covariance and contravariance
Memoization
In computing, memoization is an optimization technique used primarily to speed up computer programs by storing the results of expensive function calls and returning the cached result when the same inputs occur again.
source
Memoization in JavaScript
https://www.cs.utexas.edu/~scottm/cs307/handouts/deepCopying.htm