472,779 Members | 1,892 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,779 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 1178
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: Rina0 | last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
3
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
by: DJRhino | last post by:
Was curious if anyone else was having this same issue or not.... I was just Up/Down graded to windows 11 and now my access combo boxes are not acting right. With win 10 I could start typing...

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.