Win a copy of Modern JavaScript for the Impatient this week in the Server-Side JavaScript and NodeJS forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Ron McLeod
  • Paul Clapham
  • Bear Bibeault
  • Junilu Lacar
Sheriffs:
  • Jeanne Boyarsky
  • Tim Cooke
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Tim Holloway
  • salvin francis
  • Frits Walraven
Bartenders:
  • Scott Selikoff
  • Piet Souris
  • Carey Brown

Some pattern advice

 
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I'm getting confused about what I imagine is a fairly common situation. I have five types of car and three types of engine. I have five car objects which therefore contain one of the three engine objects each. A total of eight objects have been initialized.
What if a certain parameter changes depending on which car contains the engine? For example, if car A contains engine 1, engine 1 needs to be set to 50 revs. If it contains engine 2 it needs to be set to 130 revs etc. etc. The only option I can think of is, I need fifteen objects and the objects are denoted by car|engine. As mentioned I want five car objects and three engine objects and be able to manipulate them depending on what type they contain.
If this makes sense, can anyone please point me to a pattern that handles this kind of thing?
Paul
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
So you need to do a decision based on both the type of the car and the type of the engine, correct?
The first thing you need to decide is: Who should be responsible for doing the decision? Would it be ok for a car to know about all the possible engines? Or the other way? Or shouldn't they know about each other and a third class needs to configure them?
 
Paul Keohan
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I would say its your third option - they need to know about each other. Another class to configure these sounds interesting. Is that the usual way forward?
I'll be more specific because the car/engine was just an example. I thought I could explain it better that way.
We have several call centers. Within each call center are several different types of agents depending on the langauge they speak. The customer calls a number and this decides which language the customer wants to connect to. Depending on which center has most agents available that speak that langauge, the call will be routed.
The agent groups need to have a connection to what centers they are in. But also, the centers need to know what agent groups they contain.
Thanks.
Paul
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Paul Keohan:
We have several call centers. Within each call center are several different types of agents depending on the langauge they speak. The customer calls a number and this decides which language the customer wants to connect to. Depending on which center has most agents available that speak that langauge, the call will be routed.


Mhh, this sounds a little bit different from the original example to me.
What would happen if you had a Router which just asked each Center about the available agents for the call and then decides about the routing based on that information?


The agent groups need to have a connection to what centers they are in. But also, the centers need to know what agent groups they contain.


Why? What behaviour is connected to that knowledge?
 
Paul Keohan
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Depending on which center the agents are in, their logging on/logging off times are different.
It seems as though the centers and the agent groups are logical object definitions - but I could be wrong. The centers store data such as which agent groups they have. The agent groups stor data such as what time they log on, which depends on the center. We also need to be able to look up how many agents in total are logged on at a center.
Paul
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
The agent groups don't necessarily need to know about the centers for this. The centers could simply configure the groups by giving them LoginInformation objects or the like, so it seems to me.
 
Ranch Hand
Posts: 260
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Originally posted by Ilja Preuss:
The agent groups don't necessarily need to know about the centers for this. The centers could simply configure the groups by giving them LoginInformation objects or the like, so it seems to me.


This is what i understand from the discussion so far
Agent1---belongs to--->1Group
Group[has as language]
CallCenter--has-->Agents
--has-->LoggingInfo
Router(as ilja suggested) gets call from customers ,queries(??) the callcenters for the availabilty of agents based on LoggingInfo and groups and assigns one of the filtered agents to the customer to take the call.
the use case (if i may call it so) ends with the customer ending the call.
Am i right in my understanding? if yes,Will it be a good design decision to create a Call class that has a language and time of call as its attributes.
How will i model the relationship between the customer,call,router and agent?
What would the class diagram look like.I have drawn one class diagram myself but it got very messy with number of relationships i have come up with.
Please comment
 
Paul Keohan
Ranch Hand
Posts: 411
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
If I made objects called AgentGroupCenter, this particular problem would go away. I could have 63 objects as opposed to 6 AgentGroup objects and 9 center objects. I want to have the objects separated.
I suppose my question comes down to, how do I handle a piece of data that is dependent on both the Center and the Agent Group - if I have an object for each?
There has already been a suggestion for creating a third class, which sounds good, but I wanted to see if I could explain more clearly what I want.
Paul
 
Gravity is a harsh mistress. But this tiny ad is pretty easy to deal with:
Building a Better World in your Backyard by Paul Wheaton and Shawn Klassen-Koop
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic