Want to read Slashdot from your mobile device? Point it at m.slashdot.org and keep reading!

 



Forgot your password?
typodupeerror
×
Programming IT Technology

The Code Is The Design 354

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."
This discussion has been archived. No new comments can be posted.

The Code Is The Design

Comments Filter:
  • I'll Add... (Score:4, Insightful)

    by Sexy Commando ( 612371 ) on Tuesday March 01, 2005 @06:38PM (#11817483) Journal
    The code is the comments.
  • boiler plates (Score:2, Insightful)

    by BBrown ( 70466 ) on Tuesday March 01, 2005 @06:38PM (#11817484)
    sigh. I hope this reads better than the headers and comments I normally struggle through when trying to understand another coder's thoughts.

  • Re:I'll Add... (Score:2, Insightful)

    by Inkieminstrel ( 812132 ) on Tuesday March 01, 2005 @06:39PM (#11817493) Homepage
    In that case the code is misleading.
  • Re:Oh Boy. (Score:0, Insightful)

    by Anonymous Coward on Tuesday March 01, 2005 @06:40PM (#11817502)
    Fuck 'em.
  • by Anonymous Coward on Tuesday March 01, 2005 @06:41PM (#11817506)
    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.
  • by Anonymous Coward on Tuesday March 01, 2005 @06:43PM (#11817538)
    Is his thesis useful, actionable in a way that is substantially different than what people were/are doing already?
  • False Economy (Score:5, Insightful)

    by Doc Ruby ( 173196 ) on Tuesday March 01, 2005 @06:45PM (#11817549) Homepage Journal
    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.
  • A nice quote (Score:5, Insightful)

    by tcopeland ( 32225 ) * <tom@@@thomasleecopeland...com> on Tuesday March 01, 2005 @06:47PM (#11817576) Homepage
    > 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.
  • by torpor ( 458 ) <ibisum&gmail,com> on Tuesday March 01, 2005 @06:50PM (#11817616) Homepage Journal
    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.
  • Re:boiler plates (Score:4, Insightful)

    by mccalli ( 323026 ) on Tuesday March 01, 2005 @06:50PM (#11817617) Homepage
    I hope this reads better than the headers and comments I normally struggle through when trying to understand another coder's thoughts.

    Fair enough, but would that same programmer have produced a decent design anyway? UML, pseudo-code, anything?

    In my opinion if their code is disorganised, their design would be too.

    Cheers,
    Ian

  • Re:False Economy (Score:5, Insightful)

    by nagora ( 177841 ) on Tuesday March 01, 2005 @06:51PM (#11817624)
    C++ is more "self documenting" than most languages, when coded properly.

    That's what they all say. Every language is self documenting when "coded properly". C++ failed in part because of the unfounded belief that its supporters had in its abilities, all of which resided not in the language itself but in the programmer's ability to "code properly". Sadly, there is nothing in the language to enforce such coding practice and it is as rare in C++ as any language.

    TWW

  • by syousef ( 465911 ) on Tuesday March 01, 2005 @06:54PM (#11817664) Journal
    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.

  • Re:Less is more (Score:3, Insightful)

    by YU Nicks NE Way ( 129084 ) on Tuesday March 01, 2005 @06:55PM (#11817667)
    Would you like to point at a particular file about which you're going to say that?
  • Re:I'll Add... (Score:2, Insightful)

    by Ohrion ( 814105 ) on Tuesday March 01, 2005 @06:59PM (#11817717) Journal
    "The code is the comments." This actually only works when both the author as well as the maintainer(s) are good coders. Unfortunately in the real world, this usually isn't the case. I've read some really crap code with GoTos all over the place where the author didn't put comments in, and the names of the procedures were all similar to "DoWork". Therefore I try to promote the use of comments in our work, especially if anything gets complex or uses non-obvious APIs.
  • Sigh (Score:4, Insightful)

    by DanielMarkham ( 765899 ) on Tuesday March 01, 2005 @07:02PM (#11817752) Homepage
    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.
  • by Mr. Slippery ( 47854 ) <tms&infamous,net> on Tuesday March 01, 2005 @07:05PM (#11817783) Homepage
    Does this sound a lot like "The Network is the Computer" to anyone?

    It does - but that phrase seems to be the submitter's invention, at least from a cursory look at the fine article. Reeves's point is much more sublte and interesting:

    The final goal of any engineering activity is the some type of documentation. When a design effort is complete, the design documentation is turned over to the manufacturing team. This is a completely different group with completely different skills from the design team. If the design documents truly represent a complete design, the manufacturing team can proceed to build the product. In fact, they can proceed to build lots of the product, all without any further intervention of the designers. After reviewing the software development life cycle as I understood it, I concluded that the only software documentation that actually seems to satisfy the criteria of an engineering design is the source code listings.

    ...

    The overwhelming problem with software development is that everything is part of the design process. Coding is design, testing and debugging are part of design, and what we typically call software design is still part of design.

    It may be that he's using "design" in a more classical engineering sense than most of us coders do.

  • I agree completely (Score:5, Insightful)

    by MCTFB ( 863774 ) on Tuesday March 01, 2005 @07:09PM (#11817815)
    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.
  • by photon317 ( 208409 ) on Tuesday March 01, 2005 @07:10PM (#11817828)
    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.
  • by reallocate ( 142797 ) on Tuesday March 01, 2005 @07:13PM (#11817850)
    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.

  • Re:boiler plates (Score:5, Insightful)

    by Rei ( 128717 ) on Tuesday March 01, 2005 @07:16PM (#11817875) Homepage
    Part of the problem with headers and comments is the exact same problem with pseudocode: they're not maintained. If they're wrong, the code program doesn't break. The longer they sit around, the less likely they are to be accurate. That's why self-documenting code is a lot more important. Simple, straightforward functions, long, descriptive variable names and functions, etc. If you have to comment a "section" of a function call with a relatively short but important comment, why not just break that part out into its own function call with a descriptive name similar to the comment that you'd use? It's not like the program will run slower; modern compilers can choose whether to inline functions or not better than programmers can in most cases.
  • by starfishsystems ( 834319 ) on Tuesday March 01, 2005 @07:21PM (#11817922) Homepage
    In reality the sequence always goes:
    requirements - design - implementation
    If you subsume the design into the implementation, then someone who goes looking at the implementation will have no way to distinguish between what was a design decision from what should be relatively arbitrary implementation decisions.

    Why is the distinction important? Two reasons, really. One is versatility. You don't want to constrain a design to having just one implementation. It's useful to be able to choose among competing implementations, say for the Java Virtual Machine for example, because implementation tradeoffs tend to have practical, often emergent and unforseen, consequences.

    The other is containment, an aspect of modularity. Since errors, including security vulnerabilities, can be expected to arise during both design and implementation, the most basic way to identify and manage them is to separate them during development. No implementation can make up for bad design, not if it's correct with respect to that design anyway, but at least the effects of a bad implementation can be addressed without breaking the design. But only if the two are clearly separated.

  • Re:Oh Boy. (Score:5, Insightful)

    by museumpeace ( 735109 ) on Tuesday March 01, 2005 @07:22PM (#11817931) Journal
    You are trolling but there are much better educated responses than your taunt deserves.
    Well, I am no UML monkey and I have seen software development process overdone so badly even the lowliest coder had rigor mortis. But let me share a few experiences that may be exceptional but I doubt it.
    1. I have actually worked with a programmer-turned-project-lead who often stated exactly the premise of TFA as a defense of his designs. He also used design reviews and other people's UML as target practice for a particularly nasty and apparently insecure dismissiveness. He was one of the most brilliant coders I ever met. He understood many programming principles better than others but had a pathological aversion to sharing insight. He was utter hell to work with, poison for the work and the workers in the team. His designs ultimately foundered when noone but him could extend or maintain them.
    2. Though language and architecture are not completely seperable, its a shitty design that can't be expressed in any thing but some particular language...saying UML or flowcharts or whatever gets in your way is just a huge hint that you don't know how to express your idea or you don't really have an idea.
    3. There is not much argument about the proclivities of programmers: they don't read other peoples code, not often enough, not with sufficient comprehension, not unless they are paid to maintain it. That is a generalization of course but with way too few exceptions. Comments, as others will surely point out, are more important for the longevity of code than the code itself. But commenting that can stand in for requirements and specifications? Virtually nonexistent, there is less of that than there is of good UML. I have been to the long, expensive funerals of way too many programs and sometimes, the companies that were built upon those programs to have much respect for an aproach to software that de-emphasises visibility of the big ideas and critical commonalities in code. Those are aspects that good design documents capture. Those are what make real software, software that can be changed by someone other than the author, software that can be quickly re-tooled for another market or a new platform, hang around long enough to make a company some money.
    I'd say the great failing of UML or other design languages or symbology is only that it is not tied to code in such a way that code changes back-propagate to the design document. Its just plain hard work to keep design and code on the same page [litterally and figuratively] but that's what you would pay a competant programmer to do. And that's why JavaDoc and its ilk are my preferred solution in this area[ but I can't point you to a solution that completes the higher level documentation job.]
  • Re:I'll Add... (Score:5, Insightful)

    by DunbarTheInept ( 764 ) on Tuesday March 01, 2005 @07:27PM (#11818000) Homepage
    That doesn't fix anything because in general I have observed that the same author who would write impossible to understand code will also write impossible to understand comments that actually mislead you more often than they help you. People who are bad at explaining a precise algorithm's details in an elegant form using Java, C, Perl, or Python are also bad at explaining it in an elegant form using English, for the exact same reasons. They're just not good at communicating carefully and clearly in general.

  • by Anonymous Coward on Tuesday March 01, 2005 @07:29PM (#11818016)
    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.
  • by roman_mir ( 125474 ) on Tuesday March 01, 2005 @07:33PM (#11818050) Homepage Journal
    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.

  • by Ungrounded Lightning ( 62228 ) on Tuesday March 01, 2005 @07:38PM (#11818092) Journal
    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.)
  • by eraserewind ( 446891 ) on Tuesday March 01, 2005 @07:40PM (#11818106)
    The whole point about software is that the "carpenter" is supposed to be automated. If the design is complete there is no need for manual translation of the design to the code. Unfortunately it's often far from complete, making many design documents a)next to useless, b)out of date the instant coding begins. That's what stuff like UML tools are trying (and largely failing miserably) to solve.
  • by syousef ( 465911 ) on Tuesday March 01, 2005 @07:42PM (#11818119) Journal
    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.
  • I have to agree (Score:3, Insightful)

    by studog-slashdot ( 771604 ) on Tuesday March 01, 2005 @07:50PM (#11818189)
    Having RTFA, I agree with Mr Reeves.

    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.

    ...Stu

  • Re:False Economy (Score:5, Insightful)

    by Viking Coder ( 102287 ) on Tuesday March 01, 2005 @08:05PM (#11818370)
    I can't read someone else's architectural design. I have no idea how the problem domain works. I have no idea what kinds of generalizations and concepts were used to break the problem down. I have no idea which facets of the problem were important, and which could be ignored. I don't know anything about the material sciences involved. What I don't know could just about fill the Grand Canyon.

    Why do you presume that reading a software design (source code) would be any different?

    It's hard to read a design - even a good one - until you "get it." Until you grok it. Those other documents you talk about are freaksihly important, and the author doesn't deny that - but they are not the design. They are of fundamental importance to the success of the design, but we shouldn't pretend that they are the design.

    You're absolutely right to refer to those things as "documents." They help document. But they are not the design.

    He's not saying skip design, he's saying that you do what you have to, in order to think the problem through (some design, some documentation, some testing, etc.), and then you work on the real, actual design (the source code.)

    Refering to "the initial programmer" like you do is completely ignoring everything he's saying.
  • Re:Oh Boy. (Score:3, Insightful)

    by jallen02 ( 124384 ) on Tuesday March 01, 2005 @08:15PM (#11818513) Homepage Journal
    Not such a brilliant coder then ehh?

    The best way I have ever heard someone explain how you can tell of an interface is good is if you look at it and think, "Of course. How else would you do it?". The design is natural and flows well for your average *skilled* programmer. If someone is very taltented but no one else can understand their designs then the code is not maintainable. Code that is not maintainable is not good. Creating unmaintainable code is something BAD programmers do. So you should consider that fella brilliantly BAD ;) The strongest strength anyone can have is realizing their limits and working around or past them. If someone never realizes they are limited they will never grow ;)

    Jeremy
  • Re:False Economy (Score:3, Insightful)

    by AuMatar ( 183847 ) on Tuesday March 01, 2005 @08:54PM (#11818978)
    The length is a poor idea. What if I'm doing GUI work- X and Y refering to cartesian coordinates make great sense. Len as a length for something does as well. It isn't as uncommon a case as you'd think at first.

    Dictionary attack- how many devs do you know who use the full name rather than an abbreviation? I can't blame them- ppm makes sense and is much easier than parts_per_million. You also have to get devs who can spell (I went through a 6 kloc assembly program misspelling the work caffeine. This word was probably used on about 300 of those lines. Never once had a compiler error, I misspelled it the same way every time- put the i before e. Didn't realise it til I handed it in and the TA pointed it out).

    Indentation- changing it once its in is a bad idea, it can hurt CMS systems. I don't mean simple ones like CVS, I mean higher level abilities like out of order removal of changes.

    Comment density- is too dense bad, or good? Probably in between, and probably depends on subject matter. I don't want a paragraph on a get function, but complex image quality algorithms deserve them. I won't get the linear algebra its doing without them.

    code complexity- I think we need a turing machine again

    Lots of nesting/mid function returns: mid function returns are good, its what stops your code from looking like spaghetti to avoid them (avoiding them usually turns into your other dislike here- increased nesting). Lots of nesting- some things need a lot of nesting (or incredibly complex if statements, which may be worse). Telling when is an exception requires a Turing AI again.

    Its a basic problem with computers- they can't judge when a rule should be followed and when not. You end up either spending a large amount of time doing pointless things to get the system to like it (a pain in the ass and leads to ugly code and unhappy coders), you get 10 billion warnings from the compiler (leading to real problems getting lost in the noise), or you get rid of the system.

    Basicly- stick to the code reviews. Your fellow devs are AIs capable of passing a Turing test. If they can't you have problems in the first place :)
  • Re:False Economy (Score:3, Insightful)

    by Javagator ( 679604 ) on Tuesday March 01, 2005 @09:17PM (#11819169)
    I would not call C++ exceptionally self documenting, but well written C++ can be very elegant. There is a chapter in Meyers Effective C++ titled, "Say what you mean and mean what you say." My copy is at work, but he mentions that the use of const, virtual functions, abstract functions, and other constructs can reflect design decisions. Also, the proper use of constructors and destructors can ensure that objects are always initialized properly, that an object stays valid over its life time, and releases its resources when it goes out of scope. Proper (as opposed to wild and "creative") uses of operator overloading and copy constructors can produce elegant easy to read and understand code.
  • Re:Oh Boy. (Score:3, Insightful)

    by Doomdark ( 136619 ) on Tuesday March 01, 2005 @09:38PM (#11819320) Homepage Journal
    I'd say the great failing of UML or other design languages or symbology is only that it is not tied to code in such a way that code changes back-propagate to the design document. Its just plain hard work to keep design and code on the same page

    And I maintain that UML is to programmers what bicycles are to fish...

  • by Anonymous Coward on Tuesday March 01, 2005 @10:04PM (#11819559)
    Sorry, I work embedded. Without some clue of what the physical interfaces are and are intended to be. Without some way of getting a system's engineer to be able to understand the code's design in the context of the hardware design, electro-mechanical components, etc, the code is useless, probably even dangerous. I'm not saying UML is the answer (actually, I believe it's part of the problem because it leads to lazy, incomplete definitions of the system), but some formal, reviewable (by folks other than other programmers) requirements and design product is crucial to a successful embedded project. Maybe the app engineers have an easier time just making pretty code, or maybe I'm not skilled enough to read-the-minds of the system's engineering folks.

    BTW: I can but hate reading schematics and VHDL to figure out what that damn FPGA does. Thank g*d for hardware engineers who write down what the registers are, how they work, etc. How do you think the system's engineer (or your QA engineer) feels about having to read your code to figure out what the damn firmware does, let alone what it's supposed to do.

    Worked on a project once where I was asked to update a broken power control system. I asked what the system had to do (i.e. what are the requirements and interfaces) and the answer was, "Well, we didn't and don't have time to write requirements and interface definitions down. Why don't you read the existing code to figure that out." Grrr.

    Folks, if you're going to do the "code is the design" thing, PLEASE don't write any safety critical software. Thanks.
  • by waveclaw ( 43274 ) on Tuesday March 01, 2005 @10:05PM (#11819568) Homepage Journal
    It's always seemed to me that design and coding are more than a bit like buiding[sic] a house and using carpentry tools.

    I find it funny that you and many other people use Carpentry as a metaphoric model for coding. However, after working as a carpenter for over half a year I have to say that it is appropriate.

    The world's best carpenter won't build much of a house unless someone's done the design

    Houses are built as a variation on a template for their entire neighborhood. In richer areas, more variation occurs, but then more money is poured into the project. In older areas, the variation in house styles is mainly due to renovation by the various tenets over the years.

    Unfortunately, most code written is mostly re-inventing of the wheel at the design and implementation level. Closed source techniques necessitated this for a long time (the highly-copyrighted Numerical Recipes books, anyone?) Open source should change the re-inventing of the wheel, but I still see a lot of people re-inventing the wheel 6 or 7 times out of 10 projects. The 8th and 9th will probably shoehorn in a custom library of crufty utility code they wrote years ago for college homework.

    But, you can't live in a design, so both skills are needed.

    Never owned a house, have we? People who can't afford to spend a long time in a motel/hotel/vacation-resort will live in half finished (but up to code) houses and use kitchens that are being actively remodeled. Similarly, you can go grab open source projects from sourcefroge.net to do little more that compile and jump right in. If I recall correctly, I had to code a Ethernet driver module for the 1.7 kernel series. No driver existed for my card. My RedHat Linux 5.6 would loose network functionality after the install. I this any different from living in a multi-story house while the bathrooms on the other floors are being built?

    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.

    A lot causes schedule slippage in both coding and carpentry. Both in carpentry and in programming projects regularly go over schedule. Customers are told that sickness and surprises will cause the schedules to slip on any construction. With programming projects it is hard to tell people that extra, unexpected work is needed. Showing customers the termite damage in a wall is easy, showing the hacks in a networking library is not.

    The correct people and only the correct people talk to customers. These people typically are the people or work with the people who do the design. With coders/software-designers being stereotyped as uncouth and kept away from the customer, the design may not reflect reality. When the customer is not aware of what they are asking (i.e. requirements creep) it is easy to tell them that additional carpentry and materials are not free. Management and the Customer seem to think that additional software features are not free. Your customer facing people must know when to say 'No' and when to say 'it will cost THIS much,' not pander to the idea that coder-time is free because the results aren't physical.

    With trim and paint to cover errors, you can get away with 'rules of thumb' in carpentry[1]. Some voids are needed to allow for expansion and contraction of joints. Management never seems to understand the need for well-defined APIs or plug-in architectures (let alone security or data integrity.) Plus, the computer is a little less tolerant of taking the software equivalent of power tools to the virtual memory manager.

    Come to think of it, carpentry is a very bad model for programming[2].

    ------
    1. Literally a thumb used as a ruler. With the massive non-squareness of some people's idea of a *square wall*
    you have to hate the flexibility of wood over long periodic thermal cycling. Here's a hit: like with bad code, a slightly off wall creeps further out of square with t
  • Re:Oh Boy. (Score:4, Insightful)

    by timeOday ( 582209 ) on Tuesday March 01, 2005 @10:11PM (#11819615)
    I'd say the great failing of UML or other design languages or symbology is only that it is not tied to code in such a way that code changes back-propagate to the design document.
    Well, Rational had (has?) their idea of "round-trip design," which in practice meant you could generate diagrams from code.

    We never found that useful, but what we did do was generate all header and implementation files from the diagrams. To change the class, you changed the diagram and regenrated the files. This way ensured the diagrams accurately reflected the static interdependecies among classes. All the real logic was in the code blocks, of course, which the tool simply copied verbatim from version to version.

    Was it useful? I guess so. I'm not sure it was more useful than the same information extracted into in a textual document more like Javadoc though.

    Anyways, yeah, you need requirements and specifications too. But don't forget those requirements and specifications are just as buggy as code that's never been compiled or run, because that's exactly what they are - very high level pseudocode, that can't be subjected to the rigor of execution in themselves.

  • by chris_mahan ( 256577 ) <chris.mahan@gmail.com> on Tuesday March 01, 2005 @10:16PM (#11819657) Homepage
    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.

  • Re:I'll Add... (Score:3, Insightful)

    by ShieldW0lf ( 601553 ) on Tuesday March 01, 2005 @11:34PM (#11820268) Journal
    If your design is good, the code tells you what it does better than comments.

    Comments shouldn't be telling you what the code is doing, they should tell you why it's doing it.

  • Re:Dangerous.... (Score:4, Insightful)

    by dubl-u ( 51156 ) * <2523987012@noSPAm.pota.to> on Tuesday March 01, 2005 @11:58PM (#11820423)
    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.

    Sweet Jesus! Did you even read the articles linked? For example, this part?
    Nevertheless, people keep insisting that my contention of "the source code is the design" means "don't do design, just code." I never said anything of the sort.

    If you're going to misunderstand the guy, you could at least do it in a new and interesting way.

    I will admit to being a project manager, not a developer.

    Ah, so that's why you feel qualified to give opinions on something you didn't even take the time to do the reading on.
  • by Greyfox ( 87712 ) on Wednesday March 02, 2005 @02:06AM (#11821046) Homepage Journal
    Back in the day you did flowcharts or pseudocode to get a good idea of what you wanted the computer to do before you put card to keypunch. Today you do UML or pseudocode to get a good idea of what you want the computer to do before you start coding. Oddly, despite the new "paradigms" and "methodologies," project failure rates seem to remain constant.

    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.

  • by GaryPatterson ( 852699 ) on Wednesday March 02, 2005 @04:29AM (#11821491)
    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.
  • Re:I'll Add... (Score:2, Insightful)

    by old man moss ( 863461 ) on Wednesday March 02, 2005 @04:32AM (#11821503) Homepage
    "writing out the methods as do-nothing stub routines"

    This can be dangerous. I once tracked down a nasty bug to a method which had been left as simply "return 0.0" (by someone else)

    The really sad thing was that there was also a test program for the code... unfortunately it only checked that f(a) + f(b) = f(a + b) ... which it did of course.

  • Re:False Economy (Score:3, Insightful)

    by deadlinegrunt ( 520160 ) on Wednesday March 02, 2005 @01:45PM (#11825056) Homepage Journal
    "... he mentions that the use of const, virtual functions, abstract functions, and other constructs can reflect design decisions"

    The nexus here is the inability of people to agree on a level of competency to understand how true Meyers, and your post, are. C++ is not only capable of showing what the code does (duh, it has to) but also reflecting design decisions. The only reason I can understand the people that do not accept this is because of limited understanding or total lack of it.

    Given its "hardcore" industrial toughness, C++ is an elegant [and complicated] language; all things considered. Like it or not, it is successful at acheiving its primary goals and then some.

    Yes - it has its warts, as well as its beauty. People often show disdain for things they don't understand more times than not by default as opposed to having valid reasons for doing so. Obviously it is not a silver bullet but it is an effective bullet. Boils down to who holds the gun.

"Life begins when you can spend your spare time programming instead of watching television." -- Cal Keegan

Working...