I think the single most important principle to writing readable code(imho)is SRP(Single Responsibility Principle)
In a nutshell
It is just making your classes and methods do one thing and that’s it.
Or at the very least name your methods accordingly if they do a couple of things.
An MS Example of breaking the SRP Rule.
bool Int32.TryParse(string s, out int result)
The benefits are numerous.
It is easy for other programmers to read your code.
Your methods get much shorter.
Refactoring becomes obvious when code starts to do more than one thing.
Unit Testing is easier and clearer.
0 Comments on “Writing Readable Code”
Leave a Comment