R. Jeevadharani
Sr. Trainer,

"Quality Code" is a term dealt with, when learning a subject called "Software Engineering". Though it is observed as a theory subject, it could be more effective, if practically approached and provided with lab sessions with software tools. Just writing a program for the given requirement won't be adequate. Learning any programming language should include Software Engineering approach. Software industry appreciates the developers to follow the best software engineering practices. To become a Software Engineer, subject in question is the "essentials". When the best practices of software engineering are followed, the developmental phase becomes much smoother and the code meets the industry standards.

One of the major areas in Software Engineering is Quality Code. The term "Quality Code" is becoming a competitive motto among software industries. Companies recognize the developers who produce quality code. During code review or walkthrough, the developers' skills are measured individually based on whether the written code meets the quality standards.

Software companies provide in-house trainings for campus selected candidates on various domains such as Java, Dot Net, Testing, Mainframe, etc, making them industry ready for their business unit. In those in-house training programs, the production of quality code along with industry best practices are emphasized. But it could be incorporated in an earlier stage itself, that is, during the academics.

What is Quality Code?

A code that fulfills the CASE criteria is considered as a Quality code. CASE stands for Correct Adaptable Secure Efficient.

Correct - functionally correct

Adaptable - accommodates changes.

Secure- prevents any security and privacy violations

Efficientmeets or exceeds the defined expectations in terms of speed, memory, etc

Best Practices in the IndustrySome of the best practices to produce Quality Code are:

  • Coding Standards

  • Code Generation

  • Unit Testing

  • Code Coverage

  • Code Analysis

  • Code Profiling

Coding StandardsCoding Standards include:

  • Coding Convention: improves readability

  • Naming Convention: provides clarity on the logic

  • Documentation: improves the understandability of the project.

Coding Convention

Coding standards differ from organization to organization, and even from project to project within an organization. Most organizations follow some default coding standards unless and otherwise the clients specify their project standards. We can also use IDE (Integrated Development Environment) features and other quality tools to implement coding standards. We will see how to implement the coding conventions in Java using NetBeans IDE.

Let us define a coding convention for a XYZ project. Consider the following code. This would be the coding convention for the project team which is developing the XYZ project.

To follow this format such as braces in next line, empty braces between operators and operands, the developer has to manually align the program. To ensure that all team members are following the same format, the Lead of the Project has to manually check all the codes, which is a time consuming and cumbersome job. This process can be automated in almost all IDEs.  Read More

Now let us see the coding convention settings with NetBeans IDE.

After applying coding conventions Follow the steps in Net Beans to create coding conventions.

1. Choose Tools from the Menu bar.

2. Select Option from the Tools menu.

3. A Dialog box will appear as shown below.

4. Select 'Editor' option from the dialog box.

5. Select Formatting tab.

6. Now change the position of braces, empty spaces, tabs and indents.

7. After setting all the options, select Export button from the dialog box.

8. Then a dialog box will appear to store the preferences as a zip file. Store it in a specific location. Now this zip file can be shared across team members to follow the same coding convention. The team members have to use the import button to load the stored preferences.

9. After saving the preferences, in case, the formatting does not apply automatically, Choose 'Source' option from the menu bar and select 'Format' option