Re: need some realworld examples

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: mattie (mattie_at_discussions.microsoft.com)
Date: 01/31/05


Date: Mon, 31 Jan 2005 13:19:05 -0800

thank you.

"Don" wrote:

>
> "mattie" <mattie@discussions.microsoft.com> wrote in message
> news:F654E1FD-F88F-4C69-8A2B-98E704105F05@microsoft.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
>
>
>



Relevant Pages

  • Re: Stategy for (Large?) 16bit COBOL code conversion to Net Express
    ... Express and Visual studio 2005 loaded on a Windows 2003 Terminal server. ... interface from application logic. ... AFTER user interface is separated from business ... Because Linux has a big chunk of the server market. ...
    (comp.lang.cobol)
  • Re: Relational model versus object model
    ... > inventory control for a retail bricks & mortar business. ... > problem solutions are inherently dynamic. ... you said it yourself: it is a data centric interface. ...
    (comp.object)
  • Re: Gradual Application Conversion
    ... we have a business object to handle each form in our ... > partition your application, entirely in VFP. ... Write test cases against the COM interface to make ... > The front end work was a horizontal slice, ...
    (microsoft.public.dotnet.general)
  • Re: Encapsulation vs separation of concerns
    ... But normal programming logic is synchronous. ... When implementing the business logic, ... persistence layer at the same time. ... For me, in a given context, an interface ...
    (comp.object)
  • Re: Relational model versus object model
    ... >>applications are reading and writing the data. ... inventory control for a retail bricks & mortar business. ... >>is decoupled from the problem solutions, it is also decoupled from the ... it is a data centric interface. ...
    (comp.object)