- 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();
}
推薦閱讀
- AngularJS Testing Cookbook
- Julia機器學習核心編程:人人可用的高性能科學計算
- Data Analysis with IBM SPSS Statistics
- Java程序設計與實踐教程(第2版)
- Python機器學習實戰
- The Complete Coding Interview Guide in Java
- Learning Vaadin 7(Second Edition)
- Teaching with Google Classroom
- RabbitMQ Essentials
- Active Directory with PowerShell
- Java Web開發詳解
- C++從入門到精通(第6版)
- Docker:容器與容器云(第2版)
- Laravel Design Patterns and Best Practices
- Go語言編程之旅:一起用Go做項目