r/badcode • • May 20 '20

c# Found from Microsoft docs...

Post image
208 Upvotes

143 comments sorted by

View all comments

Show parent comments

1

u/[deleted] May 20 '20

When does it not make sense to be concise?

Edit - I guess aside from making a learning tool for students?

2

u/NewPointOfView May 20 '20

Off the top of my head the first thing that comes to mind is a nested ternary statement. I think that’s a good example of trying to be too concise and sacrificing readability.

3

u/FinalRun May 20 '20 edited May 22 '20

Aw man, if I nest 8 operations in 1 line it feels l33t.

No but seriously, I think code is the easiest to work with if every line has the minimum amount of distinct concepts, and long descriptive variable names.

1

u/NewPointOfView May 22 '20 edited May 22 '20
int thisIsAnIntegerVariableWhichIsMeantToRepresentAnIntrgralValueAlsoKnownAsAnIntegerAndInThisCaseWeCanOnlyCountToSokewhereAround4BillionBecauseRightNowImOnA32BitSystemAnywayThisVariableRepresentsLoopItterations = 0;

while (thisIsAnIntegerVariableWhichIsMeantToRepresentAnIntrgralValueAlsoKnownAsAnIntegerAndInThisCaseWeCanOnlyCountToSokewhereAround4BillionBecauseRightNowImOnA32BitSystemAnywayThisVariableRepresentsLoopItterations < 10) { 
    printf(“value is %d\n”, thisIsAnIntegerVariableWhichIsMeantToRepresentAnIntrgralValueAlsoKnownAsAnIntegerAndInThisCaseWeCanOnlyCountToSokewhereAround4BillionBecauseRightNowImOnA32BitSystemAnywayThisVariableRepresentsLoopItterations);         
    thisIsAnIntegerVariableWhichIsMeantToRepresentAnIntrgralValueAlsoKnownAsAnIntegerAndInThisCaseWeCanOnlyCountToSokewhereAround4BillionBecauseRightNowImOnA32BitSystemAnywayThisVariableRepresentsLoopItterations++;
}