views:

182

answers:

3

hi there,

Codebase size has a lot to do with complexity of a software system (the higher the size the higher the costs for maintenance and extensions). A way to map codebase size is the simple 'lines of code (LOC)' metric (see also blog-entry 'implications of codebase-size').

I wondered how many of you out there are using this metric as a part for retrospective to create awareness (for removing unused functionality or dead code). I think creating awareness that more lines-of-code mean more complexity in maintenance and extension can be valuable.

I am not taking the LOC as fine grained metric (on method or function level), but on subcomponent or complete product level.

+3  A: 

I find it a bit useless. Some kinds of functions - user input handling, for example , are going to be a bit long winded no matter what. I'd much rather use some form of complexity metric. Of course, you can combine the two, and/or any other metrics that take your fancy. All you need is a good tool - I use Source Monitor (with whom I have no relationship other than satisfied user) which is free and can do you both LOC and complexity metrics.

I use SM when writing code to make me notice methods that have got too complex. I then go back and take a look at them. About half the time I say, OK, that NEEDS to be that complicated. What I'd really like is (free) tool as good as SM but which also supports a tag list of some sort which says "ignore methods X,Y & Z - they need to be complicated". But I guess that could be dangerous, which is why I have so far not suggested the feature to SM's author.

anon
sorry, forgot to mention: i mean the overall lines-of-code metric, which the whole codebase has. not too fine grained per method or function. i am taking it more as a metric for the overall software-process and being aware and keep the lines-of-code of the whole codebase as low as possible, there was a saying something like 'beauty is not when there is nothing more to add but when there is nothing to take away')
manuel aldana
@Manuel At the codebase level it's meaningless - how can you know how many LOC's you need or are good? You can't.
anon
You misunderstand me. I don't mean to see it as absolute metric (i.e. saying you need 1K LOC to implement this x feature is absolutely nonsense). I merely see LOC as a process metric to be more aware that maintaining big systems (which high LOC expresses) comes with a high cost. Nowadays one of the big problems with software systems is the fraction of dead-code (I read different numbers from 20-60% code) and dead/unused-features. With "LOC awareness" on process level I see one way to fight against it.
manuel aldana
@Manuel Well if dead code (not sure what that is) is your concern, then _that_, rather than LOC should surely be your metric of interest. As I'm not sure what you mean by the term, I can't offer any further advice.
anon
dead-code is: code which is never executed, dead-features: features which are deprecated or are never used by users and thus can be removed. LOC metric does NOT tell you: from 100K 10K can be removed (you just don't know the dead code fraction). I see LOC more as a process metric to take action, e.g.: "Codebase has increased 25K in the last month, in next sprint we plan dedicated clean-up effort." In my view being LOC aware in the whole team you can create a culture of YAGNI and get a better feeling of size. Higher LOC means higher costs in maintenance + extension.
manuel aldana
A: 

Not always true. While it is usually preferable to have a low LOC, it doesn't mean the code is any less complex. In fact, its usually more-so. Code thats been optimized to get the minimal number of cycles can be completely unreadable, even by the person who wrote it a week later.

As an example from a recent project, imagine setting individual color values (RGBa) from a PNG file. You can do this a bunch of ways, the most compact being just 1 line using bitshifts. This is a lot less readable and maintainable then another approach, such as using bitfields, which would take a structure definition and many more lines.

It also depends on the tool doing the LOC calculations. Does it consider lines with just a single symbol on them as code (Ex: { and } in C-style languages)? That definitely doesn't make it more complex, but does make it more readable.

Just my two cents.

TkTech
i get your point. that is why i said not to quantify the metric. i am just arguing, when you have an existing product. the more code you will produce on this product the more complex it will be to adapt in future.
manuel aldana
A: 

I'm thinking it could be used to reward the team when the LOC decreases (assuming they are still producing valuable software and readable code...).

Martin Wickman

related questions