views:

339

answers:

8

Like the subject suggests, what are some creative ways to curb laziness in co-workers? By laziness I'm talking about things like using variable names like "inttheemplrcd" instead of "intEmployerCode" or not keeping their projects synced with SVN, not just people who use the last of the sugar in the coffee room and don't refill the jar.

So far the two most effective things I've done both involve the core library my company uses. Since most of our programs are in VB.net the lack of case sensitivity is abused a lot. I've got certain features of the library using Reflection to access data in the client apps, which has a negligible performance hit and introduces case sensitivity in a lot places where it is used. In instances where we have an agreed standard which is compromised by blatant laziness I take it a step further, like the DatabaseController class which will blatantly reject any DataTable passed to it which isn't named dtSomething (ie- must begin with dt and third letter must be capitalised). It's frustrating to have to resort to things like this but it has also gradually helped drill more attention to detail into their heads.

Another is adding some code to the library's initialisation function to display a big and potentially embarrassing (only if seen by a client) message advising that the program is running in debug mode. We have had many instances where projects are sent to clients built in debug mode which has a lot of implications for us (especially with regard to error recovery) and doing that has made sure they always build to release before distributing.

Any other creative (ie- not StyleCop etc) approaches like this?

+8  A: 

Have regular code reviews and they will be shamed by the public humiliation (ok, maybe not humiliation). Keep in mind most programmers are not particularly enthusiastic, it's just a job and they want to get home to the kids.

Craig
When the worst offender owns the company, I don't think that will help :)
FerretallicA
@FerretallicA: Then your screwed. Change like the one you are talking about can only come about when it's mandated and enforced from the top. Otherwise you just create tension between management and yourself.. Guess who will win that one?
Chris Lively
+5  A: 

Hi

You tell us that your coworkers don't adhere to an agreed standard out of blatant laziness.

What do they say ? Do they say that the standard is a pile of poo ? That they get nothing out of adhering to the standard ? That they are working 12 hour days 6 days a week to ship working code and that the editor you've provided them with doesn't offer auto-complete to help them make sure that source files adhere to the standard ?

Is any of your co-workers posting on SO asking 'How do I get rid of an interfering co-worker who walks round with a copy of a 10 year old coding standard to beat me over the head with ?'

Please don't be offended, but do think this through. What is their view of the situation ? And is it your job to police their activities ? Why isn't the project manager doing it ?

Regards

Mark

High Performance Mark
This is what frustrates me most - the worst offender is the company 'boss', who is frequently saying things like "We need to make this the rule", "Yep that has to be the standard" etc. Just before Christmas I made an issue of commenting things which aren't immediately obvious even if you think you're the only person who'll ever have to work on it. The result?...
FerretallicA
Dim blrcptpaid As Boolean 'is the receipt paid
FerretallicA
You raised another point - auto-complete. As difficult as the SHIFT key may seem at times, you really only need to type it properly once!
FerretallicA
+1  A: 

You might want to look into hungarian notation, how it was abused (your example is perfect) and exactly why it's been eschewed for more clear conventions.

Otherwise someone might think you're lazy for not keeping up to date with best practices....

A quick review of the wikipedia article on it, or more to the point Microsoft's guidance on General Naming Conventions might help. Item #4 is "Do not use Hungarian notation"...

Chris Lively
We use a balance. Hungarian notation is generally used for things which are very common (eg DataTables are always dtName) and form controls (eg txtName for textboxes), but not for things like class properties, local variables. I don't think Hungarian notation is completely evil. It has its place at times. Either way, the issue isn't about keeping up with the Jones' of best practices so much as conventions, standards and best practices that we agree on in-house. Hungarian notation vs not is more of an ideological argument. MarkupPercent vs markuppercent (or decMarkupPercent) is just lazy :)
FerretallicA
I would disagree with the statement "It has its place at times". Consider a textbox for a start date. You might call it txtStartDate. Later you decide to use a .net date control.. Do you refactor? What if you decide later to rip out the regular .net controls and use ones from another vendor? Are they renamed again? This is why we don't use "Systems Hungarian". Because the underlying data type has a tendency to change over time. If you were using "Apps Hungarian" then it might be okay.
Chris Lively
Further I would say this isn't an ideological argument. It's about maintenance and readability. This is why MS says don't do that.
Chris Lively
I find, regardless of situations like a date box preceded by "txt", simply having something there to immediately recognise that a variable refers to a control on a form vs a standard variable is worth the minimal trade-off.
FerretallicA
Then I would say use a convention like "inputName" or "formName" or something that describes the data, where it came from and/or it's purpose. This way you can actually determine what it is you are dealing with. The convention of "txt<Control>" only says that at some point this was a control on the form. Possibly an asp textbox, but maybe something else entirely.
Chris Lively
The point of my answer is simply that you might want to seriously evaluate your own stance on parameter names because, quite frankly, the method you have picked is widely recognized as causing more harm than good. Therefore someone else looking at your code would probably wonder about the quality of the programmer that wrote it. Which leads us to the idea of Glass Houses.
Chris Lively
I think the idea here is more one of flogging a dead horse.
FerretallicA
+2  A: 

Start a contest. Whoever finds and fixes most of this kind of issues during the week gets a free beer or something.

Or push it even further: specify issues which you want to fight with. Every time someone finds one they get a point and code author loses the point (and have to fix it). It means if you find it in own code it's neutral for you but if someone else does it you lose the point.

Then get whiteboard and update stats every day or so. Think about StackOverflow-like achievement system (First crappy variable name found; case sensitivity policeman etc). Make it a game. People will have fun at the same time when they will be fixing code.

pawelbrodzinski
+1  A: 

I like the idea of counting mistakes and laziness examples. Whoever has the most at the end of each week gets itching powder all over their mouse and keyboard.

+2  A: 

Create a subversion hook that runs a lint program on the code as it is checked in. Store this number and if the lint score decreases email the team the revision that caused the regression and the user that caused the regression.

The beauty is this will be automated so you don't seem like the jerk for calling people on BS coding practices. We have much the same issues here.

MattK
Way out of my know-how :P Besides which... isn't lint only for C?
FerretallicA
This is selected as the 'answer' as it's the only one submitted which shows any real degree of creativeness. Even if I can't put it into practice myself, it still sounds pretty neat.
FerretallicA
There is lint for many other languages than C. We use pylint on a daily basis. Not sure about VB.net, but wouldn't be surprised if there was something like this.
MattK
+1  A: 

Have a shirt that says "I broke the build" ... Anyone who does that wears it.

Ankur Gupta
Perhaps not a shirt but definitely a comically oversized hat or headpiece of some description :)
FerretallicA