class design question (inner classes)

coxalan coxalan at web.de
Tue Sep 11 09:09:15 PDT 2007


Regan Heath Wrote:

>  > The class SymmetricGroup
> > should collect everything that all of its elements (the object of the
> > class Permutation) have in common.
> 
> Like .. (list please).  Are they all data members or methods as well.
 
Definitely methods, like
uint order()
which returns the number of the elements of the group.

For the SymmetricGroup there are no other data members, but for other Groups there could be arbitrary data members (like a big array where the multiplication results are stored).

> [...]
> Ok.  I think I have reached the limit of my usefulness here :)
> 
> Someone else is bound to have some ideas.

It was my fear that I put too much technical mathematics stuff into my posting.

I already put this question (in C++ form) into a mathematical internet forum, but then the  OOP-design part of the discussion got stuck at a very basic level... :-)



Now I rethought my question and how I can put it on a more abstract level to get out the math part.

I guess my problem comes down to this point:

class Outer {
    class Inner {
        [...]
    }
    [...]
}

main() {
    A a = new A();
    [... initialize many a.Inner objects here ...]
}

Once that "a" is initialized, te reference "a" stays constant all the time. So all further references/pointers to "a" are redundant. Especially, the references to "a" stored in "a.Inner" inner objects are redundant.
So if there was a way to tell the compiler that the reference a will never change, the compiler could do the optimization and skip all these inner-class-references.

Now the question is:
Is there currently a way to achieve a satisfying, equivalent result?
If not: Should I make this a feature request?

coxalan



More information about the Digitalmars-d mailing list