I'm working on ASP.NET MVC project where controller calling static class that run R scripts from external R project
Controller
public ActionResult Index()
{
Rscript.Run("WordCloud");// name of script file for example WordCloud
return View();
}
Rscript
public static class Rscript
{
public static bool Run(string filename)
{
var rCodeFilePath = $"\\RProject\\{filename}.R";
var rScriptExecutablePath = @"C:\Rscript.exe";
var result = string.Empty;
try
{
var info = new ProcessStartInfo
{
FileName = rScriptExecutablePath,
WorkingDirectory = Path.GetDirectoryName(rScriptExecutablePath),
Arguments = rCodeFilePath,
RedirectStandardInput = false,
RedirectStandardOutput = true,
UseShellExecute = false,
CreateNoWindow = true
};
using (var proc = new Process())
{
proc.StartInfo = info;
proc.Start();
proc.Close();
}
return true;
}
catch (Exception ex)
{
//return false;
throw new Exception("R Script failed: " + result, ex);
}
}
}
How can I represent the relationship in UML class diagram between controller and static class Rscript?
Is there a relationship between R scripts files and MVC should represented in UML?
1 Answer 1
How can I represent the relationship in UML class diagram between controller and static class Rscript?
I would need to see the complete controller class to be absolutely certain, but based on the code that you have demonstrated, the Controller
and the class Rscript
would each be represented by a class. There would be a Dependency between the Controller
class and the Rscript
class. Since Rscript
is a static class and the controller doesn't hold onto an instance of one at a class level, it doesn't seem like you can use a stronger relationship, such as an Association. You can make sure to indicate that the Dependency is only one way, though - the controller is dependent on Rscript
, but Rscript
is not dependent on the controller.
To make the model more clear, you can use stereotypes on the Rscript
class to indicate that it is static as well as to annotate the dependency.
Is there a relationship between R scripts files and MVC should represented in UML?
Because the scripts live outside of your application and are separate entities, I would not expect them to show up on a class diagram.
Instead, you may want to show the interactions between systems on diagrams such as a component diagrams or activity diagrams. You can also use a sequence diagram to define the behavior of the Rscript
class's Run
method. If the script executables are sufficiently complex, you may have various sequence or data flow diagrams for those as well.
-
controller class only contains the above index actionresultprogrammer– programmer2018年04月29日 07:54:16 +00:00Commented Apr 29, 2018 at 7:54
Is there a relationship between R scripts files and MVC
-- The R scripts are part of the Model.