Skip to content
patrobic edited this page Oct 4, 2017 · 21 revisions

Welcome to the BlindAid wiki!

PROGRAM STRUCTURE PAGE HERE: https://github.com/patrobic/BlindAid/wiki/Program-Structure

Following is an outline I've put together of a few coding guidelines to help you all understand my code and in your own programming.

SOLID Principle

By far the most important is the SOLID principle (this will make you a better programmer!), available here: https://youtu.be/huEEkx5P5Hs

I will leave you to look it up (many articles available online), but here are the five points (the first one/two are most important!):

  • S — Single responsibility principle A class/function must not have/accomplish more than one purpose!
  • O — Open closed principle A class's functionality must be closed for modification but open to extension!
  • L — Liskov substitution principle
  • I — Interface segregation principle
  • D — Dependency Inversion principle

Functor Class Design

A class encompasses Functionality, Input and Output. the Functor Class Design Principle allows creating an object that behaves like a function. By definition it must have an operator()() function, which executes its funcitonality.

You provide it input either as parameters, or through an "Input Class" (either through the operator or an Init(...) function). You can also access its output results either as internal members, or regroup them in a "Result Class".

  • Class FunctorParams { ... }
  • Functor functor;
  • functor(FunctorParams); OR functor.SetParams(FunctorParams);
  • Class FunctorResults = functor.GetResult(); OR Class FunctorResults = functor._results;

Data Passing/Storage by Pointer

I typically create data by value in the root module, and then pass it to subsequent modules or store it in dependent classes by pointer, to minimize data reallocation/unnecessary memory usage caused by passing by value.

I also avoid passing by reference, because it gets tricky with constructor Member Initialization Lists (i.e. a reference value MUST be initialized in the constructor, whereas a pointer can be declared/passed as NULL).

Count Lines of Code

  • Hit Ctrl+Shift+F
  • Enable "Use Regular Expressions"
  • Look in "Entire Solution"
  • Search for ^(?([^\r\n])\s)[^\s+?/]+[^\n]$
  • Scroll down to bottom of search window
  • Line count indicated by "Matching Lines"