Solved

Interfaces

Posted on 2003-11-09
9
225 Views
Last Modified: 2010-05-03
Hi,
Can anybody tell me wht is main purpose of interfaces in  project?
Thanks
Archana
0
Comment
Question by:archanamanju
9 Comments
 
LVL 100

Expert Comment

by:mlmcc
ID: 9711632
What kind of interfaces?

In general an interface is how information is passed from one object to another.

For instance the user interface allows the user to communicate information and actions to the program.  (Keyboard, voice, mouse, etc)

Subroutines can also have an interface.  This is the parameter list in the subroutine heading

sub PrintData (Name as string, address as string)

Calling routine simply passes the name and address to the print routine

  PrintData MyName, MyAddress

mlmcc
0
 
LVL 11

Expert Comment

by:bingie
ID: 9711687
homework
0
 
LVL 4

Expert Comment

by:brother7
ID: 9711774
Are you referring to the use of Interfaces in VB.NET?  If so, then it's purpose is to be able to handle objects, that are otherwise not related, in a polymorphic manner.  For example, a tree, a file and a person are not related... you can't say that they inherit from a common base or from each other.  However, they all have an age.  So you can create an interface IAge that each class implements.  Then you can retrieve Age for each object that implements the interface IAge.
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 

Expert Comment

by:zljk
ID: 9721340
Interfaces in VB and VB .NET as well in other Object oriented or object based (VB6) languages serve the same purpose - providing mechanism of accessing different objects in the same manner. Suppose you are writing an application that can store some data somewhere. A user of the application can choose will the app store the data in the text file or the database. You can do something like this : (VB 6 example)

'interface class - has empty methods since it doesn't actually do anything. Let's call it IStorage, and add a single method to it:

Public Sub Store (byval data as string)
'
End sub

Now we can create two new classes - CDBStorage and CFileStorage.

'CDBStorage

Implements IStorage

Private Sub IStorage_Store (byval RHS as string)
    'here comes the actual code that writes data to the database
End sub

'CFileStorage
Implements IStorage
Private Sub IStorage_Store (byval RHS as string)
    'here comes the actual code that writes data to a file
End sub

Now you can ask user does he wants to store data in the database or file, and do something like this:
Dim oStorage as IStorage
If bStoreToFile Then
    Set oStorage = new CFileStorage
elseif bStoreToDB Then
   Set oStorage = New CDBStorage
End if

oStorage.Store ("my data")

This might be over-simplified example - in the real world you'd have several methods of the IStorage class, but I hope you got it.




0
 

Author Comment

by:archanamanju
ID: 9735290
Sorry,This is not i was looking for...
actually i have been asked in 1 interview that ...
Could u pls tell me the main purpose of interface in Com components..?
Can anybody answer me this pls.
Thanks in Advance
Archana
0
 
LVL 100

Expert Comment

by:mlmcc
ID: 9736666
Since COM components are subroutines and functions the interface specifies the required parameters and return values.

mlmcc
0
 

Accepted Solution

by:
amp072397 earned 0 total points
ID: 10528726
PAQed - no points refunded (of 20)

amp
Community Support Moderator amp~at~experts-exchange.com
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
Input past end of file vbs script 9 82
change vba from autofit to 13.5 width? 4 28
Visual Studio 2005 text editor 10 35
Protecting vb6 & .Net code Obfuscation 18 97
When designing a form there are several BorderStyles to choose from, all of which can be classified as either 'Fixed' or 'Sizable' and I'd guess that 'Fixed Single' or one of the other fixed types is the most popular choice. I assume it's the most p…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…

861 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

30 Experts available now in Live!

Get 1:1 Help Now