0

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);

            }
        }
    }
  1. How can I represent the relationship in UML class diagram between controller and static class Rscript?

  2. Is there a relationship between R scripts files and MVC should represented in UML?

5
  • Is there a relationship between R scripts files and MVC -- The R scripts are part of the Model. Apr 25 '18 at 20:09
  • @RobertHarvey can you please explain why R scripts are part of models?
    – programmer
    Apr 27 '18 at 5:54
  • The short answer is "because they're not part of the View or the Controller." Apr 27 '18 at 14:43
  • @RobertHarvey so What are the features that make it a model? I need a reason to support my answer please
    – programmer
    Apr 27 '18 at 17:40
  • It's not just any R script. It's your R script. It doesn't do anything to supplement the behavior of the Views or the Controllers, which means it's part of your Model by default. Apr 27 '18 at 18:01
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.

1
  • controller class only contains the above index actionresult
    – programmer
    Apr 29 '18 at 7:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.