Show Posts

This section allows you to view all posts made by this member. Note that you can only see posts made in areas you currently have access to.


Topics - DamonCarr

Pages: [1]
1
Suggestions and Requests / Ability to Recognize UML Dependencies inside Code
« on: September 16, 2005, 06:28:40 pm »
Hi!

I was really hoping that a 'Binary .NET Dissambly' would pick up a UML Dependency where I am instantiating a new class (it is not maintained, it lives only for the duration of the method) and is not a parameter passed in or out. Therefore the only way you could know about it is from code.

Perhaps my UML is wrong.. Is it not true that if a method in Class A instantiates Class B and calls services of Class B that you have a dependency now between Class A and Class B (uni-directional)?

I created an application to test this as I need it to calculate a metric I am working on for my book. I need to know about these dependencies but without a reverse engineering or access to code, there will be cases like this I don't know about.

Sparx doesn't show the dependency line on the class diagram, it only shows the Association that exists. Here is the code:

using System;

namespace UMLDependencyFailure
{

internal class Startup

{


[STAThread]


private static void Main(string[] args)


{



AnswerQuestion oAnswerer = new AnswerQuestion();



QuestionAsker oAsker = new QuestionAsker(oAnswerer);




bool Result = oAsker.IsSumOfIntegersTheSame(100, 50, 50);




Console.WriteLine(Result);



Console.Read();




}

}
}

namespace UMLDependencyFailure
{

public class QuestionAsker

{


private readonly AnswerQuestion _Answerer;



public QuestionAsker(AnswerQuestion oAnswerer)


{



_Answerer = oAnswerer;



}



public bool IsSumOfIntegersTheSame(int ExpectedSum, int SumOne, int SumTwo)


{



return _Answerer.IsQuestionTrue(ExpectedSum.ToString(), SumOne, SumTwo);




}



}
}

namespace UMLDependencyFailure
{

public class Calculator

{


public Calculator()


{}



public int AddTwoInts(int inOne, int inTwo)


{



return inOne + inTwo;


}

}
}


namespace UMLDependencyFailure
{

public class AnswerQuestion

{


public AnswerQuestion()


{}



public bool IsQuestionTrue(params object[] oParams)


{



Calculator oCalc = new Calculator();




int Result = oCalc.AddTwoInts(int.Parse(oParams[1].ToString()), int.Parse(oParams[2].ToString()));




return (Result == int.Parse(oParams[0].ToString()));


}

}
}


As you can see, in the AnswerQuestion class in the IsQuestionTrue method I create a new instance of :

Calculator oCalc = new Calculator();

and call:

int Result = oCalc.AddTwoInts(int.Parse(oParams[1].ToString()), int.Parse(oParams[2].ToString()));

This should of created a dependency but there isn't one. AM I WRONG? Is this NOT a UML Dependency?

Kind Regards,
Damon Carr, CEO
agilefactor
www.agilefactor.com

2
Suggestions and Requests / Re: CRITICAL - But I am sure you know about this
« on: December 18, 2004, 06:16:59 pm »
Hello? Are people just off for the holidays?

Damon

3
Suggestions and Requests / Design Patterns in Base Product?
« on: February 24, 2004, 06:50:17 pm »
Do you have plans in shipping support for Design Patterns (say the Gof set) in your next release?

I have the work that was done and it is very helpful but it would be better if it was a supported, integrated feature (at least in my mind).

Regards,
Damon Carr

4
General Board / Code Generation Preview
« on: March 07, 2004, 11:59:45 pm »
Is there a way to preview code generation before it is actualy saved to a file in version 3.6? I often want to just look at the code BEFORE a file is created...

Thanks,
Damon Carr

5
General Board / Latest Documentation on Sparx EA
« on: June 07, 2004, 01:20:57 pm »


Hello!

When can one find the latest and greatest documentation on all items? I just compared the 'web documentation' from my docs with the latest build and THEY WERE DIFFERENT. Is my only choice to go to the web?

Kind Regards,
Damon Carr

6
Automation Interface, Add-Ins and Tools / Visio UML to Sparx (XMI)
« on: March 11, 2004, 03:42:01 pm »
I found this tool that will create XMI files from Visio UML diagrams (used by many .NET developers as Visio comes with the Enterprise Architect version).

With the XMI you can use the 'Import Package from XMI' feature.

We used it and switched to Sparx as your tool is much better for our needs. Here is where to find the XMI Generator:

http://msdn.microsoft.com/library/default.asp?url=/library/en-us/dnvisio02/html/umlxmi.asp

Here is the article:

UML to XMI Export Functionality
Microsoft Corporation


February 2002

Applies to:
  Microsoft Visio 2002 Professional
  Microsoft Visual Studio .NET Enterprise Architect (Visio for Enterprise Architects)

Summary: Learn how the XMI Export download helps developers to access information from a Visio UML model by exporting it to an XML file. (4 printed pages)

Download Xmiexport.exe.

Contents
Introduction
User Scenario
Availability and Usage
Installing the XMI Export Facility
Building and Executing the Sample Visio Add-on

Introduction
This article describes the UML to XMI export functionality that has been added to the Visio UML Solution. Since the UML Solution in Microsoft® Visio® Professional 2002 and Visio for Enterprise Architects (a component of Microsoft® Visual Studio® .NET Enterprise Architect) does not expose an object model API through which UML model elements can be accessed, the export functionality is provided through a separate DLL. The following user scenario describes how a developer can access and use information from a UML model in another application.

User Scenario
A developer wants to write an application that uses information such as class, attribute, or operation names from a UML model that was created with the Visio Professional UML Solution, available from Visio Professional or Visio for Enterprise Architects.

Since the UML Solution does not expose an object model API through which UML model elements can be accessed, the export functionality is provided in a separate DLL (XMIExport.dll). The developer can invoke the XMI Export component and export most of the information contained in static structure, component, and deployment diagrams in an XML file that is compliant with the XMI standard .

The third party application can then parse the XML file using standard techniques like DOM or SAX to access the desired data from the UML model. The DTD file uml.dtd is needed in order to validate and view the XML file, and can be downloaded from the OMG Web site. The supported UML diagrams are class (static structure) diagram (most elements), component diagram (component element), and deployment diagram (node element).

For example, the following UML class (created on a static structure diagram in Visio) will be exported to the corresponding XMI files shown below (note that only a fragment of the XML file is shown).

AccountService
-InterestRate
+interestRate() : float
+calculate(inout amount : double) : double


<Foundation.Core.ModelElement.name>AccountService</Foundation.Core.ModelElement.name>
  <Foundation.Core.ModelElement.visibility xmi.value="public" />
  <Foundation.Core.GeneralizableElement.isRoot xmi.value="false" />
  <Foundation.Core.GeneralizableElement.isLeaf xmi.value="false" />
  <Foundation.Core.GeneralizableElement.isAbstract xmi.value="false" />
  <Foundation.Core.Class.isActive xmi.value="false" />

<Foundation.Core.ModelElement.name>interestRate</Foundation.Core.ModelElement.name>
  <Foundation.Core.ModelElement.visibility xmi.value="private" />
  <Foundation.Core.Feature.ownerScope xmi.value="instance" />

<Foundation.Core.ModelElement.name>calculate</Foundation.Core.ModelElement.name>
  <Foundation.Core.ModelElement.visibility xmi.value="public" />
  <Foundation.Core.Feature.ownerScope xmi.value="instance" />
  <Foundation.Core.BehavioralFeature.isQuery xmi.value="false" />
  <Foundation.Core.Operation.specification />
  <Foundation.Core.Operation.isPolymorphic xmi.value="false" />
  <Foundation.Core.Operation.concurrency xmi.value="sequential" />

Availability and Usage
The XMI Export functionality is available only through Visio Automation by invoking the Run command in the Visio API.

To access the XMI export functionality, use the Run API of the Visio add-on component. The following two parameters must be supplied to the Run command:

Parameter Description
/CMD=400
Visio UML Solution recognizes the 400 command as the XMI export function
/XMIFILE="yourfilename"
This parameter specifies the file where the XMI output will be written. The file name must be double-quote delimited. No blanks are allowed between the "=" and the file name. The file is created if it does not exist. An existing file will be overwritten.

For example, in Visual C++, the API returns VAORC_SUCCESS if the export succeeds.

VAORC rc = (VAORC)cAddon.Run(BSTR_HELPER_CLASS("/CMD=400 /XMIFILE="C:\\TEST.XML""));
Note   The sample code files accompanying the XMIExport.dll in the download demonstrate how to invoke the XMI Export functionality of the Visio UML Solution from a Visio add-on. The add-on is built using Microsoft® Visual C++® in Visual Studio .NET.
Installing the XMI Export Facility
To install the XMI export facility, copy the XMIExport.dll file to the Visio DLL folder named <VisioInstallationPath>\DLL.

Building and Executing the Sample Visio Add-on

Load the sample Visual Studio solution file VisioUmlAddon in Visual Studio .NET and build the solution; the result is a file named VisioUmlAddon.vsl in the Debug folder (created by default in the folder where the VS solution file is).
Copy the VisioUmlAddOn.vsl file to the folder <VisioInstallationPath>\1033\Solutions\Visio Extras.
Create a UML static structure diagram and add elements to it. From the Visio menu, select Tools, point to Macros, and then click Visio Extras. A new menu item, XMI export, will appear. Select it and choose a file name from the Save As dialog box. A message is displayed (Export to XMI succeeded) after completion of the export process. Browse to the exported .xmi file.

To open the file in Microsoft® Internet Explorer, place the DTD file uml.dtd into the same folder as the saved .xmi file.

Regards,
Damon Carr

Pages: [1]