0% found this document useful (0 votes)
4 views8 pages

Coding Style Guide

The document outlines coding style guidelines that promote clean, consistent, and maintainable code, facilitating better teamwork and readability. It includes specific formatting rules, such as namespace declarations, indentation, and SQL query practices, as well as commenting standards to enhance code clarity. Following these guidelines helps developers collaborate effectively and maintain code more efficiently.

Uploaded by

dhimmar464
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
4 views8 pages

Coding Style Guide

The document outlines coding style guidelines that promote clean, consistent, and maintainable code, facilitating better teamwork and readability. It includes specific formatting rules, such as namespace declarations, indentation, and SQL query practices, as well as commenting standards to enhance code clarity. Following these guidelines helps developers collaborate effectively and maintain code more efficiently.

Uploaded by

dhimmar464
Copyright
© All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd

Coding Style

[Link] Style

Code styling is a set of rules to write clean and consistent code. It helps
developers easily read, understand, and work on code together.

Example:

Why does having coding Styling matter ?

●​ Easy to Read: Helps anyone understand the code quickly.

●​ Consistent: Makes code look the same, even if written by different

people.

●​ Better Teamwork: Easier for teams to collaborate.

●​ Simple Maintenance: Fixing or updating code becomes faster

2.1 Formatting

2.1.1 General

1.​ Never declare more than 1 namespace per file.

2.​ Avoid putting multiple classes in a single file.

3.​ Curly Braces:


○​ Always on a new line.

○​ Always use them in conditional statements.

​ ​

4.​ Always use a Tab & Indention size of 4.

5.​ Declare each variable independently – not in the same statement.


6.​ Place namespace “using” statements together at the top of the file.

Group .NET namespaces above custom namespaces.

2.1.2 Page Code Regions

●​ Organize code using regions for clarity:


●​ For C#:

●​ For JS:

●​ For HTML:

2.1.3 Back End – SQL Server formatting


1.​ Uppercase Keywords: Use uppercase for all SQL keywords.

2.​ Indentation: Break long queries for readability.


●​ Bad Example:

●​ Good Example:

3.​ Use Single Quotes for Strings


●​ In SQL, always use single quotes (') to enclose string values.

Explanation: To include a single quote (apostrophe) within a string, nest


single
quotes
4.​ Use parentheses to increase readability

5.​ Use BEGIN...END for Multiple Statements


●​ When you have multiple statements within a conditional block (IF,
CASE, etc.), use BEGIN...END to group them together.

6.​ Use One Blank Line Between Code Sections


●​ Separate different sections of your code with a blank line to improve
readability.

7.​ Use spaces so that expressions read like sentences.


●​ Make expressions readable by adding spaces around operators.

8.​ Format JOIN operations using indents Also, use ANSI Joins instead of old
style joins4
●​ Old Pattern:
●​ With JOIN keyword (Correct Format)

2.2 Code Commenting

2.2.1 General
●​ All comments should be written in the same language, be grammatically
correct, and contain appropriate punctuation.
●​ Use inline-comments to explain assumptions, known issues, and algorithm
insights.
●​ Do not use inline-comments to explain obvious code. Well-written code is
self-documenting.
●​ Do not “flowerbox” comment blocks

2.2.2 Comment template for adding new code


2.2.3 Comment template for modifying existing code

2.3 Coding

2.3.1 Back End – SQL Server


●​ 1 Do not use SELECT * in your queries. Always write the required column
names after the SELECT statement. This technique results in reduced disk
I/O and better performance:

●​ Use SET NOCOUNT ON at the beginning of stored procedures


This suppresses messages like ‘(1 row(s) affected)’ after executing INSERT,
UPDATE, DELETE and SELECT statements. Performance is improved due to
the reduction of network traffic.

You might also like