Positive Conditionals – Clean Code Post 1

This is the first of my Clean Code posts and it is to do with the use of Conditionals in code.  It is better to use a Positive Conditional over a Negative Conditional.

An example of using a Positive Conditional in code is shown below:

if (LoggedIn)
{

}

The example above is far better to use over the Negative Conditional example below:

if (!IsNotLoggedIn)
{

}

Writing Clean Code

I recently watched a very good course on Pluralsight on writing Clean Code.  It is called Clean Code: Writing Code for Humans and is authored by Cory House.  I highly recommend it if you are lucky to have a Pluralsight subscription.

After watching the course I thought it would be good to write a few posts on writing Clean Code, which is what I plan to do over the coming weeks.  I will be including some tips I have picked up over the years.

Other Resources
There are various other resources already available on writing clean code and on how to improve as a Software Engineer.

Robert C Martin (Uncle Bob) has a collection of videos that you can pay to watch on Clean Code on the website https://cleancoders.com.

Below are a few books that are also well known in the industry

  • Clean code by Robert C Martin (Uncle Bob)
  • Code complete by Steve McConnell
  • The pragmatic programmer by Andrew Hunt and David Thomas

If you are reading this and have any other suggestions please feel free to leave a comment with the details.