java - Explaining Interfaces to Students -
For some years I was a teaching assistant to introduce the programming module - Java for the first year graduation
Most of it went well and we managed to get students very well-object-oriented programming, but one thing that rarely was seen in the interfaces was that the students.
Whatever explanations we have proved to be useful to be useful for learning or have turned away from their status as beginners. The response we received was translated as "I ... see," "I can not understand and these are not useful".
Is there a way to teach students successfully about any interface? I am not a teacher assistant, but it is always naked on me.
If you are trying to convince the beginner, I will be with the idea that the interface code For example, we may be going to paint some objects:
public class painter { Private list & lieutenant; Pentable & gt; PaintableObjects; Public Painter () {Paintable Object = New Arrestist & lt; Pentable & gt; (); } Public Zero Color AllObjects () (for paintable paintable: paintableObjects) {paintable.paint (); }}} Public Interface colorful {Public zero color (); }
Now you can convince those students that painter painter objects in the colorless interface will need ways to paint some types of objects, such as paintFences ()
and paintRocks ()
and we need to have a new archive
for each type of items, we want the artist to be able to paint.
But thankfully we have the interface that makes painting objects a breeze and how objects are painted, those classes are completely left out, which apply the Pentium interface < / P>
Edit
Another advantage I forgot to mention is that if you need to add new objects to paint in your code base , Is a new class ready Literacy that change never applies Pentetebl and painter class. In this sense the painter class is never dependent on painting objects, it should only be able to paint them. Edit 2
> James Reubald reminded me of an important use of the interface: Being an interface between my luggage, And with the same interface as Painter Objects, you allow others to grow more easily. A developer can work on painter objects and another can work on painable objects and everyone has to work properly together, already defines a common interface that they will use both. I know that when I worked on projects with other college level people, then you are really useful when you are trying to work in all parts of the project and still all components are good at the end Meet in kind.
Comments
Post a Comment