What is the advantages of using interfaces?
What's the difference between defining methods in your classes and with having interfaces, diba ma doble2x naka ug declare?
What is the advantages of using interfaces?
What's the difference between defining methods in your classes and with having interfaces, diba ma doble2x naka ug declare?
Do some research on the uses of interfaces. Suppose you are referring to Java language, I can share to you few sources:
Interface (Java) - Wikipedia, the free encyclopedia
Java: Advantages of Interfaces | Ben Pryor’s blog
try researching about oop concepts... you'll learn more of the advantages of interfaces...
I ask you what are the advantages, then you tell me to go research.... Let's put it this way, to all of you who have implemented interfaces in real world projects, can you please explain what advantage can we obtain when we use interfaces instead of just declaring methods in our classes irregardless of what programming language you are using.
Last edited by Tin_Tin; 02-19-2011 at 11:28 PM.
Makita nimu ang tanang advantages if you do some research. A simple google will do.
Again, the answers are here:
Interface (Java) - Wikipedia, the free encyclopedia
Java: Advantages of Interfaces | Ben Pryor’s blog
if you understand Object Oriented concepts such as polymorphism and even abstraction, you can fully understand the use of interfaces.
One important use: Flexibility
for example;
- to do graphics for my game, i can abstract the rendering by using interface.
I can declare an interface for my renderer and the application will not worry how the graphics are handled.
the graphics can be rendered by either GDI or SDLor any renderer
example:
interface IGraphics
{
void DrawLine();
void DrawCircle();
...
}
class GDIGraphics extends IGraphics
{
//do rendering using GDI
}
or
class SDLGraphics extends IGraphics
{
//do rendering using SDL
}
and my application layer wont care how the rendering is being done.
if i want to use pure GDI then i just
void Initialize()
{
IGraphics* gfx = new GDIGraphics; //use GDI
}
...
void DrawObjects(IGraphics* gfx)
{
gfx->DrawCircle();
}
As you can observed, you have a very flexible code. If you want to use the SDL in the above code, you only change the initialization part,
the above example is just one of the manny application for using interfaces classes.
you cant write a good java or c++ (or any object oriented language) program without utilizing abstract classes and/or interfaces.
Last edited by cebugdev; 02-20-2011 at 07:28 PM.
So more on sa design/architecture sa imong program na siya. Sa OOP kani ra gyung interfaces ang akong wala jud nasabtan sukad pa pag college.
Yep.. ma-consider rapud nimo as design/architecture ang Interfaces. But more on polymorphism gud ni ang interfaces.
MakaEncounter ka ani if magDeal naka og different objects (internal or external) but same ra ang methods(& same signature) ang imo iCall.
By using interface, no need na nga iIdentify pa nimo cla unsa cla nga type of object.
NakaAppreciate ko aning interface atong nagDev mi og plugin-based system.
refer sa example ni cebugdev, bali mao gud na xa ang concept sa interfaces.
To illustrate the use of interfaces is this.
Suppose you have these classes: ClassA, ClassB, and ClassC and all have methods: show(), display(), and retrieve() respectively. You can use an interface on your superclass (say ClassZ) to implement the same methods such as this, because show, display, and retrieve act the same thing.
Try review / research on design patterns bai, ma appreciate jd nmo dre how to use interface.
Similar Threads |
|