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 8873895
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T18:34:55+00:00 2026-06-14T18:34:55+00:00

I have a solution with two projects each producing a separate dll that is

  • 0

I have a solution with two projects each producing a separate dll that is used by another windows application. Each of those projects has a class called MyActions with only one method like so

Project1

   public class MyActions
    {
        public SomeTypeA DoJob(string str1, string str2)
        {
        }
    }

Project 2

   public class MyActions
    {
        public SomeTypeB DoJob(string str1)
        {
        }
    }

The two return types of these two classes are as below

    public class SomeTypeA 
    {
         public string stringA { get; set; }
         public int someInt { get; set; }
    }


public class SomeTypeB 
{
     public string someStringA { get; set; }

}

The method DoJob in the both the classes of these individual projects have almost 80% code that is the same. Project1 is the one whose MyActions class’s DoJob method has some extra bits specific to only Project1.
Now here is the twist.. Project1 is eventually going to be scrapped and its dll will no longer be used.I want to write the code in the best possible way that ensures there is no repeat of code and so that I dont have to make any modifications to remove any un-required code in Project2 once Project1 is discontinued.

I was thinking of using inheritance and overriding the DoJob method. How would that work if their return types are different and they have different input parameters? Perhaps push one of the parameters from Project1’s MyActions class to its constructor? I was also thinking of adding a link to Project2’s MyActions class in Project1. But not sure about how to go ahead with implementing that and not repeating myself or possibly running into unforeseen problems later. Any tips, suggestions?

  • 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. Editorial Team
    Editorial Team
    2026-06-14T18:34:56+00:00Added an answer on June 14, 2026 at 6:34 pm

    Your thought about inheritance is a good one. From your question in read between the lines that you were considering to let Project 1 inherit from Project 2. That’s a possibility but probably not the best solution. Here is what I would suggest.

    Create a super class for MyActions that both projects extend. Into this class you can move all the code that is shared across both projects (your 80% code of the method). The specific implementations in your MyAction in each project then implement the DoJob method as needed and make use of the provided methods from the super class.

    Once you scrap project 1 there will be no changes that have to be made to project 2’s code. You end up with a super class though that you do not really need any more in that case. However you won’t be repeating yourself anywhere.

    I am not yet familiar with the exact differences between java and C# so bear with me if there are differences. This is what code might look like in java.

    abstract class AbstractMyActions {
    
        protected SomeType commonMethodForBothProjects() {
            ...
        }
    }
    
    public class MyActionsA extends AbstractMyActions {
    
         public SomeType doJob(SomeParameter ..., SomeParameter ...) {
             $this->commonMethodForBothProjects();
             // Additional steps
         }
    }
    

    You get the idea.

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

Sidebar

Related Questions

I have wrote an application that consists of two projects in a solution, each
I have a system that has three applications (one windows application and two web
I have a Visual Studio solution that contains two projects. One is a Windows
I have two unit test projects in my VS 2010 solution. Each project has
I have two projects in my Solution. One implements my business logic and has
I have two WIN32 DLL projects in the solution, main.dll should call a function
I have a VS 2011 solution file with two projects, each is a project
I have a Solution that has two class libraries. I'm trying to convert the
I've got a VS2010 solution with two projects, each containing a Windows service hosting
My solution in in c# has two projects. Each in their own seperate folder.

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.