posted 21 years ago
Sometimes you don't always start from the abstract and work toward concrete. Sometimes, you start with something concrete, but some subset of those can have something "abstracted out" to a middle layer. Let me try to come up with an example - forgive me if this is remarkably contrived.
In this example, it is quite possible to have an instance of Employee. Perhaps that instance represents you or me - we each have a first name and last name, we each have a social security number, and we each have an employee ID.
Now, let's imagine that, for some reason, we want to have some instances that represent baseball players. Every baseball player has a number and a team, but not all players can do the same things. In this case, only a Pitcher can throw a pitch and only a Batter can swing a bat.
What I've done is "abstracted out" the things that are common to all players, such as the number and team. Those things are put into an abstract class that Pitcher and Batter will inhherit from. But, as that isn't a "full" representation of a baseball player, I've made that class abstract - it doesn't truly represent a baseball player because, even though it identifies some things that all baseball players have, it doesn't include what baseball players can do.
Therefore, I've created some concrete classes that extend BaseballPlayer that include the unique capabilities of each type of player.
As you can see from this example, although it is rather contrived, there is some benefit from starting with a concrete class, extending it was an abstract class, and then extending that with more concrete classes.
I hope that helps,
Corey
[ March 30, 2004: Message edited by: Corey McGlone ]