Sunday, November 28, 2021

Size Limit of Source Codes

Using a monospace font on a one inch margin letter size paper, a 12 point font has 78 columns and 54 lines, and a 10 point font has 93 columns (truncate from 93.6) and 63 lines (truncate from 63.8). Thus, the soft limit is that a single source file has 78 columns and 54 lines (the 54th is blank); and the hard limit is 93 columns and 63 lines (the 63rd is blank). For places where physically printing codes for code reviews, the limits makes sense.

Remember that a source code should only contain a single function unless they are allocator and deallocator pair; known as constructor and destructor respectively in object oriented programming. The source file should named as ./src/LibraryName/FunctionName.c, and the object archive library should be named ./lib/LibraryName.lib or ./bin/LibraryName.dll for statically and dynamically linked libraries respectively. Headers shall be named ./include/LibraryName.h as an interface to the object class defined in the library. The Hungarian Notation of libLibraryName.a and libLibraryName.so.VersionNumber makes it so GNU. VersionNumber is necessary because they cannot understand SOLID principles.

Single Responsibility Principle means there is one and only one concrete class and that is the LibraryName.dll file.
Open Close Principle means that the interface is closed so the only change possible is by inheritance.
Liskov Substitution Principle means you should not have DLL-HELL.
Interface Segregation Principle means that the class hierarchy have many client-specific interface to a single class.
Dependency Inversion Principle means that Entities depends on Systems not Components. This means that object oriented programming is always Entity Component System.

No comments: