Archive | June, 2020

Coding Guide Lines

25 Jun

Recently I have been working in a big mathematical simulation desktop application project that contained lots of entities that were interacting with each other with some degree of complexity and required the GUI to update in real time in response to user inputs that triggered certain calculations.

Somethings I have learned the hard way and included some rework to fix, below are the lessons I have learned during this project.

  1. Wrap all primitives and Strings in classes
  2. Wrap any collection in a separate class
  3. use Getters/Setters
  4. Use parent reference in your child objects
  5. Use data aware controls as much as possible.
  6. Put all string literals in a single class as static variables
  7. Use MVVM or MVC to separate between business logic and presentation.
  8. Concentrate business logic in pure classes that doesn’t contain anything else.
  9. Never ever duplicate code, instead encapsulate and reuse. even if its time consuming.
  10. Try using design patterns whenever possible (creational patterns was a life saver in my case.)

I know my rule about using Getters/Setters contradicts with the Object Calisthenics. but I actually had to use them to get/set the value based on the selected global unit system Object, and to fire events that refreshed the GUI element associated with the data model variables.

https://williamdurand.fr/2013/06/03/object-calisthenics/