What was the strangest coding standard rule that you were forced to follow?
71–80 of 83 posts
Re: What was the strangest coding standard rule that you were forced to follow?
#72Earlier quoted context omitted.
Yeah, you'd likely need some other way to refer so a position in the code than the line number. Maybe an anchor (like html) or a path in the syntax tree.
These tools already exist: JavaScript tools like minfiers or CoffeeScript can generate source maps which map code lines from one format to code lines in another format. http://www.html5rocks.com/en/tutorials/developertools/source...
Re: What was the strangest coding standard rule that you were forced to follow?
#73Maybe someone knows of a solution but it would be great if SVN/version control was able to store a standard formatted version of source code and then depending on client/user preferences could reformat the file accordingly on checkout and then also be able to factor in / unformat when doing diffs/checkins. I feel like if it could work like this it would mitigate a lot the inevitable battles that take place over small…
This won't work, except for trivial codebases, I guess. Dean Whelton argued a similar thing once [1]. There are always things that resist automated formatting or that are downright destroyed when using it. I use Ctrl+Shift+F or Ctrl+E,D sparingly for that reason. Eclipse has a tendency to mangle Javadoc comments sometimes. Sometimes you're breaking a long method invocation or formula over multiple lines for readabili…
In Python you can get the whole return statement. Especially when adding a similar type of method, e.g.: Django view functions. Makes
git add -p
more fun.Re: What was the strangest coding standard rule that you were forced to follow?
#74[1] http://msdn.microsoft.com/en-us/library/aa260976%28v=vs.60%2...
Re: What was the strangest coding standard rule that you were forced to follow?
#75> To NEVER remove any code when making changes. We were told > to comment all changes. I'm afraid given this rule, I would abuse it horribly. My backspace key would no longer function and every typo I make would introduce a new set of /* */ comments. Every refactoring would have the old type, variable, line, function, or entire class commented out with the fixed code alongside it. Bonus points for interleaving the ol…
I understand the rule, we have this rule in place with a caveat. The rule protects us from a few common events, first being that where some developers just love to tinker with code outside the scope of their project. The second is simply a bad design where the results affected other code in unexpected ways. There have been a few times were code was reverted and having the code merely commented out saved time, time sp…
Re: What was the strangest coding standard rule that you were forced to follow?
#76Earlier quoted context omitted.
Joel Spolsky wrote a good summary about the Hungarian notation, and how it got corrupted within Microsoft: http://www.joelonsoftware.com/articles/Wrong.html
Thanks for the explanation. The original idea was pretty good. But I've only, ever, seen the corrupted variant in the wild. And coding standards that enforce it. Hence my annoyance.
Re: What was the strangest coding standard rule that you were forced to follow?
#77The strangest coding standards were imposed when I was working at an AS/400 shop a dozen years ago. No indentation allowed. Even though the modern compilers supported it, it looked ugly to veterans who had worked with fixed-format compilers for 30 years. No comments in the code allowed. The function had to be entirely clear by looking at the code. Any code that needed comments for clarification was considered too 'cl…
> No comments in the code allowed. That's not necessarily bad advice - at least as a starting point. If you use descriptive variable/function names, then a huge amount of your commenting usually needs go away. The big advantage is that people are rarely very good at updating comments - at which point they become at best useless and often downright misleading, Whereas most coders will hopefully at least consider renam…
Now, let's play a game. :) I'm going to Gist the example RPG program from Wikipedia, but with all the comments stripped out. Take a guess as to what it does:
https://gist.github.com/4204324
(Note that the spacing shown here is absolutely essential. Keep this in mind if you ever feel like complaining about whitespace in Python.)
Answer:
http://en.wikipedia.org/wiki/IBM_RPG#Example_code
My company's entire internal business infrastructure is written in, perhaps, millions of lines of this (commented, thankfully).
"Right," you may say, "but this is surely easy enough to read for someone who's used RPG for a while." Now consider that (afaik) RPG hasn't been taught in schools since the 70s, and that this entire format is alien to folks reared on Java. Even a poor comment in this environment is like suddenly stumbling across a line of semi-cogent English scribbled in the margins of the Necronomicon. Which is to say, it might just hold the insanity at bay for a while longer. :)
Footnote: the Wikipedia article mentions a "FREE" mode that makes writing RPG much more similar to modern languages (what an old hand here might call "freeform" languages, a.k.a. languages that aren't column-based). But I get the feeling that the gp's company would regard such notions as heresy.
Re: What was the strangest coding standard rule that you were forced to follow?
#78The worst thing I've ever seen: http://blog.jgc.org/2007/08/why-you-dont-want-to-code-for.ht...
Most amusing I've seen was Java code that was rather over zealous about DRY and no-string-literals in code (i.e. all strings had to be define as constants). This resulted in code like: url = HTTP + COLON + SLASH + SLASH + WWW + DOMAIN_NAME + DOT + COM; based on lots of definitions like: public final static String COLON = ":"; public final static String SLASH = "/"; public final static String DOT = "."; public final s…
Re: What was the strangest coding standard rule that you were forced to follow?
#79Earlier quoted context omitted.
This won't work, except for trivial codebases, I guess. Dean Whelton argued a similar thing once [1]. There are always things that resist automated formatting or that are downright destroyed when using it. I use Ctrl+Shift+F or Ctrl+E,D sparingly for that reason. Eclipse has a tendency to mangle Javadoc comments sometimes. Sometimes you're breaking a long method invocation or formula over multiple lines for readabili…
"It's sometimes astonishing how the pursuit of optimal diffs masks the intent of a change where an added method diff starts with the closing brace of the previous method, for example." In Python you can get the whole return statement. Especially when adding a similar type of method, e.g.: Django view functions. Makes git add -p more fun.
Re: What was the strangest coding standard rule that you were forced to follow?
#80I was talking to someone today, and they commented: "Good programmers eventually learn to misspell words like void or int so that they can name their variable names what they want to name them." I of course told him that this was terrible advice, and would mess with the next person who had to maintain the code because you couldn't tell at a glance if a word was a keyword or a keyword mispelled. I asked him what langu…
klass for a variable of type Class is totally normal in Java.