kul_th_las
Guest
|
 |
«
Posted
2003-12-23 02:52:42 » |
|
One of my favorite links from years ago - and it's still around, and even actively updated. A collection of humorous tips on "How to write unmaintainable code". Try to ignore the excessive use of adverts... http://mindprod.com/unmain.html
|
|
|
|
|
zparticle
|
 |
«
Reply #1 - Posted
2003-12-23 14:24:01 » |
|
I love that site, my favorite part is: Hungarian Notation is the tactical nuclear weapon of source code obfuscation techniques; use it! Due to the sheer volume of source code contaminated by this idiom nothing can kill a maintenance engineer faster than a well planned Hungarian Notation attack.
|
|
|
|
Jeff
|
 |
«
Reply #2 - Posted
2003-12-23 17:28:33 » |
|
A man after my own heart
Who ever thought that trying to turn the human into the type safety mechanism could be a good idea???
|
|
|
|
Games published by our own members! Check 'em out!
|
|
princec
|
 |
«
Reply #3 - Posted
2003-12-23 17:51:26 » |
|
Probably the same bloke who decided that semicolons and curly braces are really great way to block structure a language. Cas 
|
|
|
|
Jeff
|
 |
«
Reply #4 - Posted
2003-12-23 18:22:56 » |
|
ROFLOL point taken.
|
|
|
|
swpalmer
|
 |
«
Reply #5 - Posted
2003-12-23 18:39:58 » |
|
Hey, I like that a lot better than Pascal's BEGIN/END... The whole purpose of parenthesis or curly braces is to group things - they aren't some obscure computer code. I guess the thing about Hungarian Notation is that you can lie with it... but I can't think of a single time I've actually encountered HN that was wrong, and before IDEs got fancy (only recently) it was the easiest way to (almost?) know what type you were dealing with. I DON'T use it in my Java code, but I do still use it for native code, simply because it is the norm on Windows. I'm not sure that the C++ IDEs have caught up to the Java IDEs either. That page is still good for a laugh though 
|
|
|
|
nonnus29
Senior Member   
Giving Java a second chance after ludumdare fiasco
|
 |
«
Reply #6 - Posted
2003-12-23 20:48:07 » |
|
Did someone say code maintenance?
Welcome to my Hell: 31 million lines of cobol and assembler in 17,000 programs with 5,000 data files stored in 35 years worth of formats (flatfiles, vsam, a nonrelational database, and db2).
This app HAS to change every year with tax laws and business requirements. Me == job security.
|
|
|
|
|
Jeff
|
 |
«
Reply #7 - Posted
2003-12-23 21:13:39 » |
|
Hey, I like that a lot better than Pascal's BEGIN/END...
The whole purpose of parenthesis or curly braces is to group things - they aren't some obscure computer code.
I guess the thing about Hungarian Notation is that you can lie with it... but I can't think of a single time I've actually encountered HN that was wrong,
Knowing human nature I'd suspect 2 things: (1) Humans make mistakes  (2) HN probably drifts towards incorrectness as code is maintained and the maintainers don't want to change every reference to a HN name. and before IDEs got fancy (only recently) it was the easiest way to (almost?) know what type you were dealing with.
Easiest way back then IMHO was Turbo Pascal  Seriously though there are at least 2 other problems with HN: (1) It obfuscates the names, making the code not read like english and instead requring a mental translation step. (2) It loads pre-fixes onto C names. Thia is bad because ANSI C says that only the first 8 characters of any literal in C need be significant to the compiler. (if you don't believe me go look it up.) If I take up 3-5 charaters with HN I've just reduced my name space to all combinations of 3 to 5 letters  And yes I HAVE run into a compiler with this limitation in the real world. (The Hitachi SH2 C compiler for the SEGA Saturn, actually.)
|
|
|
|
blahblahblahh
|
 |
«
Reply #8 - Posted
2003-12-24 00:37:23 » |
|
Merely in the interests of balance  ...HN can be worthwhile in limited doses. I don't in any way disagree that mostly it was just a hack to make up for lack of advanced IDE's, but even today there are some aspects of a thing that SHOULD be encoded in a name. E.g. nowadays I couldn't live without prefixing all interfaces with "i" - it makes SUCH a big difference on large projects. You can confidently read code and check with a glance whether it's using the available abstraction (should nearly always be coding to interfaces in big projects), and it makes reading foreign source much easier when you on your first pass you can just look for the i-names and worry about the specific implementations (classes) being used later. But...that only works because changing an interface into a class is almost unheard of in java coding - the fact of being an interface is so much of what it is that putting the i in the name is a safe permanent change. I totally agree that many HN aspects are (as someone previously noted) much more fluid  . OTOH...ARGGHH!: http://support.microsoft.com/default.aspx?scid=http://support.microsoft.com:80/support/kb/articles/Q110/2/64.asp&NoWebContent=1
|
malloc will be first against the wall when the revolution comes...
|
|
|
blahblahblahh
|
 |
«
Reply #9 - Posted
2003-12-24 00:41:18 » |
|
Probably the same bloke who decided that semicolons and curly braces are really great way to block structure a language. Cas  ...and who thought it would "make sense" to put the opening brace at the end of the first line, rather than first on a following new line. What a weirdo [shakes head in wonder]. I mean, it's not as if anyone would ever really BELIEVE it was true, is it? It's just something for bored people to try and justify... 
|
malloc will be first against the wall when the revolution comes...
|
|
|
Games published by our own members! Check 'em out!
|
|
Jeff
|
 |
«
Reply #10 - Posted
2003-12-24 18:08:20 » |
|
...and who thought it would "make sense" to put the opening brace at the end of the first line, rather than first on a following new line. What a weirdo [shakes head in wonder]. I mean, it's not as if anyone would ever really BELIEVE it was true, is it? It's just something for bored people to try and justify...  Are you just saying its a religous discussion? Because the brace can ofcourse go anywhere in C/C++/Java because in all sane modern languages whitespace is not significant. (Note that this is NOT true for XML where <FOO> is a legal tag but < FOO> is not.)
|
|
|
|
swpalmer
|
 |
«
Reply #11 - Posted
2003-12-25 02:09:41 » |
|
Now you're gonna upset the Python folks  ... I haven't used Python but I've heard only positive comments about it, so significant white space can't be all bad. /me pokes stick in the fire...
|
|
|
|
Jeff
|
 |
«
Reply #12 - Posted
2003-12-25 09:13:38 » |
|
OR you only hear positive things about it because the *only* reason to use it is because you happen to personally love it.
**ducks the flying fruit**
|
|
|
|
javapunk
Senior Newbie 
|
 |
«
Reply #13 - Posted
2003-12-25 11:37:29 » |
|
The ONLY reason I use Python is because I hate perl. 
|
JavaPunk
|
|
|
tortoise
|
 |
«
Reply #14 - Posted
2003-12-25 13:03:33 » |
|
Probably the same bloke who decided that semicolons and curly braces are really great way to block structure a language. Yeah! Hey, wait a minute. Braces and semi-colons are a great way to structure a language. But to be sure, hungarian notation is of the devil and could only have originated at that place.
|
|
|
|
|
cfmdobbie
|
 |
«
Reply #15 - Posted
2003-12-26 00:20:42 » |
|
Because the brace can ofcourse go anywhere in C/C++/Java because in all sane modern languages whitespace is not significant.
(Note that this is NOT true for XML where <FOO> is a legal tag but < FOO> is not.) Apples, oranges - you really can't compare things like that. And the example you cite for XML is just about the only place whitespace matters... Anyway, try putting whitespace in the middle of your identifiers, or in your operators ("x= =y"). Java can't be a sane, modern language then! 
|
Hellomynameis Charlie Dobbie.
|
|
|
javatypo
|
 |
«
Reply #16 - Posted
2003-12-26 01:14:08 » |
|
you guys are so frigging funny..
that site is great...
i tried python but its so weird .. i cant stand it. id rather perl.. but i dont need to use it for anything. i use php on my website tho..
|
|
|
|
|
swpalmer
|
 |
«
Reply #17 - Posted
2003-12-26 03:47:55 » |
|
id rather perl.. Perl is a sin against humanity. The very definition of unmaintainable code. Obfuscation by design... The reason Bugzilla sucks so bad, etc... I spit on it... ptttheeww I grabbed bugzilla a long time ago because it was a known issue tracker and I needed something in a hurry... I took a look at the code - because unlike Java it needed to be modified to work on Win NT... That was chore. I showed my coworkers (C/C++ guys) we all had a good laugh at it. Many of us found it hard to believe.  These off-topic posts are a fun way to waste time 
|
|
|
|
tortoise
|
 |
«
Reply #18 - Posted
2003-12-26 12:38:06 » |
|
Perl is a sin against humanity. The very definition of unmaintainable code. Obfuscation by design...
This coming from the hungarian notation supporter?  Perl is great, down right excellent even, if not abused. It's a wonderful language to work in if you have a little self control.
|
|
|
|
|
swpalmer
|
 |
«
Reply #19 - Posted
2003-12-26 14:12:00 » |
|
I don't use Hungarian notation in any of my Java code. I do use it in C/C++ because that is the norm for the people I work with, and not doing so would basically create a problem much more real than the HN itself. I don't particularly like HN, but it hasn't caused me significant grief. Now Perl on the other hand... sheeesh! I like the power of regular expressions.. but they ARE cryptic.. heck Jeff doesn't even use the a?b:c operator... (which I like) ... I can imagine how someone that finds that overly complex sees Perl code. It's not that Perl isn't powerful.. it's that it is too terse (and it isn't really the regular expressions that I have a problem with). I just don't agree that representing the same thing with less characters is a good thing... Typing isn't what slows down coding. Perl certainly puts the 'code' in source code... let me get out my secret decoder ring so I can follow the algorithm  .
|
|
|
|
|
|
tortoise
|
 |
«
Reply #21 - Posted
2003-12-26 19:50:43 » |
|
my last job had me working completely in Perl. I was indifferent to it at first, but after about a month or so I came to really like it. It's really, really not that bad and I honestly think people who say it is just never bit the bullet and learned it. There is a method to the madness and once you see it, Perl becomes very logical (and elegant, believe it or not).
And regular expressions are not so bad once you get a feel for them. I always assumed they were as cryptic as can be, but there's only a few constructs that form them. For particularly complex ones, the '/x' modifier can be used to comment them. The up side is they make writing programs that parse lots of text incredibly succint, dozens if not hundreds of fewer lines than equivalent Java or C code. Perl can really be quite beautiful in the right situation.
|
|
|
|
|
blahblahblahh
|
 |
«
Reply #22 - Posted
2003-12-26 20:28:14 » |
|
IMHO, regexp's are very easy and clever and wonderful; the standard perl5 encoding of the regexp symbols is evil, horrible and stupid. Hand-written regexp's e.g. in a mathematical text describing finite automata are generally trivial to read and understand. But to:
- Use alphanumerics (amongst others) as special symbols
- Use arbitrary rules of when a symbol is itself, and when it's escaped
- Make the escaping very very difficult to follow without a suitably intelligent char-by-char color-coding text editor
- Make the whole thing case-sensitive!
seems deliberately evil. Basic perl's pretty good, but I've never had any faith in making it OO and such-like; a language which massively simplifies itself to the point that your 3 basic datatypes are "string, list and map" seems not really suited to anything complex enough to require OO. If you just perl to do simple (and very fast to create) programs it's good; once upon a time it was "great" (when it was v.effective at e.g. making up for the crap UI deficiences in lots of shell apps), but now that far more mature and carefully planned things have appeared (python, bsh, php etc) that can handle the simplicity and the complexity it's not really got a purpose any more, IMHO. Why code something in perl if you can do it with the same number of lines of code in python or beanshell?
|
malloc will be first against the wall when the revolution comes...
|
|
|
blahblahblahh
|
 |
«
Reply #23 - Posted
2003-12-26 20:32:15 » |
|
And regular expressions are not so bad once you get a feel for them. ... The up side is they make writing programs that parse lots of text incredibly succint, dozens if not hundreds of fewer lines than equivalent Java or C code. Perl can really be quite beautiful in the right situation.
...sure; excepting only that "perl5-compatible regexps" have been available for Java and C++ for years (e.g. I was definitely using OROinc's java regexp's 3 years ago...)
|
malloc will be first against the wall when the revolution comes...
|
|
|
Preston
|
 |
«
Reply #24 - Posted
2003-12-27 06:44:39 » |
|
Perl is a sin against humanity.
;-) I think "Perl is a write only language". Powerful but usually unreadable by others (who didn't programm the script). Personally I'd add: No need for PERL when there's (GNU) AWK. :-)
|
Memento mori.
|
|
|
swpalmer
|
 |
«
Reply #25 - Posted
2003-12-27 22:49:55 » |
|
...once you see it, Perl becomes very logical Where as most other languages start out logical and get better. I believe that people with a mind for programming can understand most of C/C++, Java, BASIC, Pascal, Python, etc.. just by looking at code that has been written in it, without knowing ANY of those languages ahead of time. It is clear enough that you can just figure most of it out by looking at it. Perl is not like that, at leazt not for me. I am sure that I could "learn" perl and in time read it and understand it with relative ease.. but I would consider that a tremendous waste of time. I would rather learn assembler, well I know assembler already, I learned it when I was about 13 years old after learning BASIC... that was relatively easy... Perl I had to force myself to learn.. just barely enough to do what I needed (make Bugzilla emailing work on Windows). I was stunned by its cryptic "elegance". Every time I figured out what a particular set of "instructions" was supposed to do my jaw would drop and I would say "Why don't they just SAY SO, instead of encoding it into an almost incomprehensible mess?", Then I would show the code snippet to a friend along with the equivalent Java or C code and we would have a good laugh at how utterly stupid Perl was. I even considered porting all of Bugzilla to Java... but only because looking at Perl had drivin me insane 
|
|
|
|
Jeff
|
 |
«
Reply #26 - Posted
2003-12-28 01:01:27 » |
|
Apples, oranges - you really can't compare things like that. And the example you cite for XML is just about the only place whitespace matters... Anyway, try putting whitespace in the middle of your identifiers, or in your operators ("x= =y"). Java can't be a sane, modern language then!  **sigh** You never took a compiler theory course, did you? == is a single token. That you cannot split a single token with whitespace has NOTHING to do with significance of whitespace. The term significance has a very specific meaning in compiler theory. The issue with <foo> is you have THREE tokens <, STRING, and >. That whitespace BETWEEN the tokens matters is what makes it significant. In C, Pascal, Java et al tokens need to be delimited, which sometimes requires whitespace and sometimes doesn't but the existence of whitespace between tokens does NOT change the meaning of the tokens. There are many good books on language theory and context free grammers in particular. The "Dragon Book" is a classic. "Crafting a Compiler" is one of my personal favorites.
|
|
|
|
Jeff
|
 |
«
Reply #27 - Posted
2003-12-28 01:03:04 » |
|
;-)
I think "Perl is a write only language". Powerful but usually unreadable by others (who didn't programm the script).
Agreed 100%. Can be very convenient to write but is VERY hard to read.
|
|
|
|
kevglass
|
 |
«
Reply #28 - Posted
2003-12-28 08:02:16 » |
|
Isn't this all opinion based? Just depends on how your mind works and what you find easy to work with?
Kev
|
|
|
|
javapunk
Senior Newbie 
|
 |
«
Reply #29 - Posted
2003-12-28 15:24:54 » |
|
Yes it is all opinion based. Same as Ford vs. Chevy, Toyota vs. Honda, do those "As seen on T.V." products really work?, magnetic braclets to help circulation, and herbal remadies  As with any language, product or car YMMV.
|
JavaPunk
|
|
|
|