Skip to main content

Developer Open Exam / Lines of Code as code metric

Last post 01:25 pm June 1, 2017 by Zi Wang
13 replies
09:01 am August 27, 2015

Hi everyone,

As I participated to a PSD training last week, with awesome people (thanks so much guys, hope you read this post :)), I took the Developer Open Exam a few times again.

Without spoiling everything, here is one question that is confusing:
**Which of the following are NOT metrics of code quality? (choose all that apply)**

Amongst the possible answers, there is **Lines of Code**, which appears to be a correct one according to the results check, but with no related given feedback.

However I consider that **Lines of Code** (source code regardless comments and blanks), especially for a specific targeted class is one of the many metrics to evaluate code quality. As an isolated indicator, it only provides the developer with a good/bad smell. The training and its manual confirms it as well, being listed with four others, so do many recommanded books in the PSD subject areas section.

So fellow developers, future candidates and Scrum.org trainers, what do you think about it? Is this a mistake in the exam itself? Am I overthinking this question? Should it be set in a more specific context?

Cheers,


09:56 am August 27, 2015

Lines of code as a metric on its own is not the best predictor of code quality.

The most effective evaluation should be a combination of size, lines of code, and Cyclomatic complexity.
Modules with large size and high complexity size tend to have the lowest reliability.

Modules with low size and high complexity are also a reliability risk because they tend to be very terse code with few comments, which is difficult to read, change or modify.

Focus on the size of code may loose its readability and maintainability.

As modern optimizing compiler implementation, the lines of code is also not the best predictor of program performance.



12:30 pm August 27, 2015

> However I consider that **Lines of Code** (source code regardless comments and
> blanks), especially for a specific targeted class is one of the many metrics to evaluate code quality.

Lines of Code might well be a measure of code quality, if it was indeed being assessed at the level of a code module. However the question only refers to "lines of code". As such, codebase A cannot be said to be of worse quality than codebase B on the grounds that its line-count is higher. The scope of work encompassed by A might simply be far greater.


06:12 pm August 27, 2015

Thank you Ching-Pei and Ian for your answers.

I indeed agree that it is not the best one. As Ian explained it more clealy, consideration to the code's location and purpose are important. As the question does not refer to any of those, there are cases where it can be a pertinent indicator, and for others, not. Thus, should this question be reformulated? :)


05:23 am August 28, 2015

I don’t think this is a Text Trap.

“Lines of code” is a valuable metric for code analysis, but not a metric of code quality.

It can be used as a referent indicator. A significant large codebase may be the outcome of bad metrics of code quality. But on its own, it is not the best predictor of code quality.

A very very sipmle example:
[code]A:
If (condition)
Return false;
Return true;

B:
If(condition)
{
Return false;
}
Return true;

C:
If (condition)
{
Return false;
}
Else
{
Return true;
}
[/code]
Which one is the best?
For modern compiler, the outcome is the same. But how about the quality?


05:51 am August 28, 2015

Excuse me for my poor english, I do my best to explain my opinion. :)

Suppose the lines of code of a module is double scaled as expected.

Let's answer the questions as follows:
1. Whats are the potential causes?
2. How can I do something to reduce the lines of code?
3. How can I do something to increase the quality of code?

I can do/perform ... to reduce the lines of code.
I can do/perform ... to increase the quality of code.

Is there an answer like "I can reduce the lines of code to increase the quality of code" per you experience?




Anonymous
06:00 am August 28, 2015

hi Romain,

You mention that you use "Lines of Code" as a measure of code quality. How do you do that ? What do you measure exactly. I would like to learn that too ..

Thanks in advance.

Muthaiya


03:40 am August 31, 2015

“Lines of code” is a valuable metric for code analysis, but not a metric of code quality.



I'd say 'not necessarily a metric of quality'. It can be, related to some context, as in the simple example provided by Ching-Pei. Same purpose but different readability, reducibility, maintainability...

As said before and to respond to Muthaiya, it gives me some appreciation on the quality of the specific piece of code I'm working on. Such a metric or guideline (limited number of lines per method, class...) is not useful just on its own, but it shouldn't be disregarded.

A good colleague of mine presented a nice analogy on that matter, that I'd like to share. He described the "Lines of code" as weight, which without details is meaningless. BMI in the other hand, is, as the weight being associated to other factors.

Getting back to my intial comment, I find those factors missing in the question, or up to the exam candidate to decide.


08:02 pm September 5, 2015

I also find the question not very clear, and I agree with Romain. Lines of Code is definitely a code quality metric, just like weight can be a metric for a person's physical health. Metrics are usually not meant to be looked at individually, and metrics are never perfect. The question didn't ask whether it is a good or valuable metric. If the question is in the paid assessment, I think the question should be amended as - "Which of the following are NOT good metrics of code quality?" Also, the Lines of Code simply should not be included as one of the answer choices because it is debatable.


06:57 pm September 6, 2015


Posted By Michael Ming Chak Lee on 05 Sep 2015 08:02 PM
Lines of Code is definitely a code quality metric, just like weight can be a metric for a person's physical health.



Hi Michael,
My opinion is:
Weight is not a health metric, but BMI is.

What does a code metric mean?
What does a code quality metric mean?

This is not a text trap.


03:07 am September 7, 2015

Thank you Ching-Pei. I think you have highlighted quality which is indeed the key.

Since the use of Lines of Code has to be under a very specific context and is so debatable, it cannot be qualified as a code quality metric. It is just a code metric that by itself doesn't tell quality. Something else must be looked at before you can evaluate the code quality.


09:39 am September 10, 2015

Glad this topic raised many reactions. I think we now all agree on that Lines of Code is a code metric but not *necessarily* a quality one, and that the key point of the question is now understood.

Still, I feel that there should be mention of "regardless of any context" or "independently" within that question, not to confuse people. ;)


07:51 am December 12, 2016

Hello,
I also stumbled over this question regarding code quality metrics (not for the first time). So far I did not found any hint on scrum.org which helps to guess the expected answer. So my question is:

Where can we find the explanation behind this question?

Otherwise this question leaves a bit abitrarily.

For the rest of the open assessments: Keep on the great work.


11:34 pm May 31, 2017

Which are NOT metrics of code quality?

Lines of Code 

Cycle time per feature 

 

Which are metrics of code quality?

Class coupling, depth of inheritance, cyclomatic complexity


By posting on our forums you are agreeing to our Terms of Use.

Please note that the first and last name from your Scrum.org member profile will be displayed next to any topic or comment you post on the forums. For privacy concerns, we cannot allow you to post email addresses. All user-submitted content on our Forums may be subject to deletion if it is found to be in violation of our Terms of Use. Scrum.org does not endorse user-submitted content or the content of links to any third-party websites.

Terms of Use

Scrum.org may, at its discretion, remove any post that it deems unsuitable for these forums. Unsuitable post content includes, but is not limited to, Scrum.org Professional-level assessment questions and answers, profanity, insults, racism or sexually explicit content. Using our forum as a platform for the marketing and solicitation of products or services is also prohibited. Forum members who post content deemed unsuitable by Scrum.org may have their access revoked at any time, without warning. Scrum.org may, but is not obliged to, monitor submissions.