---
title: "Discussion on \"First And Most Important Lesson To Writing Good Code\" | Hashnode"
description: "Discussion on \"First And Most Important Lesson To Writing Good Code\". First And Most Important Lesson To Writing Good Code"
url: "https://hashnode.com/posts/first-and-most-important-lesson-to-writing-good-code-1/6141a7efc5f31102b885e86d"
---

[Feed](https://hashnode.com/feed) /

Discussion

# [First And Most Important Lesson To Writing Good Code](https://paddockson.hashnode.dev/first-and-most-important-lesson-to-writing-good-code-1?utm_source=hashnode&utm_medium=feed)

First And Most Important Lesson To Writing Good Code

Sep 15, 2021 · 4 min read · paddockson.hashnode.dev  
Read the article

-   [#career](https://hashnode.com/tag/career)
-   [#learn-coding](https://hashnode.com/tag/learn-coding)
-   [#csharp](https://hashnode.com/tag/csharp)
-   [#clean-code](https://hashnode.com/tag/clean-code)
-   [#programming](https://hashnode.com/tag/programming)

## Written by

[Matt Paddock](https://hashnode.com/@Paddockson)

@Paddockson · UK

  
[View profile](https://hashnode.com/@Paddockson)

Please don't ever give up or give In.

Developer for an insurance solution company and personal developer for my own business.

## Responses 1

Comments are turned off for this post.

[Art Stępkowski](https://hashnode.com/@art-stepkowski)

[Sep 15, 2021](https://hashnode.com/posts/first-and-most-important-lesson-to-writing-good-code-1/6141a7efc5f31102b885e86d/comment/61420acb82e95e55a8738d55)

Are you sure that:

```
            if (newLevelOfHappiness == maxHappiness)
            {
                return true;
            }
            else
            {
                return false;
            }
```

is an example of clean code?

[Matt Paddock](https://hashnode.com/@Paddockson)

[Sep 15, 2021](https://hashnode.com/posts/first-and-most-important-lesson-to-writing-good-code-1/6141a7efc5f31102b885e86d/comment/61420acb82e95e55a8738d55#reply-6142109cb95e345575e99d0c)

As the post was written for people starting into the industry this is an example of clean code. You could argue this is cleaner:

```
         private bool test(int x, int y)
        {
            if (x == y) return true;

            return false;
        }
```

But this not as readable for someone who may have 0 experience in the industry and self taught. Separation of methods, naming and unnecessary code was mostly the point around this, being the SOLID principles as a developer.

If you prefer I can update this with more advanced understanding to keeping methods clean.

[Art Stępkowski](https://hashnode.com/@art-stepkowski)

[Sep 15, 2021](https://hashnode.com/posts/first-and-most-important-lesson-to-writing-good-code-1/6141a7efc5f31102b885e86d/comment/61420acb82e95e55a8738d55#reply-61421728b95e345575e99e4c)

[Matt Paddock](https://hashnode.com/@Paddockson)

No, this isn't example of clean code. It's antipattern.

```
if(expression) {
  return true;
}
else {
  return false;
}
```

You second proposition is still the same antipattern. From my point of view, teaching antipatterns is wrong. Any live coding session will be a disaster for begginer with bad habits. Writing a code like this, during a job interview, is a red flag for me.

Proper (clean) version of IsHappy function should look like this (2 is magic number and should be moved to const).

```
        public bool IsHappy(int levelOfHappiness, int maxHappiness)
        {
            return levelOfHappiness * 2 == maxHappiness;
        }
```

Teaching SOLID principles is great (I know senior devs with problems with it), but do you really think, that refactoring lesson is good for absolute begginers? To refactor code one should know a little bit more about coding than pure basics.
