O'Reilly logo

Professional Test-Driven Development with C#: Developing Real World Applications with TDD by Jeff McWherter, James Bender

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

SUMMARY

Developers never write perfect code the first time. In practice, trying to write the “perfect method” the first time through is a mistake. Strive to get your application working and your tests passing. With a suite of unit tests that validate your code, you can refactor fearlessly.

Refactoring is to code what editing is to a book or article. Be merciless with your code. Refactor it to increase maintainability. Refactor to make your code more testable. Refactor it to ensure that it obeys the three tenets of OOP: encapsulation, inheritance, and polymorphism. Refactor to make sure you are abiding by the SOLID Principles: Single Responsibility, Open/Closed, Liskov Substitution, Interface Segregation, and Dependency Inversion. All these things not only increase the quality of your code, but also sharpen your skills as a developer and make you a better practitioner of TDD.

Code smells are antipatterns in code. Learn to identify them. Familiarize yourself with refactoring patterns to be able to quickly and easily deal with these code smells. Be sure to use your unit tests to verify that you have not broken the code's business functionality with your refactoring.

Finally, continue to study the tenets of OOP and the SOLID Principles. These concepts are not destinations; they are journeys. You'll always have opportunities to improve how you write code. Don't stop learning.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required