[Date Prev][Date Next][Thread Prev][Thread Next][Author Index][Date Index][Thread Index]

Re: [zzdev] Proper abstractions

Hi Tuomas--

I agree about abstractions, but the particular way you coded this one
seems to be really clumsy to me -- a nameless inner class for each
iteration. Why not use something like an enumeration, i.e.:

ZZAlternator i = new ZZAlternator(...)
for(i.start(accursed); i.more(); i.next()) {
    if(done.get(i.cell) != null) { i.stoppart(); continue; }
    if(i.distance() > rows) { i.stoppart(); continue; }
    col[i.steps() + cmain] = i.cell;
for(<every cell in col>) {
     for(i.start(<current col cell>); i.more(); i.next()) {
		// plac the cell

Possibly we could even abstract out the recursion:

ZZAlternator alter = new ZZAlternator(...);
ZZDimRecursor rec = new ZZDimRecursor(dims, alter, ...);
for(rec.start(accursed); rec.more(); rec.next()) {
    if(done.get(rec.cell) != null) { rec.stoppart(); continue; }
    if(rec.distance() > maxdepth) { rec.stoppart(); continue; }
    // (place cell)

- Benja

Tuomas Lukka wrote:
> Whew, finding the proper abstraction can make things a LOT easier.
> One I just discovered is that going along a rank in two directions at
> once (alternating), starting from a given cell is what made the vanishing
> and row-column views so complicated. Abstracting this out to ZZIter made
> such a difference (also of course separating rowcol from vanishing).
> Now, we can start thinking about bootstrapping in an easier way since we
> have that abstraction... I'm thinking of starting to code views first in
> terms of cells to gain some experience.