Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


What's Your Code Quality?


What's Your Code Quality?

Author
Message
Steve Jones
Steve Jones
SSC-Dedicated
SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)SSC-Dedicated (36K reputation)

Group: Administrators
Points: 36040 Visits: 18734
Comments posted to this topic are about the item What's Your Code Quality?

Follow me on Twitter: @way0utwest
Forum Etiquette: How to post data/code on a forum to get the best help
My Blog: www.voiceofthedba.com
mhli
mhli
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 9
Well I personally use code smells to measure quality of code. To me one of the worst examples of bad code is when the same logic or even same piece of code is present several places.

One of the worst things I've encountered was having the same logic in C# and in SQL, being used in different circumstances. That meant that if you wanted to change something you'd had to change it in at least two locations, and it was hard to ensure that all scenarios was covered.
Dennis Wagner-347763
Dennis Wagner-347763
Valued Member
Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)

Group: General Forum Members
Points: 64 Visits: 227
WTFs/minute sounds like a good measurement. Exceptional code can be measured in days between WTFs, really good code can be measured in WTFs/hour and really poor code in WTFs/second.
mhli
mhli
Forum Newbie
Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)Forum Newbie (6 reputation)

Group: General Forum Members
Points: 6 Visits: 9
Dennis Wagner-347763 (2/21/2011)
WTFs/minute sounds like a good measurement. Exceptional code can be measured in days between WTFs, really good code can be measured in WTFs/hour and really poor code in WTFs/second.


That's essentially just hertz. In theory you could then have GHz code - although in practice it will more likely be in µHz (mikrohertz).
jrhutch
jrhutch
SSC-Addicted
SSC-Addicted (482 reputation)SSC-Addicted (482 reputation)SSC-Addicted (482 reputation)SSC-Addicted (482 reputation)SSC-Addicted (482 reputation)SSC-Addicted (482 reputation)SSC-Addicted (482 reputation)SSC-Addicted (482 reputation)

Group: General Forum Members
Points: 482 Visits: 95
You measure quality in code the same way you measure quality in science, through peer review.

In .Net development (and I'm sure in other languages/platforms) we have static code analyzers that can help by pointing you towards potential problems. But the best way to ensure good quality code is through code reviews. These can be quick and informal like "Can you take a look at this before I check it in?", or they can be more formal where and reviews a piece of code that one person wrote.

The group reviews can turn ugly, and that needs to be kept under control, but they can also be educational as everyone gets to see what other people are doing that's right and wrong, and hopefully clean up in their own code as a result.
Dennis Wagner-347763
Dennis Wagner-347763
Valued Member
Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)Valued Member (64 reputation)

Group: General Forum Members
Points: 64 Visits: 227
Obviously my first post was just in jest.

While peer review isn't really a true measurement because it's subjective (like judges in the Olympics -- yecch), it is a great way to bring a team together cohesively. The best team environment I ever worked in had multi-phased code reviews (algorithm, psuedo-code, development code, production code) by at least two team members -- and not always the same ones. We strived to achieve the following:

1) Each piece of code did one thing and one thing only
2) Each piece of code was similar in look and feel to all other code to make maintenance easier
3) Never have more than one copy of code that does the same thing.

We had one rule for code review -- keep your personal feelings about another person out of the room -- be objective. We delivered the project on time and with very little defects.
jay-h
jay-h
SSC Eights!
SSC Eights! (919 reputation)SSC Eights! (919 reputation)SSC Eights! (919 reputation)SSC Eights! (919 reputation)SSC Eights! (919 reputation)SSC Eights! (919 reputation)SSC Eights! (919 reputation)SSC Eights! (919 reputation)

Group: General Forum Members
Points: 919 Visits: 2220
Most of these rules successfully separate gawdawfull code from adequate code. Separating adequate code from good or great code is a lot more difficult.

How do you differentiate a technically proficient painting from a great one, or a decent piano from a great one, or a decent meal from a great one? Rules don't help so much there but we can often sense the difference when we encounter it. Alas the same thing happens with code.

...

-- FORTRAN manual for Xerox Computers --
dmbaker
dmbaker
Mr or Mrs. 500
Mr or Mrs. 500 (571 reputation)Mr or Mrs. 500 (571 reputation)Mr or Mrs. 500 (571 reputation)Mr or Mrs. 500 (571 reputation)Mr or Mrs. 500 (571 reputation)Mr or Mrs. 500 (571 reputation)Mr or Mrs. 500 (571 reputation)Mr or Mrs. 500 (571 reputation)

Group: General Forum Members
Points: 571 Visits: 3436
mhli (2/21/2011)
Dennis Wagner-347763 (2/21/2011)
WTFs/minute sounds like a good measurement. Exceptional code can be measured in days between WTFs, really good code can be measured in WTFs/hour and really poor code in WTFs/second.


That's essentially just hertz. In theory you could then have GHz code - although in practice it will more likely be in µHz (mikrohertz).


I think "hurtz" would be a better name. If you have mHurtz code then you've got problems, but GHurtz...now you're in serious pain.

:-)



James Goodwin
James Goodwin
Ten Centuries
Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)Ten Centuries (1.4K reputation)

Group: General Forum Members
Points: 1363 Visits: 1107
Most of these rules successfully separate gawdawfull code from adequate code. Separating adequate code from good or great code is a lot more difficult.

Separating good from great code is certainly more difficult, but also less necessary.

How do you differentiate a technically proficient painting from a great one, or a decent piano from a great one, or a decent meal from a great one? Rules don't help so much there but we can often sense the difference when we encounter it. Alas the same thing happens with code

I disagree. Part of the reason that experts can distinguish between good and great is because they have a language to discuss the differences with. An amateur may know what they like and don't like but has difficulty describing the what and why of their opinion. To take the piano example, the amateur may be able to tell you that one piano sounds better to them, the expert will be able to talk about the nuances of the sound that make it sound better (harmonic range, sound board reverberation, etc.) Certainly, experts may disagree on the weight to give various aspects of an artistic endeavor, but that doesn't invalidate the process itself.

Likewise, there are aspects of computer code that make one piece of code better than another, the lowest level distinction is, of course, works versus fails. Beyond that there are measures of maintainability, efficiency (O notation), reusability, coupling, cohesion, documentation, etc.

In database design, the ability to add objects or elements without having to rework large swaths of existing code is certainly an aspect of the quality of the design that the beginner often fails to recognize but that the expert does.
--
JimFive
Eric M Russell
Eric M Russell
SSCarpal Tunnel
SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)SSCarpal Tunnel (4.6K reputation)

Group: General Forum Members
Points: 4575 Visits: 9500
The problem with metrics is that most company's simply don't have an official standard. Ask ten different managers (in the same department) to examine a piece of code, and you'll get 10 different opinions about about how well it conforms to their personal standard. Most managers keep their standards only inside their head, so it even evolves over time. Just like food in a restraunt, the end users are the final judge of the quality of your code.


"The universe is complicated and for the most part beyond your control, but your life is only as complicated as you choose it to be."
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search