Writing Readable Code

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.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google photo

You are commenting using your Google account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )

Connecting to %s