Software Engineering is a team activity where every individual is playing a vital role. Most successful software projects are granted for team players and not individual efforts. Purpose of this article is to familiarize developers involved to keep few things in mind while they are developing the product. It will help you in the project as well as improve your team abilities for future. We will focus on developers to agree on a standard and follow it through the software development.
Following list describes areas or things that we need to take care of while developing softwares.
1. XML Comments
Always use XML comments for each major block of code. We don’t focus to write comment on every line of program. But only on the major block of code like if you are developing a class, then first add comment with class. Secondly add comments on the public methods or members of class. An example of this is as
/// Connect to database through MySQL Connector Provider
/// and perform data manipulation operations
public class DBConnection
MySqlConnection connection = null;
MySqlCommandcmd = null;
MySqlDataAdapter da = null;
DataSet ds = null;
/// default constructor
connection = new MySqlConnection();
/// open connection
private bool OpenConnection()
connection.ConnectionString = AppSettings.DB_CONNECTION_STRING;
catch (Exception ex)
2. Avoid Using Constants or Magic Numbers
Avoid using constants or magic numbers in the program. For constants define Enums there and use them. See below example.
Public enum Reports
COMPLAINT_PRIORITIES = 1,
COMPLAINT_STATUS = 2,
COMPLAINT_TYPE = 3,
DEPARTMENT_AND_COMPLAINTS = 4,
SYSTEM_USERS = 5
Here rather than using constants you can use enum throughout the program.
3. Use Configuration Manager
Never use/access configuration files settings directly or you can say use of configuration manager on the forms or pages you develop is not good practice. For thisyou can add a class “AppSettings”. In this class you can define your own constants and populate them from the configuration file. See below snap code for this.
Public static class AppSettings
Public static string DB_CONNECTION_STRING = ConfigurationManager.ConnectionStrings["dbConnectionString"].ToString();
Public static string APP_REPORTS_PATH = ConfigurationManager.AppSettings["REPORT_PATH"].ToString();
Make constants with upper case letter like in above example.
5. Keep Track of Warnings
Keep track of the warnings as well while developing. This will suggest you many things regarding your code. For example if you define a variable and don’t use in code, you will get a warning regarding this. By doing this you will remove un necessary code/variables from the file.
6. Use of foreach Loop
For collections try your best to use “foreach” like loops and not the traditional for or while loops.
7. Empty Strings
Empty string comparison or assignment is not appreciated through (“”), but instead use the string.Empty. You will mostly need this on clearing the form controls.
8. Exception Handling
Your code should use exception handling and give proper messages to user.
9. Use Methods
Don’t write code directly in the form control events, instead make your own functions/methods and call them from your events as required.
10. Hot Keys
Make your form controls user friendly and useable through keyboard. For this use hot keys and accelerator keys.