By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,679 Members | 1,500 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,679 IT Pros & Developers. It's quick & easy.

passing parameter as an interface type

P: n/a
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
Nov 16 '05 #1
Share this Question
Share on Google+
6 Replies


P: n/a
wiredless wrote:
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?


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
Nov 16 '05 #2

P: n/a
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/<#P**************@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]
Nov 16 '05 #3

P: n/a
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" <mo**********@sprintpcs.com> wrote in message
news:%2****************@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

Nov 16 '05 #4

P: n/a
This thread was great, helped me out, cheers!
Nov 16 '05 #5

P: n/a
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 :)

Nov 17 '05 #6

P: n/a
Is it possible to exclude just this error instead of relaxing the whole
deal?

Nov 17 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.