Unmaintainable code...

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

I love that site, my favorite part is:

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???

Probably the same bloke who decided that semicolons and curly braces are really great way to block structure a language.

Cas :slight_smile:

ROFLOL point taken.

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 :slight_smile:

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.

[quote]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,
[/quote]
Knowing human nature I’d suspect 2 things:
(1) Humans make mistakes :slight_smile:
(2) HN probably drifts towards incorrectness as code is maintained and the maintainers don’t want to change every reference to a HN name.

Easiest way back then IMHO was Turbo Pascal :stuck_out_tongue:

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 :frowning:

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.)

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

[quote]Probably the same bloke who decided that semicolons and curly braces are really great way to block structure a language.

Cas :slight_smile:
[/quote]
…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… ::slight_smile:

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 is a legal tag but < FOO> is not.)

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…

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

The ONLY reason I use Python is because I hate perl.
;D

[quote]Probably the same bloke who decided that semicolons and curly braces are really great way to block structure a language.
[/quote]
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.

[quote]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 is a legal tag but < FOO> is not.)
[/quote]
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! :stuck_out_tongue:

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…

[quote]id rather perl…
[/quote]
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.
;D

These off-topic posts are a fun way to waste time :stuck_out_tongue:

This coming from the hungarian notation supporter? :slight_smile:

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.

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 :).