#Class Nesting vs Packaging (repost)

4 messages · Page 1 of 1 (latest)

indigo holly
#

Should packaging be used over just nesting the classes and why. Storing classes in a package as apposed to nesting them in a relevant or parent class. I am mostly interested in the difference in efficiency, but general information on the similarities and differences between class nesting and packaging would be helpful. I am not interested in whether it's non-standard or hard to visualize.
The general situation where im focused on is below. That is the storage of many classes that are extensions of a class.

abstract public class Creature {
    // variables methods etc.
    abstract public class Humanoid extends Creature{
        // variables methods etc.
        public class Human extends Humanoid {
            // variables methods etc.
        }
        // many more public classes that extend Humanoid
    }
    // more abstract public classes like Humanoid that each have many more nested public classes that extend them
}

or a package structure like:

Main.java
Creatures
 L  Creature.java
 L  Humanoid.java
 L  Human.java
 L  ...classes extending Humanoid
 L  ...other abstract classes extending Creature
 L  ...classes classes extending ^^^

since java bot didn't respond to the original post I thought it might be bugged so I have reposted it.

tender arrowBOT
#

Hey, @indigo holly!
Please remember to /close this post once your question has been answered!

desert widget