PHP Developers Network

A community of PHP developers offering assistance, advice, discussion, and friendship.
 
Loading
It is currently Sun Oct 22, 2017 7:39 pm

All times are UTC - 5 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Mon Nov 21, 2005 9:21 am 
Offline
DevNet Master
User avatar

Joined: Thu Aug 15, 2002 5:53 am
Posts: 4235
Location: Sussex, UK
If you've always been challenged to write unmaintainable code, i.e. code you yourself won't understand anymore immidiately after completion or later, here's a tutorial:

http://thc.org/root/phun/unmaintain.html wrote:
In the interests of creating employment opportunities in the Java programming field, I am passing on these tips from the masters on how to write code that is so difficult to maintain, that the people who come after you will take years to make even the simplest changes. Further, if you follow all these rules religiously, you will even guarantee yourself a lifetime of employment, since no one but you has a hope in hell of maintaining the code. Then again, if you followed all these rules religiously, even you wouldn't be able to maintain the code!

You don't want to overdo this. Your code should not look hopelessly unmaintainable, just be that way. Otherwise it stands the risk of being rewritten or refactored.


This was written for Java, but just as nicely applies to PHP.


Btw.: If you haven't noticed the irony of that tutorial (or this post): you should always endeavour to have code-maintenance pretty much at the very top of your priority list when you code.


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 21, 2005 10:32 am 
Offline
PHP Evangelist
User avatar

Joined: Tue Aug 13, 2002 3:35 pm
Posts: 3547
Location: Calgary, Canada
LOL

A friend of mine told me he does that and he was proof to me that this really does work and does give you repeat contracts. :D So I've been doing it for quite some time now and I must say, it's working for PHP also (though a Zend Encoder would make that so much easier).

That article is an instant classic in my eyes and should be in any freelancers bookmarks! :wink:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 21, 2005 11:14 am 
Offline
Forum Regular
User avatar

Joined: Fri Mar 19, 2004 2:51 pm
Posts: 873
Quote:
A friend of mine told me he does that and he was proof to me that this really does work and does give you repeat contracts. Very Happy So I've been doing it for quite some time now and I must say, it's working for PHP also (though a Zend Encoder would make that so much easier).

Don't think I need any help from Zend. My production code is definitely unmaintainable. Redundant data and code plus no white space or comments. However, what's on the server and what I maintain are two different things. :wink:


Top
 Profile  
 
 Post subject:
PostPosted: Mon Nov 21, 2005 2:04 pm 
Offline
Tutorials Group

Joined: Sun Jan 04, 2004 11:30 pm
Posts: 2692
Buddha443556 wrote:
Don't think I need any help from Zend. My production code is definitely unmaintainable. Redundant data and code plus no white space or comments. However, what's on the server and what I maintain are two different things. :wink:

Thats funny. My "production code" at work looks like you could eat off of it. Sparkling, well-commented, OOP design..

The work I do off-hours for fun is just the opposite.. Procedural, hardly-commented, pile of legacy code and quick hacks.

Of course, I'm spending the time to make it more consistent, and less kludgy, so I feel the pain of unmaintainable code every day. :)


Top
 Profile  
 
 Post subject:
PostPosted: Thu Dec 01, 2005 10:08 am 
Offline
DevNet Resident
User avatar

Joined: Sat Jun 01, 2002 10:16 am
Posts: 1136
Location: San Diego CA
Some years ago a restaraunt chain that I had called on without result called me and asked me if I programmed in BASIC. After I told them that I did when doing so was unescapable they asked if I could come in that very day. Seems their programmer (all one of them) had quit without notice and the computer was crashing. They were unable to run payroll and the next day was payday.

Their computer was running interpreted BASIC (actually this was many years ago) and the programmer had done some sabotage before leaving. It took several hours to determine that, however, as I was wading through page after page of the most convoluted nonsense spaghetti code you ever could conceive of, with not one single comment in it. This programmer was of the "I'm going to prove how intelligent I am by writing code that is so complex that only I can understand it" school.

I actually managed to find the problem and get payroll done on time. But then I was there for, I think it was six months, on a full-time basis cleaning up the mess. First I had to find all the sabotage, which was of all kinds. Some caused crashes, but some simply caused bad output. This programmer had to have spent more than a full day inserting all the sabotage before leaving. Then I was re-writing code. I would take something that was like nine pages and rewrite it in a function that was twenty lines.

I never did figure out if the programmer wrote the code that way out of hubris or ignorance. But I had one of the longest contracts I had done at the time, and a few free steak dinners to boot.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC - 5 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Jump to:  
Powered by phpBB® Forum Software © phpBB Group