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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T00:46:01+00:00 2026-06-09T00:46:01+00:00

So in order to create commands (based on the pattern) in any class, that

  • 0

So in order to create commands (based on the pattern) in any class, that class has to know about the receiver class in order to pass it into the constructor of the command, which then couples the classes together. Is there a way to use the command pattern and keep a measure of indirection between the two classes?

The only solutions I can think of are:

  • Use a mediator, but how exactly I don’t know since at the least the command would still need to be passed the class even if it was just its interface
  • Use a facade, but that couples any command calling class to the facade
  • Use an event system instead of commands, but that has too much overhead in execution and just writing the code itself
  • Use a creation pattern to make the commands somehow but that couples everything to that object

My biggest concern with the event system is that from my experience with event systems the amount of code you have to write to get the sender and receiver interacting without knowing about each other is insane and not practical at all- every method I want accessible by an event requires me to modify at least one other class and usually more, which creates problems just as bad as tightly coupled spegetti code. Also I usually need classes to send responses to events which is also very cumbersome.

  • 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-09T00:46:04+00:00Added an answer on June 9, 2026 at 12:46 am

    The command pattern isn’t meant to decouple the creator and the receiver; these classes are usually already coupled or may even be the same class.

    What the command pattern does is decouple the implementation from the class which executes the command. Once the command has been created, it can be passed to the UI layer or over the network to a remote client, and the executing class does not require any knowledge of how the command is implemented.

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

Sidebar

Related Questions

When I create table that has definition of FK's directly in CREATE command and
I am trying to create a generic Exists() Command class that is able to
I have some sprocs that need a temp table. In order not to hardcode
I need to automate R to read a csv datafile that's into a zip
I am just curious how to create new object in the command. (in order
Below are commands in an i2b2 database setup tutorial to create a bunch of
I've seen and worked with a lot of older, JDBC-based DAO code that usually
At this moment we are building a new architecture that is based on the
I am using a 3rd-party object I didn't create that over time consumes a
Mysql has memory based data engines, which means it keeps the data in RAM.

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.