-
Nov 8th, 2009, 09:03 AM
#1
Thread Starter
Addicted Member
Relatime usage of abstract class and interfaces
Hi all,
I jus want to know the situations of using abstract class and interfaces in real time.
plz anyone reply me..
Thnks,
Priyajee
-
Nov 8th, 2009, 09:08 AM
#2
Re: Relatime usage of abstract class and interfaces
Hey,
When you refer to "real time", are you actually meaning in real world example?
I use abstract classes for the Data Provider Model that I use. The Abstract Base classes define what methods need to be overridden by the actual Data Provider.
So, for instance, I have an Abstract Base Class called ArticlesProvider, which has methods such as GetArticles, UpdateArticle etc.
Then I have other classes, namely SqlArticleProvider, and MySqlArticleProvider which inherit from the Abstract Base Class, and implement those methods specifically for SQL Server and MySql Database.
Hope that helps!!
Gary
-
Jan 23rd, 2020, 05:27 AM
#3
Lively Member
Re: Relatime usage of abstract class and interfaces
Hey,
When you refer to "real time", are you actually meaning in real world example?
Interface is used when you want to define a contract and you don't know anything about implementation.
Abstract class is used when you know something and rely on others for what you don't know.
EX:-
we want to start a service like "makemytrip.com" or "paytm" where we are responsible for displaying the flights from various flight service company and place an order from customer.
Lets keep our service as simple as,
1.Displaying flights available from vendors like "airasia", "jetair" and "emirates".
2.Place and order for seat to respective vendor.
suppose I have to use few methods everytime like Flight,Flight_time etc i.e complasary to override those methods .so these all are abstract method and service,food that is not complasary that would be considered as non-abstract method.That time using abstract class is not required . because all flight depends on factors like time,service etc..That time interface are not used.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|