There is a point to this story, but it has temporarily escaped my mind...
Contact Me MyFaceBook MyLinkedIn MyGitHub MyTwitter

My Coding Style

My coding style tries to minimize complexity. The main motivation is that well-styled programs are easier to understand and are more extensible.

All-Languages

  • Minimize horizontal complexity, that is, the depth of nesting of control structures, as well as the total line length. No line of code should extend past 100 characters.
  • Minimize vertical complexity, that is, the code length in lines. If you have many lines of code, you may want to consider splitting into multiple units.
  • Minimize the number of parameters. Consider using a structure to pass the information
  • Minimize the number of looping blocks, the number of contained instructions, and the number of nested levels
  • Minimize the number of consecutive conditionals
  • Variables
    1. Minimize the number of variables, mostly by inlining variables which are used only once
    2. Minimize the visibility of variables and other identifiers by defining them at the smallest possible scope which also minimizes the variable life time.
    3. Minimize the accessibility of variables, by preferring private variables
    4. Minimize variable name length, but do use complete words and not acronyms. Acronyms are acceptable only when generally accepted by the industry
    5. Minimize the use of arrays by replacing them with collections provided by standard and of-the-shelf libraries.
  • Control
    1. Minimize the use of conditionals by using specialized constructs such as ternarization and inheritance.
    2. Simplify conditionals with early returns
    3. Simplify logic of iterations with early exits (return, break, continue)

C#

For C# language, I have standardized on the Microsoft Coding Standard with one exception. I use the new Code Analysis feature in Visual Studio, Microsoft StyleCop 4.4, and Microsoft FxCop 10.0. Most of my project code either belong to my employer or the client, so I turn off SA1633, SA1634, SA1635, SA1637, SA1638, SA1639, and SA1640. Each of these rules deal with the a “properly formatted file header” containing copyright, file name, summary and company text. I sometimes ignore the Strong-Name and Globalization rules if the project will not be used outside of the en-us locale.

Python

Bash

PHP

Java

Copyright © 2022 by Julian Easterling. SOME RIGHTS RESERVED.
Privacy Policy              Terms of Use             


Creative Commons License
Except where otherwise noted, content on this site is
licensed under a Creative Common Attribution-Share Alike 4.0 International License.


All of the opinions expressed on this website are those of Julian Easterling and
do not represent the views of any of my current and previous clients or employers in any way.

If you notice an error on the site or content that has not been properly attributed, bring
it to my attention using the contact page and I will endeavor to fix it as soon as I can.

I accept no responsibility or liability for any damages incurred by following any of
my advice or by using any of the information on my site or of those sites that I link to.