Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 106033
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T01:31:59+00:00 2026-05-11T01:31:59+00:00

So I’m refactoring a legacy codebase I’ve inherited, and in the process I found

  • 0

So I’m refactoring a legacy codebase I’ve inherited, and in the process I found a static class that encapsulates the logic for launching 3rd party applications. It essentially looks like this (shortened for brevity to only show one application):

using System.IO; using System.Configuration; public static class ExternalApplications {     public string App1Path    {       get       {          if(null == thisApp1Path)             thisApp1Path = Configuration.AppSettings.Get('App1Path');          return thisApp1Path;       }    }    private string thisApp1Path = null;     public bool App1Exists()     {       if(string.IsNullOrEmpty(App1Path))          throw new ConfigurationException('App1Path not specified.');       return File.Exists(App1Path);    }     public void ExecuteApp1(string args)     {        // Code to launch the application.    }  } 

It’s a nice attempt to separate the external applications from the rest of the code, but it occurs to me that this could have been refactored further. What I have in mind is something like this:

using System.IO; public abstract class ExternalApplicationBase {     protected ExternalApplicationBase()    {       InitializeFromConfiguration();    }     public string Path { get; protected set; }     public bool Exists()     {       if(string.IsNullOrEmpty(this.Path))          throw new ConfigurationException('Path not specified.');       return File.Exists(this.Path);    }     public virtual void Execute(string args)    {       // Implementation to launch the application    }      protected abstract InitializeFromConfiguration();  }  public class App1 : ExternalApplicationBase {     protected virtual void InitializeFromConfiguration()    {       // Implementation to initialize this application from       // the application's configuration file.    }   }   public class App2 : ExternalApplicationBase  {     protected virtual void InitializeFromConfiguration()    {       // Implementation to initialize this application from       // the application's configuration file.    }   } 

My concerns are as follows:

  1. A class, interface, or other construct may already exist that does this, and I just haven’t stumbled across it.

  2. It may be overkill for what I want to do. Note, however, that the application uses at least three separate 3rd party applications that I have identified so far (and more are almost certain to pop up).

  3. I’m not entirely comfortable with the name of the base class. It seems fuzzy, and not very informative (but I couldn’t think of much better, given that Application is already well defined, reserved by the Framework, and would create a gross level of confusion were I to use it).

  4. The idea is that I want to be able to keep the application configuration data (it’s path and executable name) in the App.Config file, and check for its existence when my application starts up; when my software needs to launch the software, I want to do it through a single method call, and not have the code building command lines and trying to launch the software manually (as it currently does).

So I’m sending out a request for help, guidance, and suggestions. Anything you can profer is greatly appreciated.

P.S. I’m asking this here because I work, as I frequently do, as a sole developer at my firm; I don’t have anyone else to bounce these ideas off of. You guys have tons of experience with this stuff, and it would be foolish of me not to ask for your advice, so I hope you’ll all bear with me. Thanks in advance!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. 2026-05-11T01:31:59+00:00Added an answer on May 11, 2026 at 1:31 am

    Here is another way of refactoring this:

    using System.IO; public class ExternalApplication {    public ExternalApplication(string path)    {       this.Path = path;    }     public string Path { get; protected set; }     public bool Exists()     {       if(string.IsNullOrEmpty(this.Path))          throw new ConfigurationException('Path not specified.');       return File.Exists(this.Path);    }     public void Execute(string args)    {       // Implementation to launch the application    }  }  public class AppFactory {    public ExternalApplication App1()    {       // Implementation to initialize this application from       // the application's configuration file.    }     public ExternalApplication App2()    {       // Implementation to initialize this application from       // the application's configuration file.    }     public ExternalApplication AppFromKey(string key)    {       // get from somewhere    }   } 

    In this case, you have a single type ExternalApplication and a factory that has methods the return a properly configured application for you.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
link Im having trouble converting the html entites into html characters, (&# 8217;) i
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have a French site that I want to parse, but am running into
Seemingly simple, but I cannot find anything relevant on the web. What is the
Does anyone know how can I replace this 2 symbol below from the string
this is what i have right now Drawing an RSS feed into the php,
I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I have just tried to save a simple *.rtf file with some websites and
I want to count how many characters a certain string has in PHP, but

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.