We Need to Discuss Code Legibility

The undiscovered continent we don’t see

Fruitless, Exhausted Discussion

The Goal

Ineffectual Solutions

Horrible Team Standards

To Each “Their” Own

Hideosity from FluentCpp

The Two Great Formatting Sins

Clutter: Whitespace is for Sissies

10 FORA=1TO10:PRINTA:NEXTA
10 FOR A=1 TO 10:PRINT A:NEXT A
if(a==1) printf("a=1");

Inversion: Backwards is Better

void uninffn(
int a
,char b
,double c
){

An Avalanche of Eyestrain

if( ( a=unscrutFn( 0 ) )==2 )
gothedach( );

Why It Matters

The Cost of Bugs

Why? Why?

The Undiscovered Continent

Photo by AncientOrigins

Example: The Ubiquity of Tables

A Few Scattered Notions

Never Omit Braces

One Operation Per Line

if (condition) executeCondition();
for(int index = 0; 
index < operations.Count();
index++)
{

Clear Variable Naming

int NumGrads;
int GraduateCount;
AnimalSpeciesCount
AnimalSpeciesIndex
PlantSpeciesCount
PlantSpeciesIndex
CountSpeciesAnimal
CountSpeciesPlant
IndexSpeciesAnimal
IndexSpeciesPlant

Strong Typing

var Bachelors = new
{
Graduates = db.Graduates .Where(g => g.Type == Bachelor)),
Ceremonies = db.Ceremonies.Where(c => c.Graduates
.Any (g => g.Type == Bachelor)
);

Obsolete Operators

if (!strcmp(name1, name2)) …

Vertical Alignment

Example 1

Person person = new Person
{
FirstName = “Chris”,
LastName = “Jeffers”,
Address = “123 Mockingbird Lane”,
City = “Gotham”,
State = “Moribund”,
PostalCode = 12345,
Phone = 2062169069,
PhoneType = PhoneType.Mobile,
Notes = “Remote Only”
};
Person person = new Person
{
FirstName = “Chris”,
LastName = “Jeffers”,
Address = “123 Mockingbird Lane”,
City = “Gotham”,
State = “Moribund”,
PostalCode = 12345,
Phone = 2062169069,
PhoneType = PhoneType.Mobile,
Notes = “Remote Only”
};

Example 2

List<Bird> parrots = db.Birds.Where(b => b.Order== Psittaccidae);
List<Bird> crows = db.Birds.Where(b => b.Order == Corvidae);
List<Bird> hummingbirds = db.Birds.Where(m => m.Order == Trochilidae);
List<Bird> parrots      = db.Birds
.Where (b => b.Order == Psittacidae);
List<Bird> crows = db.Birds
.Where (b => b.Order == Corvidae);
List<Bird> hummingbirds = db.Birds
.Where (m => m.Order == Trochilidae);

Example 3

public void ExampleFunc()
{

}

Conclusion, For Now

Resources

American Software Developer living in Vietnam. Classical musician (guitar, woodwinds), weightlifter, multilingual, misanthrope • XY

Get the Medium app

A button that says 'Download on the App Store', and if clicked it will lead you to the iOS App store
A button that says 'Get it on, Google Play', and if clicked it will lead you to the Google Play store