J
Justin Fondriest
//Reusing the implementation
//**The simplest way to reuse a class is to just use an object of that
class directly, but you can also place an object of that class inside
a new class. We call this "creating a member object." Your new class
can be made up of any number and type of other objects, in any
combination that you need to achieve the functionality desired in your
new class.
Because you are composing a new class from existing classes, this
concept is called COMPOSITION(if the composition happens dynamically,
it's usually called AGGREGATION). Composition is often referred to as
a "has-a" relationship, as in "A car has an engine."***//
Ok...so is this saying "a car has an engine", with regard to code
would be more like "a car (class)"--as in every car class--"has an
engine(object)"?
Now whether I am right or wrong...could someone take maybe 3 minutes
to explain what composition is in layman's terms?
does it have anything to do with the "import" feature that you put in
a program before you "instantiate"(?) the class?
Thanks for anyone willing to help...I am trying to learn to code so,
hopefully, I can do something good for the world with it...but I think
I may be a good candidate for the slow bus when it comes to java...
//**The simplest way to reuse a class is to just use an object of that
class directly, but you can also place an object of that class inside
a new class. We call this "creating a member object." Your new class
can be made up of any number and type of other objects, in any
combination that you need to achieve the functionality desired in your
new class.
Because you are composing a new class from existing classes, this
concept is called COMPOSITION(if the composition happens dynamically,
it's usually called AGGREGATION). Composition is often referred to as
a "has-a" relationship, as in "A car has an engine."***//
Ok...so is this saying "a car has an engine", with regard to code
would be more like "a car (class)"--as in every car class--"has an
engine(object)"?
Now whether I am right or wrong...could someone take maybe 3 minutes
to explain what composition is in layman's terms?
does it have anything to do with the "import" feature that you put in
a program before you "instantiate"(?) the class?
Thanks for anyone willing to help...I am trying to learn to code so,
hopefully, I can do something good for the world with it...but I think
I may be a good candidate for the slow bus when it comes to java...