Replacing Humans with Software Inspectors
An anonymous reader writes "What if you were able to perform a portion of your code reviews automatically? In this first article of the new series 'Automation for the People', development automation expert Paul Duvall begins with a look at automated inspectors like CheckStyle, JavaNCSS, and CPD. The piece examines how these tools enhance the development process and when you should use them." From the article: "Every time a team member commits modifications to a version control repository, the code has changed. But how did it change? Was the modified code the victim of a copy-and-paste job? Did the complexity increase? The only way to know is to run a software inspector at every check-in. Moreover, receiving feedback on each of the risks discussed thus far on a continuous basis is one sure-fire way to keep a code base's health in check automatically!"
If you've got a reasonably recent JVM installed you can run CPD via Java Web Start here.
There are some examples of CPD output there too - like the duplicate code chunks that it found in the JDK source code and in the Apache httpd source code.
For much more on CPD, see chapter 5!
The Army reading list
from the article:
...way to keep a code base's health in check...
Uhhhh, maybe you should try an english language cliche parser instead?
I would say that, like any other code generator, wizard, druid, whatever you want to call it, this has a great potential to help with programming. As long as developers using it don't get lazy about checking their own code.
As a tool to point out obvious code flaws, catch conflicting code in large projects, etc. this is great. But I've found over the years that if you don't understand how to do something manually and aren't able to second guess a tool when it makes a mistake then these types of things can end up being more trouble then they're worth.
Just my $.02
Creationist Textbook Stickers Declared Unconstitutional by CowboyNeal
...has done a couple of short podcasts on continuous integration and whatnot too.
The Army reading list
These tools are very limited in their scope - FindBugs is a very useful and powerful tool for locating bugs or potential bugs in Java code, and I've used it to find some potentially serious bugs in large, relatively mature pieces of code before now. Using it to help find potential failures in newly modified pieces of code seems like a good idea.
++ Say to Elrond "Hello.".
Elrond says "No.". Elrond gives you some lunch.
The only way to know is to run a software inspector at every check-in.
Or you can hire people who are good and who you trust. A real human will do a better job of 'code reviewing' every time, and if you hire good people, then you don't need to worry about what they commit. An occasional check should be enough to make sure you haven't accidentally hired a loser. (Also human code reviews, if done correctly, are great because they help everyone become better programmers).
This is easy to do in small companies, but somewhat harder in big companies. Still, if I were CEO, and my managers started using this tool, I would get worried and start thinking seriously about how to change the company culture. You don't want your company to become like Qualcomm, or Novell, where bureaucracy rules the day.
Qxe4
Every developer (or, worse, team lead) thinks they are teh sh1t and no coding style or standards set by anybody else should apply to them so they stop running automated inspectors unless its hand-tweaked for their own personal coding style (incidentally thus defeating 95% of the benefit of a coding style automated inspector).
If people would put aside their belief that their coding style is best and accept that when being paid to work on a big project you should behave according to the overall consensus, then these offer huge benefits in increased productivity during manual inspections; most of the time human hubris renders them a wasted effort
...welcome my new automated, software-inspecting overlords.
playmoney.me - The free alternative to paper board game play money
"Go away or I will replace you with a very small shell script."
"What if you were able to perform a portion of your code reviews automatically?"
:).
You mean like "gcc project.c"? Without that, I'd have to be in marketing
--
make install -not war
In Soviet Russia, something inspects something, and it's really funny!
stuff |
If only we could run CPD (copy/paste detector) on /.
I bet the numbers would be off the charts!
"Was the modified code the victim of a copy-and-paste job?"
I want the code to be copy/paste every time, if it works and is maintainable, rather than sparkling new code. Why would I want some robot enforcing some need to reinvent the wheel every time I need to roll?
If this thing is going to be smart, it would look at code to replace with code elsewhere in the repository. I'm tired of doing that myself, and not copy/pasting enough. By which I mean factoring common code into its own scope, then pasting a reference to it.
--
make install -not war
Though it is Java based, they left out quite a bit.
Instead of depending on style checkers for formatting, just get a good programming editor
and configure it for the style. This may not take care of all of it, but it can help.
I'm a big believer in lint and PCLint , which also can be used for style checking. I don't know how good JLint.
The piece skipped out on automated testing -- ie. Purify.
They missed BoundsChecker.
Fight Spammers!
We've experienced those brief and tempestuous infatuations with flowcharts, Warnier-Ott diagrams, top-down programming, structured programming, Jackson structured programming, source code control, the waterfall model, Royce's Final Model, the spiral model, the sashimi model, object-oriented programming, CASE tools, Rational Unified Process, SEI's Capability Maturity Model for Software, SEI's CMMI, feature points, function points, agile methodologies, and Extreme Programming, and... well... they were just trips to the moon on gossamer wings.
But this. This is different. Totally different. It's the real thing this time.
"How to Do Nothing," kids activities, back in print!
The thing to remember about automated code inspectors is: be smart about it.
// Iterate over all files /* nothing to do here */) // Get the next file // If the file has a modification date later than now // Throw an exception stating that the file is modified in the future
Don't trust the code inspector to enforce a policy (except maybe coding style).
There's a lot of boilerplate code that goes into a program, and a code duplication monitor will cause all sorts of headaches in this area.
The same problem exists with comment checkers. If code is written properly, there is usually very little need to comment inside most methods. The name and javadoc will give more than enough description of what the method will do (you DO use javadoc, don't you?)
It's only as the method's complexity increases to a point where it's not blatantly obvious what's going on inside that you need comments at that level.
I've had too many managers force me to comment like this:
for(Iterator iter = files.iterator(); iter.hasNext();
{
File file = (File)iter.next();
if(file.lastModified() > new Date().getTime())
{
throw new ModifiedInFutureException(file.toString() " + has a modification date in the future");
}
}
Ok it looks much uglier after running through Slashdot's dumb filter, but you get the idea.
The above code in reality needs no comments whatsoever, except perhaps a single line at the top saying "Disallow modification dates in the future", but a bad policy caused ALL code checked in to comply with silly regulations, resulting in countless hours lost.
In truth, the date check code itself should have been implemented as a policy class to be added to the verify method, but I digress.
Who inspects the inspector?
The mods have no sense of humour! This is funny!
I haven't read the article true /. stylee, but I'm going to go ahead and assume it's about using code checkers to check code is valid. I use W3's markup and css validation services for this purpose. If I get a problem (or even if I don't), as a first step, I run the code through their validation services.
Comment removed based on user account deletion
I've heard that automation is highly prevalent in the IT industry and that it's taking even more jobs than offshoring. I kinda laughed out loud at the idea that it's taking a lot of coder jobs, but now I see this foolish trend actually exists.
Automation can only go so far. This is a rubber band phenomenom that will snap back into proper size when automation turns out to fail.
Failure is a guaranteed and major part of any effort to convert analog to digital. Programming is highly analog, believe it or not - it involves a lot of "analog" creativity, even in the optimization process. This is why pure machine language code will always be faster - even if more horribly difficult - than any high level code. Having a machine - programmed by fallible humans - checking fallible code - is just another path for potential failure.
It also has another nastier effect - programmers will get lazier and expect the machine to check their code. If the machine misses something, what experience do they have to catch it?
Inevitably these errors pile up and it'll come down to a human - or team of humans - to dig into the guts of the code and find out what's really wrong. If all this automation actually happens, who will get the job experience to fix all the bugs that got by the automated software checkers?
--- Grow a pair, liberals... stop letting the Republicans bully you!
The point of having code review is to help mentor others who have either less experience or other core competencies outside of the project at-hand.
QA may be a nifty side-effect but if you have a QA team, then code review is hands-down a mentoring process.
"I have an odd craving to whisper about those few frightful hours in that ill-rumored and evilly shadowed seaport of dea
Slashdot's title of 'replacing humans' aside, this article is right on. We do peer reviews of our code, but before we do, we make sure it meets our checkstyle conventions, and fix at least some of the egregious things that PMD, Findbugs, and a couple of the other reports we can get out of our Maven build system without any real effort.
This makes our reviews more productive, because people don't get caught up in discussions over curly brances, finding copied code, issues with contructor and exception idioms, etc.
The slashdot crowd is going to envison pointy-haired bosses basing performance reviews on this kind of stuff, which is a legitimae fear and shouldn't happen. Used in the hands of real software engineers though, this is similar in spirit to the woodworker's adage "measure twice, cut once". Loosely applied, "You know what you are doing, but be your own safety net".
-db
The trouble with most of these tools is that they're aimed at local coding style issues, not global problems.
Typical global problems that are potentially machine-checkable before execution are:
Those are the kinds of things you need tools for. What we're seeing are tools that check for the easy-to-check but less important stuff.
Quibbling over formatting is silly. White space formatting doesn't affect functionality of the code at all. (Unless you're using python and that's a whole different discussion) What should really happen is my editor should display the source the way I'm used to seeing it. I should be able to configure the view style and the actual in-file formatting remains unchanged. My cube mate across the way see's the source in HIS style. He's happy. I'm happy. This doesn't seem hard to me.
-=Robo=-
There was a time when movies had plots. So you knew who's ass it was, and why it was farting.
-Not Sure
http://packages.debian.org/stable/admin/vrms
Virtual Richard M. Stallman
The vrms program will analyze the set of currently-installed packages on a Debian GNU/Linux system, and report all of the packages from the non-free tree which are currently installed.
Future versions of vrms will include an option to also display text from the public writings of RMS and others that explain why use of each of the installed non-free packages might cause moral issues for some in the Free Software community. This functionality is not yet included.
Means you hired people who dont have a clue.
You arent using basic conventions effectively and you *may* not have an architectural pattern which facilitates newbies and experienced alike in coding consistently...
Just because thats the nice thing to do in a well understood architectural context.
Of course these tools help overall but micro-management of the end result instead of using (more or less obvious) conventional approaches in combination with a solid architecture is not so smart. Your 25 pages are easily and probably best ignored.
A tool will let you enforce wierdness but if your shop wholesale is ignoring your coding standards then you either have really bad people or you have really bad coding standards.
That stuff at the top of your ass crack is not lint. It is shit covered toilet paper.
Quibbling over formatting is silly. White space formatting doesn't affect functionality of the code at all.
fyi, FindBugs doesn't look at the source code at all, only at the compiled bytecode.
You write your nine symphonies, then you die.
and if you hire good people, then you don't need to worry about what they commit. An occasional check should be enough to make sure you haven't accidentally hired a loser.
This is still a commonly held belief, but it's just not true.
Allow me to quote from a 2004 OOPSLA paper: "we have found that even well tested code written by experts contains a surprising number of obvious bugs." (Link to entire paper is here.)
Even very good programmers make mistakes sometimes, and some of them are simple enough to be found by tools like FindBugs. Some of these have managed to slip through multiple human code reviews.
[Disclaimer: I work for the Findbugs Project.]
You write your nine symphonies, then you die.
Actually, you've got everything backwards. You're the one putting OOP on a pedestal. You're the one saying that it's not possible to write good programs that aren't OOP. You're the one saying that the OOP technique I mentioned, references to common code objects, defines OOP with one good idea.
I just posted about how copy/paste isn't always bad. I mentioned an OOP reason why, which is also just a good programming reason. You then went nuts.
Maybe if you start having these debates with yourself out loud, or with your shrink, you won't have to have them with me.
--
make install -not war