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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T22:33:10+00:00 2026-06-17T22:33:10+00:00

I’m pretty exhausted trying to connect/link between practical issue to a theoretical equivalent .

  • 0

I’m pretty exhausted trying to connect/link between practical issue to a theoretical equivalent .

I will choose a very very simple example trying to illusrate my problem.

Suppose I have a Worker class:

class Worker {
private : // default access modifier 
     int workerId;
};

Suppose I have a Table class:

class Table {
private : // default access modifier 
    int tableId;
};

Suppose I have a ResturantManager class:

class ResturantMangager
private: // default access modifier
    list<Table*> allTables;
    list<Worker*> allWorkers;
public:
    // the function should tell the worker that he should call one of its function,
    // its decision to what table to put the client returned by its function 
    // must be somehow updated in the allTables (mark the table he chose to put the client
    // as unavailable).
    void putClientInTable(const Worker& worker, const Client& client);
};

Now I want to allow the worker to put a client in one of the available tables and after that I want the Resturant’s class data member allTables to mark this table (by ID lookup) as unavailable.
That means that the Worker should be able to decide what table to choose (or the ResturantManager tells him – I can’t see how It can be achieved differently) and then the ResturantManager’s allTables must be updated either.

I’m looking a design pattern (http://sourcemaking.com/design_patterns) which most suitable to this idea.

Is there any design pattern approriate to this issue?

Thank you all.

  • 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-17T22:33:11+00:00Added an answer on June 17, 2026 at 10:33 pm

    “I’m just not sure if there is a design pattern which sutiable to this idea and I can use it. It is always better than inventing the wheel again?

    A very agreeable approach. But to answer your question properly, you should ask yourself “what idea?”. Patterns exist to solve general problems. Your problem deals with restaurants and workers, so as such, you might find it troublesome to choose a specific pattern.

    Also, there is no such a thing as a “holy” design pattern to adopt in all situations. There isn’t a design pattern which is suited for modeling restaurants, cars, or whatever. You have to abstract those details out of your model and figure out what is the essence of the problem you’re solving.

    What kind of relationship are you trying to establish between your classes? How shall these associations be navigated?

    Programs are not static databases: they do something with your data, and your data structures should be designed in a way that best suits them for the kind of processing your algorithms are supposed to do. There is rarely such a thing as a “universally good” design. If someone tells you there his, listen to him with suspicion.

    Is your program supposed to find out what table a certain customer is sitting at? Is it supposed to find out which customers are sitting at which table? Is it supposed to find out which waiters are serving which customer, or which table, or how many times each waiter has served the same table throughout the day?

    In other words, what are the operational requirements of your program? How frequently is it likely to perform the above lookups? Are insertions expected to be more frequent than lookups? And lookups by name of a customer, or ID of a table, more frequent than just plain iterations over the whole set of tables/waiters/customers to print out a report?

    You can’t find the right design if you don’t make it clear what should it be right for. So to sum up, there’s two things you should do:

    1. Identify (or at least try to make reasonable assumptions on) the operational requirements of your program;
    2. Selecting the appropriate design pattern by reasoning in abstract terms, i.e. removing the details which are specific to your application domain.
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
That's pretty much it. I'm using Nokogiri to scrape a web page what has
I have just tried to save a simple *.rtf file with some websites and
I am trying to understand how to use SyndicationItem to display feed which is
I have this code to decode numeric html entities to the UTF8 equivalent character.
I am doing a simple coin flipping experiment for class that involves flipping a
I am trying to render a haml file in a javascript response like so:
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I'm trying to select an H1 element which is the second-child in its group

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.