barrym95838 wrote:
GARTHWILSON wrote:
... and it was over 100 lines for one word. Looking at it though, I couldn't really see any way to factor it and give the factors meaningful names that were any shorter or more descriptive than the code and comments in it. You would have ended up with code that was more unreadable, and more inefficient because of calling all these single-use "subroutines". I seem to remember it had a giant CASE statement that was very clear. I seem to remember Chuck Moore doesn't like CASE statements. Jump tables are good if the input numbers are consecutive and without big gaps; but that's not always the situation.
Global optimization is an inexact science, and you were probably correct that the word in question was optimal. The question I would ask: "If you step way back and look at the entire picture, is there a clever way to avoid having to code that particular word in the first place?"
Sometimes the answer is yes; but there have been times that I've seen someone advocate for something simpler when clearly they didn't realize why their solution would not work. (This was usually in circuits, not software, but the principle still applies.) After much time spent to try to communicate it, the light finally goes on, and they realize why it won't work. Other times, I could not convince them. That's usually the boss, so instead of arguing, I built up something the way he was so sure would work, and demonstrated it, and then he goes away scratching his head, muttering something about, "I don't understand it. I was
so sure it would work!" (and his respect for his engineers increases.) Other times, it was the other way around, and I went through with it to prove it does work.
Attachment:
Dilbert1.jpg [ 55.1 KiB | Viewed 1101 times ]
Anyway, although shorter code is
usually clearer and more efficient, that's not
always the situation. In the case of factoring carried too far, the code is not actually shorter, just more chopped up, and may require a lot of looking up of what the ingredients do to figure it out.
Quote:
It reminds me of a joke that I heard on the radio years ago that still makes me laugh. An astronaut and a cosmonaut were talking at a bar over a couple of drinks, and the astronaut pulled out a fancy ink pen that could survive extreme cold and heat, and write upside down and in zero G. He bragged about how NASA had spent hundreds of thousands of dollars developing it and the ink that it used, and that it was an example of what was possible in the 'free' world. The cosmonaut instantly recognized this dig at his country, but had a perfect reply: "On Soyuz, we use pencil."
You can see where my analogy is clumsily headed, right? Is the routine you mentioned the 'INK' for the pen?
I agree, although I will also comment that in a place I worked in the mid-1980's, I sometimes had to go into the cleanroom where they did the wafer fab, and everything had to be lint-free and dust-free; so you had to wear special clothes, use special lint-free paper, and so on. A pencil which would produce graphite dust was definitely out, but a common pen would be fine. (I'm sure a normal pencil would have been fine in the spacecraft though.)