LabPHEW!!!
When you go to a restaurant and the rest-rooms are unhygienic it is fair to assume that the food will be rubbish. The same intuition can be applied to software designs. This feeling that something is wrong or going wrong is a code smell and it's grown up sibling is an anti-pattern.
An AntiPattern is a literary form that describes a commonly occurring solution to a problem that generates decidedly negative consequences. The AntiPattern may be the result of a manager or developer not knowing any better, not having sufficient knowledge or experience in solving a particular type of problem, or having applied a perfectly good pattern in the wrong context. http://sourcemaking.com/antipatterns
http://ackandnak.com/comics/your-code-smells.html
Some work has been done on this by the OOP community and the thing that chimed with me is that I have been called into rescue projects and these are large programs, superficially architected using known techniques and yet they are design failures.
With LabVIEW we have an advantage because of it's graphical nature, so a simple test of a design is can you read the block diagram and understand the functionality of the source-code. If not something smells!
I apply some very simple rules when reviewing code, the simplest of which is Make the block diagram understandable!
This example is used as an example as why LabVIEW is a bad language, I find this annoying as it is a poorly designed small application. I would suggest examples like this could be found in any language. The more interesting question is why is it bad?
One technique used when estimating a software designs complexity is called Function Point Analysis and it essentially involves identifying functional decisions and adding them up, each function point can then be described as a lump of work. The code above doesn't have many function points but is almost entirely unreadable.
Training and certification has improved the situation greatly and we are not called in to rectify bad code as often as we were used to, instead the increasing power of LabVIEW has led to more complex code.
With regards bad vs complex I would suggest that complex is worse for the following reasons....
Bad code will usually become unwieldy before it becomes unusable, so if you are fixing bad code it is usually a smaller functioning item.
Complex code is usually on larger systems (and therefore I would suggest more important to a business) and will therefore have a larger weight of expectation about it.
This I think makes a large project more likely to fail and the impact of that failure much more painful.
The link below gives the best measurement of your code when being reviewed http://www.osnews.com/story/19266/WTFs_m
Writing code … is not an exercise in manliness— Mark Hahn
Code Smell #1: Can an experienced LabVIEW programmer understand the block diagram? If not, something is up....
In future blogs I'll be looking at complexity in greater depth. A final pithy quote and that'll do for me!
"The majority of the cost of software is incurred after the software has been first deployed. Thinking about my experience of modifying code, I see that I spend much more time reading the existing code than I do writing new code. If I want to make my code cheap, therefore I should make it easy to read.” – Implementation Patterns by Kent Beck