473,399 Members | 2,146 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

need some realworld examples

hi,

i was just reading an article on interface-based programming and the example
they used was pretty good to get the concept across.

dim dog as IDog
dog=new CBeagle
dog.bark

ok, i kinda understand. but i can't imagine what to relate this to in the
business world. could you give some quick examples and explanations of
business related topics where this would be useful. please, the more examples
and analogies the better. very new to this.

thanks,
mj
Nov 21 '05 #1
2 1195
Don

"mattie" <ma****@discussions.microsoft.com> wrote in message
news:F6**********************************@microsof t.com...
hi,

i was just reading an article on interface-based programming and the example they used was pretty good to get the concept across.

dim dog as IDog
dog=new CBeagle
dog.bark

ok, i kinda understand. but i can't imagine what to relate this to in the
business world. could you give some quick examples and explanations of
business related topics where this would be useful. please, the more examples and analogies the better. very new to this.

For one, instantiating objects using interfaces allows you to be more
specific later on your code. e.g.:

Dim dog as IDog

If userWantsANiceDog then
dog = new GermanShepherd
Else
dog = new Chihuahua
End If

dog.bark
One example with which you might use interfaces in variable declarations
might be if you had some of contact management program in which a contact
might be a person or a business. You might do something like this:

(pseudocode)

IContact interface
Function PrintDetails()

PatientContact class
Property FirstName
Property LastName
Implements PrintDetails()
Print FirstName & " " & LastName

BusinessContact class
Property CompanyName
Implements PrintDetails()
Print CompanyName
Here you have an interface (IContact) with one method: PrintDetails. You
also have two classes (PatientContact and BusinessContact), both of which
implement IContact. As you can see, each one implements the PrintDetails
method differently, though, because they store different information. When
you have something like the above, you can do neat things like this:

Public Function PrintContactDetails(ByVal contact as IContact)

contact.PrintDetails

End Function

This function will take either PatientContact or BusinessContact objects and
tell them to print their details.

Imagine an inventory control system. You might have an interface called
IProduct. Every product class could implement this class, and it could
provide methods for doing general tasks like retrieving a product
description or whatever. Then your business logic would just work with
IProduct objects whenever it doesn't care about what specific kind of
product it might be (for example, you might just be displaying a list of
product names).

I recently stumbled onto this stuff. It comes in really handy sometimes.

- Don
Nov 21 '05 #2
thank you.

"Don" wrote:

"mattie" <ma****@discussions.microsoft.com> wrote in message
news:F6**********************************@microsof t.com...
hi,

i was just reading an article on interface-based programming and the

example
they used was pretty good to get the concept across.

dim dog as IDog
dog=new CBeagle
dog.bark

ok, i kinda understand. but i can't imagine what to relate this to in the
business world. could you give some quick examples and explanations of
business related topics where this would be useful. please, the more

examples
and analogies the better. very new to this.

For one, instantiating objects using interfaces allows you to be more
specific later on your code. e.g.:

Dim dog as IDog

If userWantsANiceDog then
dog = new GermanShepherd
Else
dog = new Chihuahua
End If

dog.bark
One example with which you might use interfaces in variable declarations
might be if you had some of contact management program in which a contact
might be a person or a business. You might do something like this:

(pseudocode)

IContact interface
Function PrintDetails()

PatientContact class
Property FirstName
Property LastName
Implements PrintDetails()
Print FirstName & " " & LastName

BusinessContact class
Property CompanyName
Implements PrintDetails()
Print CompanyName
Here you have an interface (IContact) with one method: PrintDetails. You
also have two classes (PatientContact and BusinessContact), both of which
implement IContact. As you can see, each one implements the PrintDetails
method differently, though, because they store different information. When
you have something like the above, you can do neat things like this:

Public Function PrintContactDetails(ByVal contact as IContact)

contact.PrintDetails

End Function

This function will take either PatientContact or BusinessContact objects and
tell them to print their details.

Imagine an inventory control system. You might have an interface called
IProduct. Every product class could implement this class, and it could
provide methods for doing general tasks like retrieving a product
description or whatever. Then your business logic would just work with
IProduct objects whenever it doesn't care about what specific kind of
product it might be (for example, you might just be displaying a list of
product names).

I recently stumbled onto this stuff. It comes in really handy sometimes.

- Don

Nov 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Marc | last post by:
Hi all, I am trying to write an application where I need the ability to open an Excel spreadsheet and do basic read/write, insert rows, and hide/unhide rows. Using win32com I have been able to...
22
by: Rafia Tapia | last post by:
Hi all This is what I have in mind and I will appreciate any suggestions. I am trying to create a xml help system for my application. The schema of the xml file will be <helpsystem> <help...
1
by: Richard Hollenbeck | last post by:
Hello Newsgroup. You have all been very helpful in the past and I thank you. I try to ask relevant questions so that they don't just benefit me, but also benefit the group. I'm currently...
31
by: mark | last post by:
Hello- i am trying to make the function addbitwise more efficient. the code below takes an array of binary numbers (of size 5) and performs bitwise addition. it looks ugly and it is not elegant...
11
by: Larry | last post by:
I will be teaching an eCommerce application development course using ASP.Net after many years of having taught classic ASP. (Course was interrupted by 18 months in the Middle East with my Army...
1
by: skootr | last post by:
Has anyone seen any COMPLETE bound form examples? By complete, I mean a form that has Add/Edit/Delete capabilities. Every example I've seen on the 'net, in books, and in the VB.Net Resource Kit...
1
by: Tyno Gendo | last post by:
Hi everyone I need to move on a step in my PHP... I know what classes are, both in PHP4 and 5 and I'm aware of "patterns" existing, but what I'm looking for are some real world projects eg....
0
by: noway001 | last post by:
Hi, I need to learn how to do unit tests for certain functions. I have googled and come accross some stuff, but all the examples are easy. I read multiple articles on code project, but it didn't...
2
by: jasiu85 | last post by:
Hey, Please take a look at the code of the two threads below: COMMON_DICT = {} def thread_1(): global COMMON_DICT local_dict = prepare_dict() COMMON_DICT = local_dict
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.