How to build quality into .NET code

Article Tags

Software developers are paid to create functionality and solve problems. With time-to-market demands putting more of a squeeze on them to produce working code, the quality of the code they write could become a lower priority as they race to get deliverables out the door, and then later try to fix any problems that might be encountered by users.

Add to this the unique challenges presented by developing software for Microsoft’s .NET platform, and quality could become compromised even further.

“What makes .NET unique among Windows platforms is that it’s garbage collected and that it runs both on the client and on the server,” explained Chris Sells, vice president of the developer tools division at Telerik. “What this means is that apps need to be tuned differently for load times and responsiveness on the client versus overall throughput on the server. Further, apps need to be profiled for memory leaks so that they’re not swamping a user’s computer or taking down a server. These things are especially difficult for .NET programmers, because the garbage collector makes it very easy to make code that works and very difficult to write code that performs well and uses memory efficiently, because the garbage collector hides flaws from you.”

Many development organizations have adopted some form of agile and continuous build and delivery to ship products more quickly, yet some argue this forces organizations to put less of an emphasis on quality. Or, to maintain the desired level of quality, they are losing some of the advantages of agile development.

Karthik Ravindran, senior director of ALM at Microsoft, said that organizations need to strike a balance between agility, quality and scale. “There’s a lot of talk about agile and agility, but without quality, it doesn’t add business value,” he said. “You have to be fast with quality built in. Quality without agility doesn’t add value either.

“Today, in an effort to capitalize on the modern business opportunities enabled by software, decision-makers and practitioners are striving hard to strike the tough balance—and this is where the challenge exists—between agility and quality without compromising either.”

There are two ways to look at the issue of code quality: development best practices, and the use of tools to ensure quality. But how does an organization define quality?#!Nail down your measurements“Code quality is a squishy thing,” said Chris Sells, vice president of the developer tools division at Telerik. “There are all kinds of ways to measure it, from things like complexity and how many functions you’ve got, and how many lines of code you’ve got in a particular function, or how well you’ve named the variables or the function names or the comments, to how well-formed, how secure it is, how robust it is. Code quality is such a huge topic.”

A good practice for developers is refactoring. “The idea is you look at a mess of code that works sort of right, but you want to refactor it to be more efficient, more readable, more maintainable,” Sells said.