Re: Stevey and overengineering



On Feb 13, 6:36 am, Jeff Lait <torespondisfut...@xxxxxxxxxxx> wrote:
You don't seem to have learned the lesson of the philosophy. The
"solution" isn't to compactify and remove white space until it fits on
a screen. That is like fulfilling a 5 page essay requirement by
tweaking the font size. It fulfills the text of the requirement while
violating the spirit.

The answer is, when you are faced with too long a function, to find a
way to factor out or simplify the function until it does fit on a
screen.

Generally, I try to separate into smaller functions first. The macro
thing is for things that I use a lot, and take up lots of space. Take
a look at the all shortest paths algorithm:

for (int i = 0; i < n; ++i) { // all shortest paths algorithm
for (int j = 0; j < n; ++j) {
for (int k = 0; k < n; ++k) {
if (distance[j][i] + distance[i][k] < distance[j][k]) {
distance[j][k] = distance[j][i] + distance[i][k];
}
}
}
}

I've used it so often that this is what I tend to write instead:

#define f(x,y) for (int x = 0; x < y; ++x)

f(i,n) f(j,n) f(k,n) if (distance[j][i] + distance[i][k] < distance[j]
[k]) distance[j][k] = distance[j][i] + distance[i][k]; // all
shortest paths algorithm

My code becomes full of little idioms like this (such as table driven
logic for moving up/down/left/right), which I recognize, but other
people don't. (YES, I KNOW THAT #define MACROS ARE EVIL. SO AM I. I
KILL C# PROGRAMMERS FOR PLEASURE.)

Even then, the rule should be taken with a heaping tablespoon of
salt. Some algorithms are naturally ugly and intractable. Splitting
them up along unnatural lines to fit a "one function one screen"
paradigm merely increases your LOC and maintance burden. And to
delete a comment to fit such a requirement? Unforgivable.

Keeping each function simple is meaningless if doing so results in
your program-as-a-whole becoming too complicated.

Of course, I tend to use 100 row screens now, so what constitutes one
screen is up for debate.
--
Jeff Lait
(POWDER:http://www.zincland.com/powder)

It isn't a hard and fast rule. But algorithms which force me to
violate it are very very rare, especially since I keep my text editor
as big as possible.
.



Relevant Pages

  • Re: Version Control Strategies For Block-Based Forths?
    ... front of the old versions of screens. ... I remember doing many paper comparisons, along the lines of the thin paper overlay method described by John Passaniti earlier. ... The "triad" was a classic printing pattern for blocks in polyForth where 3 blocks would fit on one printed page. ... Since most revision control systems assume that there are a combination of pieces that need to be put together and most block based systems assume that there are only one set of blocks, which typically fit onto a floppy, there was not much effort put into tools to manage the source base. ...
    (comp.lang.forth)
  • Re: Bloody hell, how hard?
    ... on the VTR for a nice double bubble airblade. ... turn base metals into gold & then back into base metals. ... about in a cramped shed, i got it to fit, but why do aftermarket screens ... *never* fit correctly, it's only a mm here & there, but come on. ...
    (uk.rec.motorcycles)
  • Re: Preview of a Stackless Zope Application
    ... Huy Do wrote: ... to fit on smaller screens. ... It needs some design work to make the necessary framework ...
    (comp.lang.python)
  • Re: Bloody hell, how hard?
    ... The Fabbri screen I fitted to the SV required some slight modification ... I've had a few Airblade screens and they've been just as good. ... It didn't fit properly anywhere and ended up chucked in the back of my ... Fireblade 929 (For sale) ...
    (uk.rec.motorcycles)
  • Re: Add-Remove Program file corrupted?
    ... Thanks for the quick response. ... Next time I'm over at my son's house, ... it shows about 3 full screens of just blank white space; ...
    (microsoft.public.windowsxp.general)