The Code Is The Design
danielread writes "In 1992 C++ Journal published an essay by Jack W. Reeves called 'What Is Software Design?' Many credit this essay as being the first published instance of assertions such as 'programming is not about building software; programming is about designing software' and 'it is cheaper and simpler to just build the design and test it than to do anything else'. developer.* Magazine has republished this groundbreaking essay, plus two previously unpublished essays, under the title Code as Design: Three Essays by Jack W. Reeves."
Here we go.
The UML monkeys are gonna have a fit!
The code is the comments.
sigh. I hope this reads better than the headers and comments I normally struggle through when trying to understand another coder's thoughts.
Might be timely to revisit
Six Laws of the New Software
Rock that crushes, Paper & Scissors that don't matter.
Given sufficiently high level languages (as appropriate for the app) this would be true.
While we are at it, the comments are not needed either (there should be a compiler warning for them).
(not completely joking)
In practice languages are too low level no matter what you use or have "leaky abstractions" which cause problems.
developer.* Magazine has republished this groundbreaking essay, plus two previously unpublished essays, under the title Code as Design: Three Essays by Jack W. Reeves."
I'm supposed to be impressed by this? Ten years to republish an article? What a rag. Why, here on Slashdot, you barely have to wait te--
[sound of post getting modded into oblivion]
Is his thesis useful, actionable in a way that is substantially different than what people were/are doing already?
It's cheaper and simpler for the initial programmer. After that, we have to spend time (and therefore money) decoding the original code, recognizing idiosyncracies, and retrofitting to work with other code. Even if it's the same programmer, a couple of years later. C++ is more "self documenting" than most languages, when coded properly. And it certainly seemed like the remedy to C, back in 1992 when that screed was written, and C++ was just beginning to be adopted by mainstream programmers. But there's no substitute for writing the requirements, feature definitions, scopes and dependencies first, then the comments in the code blocks, then the code, and tar'ing those docs with the source code. The initial hump is steeper, but the total area under the work curve, over the product lifecycle, is much less.
--
make install -not war
> Personally, I think a person with his feet on
> the desk staring at the ceiling can be "doing
> design" just as seriously as someone playing
> with UML diagrams in ROSE.
So true. Although I find it helpful to move along these reveries by writing little test apps to put wheels on some ideas... just little 10-20 liners to help get a better handle on things.
The Army reading list
and can only describe how much i agree with this in utterly banal terms.
code is design.
take any programming language, whatever virtue, whatever failure, it does not matter. the fact that it is a language at all, proves it.
because any single language exists solely and uniquely by and for design. language is for designing things, and describing the design of things to other people, over a process called 'time'.
design implies persistence, and as we all know, time destroys all things. language is design over time, and the multitude languages of mankind, even that of his machines, exists to design things.
i mean to say, this is a language truth, not just a computer programming truth.
programming languages, as language, are a designed language used to describe very specific activities.
take any real-life problem, turn it into a virtual machine, design a language around it (or use whatever is there, in the situation being systemized, already), and you have your application done.
language: the worlds most intentionally widely misunderstood subject.
; -- the corruption of government starts with its secrets. a truly free people keep no secrets. --
Probably something like this?
5 57799@@>>>BBBGGIIKK"[b]-64;C="C@=::C@@==@=:C@=:C@= :C5""31/513/5131/") :0, I (x,Y/2,X ;y-=S*M ;z-=C*M ;b=x* x/M+ y*y/M+z ,0),b =E, a+(a>b ?-b:b)): -1.0);}Z;W;o ,y,z,k, ;}Q;T; ;n(e,f,g, h,i,j,d,a, b,V){o(0 ,e,f,g,h,i,j,a);d>0w =g-C*M,b=(-2*u-2*v+w)b ,b*=200,b/=(M*M),V=Z,E!=0?(u=-u*M/E,v=-v*M/E,w=-w* M// 2),j-=w*E/(M/2),n(e,f,g,h,i,j,d-1/ =2, U/=2,V=V<22?7: (V<30?1:(V<38?2:(V<44?4:(V==44?6:3)))): 0,T +=V&2?b :0,U+=V &4?b:0) :(d==P?(g+=2 /M,U<M /5?(Q=255-210*U /M,U=255 -720* U/M):(U -=M/5,Q=213-110*U ;t(x,y ,a, b){n(M*J+M *40*(A*x +a)/X/A-M*20,M*K,M ;G+=T;B +=U;++a<A?t(x,y,a,G ; }main(){printf("P6\n%i %i\n255"
X=1024; Y=768; A=3;
J=0;K=-10;L=-7;M=1296;N=36;O=255;P=9;_=1<< 15;E;S;C;D;F(b){E="1""111886:6:??AAF"
"FHHMMOO55
"31/531/53"[b ]-64;S=b<22?9:0;D=2;}I(x,Y,X){Y?(X^=Y,X*X>x?(X^=Y
)):(E=X); }H(x){I(x, _,0);}p;q( c,x,y,z,k,l,m,a, b){F(c
);x-=E*M
*z/M-D*D *M;a=-x *k/M -y*l/M-z *m/M; p=((b=a*a/M-
b)>=0?(I (b*M,_
(c,x,y, z,k,l, m,a){Z=! c? -1:Z;c <44?(q(c,x
l,m,0,0 ),(p> 0&&c!= a&& (p<W ||Z<0) )?(W=
p,Z=c): 0,o(c+ 1, x,y,z, k,l, m,a)):0
U;u;v;w
&&Z>=0? (e+=h*W/M,f+=i*W/M,g+=j*W/M,F(Z),u=e-E*M,v=f-S*M,
/3,H(u*u+v*v+w*w),b/=D,b*=
E):0,E=(h*u+i*v+j*w)/M,h-=u*E/(M/2),i-=v*E/(M
,Z,0,0),Q/=2,T
,Q+=V&1?b
,j=g>0?g/8:g/ 20):0,j >0?(U= j *j/M,Q =255- 250*U/M,T=255
-150*U/M,U=255 -100 *U/M):(U =j*j
/M,T=255-435*U
/M,T=168-113*U / M,U=111 -85*U/M) ),d!=P?(Q/=2,T/=2
,U/=2):0);Q=Q< 0?0: Q>O? O: Q;T=T<0? 0:T>O?O:T;U=U<0?0:
U>O?O:U;}R;G;B
*L-M*30*(A*y+b)/Y/A+M*15,0,M, 0,P, -1,0,0);R+=Q
b):(++b<A?t(x,y,0,b):0);}r(x, y){R=G=B=0;t(x,y,0,0);x<X?(printf("%c%c%c",R/A/A,
/A/A,B/A/A),r(x+1,y)):0;}s(y){r(0,--y?s(y),y:y)
"\n",X,Y);s(Y);}
Courtesy IOCCC:http://www0.us.ioccc.org/2004/gavare.c
An Indian-American Hindu committed to non-violent thought/speech/action alarmed by the global explosion of radical Islam
Does this sound a lot like "The Network is the Computer" to anyone?
Stop with the pseudo-clever melodramatic BS already.
Good code following the design is nothing new. Jumping straight into coding without a design document that the WHOLE team AND your clients/users can read however is insane.
I'm all for productive laziness but this is just plain BS.
These posts express my own personal views, not those of my employer
Would you like to point at a particular file about which you're going to say that?
Perhaps slashdot should have a special section for newbies who don't want to do the hard work of creating software and would rather just hack.
Yes, staring at the ceiling can be just as good as playing with UML. But your job is to communicate -- to the team, to the customer, to the poor maintenance programmer -- just what the heck you are trying to accomplish in your code. The "being the smart kid" should be the easy part. The "getting clarity and agreement on scope and solution space" is what they are paying you for.
I've found that it is very hard to communicate to the customer the contents of a switch statmenet using polymorphism. Hence the reasons for layers of abstraction. Model, design, plan at just enough detail that you can communicate and agree on a strategy with all the stakeholders. Then go play with the bits and bytes.
Whenever I bring stuff like this up to the powers that be, their response is basically just, "Shut-up and code." Then conversations like this take place between employees:
Dilbert: I'd quit and become an entrepreneur, but I don't know how they handle such huge risks.
Wally: Denial, probably.
Alice: We got bought by our arch-rival this morning. Their CEO says he plans to be as "humane" as possible.
Dilbert: He sounds nice.
Wally: Maybe we'll get bonuses.
A programmer is a machine for converting coffee into code.
Design importance has a direct relationship to the size/complexity of the system being designed AND the "system" that is designing the system. By that I mean, design is a loose term. Me and my roomate can design better by talking about a general idea, and then sitting down and writing code while making adjustments where needed. This process wouldn't work in most coroporate cube farms where you have varying levels of skill, vision, ability to learn, types of users, and the all knowing PHB. This is a stereotype. I picture them developing a strict design that has to be followed. What is important, no matter what type of design you have in front of you is FLEXIBILITY. That designs needs to be able to change without throwing the whole system off balance. In fact, design should be a process which includes the implementation of itself.
There are many styles to writing code, but I think that if you are verbose with the naming of your variables, as opposed to naming your variables with unintelligible abbreviations, then that goes a long way to long term code maintenance.
Well written code should read like a book and only need commenting for blocks of code which are not completely obvious as to what their intent happens to be (for example some hack you write up to get around a bug in a library you are using at the time).
One of the most annoying things is the fact I choose not to use an IDE, so developer documentation inserted into the code to describe a function or class or whatever just clutters up the reading of the actual code.
Furthermore, most of the developer documentation of your typical programmer is such that all it describes is the arguments a function takes and what is supposed to be returned, while doing nothing to explain the purpose of the function and why it might be used. In other words, most of the time documentation is useless and just gets in the way because it doesn't relate to anything which makes sense (for humans to understand something new, usually you need to relate it to something they already understand).
So as a general rule of thumb, if you can read the code out loud (or in your head) and you don't constantly have to stop to analyze the code to see what the context of some variable happens to be at any given time, then you are doing a good job. If on the other hand your code cannot be read out loud (because of inaudible variable names), then the odds are some other programmer is going to have to review every other line of your code just to try and make sense of it all.
An ex-employee of mine who I didn't audit very well, spent a ton of time documenting his code in some of the most anally-retentive ways. However, his code just never had any flow. To date, I have had to scrap much of what he worked on because his code was not maintainable.
So in essence, if you have poorly written code, then all the documentation in the world won't do much because poorly written code makes your design inflexible and hard to work with, while well-written code that you can read like a book usually is simple enough that you can mold it into something more useful later on.
So I agree that the code is the design and the design is the code. You can come up with the most elaborate UML diagram known to man, but if the code has no flow to it, and a whole lot of hacks are needed to implement a rigid design structure, then the design overall in the end is going to suck.
If you are going to do documentation, keep your modules small and do it once you are pretty certain the modules won't be changing much from that point on. If you are uncertain, then it is probably best to just ignore the documentation process until things are more set in stone.
I won't argue the point, as he does a better job than I could, but I whole heartedly agree with his take on the matter. Especially that paragraph in the "new" essay (2nd one of the 3 in the linked page) that makes the analogy about doctors in discussing the "Less Able Programmer" problem.
11*43+456^2
But there's no substitute for writing the requirements, feature definitions, scopes and dependencies first, then the comments in the code blocks, then the code, and tar'ing those docs with the source code. The initial hump is steeper, but the total area under the work curve, over the product lifecycle, is much less.
Actually there is: Co-evolving the spec documents, comments, and code. Yes it helps a LOT to plan ahead - and it's a must if you want things to have a chance of getting done in any reasonable time. But trying to cast a spec into concrete in advance of coding is a false economy, too. The spec must remain maleable so the internal problems with it that are discovered during the coding phase can be corrected.
The thing there IS no substitute for is documentation separate from the code itself - whether it's a spec document, good comments, or (preferably) both. Self-documenting code is a falacy - because the code only documents what the code does, not what the code SHOULD do. (Grep is a great program. But it's REALLY broken if what you wanted was cat, or ftp.) Testing doesn't check that a program is "right" - only that it matches a spec. If you're trying to verify correctness of someone else's "self-documenting" code the only thing you can test is the complier. B-)
That applies to you trying to test your OWN code later. You are not the same person you were two months - or even two hours - after you wrote it.
Bantam Dominique roosters crow a four-note song. Once you've heard it as "Happy BIRTHday" you can't NOT hear it that way
While it may be true that designing is the most critical part of coding, it's dangerous to equate the code and the design. Because that implies, obviously, that writing code is the same as designing it, so just skip any forethought about design concerns and launch right into the coding.
I will admit to being a project manager, not a developer. And I know that thinking through requirements and design specs is the "eat your vegetables" part of programming, and no one really enjoys it nearly as much as writing code. But I constantly see "code without design" being one the the easiest ways to get code that crashes, throws unidentifiable errors, won't handle valid input, or will produce invalid output.
Good design matters. Good coding matters. They go together, but they're not the same.
It's always seemed to me that design and coding are more than a bit like buiding a house and using carpentry tools. The world's best carpenter won't build much of a house unless someone's done the design (even if it's just one more 3-bedroom ranch he's built many times before -- that design is imprinted in his memory.)
But, you can't live in a design, so both skills are needed.
In the end, people who stand around and argue that good carpenters don't need designs, or vice versa, miss their completion date and lose the customer.
-- Slashdot: When Public Access TV Says "No"
The idea is that great code resembles a picasso more than a f-16 fighter.
Picasso could not tell people how he did it, or rather people could not understand picasso's explanation.
An F-16 fighter, however, given enough years of schooling, could be explaned in great detail to anyone. This is why, although incredibly complex, there are thousands of F-16s out there. Yet there are only Picasso's picassos.
Likewise a great coder can't really explain how he wrote the great code. He just could. You can see the result, admire it, copy it even. But to apply the same "creative process" to a different problem, you'd have to be the original programmer.
I say this is why great programming is art and bad programming is not. Just like picasso is an artist and the guy who repainted the wall is not. It's because the "creative process" can't be passed on. It has to be self-invented.
Anything Shakespeare is Shakespeare. Nobody else can write Shakespeare, because they don't have the same creative process he did.
You can study Shakespeare, Picasso, Beethoven all your life and never be able to emulate them. Likewise a great coder's code can be copied, but the process that made the code can't be replicated.
"Piter, too, is dead."
You haven't seen my code. Nothing designed about it.
I assume you work for Microsoft?
I think we can keep recursing like this until someone returns 1
Ultimately, I'd agree that "code is design", but that this is an overly simplified view. Looking at "x = y + z" and knowing an addition operation is being performed is one thng, but what do these symbols stand for? Why is the operation being done? How does this fit into the overall function of the software? These questions start to become more difficult and time consuming for a human being to answer without an overall design as a project increases in size and complexity.
For example, I might be able to look at an init script and, sans documentation, quickly understand what's going on to the point that I can understand and modify the script. It's hard to argue that I could use the same process for contributing a patch to say, PostgreSQL. I guess I'm trying to say that the relative efficency of people using different forms of design (either code, or explicit design documentation) is analagous to algorithmic complexity for programs.
For me, I can stare at the ceiling fan and draw bubble diagrams for weeks, and actually have a decent plan ..... for some definition of "decent".
Then I start coding, and about 10 lines into it I realize I've got a major flaw in my design that I could seen weeks ago if I'd been coding. So insofar as "The Code is the Design" stands in opposition to and absolutist commitment to "Da all Design First, Code Later" I'm 100% for it. Insofar as it stands in opposition to "Think about what you are going to do, then do it" I'm against it. Design should start out big a fluffy, and implementation should start out small and concrete. So by the end of the project, The Design==The Code, but while you are making it, you better think of designing as something different than coding, or you'll end up having no design at all.
I'm starting to sound like "the panther", so I'm stopping now.
Unknown host pong.
Yeah, the code is the documentation and the requirements and the business definition. Of-course it is if you have nothing else. That's what it becomes if noone bothers to update the docs.
Let me tell you something about that. I have worked on way too many projects (including the current one) where this was the case - there was only code, or the docs were so out of date that really, there was only the code. It's horrific in most cases. Certainly there are horror levels but I am serious, it is just freaky.
Do you know what happens to a project without documentation? Let me tell you what happens: the only way someone can maintain it, given strict deadlines and/or budget constraints is by fixing the bugs without actually understanding the design. So your fix becomes just a special rule for a special case and in the worst scenario it is also a fix that only works for a special kind of data. So what happens at the end with such a project? A 30 year old COBOL program situation - too many rules that are not generalized all over the place with all kinds of side-effects. Good luck supporting that shit.
I will take a high level document describing the system any time instead of jumping into the code right away. I prefer to know the components of the system, the main players, where the configurations are, what patterns are used to develop the system before jumping into the code. It is just too damn bad that it does never happen that way.
You can't handle the truth.
The article title is misleading.
It makes it sound like he's talking about coding with no forethought and eschewing all documentation (including all comments) in favor of letting the code be the documentation (the "self-documenting code" falacy that has been touted - and known to be false - since at least the early '70s).
What he's actually arguing is that the steps of the process are misnamed - and that this results in mismanagement. The documents currently called the "design" are just requirements and a high-level / overview documentation of early thoughts. The process currently called "coding" is actually most of the design work.
This is recognized in the silicon industry - where CAD tools have evolved the process of "designing a chip" into something virtually identical to "writing an application". But in the silicon industry the nomenclature is still "designers" for "programmers" - and "verification-" or "design assurance-" engineers for "test engineers".
(The latter, by the way, is a highly skilled specialist {in either software or hardware operations} that many software shops don't use, substituting "testers", or confusing them with testers when they happen to have gotten one by mistake. On the "hard side of the force" such people are normally recognized as high-status (and high-pay) pros - the architect's police force and the designers' respected teammates and designated rescuers.)
Bantam Dominique roosters crow a four-note song. Once you've heard it as "Happy BIRTHday" you can't NOT hear it that way
Take something more tangible like a car design. If you lumped destailed descriptions of all the blueprints for the individual components in a nicely bound document without any overall design schematic how hard would it be for anyone to get an overall picture of how the car would look and feel?
What if you asked your average customer to work out if they'd like the car based on these ideas?
This is very much like what you're asking business analysts and users to do if you provide a source code listing and nothing more. If I was in charge of a project, and that's what you handed me after I gave you business requirements, I'd seek to have you removed from the project.
These posts express my own personal views, not those of my employer
man did anyone actually read the damn article?
He's not saying you don't do traditional software design work, or document. He's saying that if you compare the work that a software engineer does, it is equivlant to the design phase of normal engineering, not the manufacturing phase. That the program you deliver, is in essence, a completed "design" not a manufactured "product".
When you roll out and install this "design" in the target environment, this is the step which equates to normal manufacturing.
It's actually pretty insightful.
Does any other programmers suffer from the paralysis caused by "design staff"? For every project my company starts, someone inevitably gets assigned the task of "designing it". The result is a bunch of incoherent scribbles, quasi-UML documents and vague ideas that us programmers are expected to work from. When we ask for more detail we get an insufficient answer. When we just go ahead and use our own initiative the design dude will moan that we havn't done it exactly how he wanted us to. The whole time I feel like smacking the design guy in the face and saying "why don't YOU fuckin' code it?"
How we know is more important than what we know.
We have ISO at my orkplace. The hardware guys have a sequence of steps of design and manufacture that are well laid out. Getting this applied to the software guys has been more difficult.
One allowable thing is to write test apps to check out areas of coding that one isn't familiar with. This mimics the hardware steps of mockups and prototyping.
Recently I wrote a network app for the first time. Once that experimentation/research was done, I had some useful info to add to the Design (text) Doc. Once I had this much done though, when the time came to "develop" (according to ISO) the developing consisted of nothing more than cutting and pasting my test app, and tweaking some parameters.
I've been wondering about this for a while because it didn't seem right, that I must have been doing something wrong, but the article filled in the missing understanding.
Upon reading this again... I realize that the Micrsoft Solution Framework really gets at this idea very well, while still being applicable to large projects. It also attempts to protect against "releasing demo code". It heavily advocates early and continuous builds with an ever expanding capability, so that the development is always *technically* at a releasable stage (within reason).
Flame away for mentioning MS in a good light.
Given sufficiently high level languages (as appropriate for the app) this would be true.
And God said, "Let There Be Light."
God uses a very high level language: four words, and the hard work is done.
-kgj
-kgj
Writing is not a science, it's an art.
You can codify writing like Heinlein, Herbert, Dickens and Rand.
No matter how many average writers you put together in a room, you won't end up with the Dune saga.
Complexity is the enemy of elegance and power.
C, Lisp, python are so popular because they are elegant, simple, and thus powerful.
It's not its complexity that makes a system great, it's its simplicity.
Likewise Shakespeare.
>Coding is not an art. It's a science. No matter how good the code is, it can be taken apart and understood by others.
Likewise Shakespeare, Heinlein, Asimov, etc. Yet still art. Because while you can reduce it to 26 + punctuation, it's the organization in time and space that makes them unique.
Great code just works, and nobody needs to go back and fix it later, because it's never going to be broken.
If it needs to be modified, you say.
I reply, why?
Because it no longer performs the needed business function you say.
I ask: And that means its broken?
You say: No, it means it needs to do something else.
I Reply: You mean, a different function?
Exactly, you beam.
I counter: Follow the Unix Way: Each program does one thing: What you need is another program.
You slouch. You know I am right.
Zen lesson over.
"Piter, too, is dead."
I can visualize lots of code/processes as UML type
,then perhaps it should be part of an IDE, when you hit NEW PROJECT. Do away with source files and include files and have the whole source in a database with each class in each 'file' or 'table', but do away with files as such, just make em transparent.
diagrams, but I see spending 4hrs drawing some crap as a waste when I could have completed the code by then.
I tend to write my code as nice as possible that even a drunk coder could understand it.
I may code up stuff fast with out UML diags, but if people/others need to maintain it, doing a high level UML or layout diag is easy enough to do on demand. Somethings are sometimes too easy to comprehend so id rather not waste hours doing fancy diagrams putting me to sleep.
Try imaging the UML diag for just IE, I bet theres a high level one, but not one down to each class/logic IF statement.
If UML is soooo important
Liberty freedom are no1, not dicks in suits.
Over the years, management has attempted to quantify software development. They've pointed to the visible tools of the trade, the flow charts and the UML, and a lot of them have mistaken that for the process of designing software. In fact the only thing that you really need to design software is an understanding of your customer's requirements (Or your requirements) and the know-how to turn that into a working system. Unfortunately that's not quite so easy to quantify, and so most management types ignore those traits in their programmers.
The folks who are always going on about six-sigma and CMM level 5 always seem to be stumped as to why they can't just give a chmpanzee a UML generator and churn out working project after working project. Turns out that despite all efforts, software design still requires you to think about your problem and how to get from where you are to where you want to be. Go figure.
I'm trying to teach myself to set people on fire with my mind... Is it hot in here?
I really can't believe this has been modded so highly.
Saying that it should just work is great, but what does that mean when an OS is being developed, and what happens if it doesn't just work?
What happens if circumstances change and the code needs to be modified to take a new situation into account?
This philosophy ties the programmer to the code for life. That means you don't get promoted, you don't get to work overseas, you don't get much. And if you leave, the code will be replaced eventually, no matter how perfect it was at the time.
Code is not an eternal thing. It is not timeless. If it were, your point would stand.
I suspect there are a lot of developers on Slashdot who like to think they're artists, and that's why your posts are being modded so highly. You may be the best programmer on the face of the planet, but then your error is in assuming that every other programmer is as good as you.
Art, however, can have the ability to stand apart from Time. A great work of literature, music, painting or physical movement can be enjoyed hundreds of years after it was created. Some are not meant to last that long, and their brevity adds to their enjoyment.
Face it. Code is not timeless. All code will require updating or replacing at some future point. You're setting your code up for removal by writing something that only makes sense to yourself.