index

goals: decoupled


Carve at the joints.

Factoring code is the the same as arithmetic, or algebra.

Arithmetic


// 24 == 3 * (2^3) 
// prime numbers: 2 & 3
Factoring 24 suggests 8-hour shifts, not 5-hour shifts. Knowing this when scheduling can be.. helpful.

Algebra


// (x+2) * (x-1) * (2*x-5)  ==  2*x^3 - 9*x^2 + 6*x + 10 

// mathematically these are prime "numbers": 
//  (x+2) 
//  (x-1) 
// (2x-5)
Break large pieces into independent, self-explanatory ingredients. Make your code an archipelago.

Code


struct PhoneCall { 
  void act(Connection*); 
  Connection*   answer(); 
  Connection*   call(PhoneNumber); 
  void          endcall(); 
  PhoneNumbers  assist(string); 
  PhoneNumbers  assist(long); 
  int     push(Message);// return queue length. 
  Message pop(); 
}; 

struct Playlist { 
  void    act(Song*); 
  Songs match(string) const; 
  Songs match(Midi)   const; 
  Song pop(); 
  int push(Song); // return queue length. 

};
Having few dependencies. Factored code.

Dependencies can be reduced using context and small classes.

nedwaves.com 2017 [171108]