0844: "Good Code"

This forum is for the individual discussion thread that goes with each new comic.

Moderators: Moderators General, Prelates, Magistrates

Qwerty.55
Posts: 6
Joined: Mon Jan 10, 2011 8:18 pm UTC

Re: 0844: "Good Code"

Postby Qwerty.55 » Mon Jan 10, 2011 8:44 pm UTC

jc wrote:
Negated wrote:You need goto to get to good code.

Heh. I've seen a couple of cases where I could make a chunk of code smaller, faster and much more readable by the introduction of one or two judicious goto statements. It was fun watching how flustered the more doctrinaire programmers got trying to argue that it was "bad code".


Like you said, Assembly uses jump/branch commands similar to Goto quite frequently. Good luck getting that OS you're working in to run without them. Most Assembly programs wouldn't run for more than a millisecond or so if jumping/branching wasn't allowed. But even in higher level languages, I've found that sometimes you'll end up with a situation where you can use either a couple of Goto statements or re-write the entire program (very difficult if you're doing SMC) and use up even more to accommodate "good code."

Speaking of which, I wrote good code once. The hardware couldn't handle it.

axtheb
Posts: 5
Joined: Wed Jan 23, 2008 1:40 pm UTC

Re: 0844: "Good Code"

Postby axtheb » Tue Jan 11, 2011 2:13 pm UTC

jc wrote:However, the machine code is logically equivalent to the source code, in whatever language you're using, and must therefore have exactly the same properties. So your source code, if it runs correctly, is equivalent to a specific string of machine code, which we know is "bad code" because it contains gotos, proving that your code is also "bad code".


You have flawed premise here - Source code is not equivalent to specific string of machine code, because during compiling, lots of information is lost.

For example you can name all your variables with good, descriptive names. Or with random strings consisting of 'a' and 'b'. Both will compile into exactly same machine code... and while one can be good code, the latter definitvely cannot.

User avatar
SirMustapha
Posts: 1302
Joined: Mon Jul 21, 2008 6:07 pm UTC

Re: 0844: "Good Code"

Postby SirMustapha » Tue Jan 11, 2011 7:14 pm UTC

And it's time for...

What did we learn from xkcd today?

The lesson today, kids, is that if you're complete shit at programming, you should do a comic on how it's "impossible" to write good code! This will make you feel better about your ineptitude.

User avatar
Thesh
Made to Fuck Dinosaurs
Posts: 6598
Joined: Tue Jan 12, 2010 1:55 am UTC
Location: Colorado

Re: 0844: "Good Code"

Postby Thesh » Tue Jan 11, 2011 8:03 pm UTC

The point was that if you take the time to do things right, your project requirements are likely to change and you will have throw out a lot of the work you have done. At the same time, if you don't do things right then you are going to have to go back and fix it later on. In either case, I've been there and done that.
Summum ius, summa iniuria.

The Mighty Thesaurus
In your library, eating your students
Posts: 4399
Joined: Wed Apr 11, 2007 7:47 am UTC
Location: The Daily Bugle

Re: 0844: "Good Code"

Postby The Mighty Thesaurus » Wed Jan 12, 2011 2:03 am UTC

It's shitty, but I'm using a shitty netbook, so it all balances out.

inb4 somebody else has made the same joke, but better
LE4dGOLEM wrote:your ability to tell things from things remains one of your skills.
Weeks wrote:Not only can you tell things from things, you can recognize when a thing is a thing

Ceterum censeo Carthaginem esse delendam

twilliams1755
Posts: 9
Joined: Wed Mar 11, 2009 4:00 am UTC

Re: 0844: "Good Code"

Postby twilliams1755 » Wed Jan 12, 2011 5:18 am UTC

Radical Pi wrote:I have now decided that all people on my FRC Robotics team must read this comic before requesting any programming done. This is a PERFECT depiction of what happened last year (3.5 weeks on "Right", 3 days on "Fast", 3 months later we made it to "Good Code"). GET OUT OF MY HEAD RANDALL!


Don't even go there. We spent 2 weeks learning the software, 3 weeks coding crap, 2 days coding right, threw it out, and coded fast. I rewrote most of the programming in my hotel room the night before competition.

User avatar
SirMustapha
Posts: 1302
Joined: Mon Jul 21, 2008 6:07 pm UTC

Re: 0844: "Good Code"

Postby SirMustapha » Wed Jan 12, 2011 5:54 pm UTC

Corrected comic.
Attachments
good joke2.jpg
Good joke corrected

ericgrau
Posts: 92
Joined: Sat Dec 13, 2008 7:14 pm UTC

Re: 0844: "Good Code"

Postby ericgrau » Sun Jan 16, 2011 3:01 am UTC

At the last company where I worked I heard someone mention that you should never start too early on a project and if you do you never tell the client you're done until the day of submittal. The more time they have the more changes they want.

samcan
Posts: 12
Joined: Wed Jan 19, 2011 6:15 pm UTC
Contact:

Re: 0844: "Good Code"

Postby samcan » Wed Jan 19, 2011 6:35 pm UTC

ericgrau wrote:At the last company where I worked I heard someone mention that you should never start too early on a project and if you do you never tell the client you're done until the day of submittal. The more time they have the more changes they want.


Isn't that the way software development projects work? You create an alpha build of the software, show it to the client (or potential end-users), and they start coming up with all these extra features they want. Things they didn't mention back during the design phase.

"I now want it to be able to solve the meaning of life! What do you mean I didn't say that earlier? Isn't it obvious that's what I've always wanted?"

In a sense, it's kind of like having the PHB for a client or an enduser. He doesn't understand how complex programming is, so he assumes everything is easy. Actually, thinking about it, I think many technologically illiterate people think that way.

killedbyllamas
Posts: 1
Joined: Fri Dec 19, 2008 10:58 pm UTC

Re: 0844: "Good Code"

Postby killedbyllamas » Sun Mar 20, 2011 6:32 am UTC

On Friday, my boss and I finished a very quick build of an awesomely functional application that our department head decided that everyone needed rightfuckingnow to address a policy change. I immediately thought of this comic and how we had totally foiled it. A bit of a dance was done, if only in my head. Also on Friday, we were informed that due to said department head's complete inability to communicate properly with anyone or get appropriate information to support her edicts, our application would not be needed because the 'real' IT department would be finished with their imminently less functional official version...in a few weeks. Then I thought of this comic again, and how an added step in the good code flow could involve upper management fuckery rendering it useless. *grumble*

User avatar
vodka.cobra
Posts: 371
Joined: Thu Mar 27, 2008 6:50 pm UTC
Location: Florida
Contact:

Re: 0844: "Good Code"

Postby vodka.cobra » Mon Mar 21, 2011 6:30 am UTC

I'm writing an online game and I discovered a function I wrote back in 2009 doesn't quite work. Then I remembered that it was this function that frustrated me enough to put the whole project on the backburner for all this time. Then I got frustrated trying to fix it. I spent four hours trying to fix it.

Then tonight I said fuck it and rewrote the damn thing. 76 lines of code and it works perfectly.
If the above comment has anything to do with hacking or cryptography, note that I work for a PHP security company and might know what I'm talking about.

User avatar
SirMustapha
Posts: 1302
Joined: Mon Jul 21, 2008 6:07 pm UTC

Re: 0844: "Good Code"

Postby SirMustapha » Mon Mar 21, 2011 2:07 pm UTC

samcan wrote:In a sense, it's kind of like having the PHB for a client or an enduser. He doesn't understand how complex programming is, so he assumes everything is easy. Actually, thinking about it, I think many technologically illiterate people think that way.


And it's time for...
What did we learn from the xkcd forums today?

People usually don't understand the difficulty of the fields they aren't familiar with! And, somehow, that's absurd.

DEVELOPER: What do you mean, you don't understand how complex programming is??
CLIENT: Well, I'm not a developer!
DEVELOPER: That's no excuse! You should know that.
CLIENT: But I never took any lessons in developing.
DEVELOPER: You should have!
CLIENT: But I am a neurosurgeon!
DEVELOPER: It's not my fault if you chose the wrong career.

scarletmanuka
Posts: 533
Joined: Wed Oct 17, 2007 4:29 am UTC
Location: Perth, Western Australia

Re: 0844: "Good Code"

Postby scarletmanuka » Mon Apr 04, 2011 8:27 am UTC

Pretty sure you're just trolling now, Mustapha, but in case you aren't --

The difference is that I, as a developer, don't assume that neurosurgery is easy. Or that general practice is easy, for that matter. Or, for example, plumbing. And if I get a tradesman to quote on a particular job, and he comes and performs that job, I don't go and complain about all the other things I'd like him to do that I didn't mention before and demand that he does them for free.

Yet somehow this sort of behaviour is not only considered acceptable when it comes to software development, it is more the rule than the exception. Customers assuming our job is easy is only part of it; the other part is not really knowing what they want and not telling us when they decide they want something different from what they originally told us. Both of these, in my view, can be grouped together under the general heading of lack of respect for the profession and/or its members.

chuck981996
Posts: 10
Joined: Fri Oct 23, 2009 9:02 am UTC

Re: 0844: "Good Code"

Postby chuck981996 » Mon Apr 04, 2011 9:32 am UTC

As your code gets more complex, it becomes more and more difficult to maintain good coding practices. Once you have many different files, classes, virtual functions and you have used polymorphism until your code is a mess of arrows and asterisks, but you realise you left out ONE SMALL DETAIL the 'good code' method would be to rewrite it all. All 30,000+ lines. Or you could just use a goto. Not that I ever have.

tuxedobob
Posts: 15
Joined: Mon Apr 04, 2011 9:27 am UTC

Re: 0844: "Good Code"

Postby tuxedobob » Mon Apr 04, 2011 9:38 am UTC

scarletmanuka wrote:The difference is that I, as a developer, don't assume that neurosurgery is easy. Or that general practice is easy, for that matter. Or, for example, plumbing. And if I get a tradesman to quote on a particular job, and he comes and performs that job, I don't go and complain about all the other things I'd like him to do that I didn't mention before and demand that he does them for free.


Are you open to learning about new concepts?

http://en.wikipedia.org/wiki/Joke


As to the rest of your post, people don't "use" neurosurgery everyday. So they tend to assume that it's not easy. People use software every day. If it's good, easy-to-use software, they assume that it's easy to make.

Why do people think being a car mechanic is an easy job, but an airplane or space shuttle mechanic isn't?

bundat
Posts: 11
Joined: Wed Jan 26, 2011 5:05 am UTC

Re: 0844: "Good Code"

Postby bundat » Mon Apr 04, 2011 11:16 am UTC

^ You missed the original point though, in that said clients always ask for "re-dos" or "changes" that completely wrecks the whole system, while assuming that said changes are easy.
Even for "easy" jobs, people can't easily ask for changes if the impact is huge.

Hmm, I wonder if one could get away with acting like that everywhere I go.

- Replace this burger with one that has no onions. And don't just take it out, because I can still taste it, go cook a new one. What do you mean I didn't say that before, that shouldn't matter.
- Take back this well-done steak, I just realized I wanted it rare. What do you mean I should've said so before? I just saw what it looks like now, and I changed my mind, and finally realized what I wanted, so get to it!
- I wanted breast augmentation surgery result to make me at least a 38DD. You just made me a 36C. Go do it over again. What do you mean I have to pay again, and that I didn't make my requirements clear beforehand?
- I think I'd want you to paint my car with a little darker shade of red. What do you mean I should've specified the requirements clearly right at the start. "Red" was all I had in mind back then, I actually had to see the painted car to make up my mind about the shade.

Sounds like fun. :D
(Although I think people get away with lots of similar stuff in the US? :P)

User avatar
SirMustapha
Posts: 1302
Joined: Mon Jul 21, 2008 6:07 pm UTC

Re: 0844: "Good Code"

Postby SirMustapha » Mon Apr 04, 2011 2:21 pm UTC

scarletmanuka wrote:Pretty sure you're just trolling now, Mustapha


Oh, people always are.

scarletmanuka wrote:The difference is that I, as a developer, don't assume that neurosurgery is easy. Or that general practice is easy, for that matter. Or, for example, plumbing. And if I get a tradesman to quote on a particular job, and he comes and performs that job, I don't go and complain about all the other things I'd like him to do that I didn't mention before and demand that he does them for free.


Are you absolutely sure? Okay, so maybe you are indeed right, and you do have a very careful attitude when approaching other people's professions. That doesn't make you the rule, though, neither as a person, nor as a developer. For one: a plumber, for example, is generally well-seasoned in understanding people's requests and in getting more information than the customer thinks he needs to give. To give a rough example, a customer may say that there's a pipe that needs to be fixed, but he won't explicitly say that the wall needs to be broken in order for him to access the pipe; the plumber, however, will know that, and will not refuse to break the wall only because the customer didn't explicitly say so. If the plumber does a lousy job, though, the customer does have to right to demand it to be fixed without extra charges. There's no absurdity in that.

The problem is that software developers and engineers often think they have the whole control of the situation, and they don't understand that the requirements often change over time, that the client doesn't have a 100% perfect understanding of what he needs before he has a prototype or a partially functional product, that he doesn't mention every detail of the requirements because certain things for him are "obvious", and so on and on. Developers often don't see that as a natural obstacle to be overcome, and see that as the client's fault. This is not just me saying: I'm taking Software Engineering classes, you see, and those topics are being constantly mentioned.

When someone wants someone to project a house, he will often "see" the house he wants, but he doesn't predict every single detail and characteristic of the house. He will only visualise certain differences and problems when he sees an actual blueprint. Is that because the client is a dumb moron that "doesn't know what he wants"? Does he think that architecture is "easy" just because he constantly wants to change things? No: the thing is that he's not an architect and he doesn't think like one. That's the kind of thing architects are ready for: a blueprint is necessary, sometimes even a full 3D model will prompt changes and fixes by the client, and that's the way things work. If an architect tells his client to go fuck himself because "he doesn't know what he wants", he will end in bankruptcy.

But with software developers, the norm seems to be very different. It's not hard to see why: information technology is very new, many people (both clients AND developers) are still getting seasoned to it, and there aren't enough rules and guidelines as there are in other areas. Many things are very hazy and unclear. It's easy for people to have a wrong attitude towards it, but nobody wants to agree on what their own share of fault is: clients think the developers don't know how to work, and developers think clients should know more about computers before having an opinion. Clients also have their share of fault, but it's up to the developers and engineers to understand that and work their way around it! That's what they're paid for! You are the developer, it's your job to know how it works, not the client's! Can we just agree that the IT people also have their share of fault? I'm just absolutely sick of people thinking they haven't, be it for laziness, arrogance, or just plain ol' stupidity.

People who work with computers are -- gasp! -- imperfect too.

scarletmanuka
Posts: 533
Joined: Wed Oct 17, 2007 4:29 am UTC
Location: Perth, Western Australia

Re: 0844: "Good Code"

Postby scarletmanuka » Tue Apr 05, 2011 4:06 am UTC

Hey Mustapha! Looks like it might be Reasonable Conversation Time again.

SirMustapha wrote:The problem is that software developers and engineers often think they have the whole control of the situation, and they don't understand that the requirements often change over time, that the client doesn't have a 100% perfect understanding of what he needs before he has a prototype or a partially functional product, that he doesn't mention every detail of the requirements because certain things for him are "obvious", and so on and on. Developers often don't see that as a natural obstacle to be overcome, and see that as the client's fault. This is not just me saying: I'm taking Software Engineering classes, you see, and those topics are being constantly mentioned.

That's certainly true, and certainly part of the problem. But there's a difference, which you don't seem to have acknowledged, between incompletely specified requirements (which happen in every software project, and which require ongoing interaction between the developers and the customers to sort out as they crop up), and arbitrary complete or near-complete changes to the requirements when the system is nearly built or has been built - which happens in a dismayingly large proportion of software projects.

That's the kind of thing architects are ready for: a blueprint is necessary, sometimes even a full 3D model will prompt changes and fixes by the client, and that's the way things work. If an architect tells his client to go fuck himself because "he doesn't know what he wants", he will end in bankruptcy.

The problem is that, to use the same analogy, a lot of customers agree on the 3D model and the blueprints, give the OK for construction, and then when the carpets are being laid tell you that they want to swap one of the bedrooms for a bathroom, add three rooms to the ground floor, and build an extra storey. And they don't think it should cost any extra, because you've already built the house, you just need to add a couple of bits to it.

developers think clients should know more about computers before having an opinion. Clients also have their share of fault, but it's up to the developers and engineers to understand that and work their way around it! That's what they're paid for! You are the developer, it's your job to know how it works, not the client's!

That is exactly my point, in fact. It is my job to know how much work is involved in making changes to a system. I don't expect the client to know. The problem is that the clients often insist that they do know.

Solar Granulation
Posts: 2
Joined: Fri Nov 06, 2009 9:58 am UTC

Re: 0844: "Good Code"

Postby Solar Granulation » Sun May 15, 2011 6:13 pm UTC

I looked into HURD a while ago, shortly after Debian came out with their implementation. I was left with the impression that it occupies neither loop, but rather the one that runs:

Start Coding. -> Do things wrong and do things slow. -> Are you done yet? -> No and the face of computing has changed in the interim. -> That's okay, keep what you've got and carry on kludging.

I genuinely don't mean to be inflamatory, although I see no way to avoid it. This is my genuine impression of HURD, unforunately.

User avatar
dr pepper
Posts: 42
Joined: Thu Oct 14, 2010 10:28 pm UTC

Re: 0844: "Good Code"

Postby dr pepper » Mon May 16, 2011 3:06 am UTC

Meem1029 wrote:I disagree about code being good XOR fast. I think it should be good NAND fast. Anything I've tried to code so far is proof of this.


That's pessimistic. The truth table would pass Neither.

Legerdemagne
Posts: 17
Joined: Tue May 17, 2011 3:16 pm UTC

Re: 0844: "Good Code"

Postby Legerdemagne » Tue May 17, 2011 5:45 pm UTC

dr pepper wrote:
Meem1029 wrote:I disagree about code being good XOR fast. I think it should be good NAND fast. Anything I've tried to code so far is proof of this.


That's pessimistic. The truth table would pass Neither.

That's the point..?

Jokes aside, code should be "good enough" and "fast enough". Perfection in both is impossible. (Roller Coaster Tycoon is legend for how close it came to perfect speed, since it was written by a single programmer in an assembly language -- but it could have been a little faster.)


Return to “Individual XKCD Comic Threads”

Who is online

Users browsing this forum: No registered users and 97 guests