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

  • SEARCH
  • Home
  • 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

Ask A Question

Stats

  • Questions 70k
  • Answers 70k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer Neither of those is actually the best (in terms of… May 11, 2026 at 1:04 pm
  • added an answer You need to select more than one property in your… May 11, 2026 at 1:04 pm
  • added an answer I wrote an email to Jan Dubois from ActiveState company.… May 11, 2026 at 1:04 pm

Related Questions

So I'm getting a new job working with databases (Microsoft SQL Server to be
So I have a Sybase stored proc that takes 1 parameter that's a comma
So I'm embarking on an ASP.NET MVC project and while the experience has been
So I've got a JPanel implementing MouseListener and MouseMotionListener : import javax.swing.*; import java.awt.*;
So I wrote some perl that would parse results returned from the Amazon Web

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.