官术网_书友最值得收藏!

Source code readability

A good code base can be easily distinguished from a bad one by how quickly a new team member or even the programmer can easily understand it after leaving it for a few years. Quite often, because of tight schedules and approaching deadlines, software development teams tend to compromise and sacrifice professionalism to meet deadlines, by not following the recommended best practices and standards. This often leads them to produce code that is not readable.

The following code snippet will perform what it is intended to do, although it contains elements written using terrible naming conventions and this affects the code's readability:

public void updatetableloginentries()
{
com.Connection = conn;
SqlParameter par1 = new SqlParameter();
par1.ParameterName = "@username";
par1.Value = main.username;
com.Parameters.Add(par1);
SqlParameter par2 = new SqlParameter();
par2.ParameterName = "@date";
par2.Value = main.date;
com.Parameters.Add(par2);
SqlParameter par3 = new SqlParameter();
par3.ParameterName = "@logintime";
par3.Value = main.logintime;
com.Parameters.Add(par3);
SqlParameter par4 = new SqlParameter();
par4.ParameterName = "@logouttime";
par4.Value = DateTime.Now.ToShortTimeString(); ;
com.Parameters.Add(par4);
com.CommandType = CommandType.Text;
com.CommandText = "update loginentries set logouttime=@logouttime where username=@username and date=@date and logintime=@logintime";
openconn();
com.ExecuteNonQuery();
closeconn();
}
主站蜘蛛池模板: 南川市| 满城县| 青田县| 高唐县| 杭锦旗| 渑池县| 深圳市| 荆门市| 安远县| 海兴县| 哈巴河县| 夏河县| 上栗县| 宁蒗| 汾阳市| 志丹县| 宜都市| 荔浦县| 萨迦县| 郯城县| 昭苏县| 绥棱县| 安乡县| 永昌县| 印江| 和硕县| 紫云| 绥滨县| 聊城市| 界首市| 宁德市| 桃江县| 绥芬河市| 库车县| 墨竹工卡县| 长武县| 那坡县| 麻栗坡县| 绥德县| 广德县| 皋兰县|