Introduction
The code that you write should communicate your intent to both the compiler and other developers who may need to read your code. And since you're the developer who will be reading your code most often, sometimes months after you originally wrote it, it's in your best interest to write code that's clear and easy to understand. Remember, you may write code once, but you will need to read it many times.
Suppose you've been asked to write some code for another group of developers. You meet with them to discuss the specification and the assignment is clear. After the meeting they tell you that you'll be working independently during development. Once you're done, you'll hand off your code to the other group. The coding task isn't beyond your skill level, but you've never had to write code that someone else will be maintaining. The team told you that as long as you follow the standard coding conventions for C#, there should be no problem. You make plans to review the C# coding conventions that relate to the code you're going to work on.
In this module, you'll learn how to choose names for your variables that describe their purpose and intent. You'll learn how to add code comments that document the higher-level requirements and your approach in code, as well as to temporarily instruct the compiler to ignore lines of code. Finally, you'll learn how whitespace can be used to help convey the relationship of individual lines of code.
By the end of this module, you'll write code more purposefully, focusing on the readability and quality of the code to communicate to both the compiler and other developers.
Important
This module includes coding activities that require Visual Studio Code. You'll need access to a development environment that has Visual Studio Code installed and configured for C# application development.
Learning objectives
In this module, you will:
- Choose a descriptive name for variables that describe their purpose and intent.
- Use code comments to temporarily instruct the compiler to ignore lines of code.
- Use code comments to describe higher-level requirements or purpose for a passage of code.
- Write code that effectively uses whitespace to convey the relationship of lines of code.
Prerequisites
- Experience using Visual Studio Code to create and run C# console applications.
- Experience printing messages to the console using
Console.WriteLine(). - Experience using the
ifandelse ifstatements to create code branches.