- C# and .NET Core Test Driven Development
- Ayobami Adewole
- 181字
- 2021-06-25 22:00:27
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();
}
推薦閱讀
- Learning Microsoft Windows Server 2012 Dynamic Access Control
- 程序員面試筆試寶典(第3版)
- 動手玩轉Scratch3.0編程:人工智能科創教育指南
- 實用防銹油配方與制備200例
- Mastering Drupal 8 Views
- C語言程序設計同步訓練與上機指導(第三版)
- Asynchronous Android Programming(Second Edition)
- RabbitMQ Essentials
- 基于SpringBoot實現:Java分布式中間件開發入門與實戰
- Java程序設計案例教程
- Building Dynamics CRM 2015 Dashboards with Power BI
- GitHub入門與實踐
- Struts 2.x權威指南
- 區塊鏈架構之美:從比特幣、以太坊、超級賬本看區塊鏈架構設計
- Modernizing Legacy Applications in PHP