 |
Code rage
Posted by jimothy on November 25, 2003 at 12:36 PM | Comments (18)
Most people believe they are a better driver than the rest of the motorists on the road. Of course, that can't possibly true; there has to be at least a handful of below average drivers. And you know who they are. The jerks to your left, right, front, and rear on the highway.
Do we as developers feel the same way, that we are a better programmer than the average Joe in our profession?
I'll admit I've experienced code rage on more than one occassion. My blood pressure raises when I come across silly mistakes which seem to demonstrate a lack of understanding of basic programming or Java language concepts. Every time I see something like new Integer(0).parseInt(aString) or the equally asinine new String("a string"), I feel as if I've just been cut off with no turn signal. "Hey, buddy, keep your eyes on the code! Ever heard of a static method?!?"
Is it just me? Am I the only one who is bothered by things like this, swearing that I myself am a better programmer who would never make such a mistake? Or do some coders simply need to pull of the left lane?
Bookmark blog post: del.icio.us Digg DZone Furl Reddit
Comments
Comments are listed in date ascending order (oldest first) | Post Comment
-
Not alone
You're not the only one :-) Those sorts of things drive me nuts too.
I think this fundamentally reduces to the fact that most programmers don't read code -- they just write it. If we had more situations where experienced programmers would read and gently correct the junior level guys, we'd have less of this sort of thing. But as is, these bad practices we all start out with don't get corrected in many instances.
Posted by: gvaughn on November 25, 2003 at 02:06 PM
-
If it were just you...
...tools such as checkstyle and pmd wouldn't exist!
Posted by: haruki_zaemon on November 25, 2003 at 03:15 PM
-
senior programmers responsibility
I don't have an issue with programming problems, just the lack of process to help monitor and correct the problems. Senior programmers are only senior, if they work with junior programmers to correct mistakes.
Are programming standards setup within the company?
Does a software inspections process exist?
Are automated software inspection tools being used?
If you answered ‘no’ to any of these, it doesn’t sound like the senior programmers are doing their job. :-(
Posted by: malcolmdavis on November 25, 2003 at 03:17 PM
-
senior programmers responsibility
Excellent points. Do other senior developers feel they get the support from management to implement the processes that Malcolm suggests? If we don't do them anyway (management be damned!), are we again failing in our job as senior programmers?
The next question is, how best to gently inform the junior developers of their mistakes? In the beginning, it's easy to just point them out and suggest an alternative, but after they've been informed and still make the same mistakes, it becomes hard to avoid the impression of nagging.
I suppose it just goes to show that being "senior" requires much more than merely x years of experience. Interpersonal skills and diplomacy are at least as important.
Posted by: jimothy on November 25, 2003 at 03:30 PM
-
Pure object-oriented languages
Your example new String("XXX") as an illustration of imature code could arguably be seen as an illustration of a pure object-oriented construct. One of the difficulties of Java for learners who have previously worked with pure object-oriented languages such as Smalltalk or Eiffel is that Java inherits some syntax from C. However, the main area of Java is OO programming. Nowadays it is hailed as the OO language of choice in the education of CS graduates. From pure OO perspective, s = new String("XXX") is correct and s = "XXX" is not correct. Sure, it is correct from the point of view of compiler optimization, but that is not the point of my remark. Obscurity of the trade should not be seen as equivalent to seniority and wisdom.
Posted by: sngraca on November 26, 2003 at 12:00 AM
-
Pure object-oriented languages
No, the intention new X() is always to create a new object, that's not the case with s="XXX". The "unoptimized" language equivalent is actually 'new String("XXX").intern()', or, avoiding "XXX" entirely, 'String.copyValueOf(new char['X', 'X', 'X']).intern()'.
From a pure OO perspective, "XXX" is more akin to the use of a factory method than a constructor. For any other class, you wouldn't call the use of a constructor when a factory method should have been used anything else but a programming error, despite the unusual syntax.
Learning shorthand syntax and semantics isn't just an "obscurity of the trade", its a fundamental tradeoff we've made to use languages with useful shorthand notations, and deliberate restrictions on unsafe practices, instead of using, say, scheme.
Its not so much that knowledge of syntax is equivalent to seniority, its that not knowing the basic syntax of your language of choice is a sign of laziness.
Posted by: ba22a on November 26, 2003 at 03:02 AM
-
Programming by Coincidence
You do know how the code got that way, don't you?
It started out as clean code, but it didn't work. So the programmer tried one thing, then another, then another, ... until it worked the way he wanted.
By that time, he's made too many changes to know which one fixed the problem. And he don't have time to clean the code up. So it all goes into source control.
I heard a Dave Thomas talk in which he describes this as Programming by Coincidence.
Posted by: weiqigao on November 26, 2003 at 04:45 AM
-
Pure object-oriented languages
I was referring to object instatiation of objects that are of primitive type. It seems however that taking on the new String("XXX") example created confusion in interpreting my observation. Consider
String s = new String("XXX");
It is a pure OO construct whereas
String s = "XXX";
is not. They are equivalent, but the syntax variation is just noise as far as OO is concerned. Granted, this distinction on String is pedantic, but it is a real issue with the primitive types. For instance,
Integer i = new Integer(1);
is an explicit object construction from class Integer whereas
int i = 1;
is introducing a non-OO entity to the language. Primitive types have been introduced for optimization purposes. Ever wondered why you need to specify the size of an array?
char[] ca = new char[10];
The size declaration allows the compiler to allocate exact machine memory for this data structure. Allowing it to change size would imply slower execution and more memory allocation. Yes, there are several collection classes for this purpose, but then, why not JUST have collection classes and make them so efficient as to render primitive types redundant? I guess C programmers would think nothing of it, but for someone with a background in symbolic computing, this is just so... primitive. I diverge. My point was that if the language designers had omitted primitive types the language would be more consistent and with less syntactic deviations such as those that Jim Cushing used as examples. James Gosling in an interview at java.net did acknowledge the contradiction and that the decision to use primitive types was an engineering trade-off.
Posted by: sngraca on November 26, 2003 at 10:19 AM
-
senior programmers responsibility
I think that "senior vs. junior" is the wrong way to look at the problem. I think a better approch is: "does the developer look critically at their own work?"
I find that programmers who have a few years under their belt often fall prey to the belief that they know everything there is to know. The really good programmers stay a little bit dissatisfied with their work, and always strive to improve.
Posted by: jt2190 on November 26, 2003 at 11:33 AM
-
Programming by Coincidence
Dave Thomas, along with Andrew Hunt, also talk about Programming by Coincidence in their excellent book, The Pragmatic Programmer, which should be required reading for all developers (and their managers). A good dose of pragmatism could prevent many of the coding mishaps, as well as a case or two of code rage.
Posted by: jimothy on November 26, 2003 at 01:06 PM
-
Not alone
I've had cvs commit messages being forwarded to me that called me a sleepy-drunk because of a silly mistake :)
I churn out many many many lines of code; there are bound to be (silly) mistakes in there.
Here is a good example:
http://cvs.sourceforge.net/viewcvs.py/uic/uicompiler/uic/widgets/UICWhatsThis.java?r1=1.3&r2=1.4
In the end; we remember that one silly mistake in 100 lines of quite good code. Thats just how humans are wired.
Posted by: zander on November 26, 2003 at 02:37 PM
-
Not me
I do the best I can and I learn from those that are better than I. I can do no more.
Posted by: robertx on November 27, 2003 at 10:41 AM
-
I know the feeling...
The one that really gets to me is when people write:
if (foo == bar) {
return true;
} else {
return false;
}
What's wrong with:
return foo == bar;
Silly thing to be annoyed about; I guess I'm just fussy.
Posted by: paulmitchell on November 28, 2003 at 01:29 AM
-
We are not better than the average developer...
The average developer is worse than we are. At least thats what I think when I see code like this:
class SomeCellRenderer extends DefaultTreeCellRenderer {
private SomeTreeModel model,
public void setTreeModel(TreeModel model) {
this.model = (SomeTreeModel)model; // OMG!
}
public Component getTreeCellRendererComponent(JTree tree, Object value, boolean selected, boolean expanded, boolean leaf, int row, boolean hasFocus) {
if(model.isLeaf(value)) { //OMG!
setIcon(foo);
}
}
}
Posted by: pyramide on November 29, 2003 at 10:00 AM
-
I know the feeling...
yeah but what if the person coding stuff like...
if(a==b)
return true;
else
return false;
... is your supervisor? I can't tell them their code sucks.
Posted by: psummers8 on December 08, 2003 at 12:59 PM
-
I know the feeling...
The tone of my blog aside, neither peer nor supervisor wants to be told their work "sucks," so we need to practice patience and diplomacy.
When you find yourself in a fit of code rage, take a little break before you discuss the faux pas with the offender (writing a blog is one good way to cool off for me!). Then, say something like, "Did you know you can get the same effect much more elegantly, like this...?" Or, for a supervisor, maybe something like, "Hey, look how much time we could save if we wrote it like this..." Yeah, I know it's not THAT much time, but hey, managers eat this stuff up! ;-)
Posted by: jimothy on December 09, 2003 at 06:19 AM
-
wow power leveling
wow powerleveling
wow power leveling
wow gold
wow items
feelingame.com
wow tips
Most Valuable WOW Power Leveling Service
wow power leveling faq
cheap wow power leveling
wow power leveling
wow powerleveling
wow power lvl
Posted by: wowleveling3 on December 13, 2007 at 06:31 PM
-
网络è¥é”€è½¯ä»¶
网络è¥é”€è½¯ä»¶
网络è¥é”€è½¯ä»¶
群å‘软件
群å‘软件
---
群å‘软件
网络è¥é”€è½¯ä»¶
论å›ç¾¤å‘软件
网站排å软件
群å‘软件
推广å°åŠ©æ‰‹ç ´è§£ç‰ˆ
论å›ç¾¤å‘软件
网站排å软件
群å‘软件
推èç»™ä½ å¾ˆå¥½çš„ç¾¤å‘软件和信æ¯ç¾¤å‘软件和供求群å‘软件
推èç»™ä½ å¾ˆå¥½çš„ç¾¤å‘软件和信æ¯ç¾¤å‘软件和供求群å‘软件åšå®¢ç¾¤å‘软件网络è¥é”€è½¯ä»¶ç½‘络è¥é”€è½¯ä»¶
网站排å软件网站排å软件网站优化软件信æ¯ç¾¤å‘软件信æ¯ç¾¤å‘软件信æ¯ç¾¤å‘软件论å›ç¾¤å‘软件网站推广软件网站推广软件åšå®¢ç¾¤å‘软件åšå®¢ç¾¤å‘软件
群å‘软件群å‘软件åšå®¢ç¾¤å‘软件论å›ç¾¤å‘软件网络è¥é”€è½¯ä»¶è®ºå›ç¾¤å‘软件
ä¿¡æ¯ç¾¤å‘软件推广软件网站推广软件网络è¥é”€è½¯ä»¶ç½‘站推广软件群å‘软件网站排å软件网站推广软件åšå®¢ç¾¤å‘软件论å›ç¾¤å‘软件群å‘软件网站排å软件网站推广软件åšå®¢ç¾¤å‘软件论å›ç¾¤å‘软件
网站排å软件
åšå®¢ç¾¤å‘软件
网站排å软件
网站推广软件
群å‘软件信æ¯ç¾¤å‘软件
å…费论å›ç¾¤å‘软件
论å›ç¾¤å‘软件
网站排å软件
å…è´¹åšå®¢ç¾¤å‘软件
网站推广软件
群å‘软件
åšå®¢ç¾¤å‘软件
网站排å软件
网站推广软件
群å‘软件信æ¯ç¾¤å‘软件
å…费论å›ç¾¤å‘软件
论å›ç¾¤å‘软件
网站排å软件
å…è´¹åšå®¢ç¾¤å‘软件
åšå®¢ç¾¤å‘软件
ä¿¡æ¯ç¾¤å‘软件
论å›ç¾¤å‘软件
ä¿¡æ¯ç¾¤å‘软件
åšå®¢ç¾¤å‘软件
qq群å‘软件
邮件群å‘软件
åšå®¢ç¾¤å»ºè½¯ä»¶
ä¼ä¸šå录æœç´¢è½¯ä»¶
ä¿¡æ¯ç¾¤å‘软件
邮件群å‘软件
论å›ç¾¤å‘软件
åšå®¢ç¾¤å‘软件
网站推广软件
网络è¥é”€è½¯ä»¶
全能è¥é”€ç ´è§£ç‰ˆ
网络è¥é”€è½¯ä»¶
论å›ç¾¤å‘软件
论å›ç¾¤å‘软件
论å›ç¾¤å‘软件
网络è¥é”€è½¯ä»¶
ä¿¡æ¯ç¾¤å‘软件
ä¿¡æ¯ç¾¤å‘软件
ä¿¡æ¯ç¾¤å‘软件
群å‘软件
论å›ç¾¤å‘软件
网络è¥é”€è½¯ä»¶
网络è¥é”€è½¯ä»¶
网络è¥é”€è½¯ä»¶
群å‘软件
群å‘软件
---网络è¥é”€è½¯ä»¶
网站推广软件
群å‘软件
Posted by: info0089099 on December 25, 2007 at 05:01 PM
|