Lew wrote:
Gene Wirchenko wrote:
Lew wrote:
[snip]
As with non-inner nested classes, if the type is needed by any other class
and its semantics are not tightly bound to those of the proposed
outer class, a standalone class is probably more appropriate.
If the semantics are tightly bound to the proposed outer class, and the sprite
state does not depend on the outer class instance's state, then a
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
I do not follow this. Please explain.
nested class might be appropriate.
If an instance of the prospective nested class does not use any of the instance
state of the prospective outer class, then it should not be an inner
class, but it might be a candidate for a nested class.
If it does depend on the state of the outer-class instance, for example if it
references an instance variable of the outer-class instance, then it
will have to be an inner class. This follows directly from the
inability of a static member to access an instance member.
Thank you. It was a terminology issue. I got this from Oracle:
"Nested classes are divided into two categories: static and
non-static. Nested classes that are declared static are simply called
static nested classes. Non-static nested classes are called inner
classes." Are these the definitions that you are using?
Yes. I should have said "static nested class" vs. "inner class"; thanks for the reminder.
but forgot to specify "static" when I said "nested". Thanks for having me clarify and, along the way, refresh the rigor of my terminology.