How To Write Unmaintainable Code 327
/ writes "Roedy Green of Canadian Mind Products has written an essay entitled "How To Write Unmaintainable Code". Following his 54 tips, you too can guarantee job-security by becoming irreplaceable. If that weren't good enough, it's even available in Spanish. "
yes! (Score:1)
the secret to my success (Score:1)
What started off as a no pay internship turned into a $60/hour job, mainly because my code was valuable and it would have been impossible for someone else to figure out what I did and how it worked.
Every time I mentioned other job offers, they just raised what they were paying me. It would have taken months for some fool to understand my code and do anything useful with it.
I decided to continue in grad. school and I feel kinda bad leaving them with an expensive mess of spaghetti. If they pay $100/hour I'll spend my winter break making it understandable.
Coding (Score:1)
The prize goes to... (Score:2)
That had be laughing outloud! Being a web developer, I have often had to work with code that tried to do many, many thing. One web page would try to accomplish thirty different things, based solely upon the querystring parameters passed in. Ugh. Now there's job security! :)
Maybe you shouldn't be working for the place. (Score:4)
-----------------------------------------
Re:the secret to my success (Score:3)
However, don't we, as programmers, have some sort of obligation to try our best to create nice, maintainable code? I may be getting a little too philosophical here, but we expect artists to paint to their best abilities, poets to write to their best ability. It seems like if someone in one of these professions purposefully wrote sloppy poetry, or half-assed a painting, that we would look down on them. Perhaps it is a pride thing, but you think you'd intrinsically want to write good code.
I am not trying to sound preachy, CFN, for I don't know if you wrote sloppy code because you wanted to, or, more likely, because you were rushed and your superiors favored quantity of quality.
Make Code Look Like Ascii Art (Score:1)
for(int i =0; i-->;)
in Java, C or C++.
Bad Command Or File Name
Help! (Score:1)
After A while... (Score:1)
-PovRayMan
For folks who complain about VB .... (Score:4)
I Quote from the essay .... Maintenance programmers, if somebody ever consulted them, would demand ways to hide the housekeeping details so they could see the forest for the trees. They would demand all sorts of shortcuts so they would not have to type so much and so they could see more of the program at once on the screen. They would complain loudly about the myriad petty time-wasting tasks the compilers demand of them.
This is precisely the reason VB is so popular for business apps. You have to really work hard to confuse matters sufficiently in a VB program so that a decent maintenance programmer can't figure it out.... although I could write my own list applicicable to Vb for my current project... My favorite: Make sure you have the same variable name to reference a database in several different classes in several different programs, but have it point to three different databases depending on which variable is in scope currently :)
Maintainable Code (Score:4)
Personally once I write some code I want it to be maintainable enough so other people can contibute for I can move on with other things. I do not feel that my life consists of solely maintaining code, why not do something challenging? Rather then babysitting one of my past accomplishments. Why not take over the world?
Fit all code on *one* page. (Score:4)
Man, the number of times I wanted to kill that guy. We called him Anti-Whitespace.
Scarey though, how that page gave guidelines that I myself have been guilty of following too many times in the past. Is there a counter-page to that one, that gives guidelines (general purpose) that make it easier to work with other programmers?
Re:For folks who complain about VB .... (Score:2)
Re:the secret to my success (Score:1)
It was impossible to keep it nice b/c new features were requested so we could demo to some client, etc.
Mgmt. was more concerned with showing it off that having it built soundly and they got what they paid for.
It actually could have been nice, but whenever they felt I was "idle" (i.e. not showing them a new feature every 2nd day, but fixing what was behind the sceens) they would find a new feature to add or have me work on some other project.
As an architect (Score:3)
Good practises in programming isn't just for academics; it's the epitome of professional code writing. A manager once tried to draw the definition of a hack and a real programmer by the completeness and bug-free state of their code. I think he's wrong. I think that a real hack writes code that no one can pick up. A real programmer writes code that anyone can pick up and fix or expand - whether it's complete at any one point or not.
--
Re:Maintainable Code (Score:1)
54 tips? (Score:1)
For those who are interested (Score:2)
And of course anyone who wants to avoid accidentally using a few of those practices could be worse advised than to buy, read, and apply the concepts in a copy of Code Complete...
Cheers,
Ben
Removing toungue from cheek... (Score:5)
Now I write good code. Maintainable. Well commented. Meaningful variable names. Nothing fancy. I know what it's like to revisit my code ten years later.
There is a problem, though.
Nobody else seems able to maintain my code. They just can't understand it.
Despite high-level pseudo-code algorithm descriptions, threaded comments, good up to date written documentation, they just can't wrap their tiny little heads around how I do things.
I can go back to something I wrote 15 years ago and fix problems without generating new ones. My code is robust enought that I can shovel out a few thousand lines and jam in another 10,000 lines, test it for a day or two and release it... and get no bug reports for another 5 years. I consider this to be maintainable code!
Go ahead... break all the rules suggested in the article. You may still produce code that other, lesser programmers simply can't cope with. The code is an expression from the mind of the person who wrote it... and sometimes writing to the lowest common denominator simply isn't possible.
And then they blame you for writing unmaintainable code.
Re:Fit all code on *one* page. (Score:2)
Unless I'm very mistaken, that's a Johnny Don't list. As in, "Don't do what Johnny Don't does". (Non-native English readers: "&$thing unless $johnny_dont->can($thing);".) If you don't do the things on the list, you won't have unreadable code.
... (Score:1)
--
What? No M$ comments? (Score:1)
senseless! (Score:1)
Re:Make Code Look Like Ascii Art (Score:1)
--
The REASON we want good code... (Score:3)
When (not if) you end up maintaining someone else's code, if the code has been written in a clean way, it can be a sure joy to work with. If not, you'll be cursing that programmer for eons.
(Lets keep Microsoft's API out of this ok
The REASON we want good clean code is so that _we CAN_ maintain it.
I have been in the position of looking at my own code 6 months, later, and gone "WTF?", and wasted lots of time trying to figure out just what the heck I did.
If I had just spent the extra time to begin with, later on I could of been more productive instead of wasting time re-engineering the damn thing.
Pay the piper up front and save time later, or be a "saving time" grinch, and find an expensive time bill later. Seems pretty obvious what "The Right Thing" to do is
Work smarter, not harder =P
Cheers
BTW, Steve McConnel has a great book: Code Complete.
Re:Help! (Score:1)
Many of the rules he mentions can be applied; just because your first block used one indent doesn't mean the second block (at the same level) need use the same indent. The "open list" line continuation trick can be good for some real horrors with some care.
Of course if you're willing to work at it you can do things like this:
(\ denotes form induced breaks not present in the original; should be 4 lines total).
Extra point if you can figure that one out and/or name the source I've shamelessly stolen it from.
Re:Fit all code on *one* page. (Score:1)
How to fail at software development (Score:2)
--
I didn't read the whole list (i don't like horror) (Score:1)
(i've actually done that, and i understand what i do in my own code, but i'd like to see somebody else try to explain it
i seriously hope this page was intended as a joke
Bad takes more time to write (Score:2)
Cheers,
Ben
War story (Score:3)
They wrote a converter that digested the assembler and produced C code... about 4 lines of C for each line of assembler code.
So a math calculation that could easily be written in 1 line of C took 30 or 40 lines of assembler which converted into 120+ lines of C. (Stop screaming!)
Their converter did not put the original source line as a comment in the new source. (Now you may scream!)
Now I gotta maintain this pile of compost. I'm looking for another job.
Thingy! (Score:4)
He forgot "Thingy"! How can you forget "Thingy"? As in "Take the thingy passed in by the user, send it through the thingy, and return the thingy to the user" and "Merge the two thingies, extract the resultant thingy, discard the other thingy, you don't need it here, and then pass the thingy on to the next thingy."
[OT] Are people missing something here? :-) (Score:2)
I'm amused by how many posts here actually took this article seriously, seeing that it came from the "It's funny. Laugh." department. I suppose the phrase "It's funny. Laugh." should be taken in the imperative? :-)
arrgh (Score:1)
lambda x,y:(x<<8L)+y,map(ord,s)),e,n):chr(b>>8*i&255),ra
If you want to post <(<) or >(>) note that the preview form converts the char entities back to characters, and double check 'em.
Not documenting units (Score:1)
Looks like some Lockheed employee took this page too seriously.
(numbering might be wrong because i got it from the googlecache [google.com] version, which has only 53 rules.
Don't normally defend sun but.. (Score:4)
Ignore the conventions in Java for where to use upper case in variable and class names i.e. Classes start with upper case, variables with lower case, constants are all upper case, with internal words capitalised. After all, Sun does (e.g. instanceof vs isInstanceOf, Hashtable). Not to worry, the compiler won't even issue a warning to give you away. If your boss forces you to use the conventions, when there is any doubt about whether an internal word should be capitalised, avoid capitalising or make a random choice, e.g. use both inputFileName and outputfilename. You can of course drive your team members insane by inventing your own insanely complex naming conventions then berate others for not following them. The ultimate technique is to create as many variable names as possible that differ subtlely from each other only in case.
(e.g. instanceof vs isInstanceOf, Hashtable)
they are all valid w.r.t the conventions.
instanceof is an operator and a keyword hence should be all lowercase, isInstanceOf is a method name, hence should start with a lower case character and the rest of the words should be capatilized, and Hashtable is a class name hence every word should start with a capital. Hashtable is the only one you could argue, but I'd say that sun just think Hashtable is one compounded word in itself not two words that describe a class's function.
Re:What? No M$ comments? (Score:1)
Re:Removing toungue from cheek... (Score:1)
--
Some more rules (Score:5)
BONUS: With compact hungarian notation, you can become even more descriptive! So really the above becomes:
So much more descriptive information, all in the same amount of space. I've been on projects using this, and the sheer of joy of it cannot be accurately described in words.BONUS: Write extremely long lines of code, well over 80 characters per line.
BONUS: Do this right before a major deadline.
BONUS: Don't use the all uppercase convention in macro names; use the same naming convention as function calls. It's even more fun to debug when you have to spend time actually figuring out do_stuff() isn't even a function call!
MORE BONUS: Nest macro calls. Use the naming convention above.
EVEN MORE BONUS: Use macro calls as variables. Make sure the expanded macro makes function calls. Or uses other macros.
----------
Re:slashdotted (Score:1)
Alex Bischoff
---
Re:Fit all code on *one* page. (Score:2)
----------
Mirrored here - really :) (Score:3)
Enjoy
Mirrored here... (Score:1)
Enjoy this
Bad mirror (Score:1)
Re:54 tips? (Score:2)
---
Job security? try fortran (Score:1)
You may laugh at this. I don't. We have a Fortran programmer that wrote a lot of legacy production code (for the Vax). I know fortran (at least up to fortran77) although I haven't written in this language for a long time. Some of the younger ppl trying to port the code to newer systems have had a miserable time. But, hey, no problem! This guy is going to port his code to run on a unix system and will rewrite in C. No wait, he decides that he will skip c and rewrite the code in a new language that he hears is all the rage; c++. Two years go by.
He gives up learning c++ and ports his code to c. Another two years go by. If you know fortran, then you know that character manipulation is a bitch. I check his code and realize that he does not know the rudimentary aspect of c. He has essentially rewritten the function atoi. yikes.
On a side note: Obscure variable names is nothing new. Take a look at old fortran code written for a system with a 8 character limit.
On another side note: Many, many moons ago in my 1st computer class (fortran), I wrote a program that used the variable names kitty, cat, meow, and woof. Kitty was the integer equivalent to cat, and meow was the integer equivalent to woof. The prof was not pleased despite my explanation of the brilliance of my choice of variable names.:)
Re:Make Code Look Like Ascii Art (Score:2)
At least it's not C code.
You can't declare variables inside of a for statement, and even if you could, I've no idea what i--> is supposed to parse as.
/peter
main(){main(fork());}
Re:the secret to my success (Score:1)
Re:Removing toungue from cheek... (Score:5)
My company (owned by me) started a small contract last month at "a small financial services company" (let's not be too specific). About two years ago, they started to migrate off of DOS, a small 3090, and some netware boxes to Solaris. In the meantime, their workload has been growing. The old mainframers decided that they didn't like UNIX and waged a two year war to get rid of UNIX. All the UNIX guys left. Then they bought out two larger (but apparently worse-run) companies that were run completely on, you guessed it, UNIX. The mainframers announced that they were old and tired and perhaps they should bring the UNIX guys back (they were apparently told that they didn't have a choice). But they wouldn't come back (lots of work in Dallas for good UNIX guys, without rabid mainframers in the next cube). For the last nine months or so, they have had one group of "Unix" "consultants" from most of the majors over there "trying to fix the code" that they inherited. The code? perl. Just perl. A little ksh junk, some C, mostly perl.
I (and two other people) are now 10% done (we estimate, and we are usually right on estimates). None of us can figure out what was so hard about the code. Really. Some of these "consultants" had teams of 20+ people here. I think that they must never have seen UNIX before in a production environment.
This industry is very, very full of the clueless, and not all of them are running NT (most, yes, but not all). When people keep talking about the coming IT salary shakeout, I think of situations like this, and lots of others, just from the last few years. Good people will always be in demand. The lusers will rapidly find it hard to pay their bills. And this is not new -- it is just filtering from the most structured areas (that would have been MVS/COBOL shops) to the least structured (just wait, web-designer weenies -- your time will come), and it is hitting UNIX now. I think that the excuse of "this is just wild and crazy code and I no mortal man could wade through this spagetti" will soon hold as much water as "it's the compiler -- it hates me!" Heh. With this company, they were not clueless -- they kept the 3090 and never ever seriously considered NT. But UNIX was still believed to be bad juju and scary, so they accepted the explanations. I suspect that they won't in the future, as we are not missing chance to point out how clear things really are.
And, as an aside, not a single one of the COBOL guys that I knew (actually, a lot of them were and are women) were never out of work more than a few weeks, and some of them have been keying for dollars since before I was born (1970, folks). Their only recent job changes have been to jobs paying $200+ an hour.
Personally, I cannot fscking wait until some of these Thai-stick Bogarting full-of-BS tool-dependant Shockwave-inflicting pretentious "artist" wannabes that make web front ends to business site such a holy terror to implement for those of us with actual skills (like perl and DB2) start being forced on pain of no work and subsequent drug withdrawl to fscking write fscking proper fscking HT-fscking-ML to the fscking spec the client fscking asked for. Without the little moving GIFs. Grrrrrr
Re:What? No M$ comments? (Score:1)
legacy code kills (Score:1)
I was handing off pages to our PERL and PHP programmers, and they knew *exactly* where everything they had to do went, and why.
I only commented a few sections, but by gum they were the important ones.
Now I'm reusing 70% of the code to do 3 sections in one month, whereas the last section took a whole month to do.
If this continues, I'll work myself into a looong paid vacation
It'll be back to normal come December when the new stuff comes in, but right now, I'm enjoying the fruits of my labour.
Work smarter, not harder, neh?
Pope
passwording function names (Score:1)
Sowing confusion (Score:1)
for(int i=5; i -->0;) (Score:1)
int i=0, x =5;
for(i=x; i-->0;) {
Bad Command Or File Name
This is news? (Score:1)
Re:Maybe you shouldn't be working for the place. (Score:3)
One you don't shoot yourself in the foot..
Two you have job security...
Nested Ternaries (Score:1)
Then again, I don't get much opportunity to use them these days...damn 4GL gibberish =)
Variable names (Score:2)
Name variables a series of l's (the letter) and 1's (the number). So you'll have:
ll1l1lll1
ll11ll1l1
1ll1l1l11
ll1111lll
and so on. Sure, if they use a font that clearly shows the difference, it's no fun. But it can be!
Re:Fit all code on *one* page. (Score:1)
Sadly true...
Spirit Breaking 101 for Junior Porgrammers. (Score:5)
Good evening class. I'll be your exorcizer of idealistic nonsense for the evening. Just call me Bruce.
Now... preach all you like about how hard it'll be for the next guy, but like customizing my car or my house... I don't worry about what the next guy will think about my code. Do you care if the next owner of your car might not like it if you paint it red? Do you care if the next owner of your house disapproves of you converting the garage into a pool room? Heck no. Well, it's the same with me. I work for my own benefit, pleasure, and satisfaction. And to do that I've gotta do the best damn job I can at work. Otherwise; no money; no fun. This philosophy is reflected in my code as well. I've cranked out some godawful nasty kluges that confuse even me when I look at them a year later... but I got the job done, by the deadline, while some of the junior programmers seem to wanna rewrite everything to make it clean rather than break the nice design of the code. Feh. That's why they're junior programmers. They Just Don't Get It (tm). Their plan would send the company under. Stuff's gotta be done now and ship next week or there's no profit for the company and no salary for the programmers. Junior programmers always seem to be self-delusional with grand plans of redesigning everything. It never happens. Requirements change *ALL* *THE* *TIME*. Any static plan is doomed to fail. Once they realize this they make the transition from dreaming programmer to master hacker... or they can't keep up with the pace of real world business and disappear. You've got to be able to deal with old crusty projects written by long gone staff with more bags and bells and whistles and ornaments hanging off the side and kluged into it, written by more people you've never met, and you've got to be able to quickly and successfully hack more stuff into it and hack it and rehack it and change old stuff and keep it all running. Successful, on the fly, under the gun kluging is what distunguishes the Senior Programmers driving the big smog polluting, shitty mileage, comfy luxury cars into the front, covered parking space and getting the stock options and profit sharing and 401Ks from the idealist larval dreamers driving their small car becuase "it's good for the environment". Self-spirit-lifting-and-self justification-bull. Given the Big Bucks, you'd ditch that Civic for a gas guzzling SUV or Corvette too. So forget the dream. Getting a clean slate to build on is a rare event. 99% of all programming jobs you'll ever be hired for will be holding together someone else's code. Insane deadlines, getting the jump on the competition mid project, reamping of requirements (many times over), decision reversals by management, your latest self-gratifying achievement being abandoned and dumped because it's not needed anymore. These will all eventually break your spirits. On the plus side, once you realize this, you will be able to succeed and advance within your company or find it easy to get hired at the next comapny. because quick thinking master hackers who can do the magic again and again despite laying waste to the original vision and still keep on kluging and have it keep on working are what companies want. If you can do this, you will succeed. Getting back to the original question... do I obfuscate my code? It may certainly look that way to the idealist, but not so. True brilliance is messy. Remember the famous comment preceeding the task switching code in Unix... /* You are not expected to understand this */ But if you can, you'll be a god... or root... what's the difference again? Anyway, class dismissed.
Re:Open Source ugly code? (Score:1)
if you let someone get burned by their own bad habits, it is sometimes enough to break them of those habits.
the article is a bit sarcastic.... at least thats how i read it.
Re:the secret to my success (Score:2)
Friday:
Me: Well I'm done with that latest addition you asked for. I'm going to clean the code up a bit and then head home.
PHB: Oh that can wait, can you add -insert feature here- and have it up by the end of the day on monday?
Its so hard to get mad when they're paying you that much. And in the end, it is job security ;)
Re:Maintainable Code (Score:1)
A) The *original* system was done on a UNISYS mainframe. Hence the initial style of this pile of rubbish.
B) Half the system is in a 4GL language, written by programmers that were learning the language for the first time.
C) Half the system was written in shell scripts. They were originally plain bourne shell (yuck), and some kind soul decided to convert them all to Korn. Unfortunately, that consisted mainly of changing the #! line. Utterly worthless.
D) Raw SQL is sprawled all throughout this stuff. The statements for executing each of these SQL scripts varries in ways you can't imagine.
E) Three-quarters of this code is on 13 different HP-UX boxes. Very old HP boxes.
F) The rest is on old SCO 3.x/4.x boxes, which were never properly installed to begin with (they core dump every time you try to shutdown the system). There is no way in hell I'm ever trying to re-install them. Never.
G) The entire system consists of about 500 shell scripts, 70 or so 4GL programs, and several hundred SQL scripts -- many of which are dynamically modified and executed by said shell/4GL programs.
H) I'm only about the fifth person to be put in charge of this code since it was written. Nobody with any experience in it works here any longer.
I think I'm going to learn to tie a noose this week =)
Re:Fit all code on *one* page. (Score:1)
:)
Shouldn't everything?
Anyone blindly adhering to a rule like that must have forgotten the meaning.
The spirit of the rule is to have understandable maintainable code - the function should be small enough to twist your mind around without getting sucked into a mental whirlpool of pointers to pointers to..., and besides you don't wnat to have to scroll too much
Obeying the letter of style rules is counter-productive - it shows a lack of understanding of the spirit.
Job Security! (Score:1)
Now, having said that, the link in question was undoubtable funny, and I'm sure none among us can cast the first stone when it comes to the listed offenses, though I doubt most really do it for job security. Usually, its the insane deadline pressure or the dreaded feature creep.
Re:Maybe you shouldn't be working for the place. (Score:1)
--------------------------------------------
Re:Maintainable Code (Score:1)
And finally, don't forget to make it IMPOSSIBLE to call the scripts by hand, something in the style of:
myscript BIG_RANDOM_NUMBER PI_TO_100_DIGITS MY_LIFE_STORY BILL_CLINTONS_FAVORITE_RESTAURANT.
Slashdot Poll? (Score:1)
None of them; all of my code is squeaky-clean
1-5
5-10
10-15
20-40
40-50
All of them, and proud of it.
3 + 6i of them
Hey, what about 16-19?
No goto (Score:2)
Job security (Score:3)
If you can't be replaced, you can't be promoted.
You're living in a dream world... (Score:2)
This is largely your own fault (Score:2)
As a responsible, professional software engineer, these are things you should be trying to do. If there is resistence to implementing a formal development process, you may have to negotiate a little bit. But ultimately, there is nothing unreasonable about doing business in a formal, well-defined manner. If they refuse to do things this way, make sure you remind them that there will be serious consequences (personally I would threaten to quit the job and work for a more reasonable employer, but that's not for everyone): bad software, missed deadlines, and maintenance hell. This gets you completely off the hook if anything goes wrong. And when things do go wrong, they'll think "he was right", and they'll realize just how good you really are.
If you want to be a successful software engineer, you need to adopt the attitude that you will NEVER be involved in a failed project (I had the chance to take an excellent course with Marshall Cline, of C++ FAQ fame, and this is one of the things he stressed most heavily and I see a lot of truth in it). You need to take a proactive approach. Take steps to ensure that management is doing things right, rather than simply sitting back and carrying out their instructions without saying a word. Of course, be diplomatic. This is part of a software engineer's job, IMHO. It is things like this that separate the men from the boys in the industry; the true software engineers from the coding monkeys. If you are a software engineer, it's your job to ensure that the company develops the best software possible, or at a more fundamental level, to minimize the time, money, and risk the company expends on the project. Doing that involves more than just coding.
Re:The Shoemaker (Score:2)
That being said, there is at least one project to create a language and editor that use "structured data" like he describes, which I founded, see "http://www.box.net.au/~matty/ultra". I'm not going to claim it will be a universal language though!
Re:Fit all code on *one* page. (Score:2)
IT'S A JOKE!! (Score:2)
Sheesh. :)
programming language and clarity (Score:2)
What differentiates maintainable code from spaghetti code is not just whether or not the syntax of the language allows for obfuscated code, or if all of the variables and functions are documented and clearly named, if some code conventions are followed or if it has been run through a beautifier, but whether the code was written with a clearly thought-out and documented design.
If the programmer has actually taken the time to think about the data structures, the algorithms, and the classes(or program sections if you aren't using an OO language), then the code becomes truly understandable. This is not to say that you can then ignore good programming techniques -- they are still necessary -- but that documenting every function, variable and data structure in a program that is otherwise a crufty mess is pretty much a waste of effort. Try it sometime -- look at the source code for Perl, and have the perlguts man page and Gisle Aas's wonderful illustrated guide to Perl's internals [home.sol.no] handy, and you'll get the idea.
I've seen code in lots of languages that would be considered 'maintainable' if all it took was strictly following a convention, but in fact was frustratingly difficult to maintain because the programmer didn't have a clear design for the system.
if else if else if else if else if else if ... (Score:3)
Say you're programming CGIs in Perl using modules. Whatever you do, don't install new modules in the system-wide site library, because that could cause all kinds of trouble! Better to put them all in
Re:Maybe you shouldn't be working for the place. (Score:2)
I was working in a PC Support role at the time and there was no mention of programming in my contract. I was, however, asked to write and maintain some programs written in Visual Basic for Excel. No agreement was made to provide them with the source code to the program, but it isn't possible to not provide them with the source code and VB for Excel is Interpreted at runtime and not compiled. Hence they would receive the code no matter what. I wrote well structured code where all variables were clearly defined and well named, but before unleashing the code to production I made a copy on a floppy and removed all comments from the production version. I also used global search and replace to rename all variables to a,b,c,d,e etc... The reason I did this was I kind of resented the fact that I was doing something that I wasn't been paid anything near what I should be getting for doing it. On a flip side, they never recognised my coding skills and I left the company a few years ago for better pastures. I still have the floppy and the programs are still in use, I will gladly do contract work for them to make changes. At a contract rate, of course.
This also has an analogy to contractors leaving time-bombs in systems to protect themselves. The practice is un-ethical, but hey - take a closer look at corporate life, what makes you think that's ethical? If you are dis-gruntled about doing coding when you are not being paid for it them it becomes very easy to justify this kind of practice. If you are being paid to do coding, then your contract should include an agreement to document your code according to a set of guidelines. Woe betide any foolish coder who uses the practices above while bound to such a contract.
There's one more (Score:2)
Ahh, but you forget Scott Adams (Score:2)
This works. Trust me.
Maintenance Programmers [sic] (Score:2)
Why? Because that's what everyone's doing, at which point they bitch and moan about how their Fortran, Basic, and Cobol programmers can't understand the C++, Perl, and Java code you've written.
Funny thing.
They sometimes even have the unbridled audacity and incredible stupidity to demand that you convert your code to look like the languages that the "maintenance programmers" understand. I've never come up with a better answer than to suggest that people run very far, very fast from this all to prevalent mentality. The world is a strange place.
Re:Make Code Look Like Ascii Art (Score:2)
if (foo)
{
int i = 0;
}
and in C++ you can define them in the for itself:
for (int i = 0; i < 100; ++i)
Perl-impaired consultants (Score:2)
Vovida, OS VoIP
Beer recipe: free! #Source
Cold pints: $2 #Product
Some terse advice (if you don't decide to quit) (Score:2)
Vovida, OS VoIP
Beer recipe: free! #Source
Cold pints: $2 #Product
Obfuscating without appearing to. (Score:2)
And, after you've seen a few thousand modules done this way, you can pretty much burn through them; it's actually kind of fun, like doing a puzzle.
The evil done by obfuscated code is nothing compared to the evil done by obfuscated architectures. Any power you give somebody can be used for good or evil, and the power you have when designing in architectural dimensions (like class hierarchies or APIs) is both greater and more subtle. Example: DDE. Real world projects include not only bits of code, but class hierarchies, databases, file formats, external interfaces etc. You can write code as limpidly as Kernighan and Ritchie, but still end up with a system that is totally unmaintainable by anybody but you. Furthermore, it will be utterly unclear to anyone whether this was deliberate, or caused by technical constraints (i.e. things you must interface with), or is somehow tied up in the nature of the problem.
Write overly complicated code, and people will think you're an idiot. Design overly complicated systems and write beautiful code to solve the unnecessary problems you create, and they'll think you're a genius.
Re:Maybe you shouldn't be working for the place. (Score:2)
>best, most maintainable code possible and then show them. Prove you're
>worth the extra bucks and you'll get it. On the other hand, prove that
>you're a bitter script-kiddie and you'll get paid accordingly.
First, I'm not saying what he did was right.
But, the truth is that business types will walk all over you if you let them. I got out of college, and started into the industry. I went to work for a company for a VERY low salary. I figured I would show them how good a coder I was, and they would up my salary. According to the other people who worked there, and saw/used/maintained my code, I am a pretty good coder. I was there for nine months and (finally) got a SIX PERCENT raise. The average salary where I am was almost twice what I was making.
The business types don't really care how good you are, or how much you code, or how good your code is, they care how much you yell and scream your head off.
>>>>>>>>>> Kvort
Design (Score:2)
I remember the good old days... (Score:2)
Started in BASIC, went through an interpereter to C and still had bits of assembler for certian bits. Wow, this code SUCKED.
I didn't have much to do with it, but I did have to emulate some things it was doing in a new Windows system (ewww).
The best part was when I found out that 'S' was a global void *. Depending on the part of the program it was used for a half a dozen different types. The structured programmer in me had spazmotic fits, but I couldn't have the programmer killed cause he was the owner of the company.
Oh, there was also a global 's' which was declared as an int but used as a void *.
Oh well, back to my stupid Access project. How can anyone work in a language without pointers?
-- I'm omnipotent, I just don't care.
My first job (Score:2)
All in all it was a great learning experience. I've developed an aversion to spaghetti since then.
Imagine if you will, a 2000+ line subroutine containing many a multi-level if-else/for-do construct, from the depths of which conditional computed GOTO statements jumped into the middle of another multi-level for-do/if-else loop. Intercal [tuxedo.org] was never more fun.
The true kick of the experience was that it was to be a code port. Not a rewrite. Not even a little. A straight port, so the original developers wouldn't have to figure out any new logic. Feh!
Re:thief (Score:2)
>contractually obligated to do, that he was
>not being paid to do, and he did it anyways...
>and he's a thief?
No, he wasn't contractually obligated--at the time he was asked. Once he began the work, it modified the contract (more technically: the company offered a contract modification, and he accepted it by performance).
Once he undertook the duty, he was obligated to due so correctly.
The company did *not* try to get something for nothing. They requested a service at the rate he was already receiving. He took the money to do so. And stole the work that he was paid to perform.
[overrated? at a default? hmm . .
Re:Hungarian notation (Score:2)
HN is a good way to indicate the kind of variable, and it does not preclude meaningfull name. What is maxTypeCode? A string? An int pointer? Pointer to a user defined type? I don't know without scrolling back up to the declaration. is numLinePayments a signed or unsigned int? On the other hand, pszMaxTypeCode tells me instantly that it's a string and iNumLinePayments is signed.
Likewise, your iNmPt example illustrates braindead programmers, not the shortcomings of HN. It should have been called iNumLinePayments.
I think too many unix coders are frightened off from HN simply because it came from Microsoft. Don't be. Try out HN, and if you don't like it properly used, then don't use it.
Re:Hungarian notation (Score:2)
Unless you're writing a device driver, WHO CARES? If you stick to the functional interface used for creating, setting, and passing that value, the type of maxTypeCode is OPAQUE. It's called ABSTRACTION, something we learn when we stop having to know encode our routines for sizeof().
The problem with becoming invaluable... (Score:3)
Re:Spirit Breaking 101 for Junior Porgrammers. (Score:2)
I uh
Re:thief (Score:2)
>modification
Actually, it's explicit: the modified contract is accepted by performing the action
>(he may have; IANL,
but I am
>and the law has stranger things in it...)
nothing strange here; this is no different as a legal principal than working eight hours instead of the six in your contract, and expecting an extra two hours pay.
>- did he also implicitly enter into an assumed
>modification that assigned intellectual property
>of his creation to the company?
It was work for hire. The employer is entitled to all of it.
>If not, and there was no such assignment in his
>original contract, then he owned the code, and >was free to do with it as he wished.
If for some reason there wasn't, he was stealing when he did it during time the company was paying him . . .
>Once he undertook the duty, he was obligated to
>due so correctly.
>Legally, or morally?
Legally.
>Morally, I'd agree with
>you... if he made the commitment, I think he
>should have followed through. Legally, though, I
>don't think there was a commitment, and
>he can't be held accountable for not doing work >he was never hired to do.
He was doing it on company time, for which he was paid. He then vandalized, it, and took the copy he wasn't entitled to.
Re:Hungarian notation (Score:2)
In any case, your point is well taken, that Hungarian notation is not as obfuscated as my not-so-contrived example makes out. My only experience with it however was on this one project which did have such convoluted examples. Hopefully my example speaks to the broader issue of useful variable naming, not just Hungarian notation.
----------
Re:Hungarian notation (Score:2)
A maintainer DOES NOT want to flip up to the top of the header files each and every time he runs across a variable to find out what it is. If a bug is signed versus unsigned related, "maxTypeCode" doesn't help at all. But an "uMaxTypeCode = -3" sticks out like a sore thumb.
Re:Hungarian notation (Score:2)
Without looking anything up, I think mps is a Microsoft/Windows/vc++ specific prefix. I do recall that "h" was for handle, and when you're using handles for *everything* in windows programming, it makes it much easier to distinguish between ints, files and handles.
But just like the guy who avoided all whitespace because he was following the rule to keep all functions one page in length, you can overdo HN. The basic idea is to use easy to remember mnemonics with prefix notation. Using "intEmployee" and "dblSalary" is equally useful.
Re:thief (Score:2)
Shall I go to a police station and confess?
Also note I was employed in the UK and you cannot apply US employment law to my case.
Some of the comments in this thread are actually quite surprising to me. There is the air that every employee should always bow their heads to their managers and never do things for themselves. There also seems to be the opinion that everyone should be selfless and not look out for number one.
I confess, I don't believe in this ethos. At the end of the day all I care about is myself and those that care about me, the rest are immaterial, but they needn't go to hell.
I did do other coding in this employment and did not alter the code, leaving explanatory comments and even writing a 40 page manual of how the system worked and both user and programmer references. In all the time I was employed there my salary rose by only 3% (OVER TWO YEARS). PC Support Analyst to Developer?
And it seems I still am judged by my peers as a thief, the devil incarnate perhaps?
Oh well, lets leave this one to the archives of
one last comment (Score:2)
.
Good idea, it's beaten to death. But one little note: I'm not talking about US employment law, but the Common Law of England
hawk, esq.