Code Readability
Learning Competencies
By the end of this primer, you should be familiar with and able to explain:
- What code readability is.
- Why it's an important skill to have as a developer.
- What code readability habits you can start building on today.
Summary
When writing or working on code as a developer, you will find you won't be the only one working on your code. You will need to share your code with colleagues or employees after you leave, and you want someone else to be able to pick up your code after you and not have to spend a week just trying to understand it. This is where Code Readability comes in.
Time Box
Challenge | Time |
---|---|
Research | 1 hour |
Reflect | 20 minutes |
Code Readability
Code Readability is about practising the following habits when you are working on code:
- Indentation/formatting your code to best practice standards.
- Consistency in how you name things and how you format your code.
- Naming things well (functions and variables) so you can tell what they do or are.
- Break things into small segments (many small functions compared to one big function).
- D.R.Y (Don't Repeat Yourself).
- Commenting a complicated section, so people have some idea before reading your code.
- Not commenting everything or obvious things.
- Refactoring.
- Clean code.
Research
Have a good look around the internet to understand code readability and techniques developers use.
First, check out Scott Granneman's article on Formatting & Indenting Your HTML This is a great article to see what is a good method of indenting HTML. Keep in mind that this indenting style should be used in all your code from this point on.