r. } 不好: // This method will save the phone number. void SaveData ( string phoneNumber ) { // Save the phone number. } 一个方法只完成一个任务。不要把多个任务组合到一个方法中,即使那些任务非常小。 好: // Save the address. SaveAddress ( address ); // Send an email to the supervisor to inform that the address is updated. SendEmail ( address, email ); void SaveAddress ( string address ) { // Save the address. // ... } void SendEmail ( string address, string email ) { // Send an email to inform the supervisor that the address is changed. // ... } 不好: // Save address and send an email to the supervisor to info页码:[1] [2] [3] [4] [5] [6] [7] [8] 第5页、共8页 |