Format Your Code

Well-formatted code makes your code easier to read, maintain, and reuse. Formatting your code professionally is an important consideration in development. Before your development team starts coding, they should write a coding guidelines document. These guidelines should include all the standards that determine how your organization formats code professionally. If these guidelines are not set at the beginning, the code will look as though many individual developers, as opposed to a coordinated development group, created the code. Formatting code is a discipline that is carried out during the coding, not at the end of it. If developers wait until after the coding to assemble guidelines, the task will most likely not get done.

When formatting your code, be sure to put in white space, comments, and indents. Most developers have good structure to their code, but skip over the task of commenting, which is necessary for capturing the why, what, when, and how of their code. Commenting your code while producing it facilitates better communication within the development team and helps with the maintainability. If you do not comment when you code, you may end up not documenting the code. A common mistake for development teams is putting off commenting until the very last part of the project and then never getting back to complete the task.

FORMAT YOUR CODE

FORMAT YOUR CODE

D Open your text editor.

Q Type the name of the class you want to create followed by {}, placing the opening and closing braces on separate lines.

D Open your text editor.

0 Type the name of the namespace you want to create and press Enter.

< Type { }, placing the opening and closing curly braces on separate lines.

—Q Between the curly braces, press Tab and type // to begin a single line comment, add the comment details, and then press Enter.

0 Type using System; to import the System namespace and press Enter.

—0 Add a documentation comment by typing /// followed by the comment.

Q Type the name of the class you want to create followed by {}, placing the opening and closing braces on separate lines.

Was this article helpful?

0 0

Post a comment