Connecting Tech Pros Worldwide Forums | Help | Site Map

passing parameter as an interface type

wiredless
Guest
 
Posts: n/a
#1: Nov 16 '05
What is the advantage of passing an interface type?

according to UML (visio) when i reverse engineer existing code to a UML
diagram I get the error

"UMLE00046: sample[Parameter] : [Parameter - WFR1] - An interface cannot be
used as the type of a parameter."

for this code:

public void OnUpdate(CCC.Sys.TestProc.ISample sample)
{

however the application does compile and run correctly.

Yes its not my code.

What is the advantage of passing an interface type?
Since UML doesn't like it should I not do it?

Thanks



Tom Porterfield
Guest
 
Posts: n/a
#2: Nov 16 '05

re: passing parameter as an interface type


wiredless wrote:[color=blue]
> What is the advantage of passing an interface type?
>
> according to UML (visio) when i reverse engineer existing code to a UML
> diagram I get the error
>
> "UMLE00046: sample[Parameter] : [Parameter - WFR1] - An interface cannot be
> used as the type of a parameter."
>
> for this code:
>
> public void OnUpdate(CCC.Sys.TestProc.ISample sample)
> {
>
> however the application does compile and run correctly.
>
> Yes its not my code.
>
> What is the advantage of passing an interface type?
> Since UML doesn't like it should I not do it?[/color]

The advantage is that it makes your code less susceptible to requiring
modification for future enhancements. By taking an interface type
rather than a specific object, all you worry about is that whatever is
passed support the functionality that the OnUpdate method needs. How
the ISample object implements the interface does not matter to you.

I'm not enough of a Visio and/or UML guru to say why the error is being
generated.
--
Tom Porterfield
Richard Blewett [DevelopMentor]
Guest
 
Posts: n/a
#3: Nov 16 '05

re: passing parameter as an interface type


Passing an interface as a method parameter is a totally valid thing to do. Consider this:

interface IPolygon

{

void Draw();

}

class Visio

{

public void DrawDiagram(IPolygon[] shapes)

{

foreach( IPolygon p in shapes )

{

p.Draw();

}

}

}

So you would think Visio should know better ;-)

Regards

Richard Blewett - DevelopMentor

http://staff.develop.com/richardb/weblog

nntp://news.microsoft.com/microsoft.public.dotnet.languages.csharp/<#PeXt80nEHA.3564@tk2msftngp13.phx.gbl>

What is the advantage of passing an interface type?

according to UML (visio) when i reverse engineer existing code to a UML
diagram I get the error

"UMLE00046: sample[Parameter] : [Parameter - WFR1] - An interface cannot be
used as the type of a parameter."

for this code:

public void OnUpdate(CCC.Sys.TestProc.ISample sample)
{

however the application does compile and run correctly.

Yes its not my code.

What is the advantage of passing an interface type?
Since UML doesn't like it should I not do it?

Thanks



---
Incoming mail is certified Virus Free.
Checked by AVG anti-virus system (http://www.grisoft.com).
Version: 6.0.766 / Virus Database: 513 - Release Date: 17/09/2004



[microsoft.public.dotnet.languages.csharp]
Jay B. Harlow [MVP - Outlook]
Guest
 
Posts: n/a
#4: Nov 16 '05

re: passing parameter as an interface type


wiredless,
The others have discussed the advantages of using an Interface.

The version of UML that Visio adheres to does not allow interfaces to be
parameters, hence the error.

However you can turn the check off using "UML - Options - UML Document -
Relax semantic error checking".

Hope this helps
Jay


"wiredless" <mobiledynamo@sprintpcs.com> wrote in message
news:%23PeXt80nEHA.3564@tk2msftngp13.phx.gbl...[color=blue]
> What is the advantage of passing an interface type?
>
> according to UML (visio) when i reverse engineer existing code to a UML
> diagram I get the error
>
> "UMLE00046: sample[Parameter] : [Parameter - WFR1] - An interface cannot
> be
> used as the type of a parameter."
>
> for this code:
>
> public void OnUpdate(CCC.Sys.TestProc.ISample sample)
> {
>
> however the application does compile and run correctly.
>
> Yes its not my code.
>
> What is the advantage of passing an interface type?
> Since UML doesn't like it should I not do it?
>
> Thanks
>
>[/color]


Paul
Guest
 
Posts: n/a
#5: Nov 16 '05

re: passing parameter as an interface type


This thread was great, helped me out, cheers!
DurayAkar
Guest
 
Posts: n/a
#6: Nov 17 '05

re: passing parameter as an interface type


Can you bypass just a certain semantic error like this one ?

I want to use the other semantic errors checked, but not this...

Because the System classes has this structure themselves :)



DurayAkar
Guest
 
Posts: n/a
#7: Nov 17 '05

re: passing parameter as an interface type


Is it possible to exclude just this error instead of relaxing the whole
deal?





Closed Thread