Java-Gaming.org    
Featured games (81)
games approved by the League of Dukes
Games in Showcase (492)
Games in Android Showcase (112)
games submitted by our members
Games in WIP (556)
games currently in development
News: Read the Java Gaming Resources, or peek at the official Java tutorials
 
    Home     Help   Search   Login   Register   
Pages: [1] 2
  ignore  |  Print  
  Unmaintainable code...  (Read 5844 times)
0 Members and 1 Guest are viewing this topic.
kul_th_las
Guest
« Posted 2003-12-23 01: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
Offline zparticle

Senior Member




Thick As A Brick


« Reply #1 - Posted 2003-12-23 13:24:01 »

I love that site, my favorite part is:

Quote

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.

Offline Jeff

JGO Coder




Got any cats?


« Reply #2 - Posted 2003-12-23 16: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???

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline princec

JGO Kernel


Medals: 369
Projects: 3
Exp: 16 years


Eh? Who? What? ... Me?


« Reply #3 - Posted 2003-12-23 16:51:26 »

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

Cas Smiley

Offline Jeff

JGO Coder




Got any cats?


« Reply #4 - Posted 2003-12-23 17:22:56 »

ROFLOL  point taken.


Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #5 - Posted 2003-12-23 17: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 Smiley

Offline nonnus29

Senior Member




Giving Java a second chance after ludumdare fiasco


« Reply #6 - Posted 2003-12-23 19: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.
Offline Jeff

JGO Coder




Got any cats?


« Reply #7 - Posted 2003-12-23 20:13:39 »

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,


Knowing human nature I'd suspect 2 things:
(1) Humans make mistakes Smiley
(2) HN probably drifts towards incorrectness as code is maintained and the maintainers don't want to change every reference to a HN name.

Quote

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

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

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #8 - Posted 2003-12-23 23:37:23 »

Merely in the interests of balance Smiley...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 Sad.

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...
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #9 - Posted 2003-12-23 23:41:18 »

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

Cas Smiley



...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... Roll Eyes

malloc will be first against the wall when the revolution comes...
Games published by our own members! Check 'em out!
Legends of Yore - The Casual Retro Roguelike
Offline Jeff

JGO Coder




Got any cats?


« Reply #10 - Posted 2003-12-24 17:08:20 »

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... Roll Eyes


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



Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #11 - Posted 2003-12-25 01:09:41 »

Now you're gonna upset the Python folks Smiley...
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...

Offline Jeff

JGO Coder




Got any cats?


« Reply #12 - Posted 2003-12-25 08: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**

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline javapunk

Senior Newbie





« Reply #13 - Posted 2003-12-25 10:37:29 »

The ONLY reason I use Python is because I hate perl.
Grin

JavaPunk
Offline tortoise

Junior Member




<3 Shmups


« Reply #14 - Posted 2003-12-25 12:03:33 »

Quote
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.
Offline cfmdobbie

Senior Member


Medals: 1


Who, me?


« Reply #15 - Posted 2003-12-25 23:20:42 »

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 <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! Tongue

Hellomynameis Charlie Dobbie.
Offline javatypo

Junior Member





« Reply #16 - Posted 2003-12-26 00: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..
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #17 - Posted 2003-12-26 02:47:55 »

Quote
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.
Grin

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

Offline tortoise

Junior Member




<3 Shmups


« Reply #18 - Posted 2003-12-26 11:38:06 »

Quote

Perl is a sin against humanity.  The very definition of unmaintainable code.  Obfuscation by design...


This coming from the hungarian notation supporter? Smiley

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.
Offline swpalmer

JGO Coder




Where's the Kaboom?


« Reply #19 - Posted 2003-12-26 13: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 Smiley.

Offline javapunk

Senior Newbie





« Reply #20 - Posted 2003-12-26 17:38:27 »

As in the words of the famous cfmdobbie
"Erk.  Learning Perl is less fun than gouging your eyes out with a spoon.   Wink"
http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=Offtopic;action=display;num=1049054236;start=1#1

JavaPunk
Offline tortoise

Junior Member




<3 Shmups


« Reply #21 - Posted 2003-12-26 18: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.
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #22 - Posted 2003-12-26 19: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...
Offline blahblahblahh

JGO Coder


Medals: 1


http://t-machine.org


« Reply #23 - Posted 2003-12-26 19:32:15 »

Quote

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...
Offline Preston

Senior Member


Medals: 4



« Reply #24 - Posted 2003-12-27 05:44:39 »

Quote

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

JGO Coder




Where's the Kaboom?


« Reply #25 - Posted 2003-12-27 21:49:55 »

Quote
...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 Smiley

Offline Jeff

JGO Coder




Got any cats?


« Reply #26 - Posted 2003-12-28 00:01:27 »

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! Tongue


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

Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline Jeff

JGO Coder




Got any cats?


« Reply #27 - Posted 2003-12-28 00:03:04 »

Quote

;-)

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.


Got a question about Java and game programming?  Just new to the Java Game Development Community?  Try my FAQ.  Its likely you'll learn something!

http://wiki.java.net/bin/view/Games/JeffFAQ
Offline kevglass

JGO Kernel


Medals: 159
Projects: 23
Exp: 18 years


Coder, Trainee Pixel Artist, Game Reviewer


« Reply #28 - Posted 2003-12-28 07:02:16 »

Isn't this all opinion based? Just depends on how your mind works and what you find easy to work with?

Kev

Offline javapunk

Senior Newbie





« Reply #29 - Posted 2003-12-28 14: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  Wink
As with any language, product or car YMMV.

JavaPunk
Pages: [1] 2
  ignore  |  Print  
 
 
You cannot reply to this message, because it is very, very old.

 

Add your game by posting it in the WIP section,
or publish it in Showcase.

The first screenshot will be displayed as a thumbnail.

Nickropheliac (16 views)
2014-08-31 22:59:12

TehJavaDev (23 views)
2014-08-28 18:26:30

CopyableCougar4 (33 views)
2014-08-22 19:31:30

atombrot (42 views)
2014-08-19 09:29:53

Tekkerue (41 views)
2014-08-16 06:45:27

Tekkerue (35 views)
2014-08-16 06:22:17

Tekkerue (26 views)
2014-08-16 06:20:21

Tekkerue (37 views)
2014-08-16 06:12:11

Rayexar (73 views)
2014-08-11 02:49:23

BurntPizza (49 views)
2014-08-09 21:09:32
List of Learning Resources
by Longor1996
2014-08-16 10:40:00

List of Learning Resources
by SilverTiger
2014-08-05 19:33:27

Resources for WIP games
by CogWheelz
2014-08-01 16:20:17

Resources for WIP games
by CogWheelz
2014-08-01 16:19:50

List of Learning Resources
by SilverTiger
2014-07-31 16:29:50

List of Learning Resources
by SilverTiger
2014-07-31 16:26:06

List of Learning Resources
by SilverTiger
2014-07-31 11:54:12

HotSpot Options
by dleskov
2014-07-08 01:59:08
java-gaming.org is not responsible for the content posted by its members, including references to external websites, and other references that may or may not have a relation with our primarily gaming and game production oriented community. inquiries and complaints can be sent via email to the info‑account of the company managing the website of java‑gaming.org
Powered by MySQL Powered by PHP Powered by SMF 1.1.18 | SMF © 2013, Simple Machines | Managed by Enhanced Four Valid XHTML 1.0! Valid CSS!