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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T06:17:48+00:00 2026-06-01T06:17:48+00:00

I have to implement a few action. Each of they have some common elements,

  • 0

I have to implement a few action. Each of they have some common elements, so they should inherit from one class. Lets say, that they are do some web actions, so base class is

public class WebAction
{
    private ServerData _serverData;
    public WebAction(ServerData serverData)
    {
        _serverData = serverData;
    }
}

Also, each of this action need to be execute, so in base class I also should have some sort of Execute() Method. Problem is, that each of this object do a little bit different thing, so It should take different parameters. My question is – witch way is best for reach this?

At first I was thinking abut some configuration object, e,g. Execute(IWebActionConfig config). In this case, I can use object like:

 LoginWebAction loginWebAction = LoginWebAction(staticServerConfig);
 LoginWebActionConfig = new LoginWebActionConfig { someData = "foo" };
 loginWebAction.Execute(loginWebActionConfig);

But is there any sense to create an additional tree of objects? Maybe will be better to configure each child of WebAction by properties?

LoginWebAction loginWebAction = LoginWebAction(staticServerConfig);
loginWebAction.someData = "foo";
// Execute will throw exception when someData not set
loginWebAction.Execute();

With of these (if any) way is better?

  • 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-01T06:17:49+00:00Added an answer on June 1, 2026 at 6:17 am

    It is possible to do in more OOP style. look at NVI pattern

    public class WebAction
    {
      private ServerData _serverData;
      public WebAction(ServerData serverData)
      {
        _serverData = serverData;
      }
      public virtual ExecuteAction{};
      public Execute()
      {
         ExecuteAction();
         //to do the rest of base code 
    
      }
    }
    public class WebActionDerived1: WebAction
    {
       WebActionDerived1(ServerData serverData, object arg1/*any unique param*/)
       :base(serverData)
       {
          _my_arg1 = arg1;
       }
       public override ExecuteAction
       {
        //call any procedure with your _my_arg1;
       }
    }
    public class WebActionDerived2: WebAction
    {
       WebActionDerived1(ServerData serverData, string arg1,
       string arg2/*otherunique param*/)
       :base(serverData)
       {
          _my_arg1 = arg1;
          _my_arg2 = arg2;
       }
       public override ExecuteAction
       {
        //call any procedure with your _my_arg1, and _my_arg2;
       }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I currently have several action buttons in different pages, and each button performs some
I have a data access library that has a few classes that all implement
I have a few classes as shown here public class TrueFalseQuestion implements Question{ static{
I have to implement the VinPower application. They offer a Java version, a C
I am building a node-based drag-and-drop editor, where each node represents one action (for
I have to implement a perceptron neural network in python. For each training epoch
From the past few days, I have been working on an Android code to
i have to implement a few CLI features and now I am trying to
I have a DataGrid that two of its columns are ComboBoxes (one contains few
I have a simple C++ DLL that implements a few custom actions for a

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.