473,386 Members | 1,766 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

passing parameter as an interface type

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
6 16238
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
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
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
This thread was great, helped me out, cheers!
Nov 16 '05 #5
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
Is it possible to exclude just this error instead of relaxing the whole
deal?

Nov 17 '05 #7

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Catherine Jones | last post by:
Hi all, we need urgent help in a matter. We are trying to pass a COM object from the client to server and are facing some problems in the same. We've our client in C# as well as the Server...
8
by: Dennis Myrén | last post by:
I have these tiny classes, implementing an interface through which their method Render ( CosWriter writer ) ; is called. Given a specific context, there are potentially a lot of such objects,...
3
by: Mark | last post by:
Hi From what I understand, you can pass arrays from classic ASP to .NET using interop, but you have to change the type of the.NET parameter to object. This seems to be because classic ASP passes...
6
by: Kevin Yu | last post by:
hi all is there a way to pass an interface as input parameter for a web method? since interface is not serializable, does that mean it's impossible to do that? Kevin
12
by: scottt | last post by:
hi, I am having a little problem passing in reference of my calling class (in my ..exe)into a DLL. Both programs are C# and what I am trying to do is pass a reference to my one class into a DLL...
7
by: Tim | last post by:
When there is a need to pass some dynamic information between 2 managed assemblies, the "Dictionary object" in Generic form can be used as a method parameter to pass the information. The...
4
by: Nathan Sokalski | last post by:
I am a beginner with AJAX, and have managed to learn how to use it when passing single parameters, but I want to return more than one value to the client-side JavaScript function that displays it....
10
by: Janus | last post by:
Hi, Is there a way to pass arguments to the callback function used inside an addEventListener? I see that I can only list the name of the callback function. For eg, I use this: var...
1
by: aeshiels | last post by:
Hopefully I have the correct newsgroup for this question. I've developed a very simple COM server in C++ as im trying to learn COM. The COM server has an array of IUnknown interfaces (MyArray)...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.