Building Maintainable Software: A Slack Takeover with Steve Smith | TechWell

Building Maintainable Software: A Slack Takeover with Steve Smith

Steve Smith

Thought leaders throughout the software community are taking over the TechWell Hub for a day to introduce themselves, answer questions, and engage in conversations.

Software architect and trainer Steve Smith is the founder of Ardalis Services, helping teams improve skills with domain-driven design and ASP.NET Core. He was also a member of Microsoft’s Regional Director program and has been recognized by Microsoft as a Most Valuable Professional since 2002.

@Steve Smith presided over our most recent Slack takeover, which led to some insightful discussions.

Producing Testable Code

“We all know we need to build quality into our code, so what principles do you find help the most with producing testable code?” —@owen

“In my experience, the biggest thing that makes code hard to test is dependencies, especially hidden dependencies that are tightly coupled,” Smith said.

Tight coupling to dependencies makes it harder to find seams in your code where you can break the system apart and isolate one part from another in order to test it. High-quality software is modular and made of loosely coupled components that can each be tested in isolation, as well as together with the rest of the system.

If you want to write unit tests, you need seams around the unit of code you're trying to test.

“The single biggest principle that helps with this is the dependency inversion principle, which is the D in the SOLID principles,” Smith advised.

Writing Maintainable Tests

“What tips do you have for writing maintainable tests?” —@Kelly M

“First, I organize tests by speed and kind of test, which typically means having them separated into unit, integration, end-to-end/functional, UI automation, and load tests,” Smith said.

This way you can easily run a single set of tests in a given scenario. Unit tests should always be fast, so you can run them any time. UI tests and load tests are often slow, so you might run them on a scheduled basis.

“The test classes themselves I organize vary granularly around what they are testing,” he continued.You also want to minimize duplication and the number of direct dependencies that exist between your tests and your system under test.”

Finally, he advised to avoid repeating your setup logic by using the builder pattern.

Blurring Job Roles

“The ratio of devs being asked to write tests is on the rise, even if the company does not 'officially' use TDD or a version of it. And those that were hired to test are being nudged into a more code-heavy role. Are the workplace changes, in your opinion, going to continue in this direction to where everybody codes, or are the roles going to separate again?” —@ArleneAndrews

Smith said he thinks automated testing is going to continue to grow in popularity. 

“More developers are open to it or expect it. More teams and companies associate software testing with automated software testing, especially as DevOps continues to gain traction.”

He doesn't think manual and exploratory testing and other quality improvement activities will disappear, but having experience with test automation can maximize employability.

Up Next

About the Author

TechWell Insights To Go

(* Required fields)

Get the latest stories delivered to your inbox every week.