Heads up! To view this whole video, sign in with your Courses account or enroll in your free 7-day trial. Sign In Enroll
Well done!
You have completed Intermediate C#!
You have completed Intermediate C#!
Preview
Using class composition and interfaces together make for a very useful pattern (common programming technique).
This video doesn't have any notes.
Related Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign upRelated Discussions
Have questions about this video? Start a discussion with the community and Treehouse staff.
Sign up
We can do something
similar using composition.
0:00
The idea of composition is to create
a new type by combining one or
0:01
more other types together.
0:05
Composition is very common in
object-oriented programming.
0:06
The level class, for example,
is composed of many IInvader objects and
0:10
many Tower objects.
0:15
Objects can be passed in at construction
time, or created any time during or
0:16
after the object's creation.
0:21
Let's use composition to create a new type
of invader that behaves like an invader,
0:23
but doesn't directly inherit
from the invader base class.
0:28
You need to sign up for Treehouse in order to download course files.
Sign upYou need to sign up for Treehouse in order to set up Workspace
Sign up