• 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 Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Time for us to create a new Pattern (BusStops Pattern) unless it already exists

 
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
(Note if one already exists, just ignore this post. )

So here is a new Pattern. We shall call it:

the BusStop Pattern

Basically it uses a LinkedList to store a Collection of events, Usually there is a count, and the count is changed at each event. You can create a "Schedule and find all the "event" points and get the count value and other derived values.

So for instance you have a Bus that have N passengers when it starts. At a particular point in time, it stops and some passengers get on and some leave, You could have a count of currentPassenger count. But you can also find out how many have gotten on so far, and how many have gotten off.

The Events could also have start and end times so that we can go even further and use each time as a point of interest.

So lets build the classes.

1. We have the Event class that stores the count, and has a start and end count

2. We obviously have the LinkedList class.

3. Maybe some Mediator type class to handle the information gathering and display.

Mark
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I think it would be much easier to discuss this if we knew the problem, context and forces of the proposed pattern...
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
My example is the Bus Stops. You have a bus that travels and makes stops, at each stop people get on, and some get off. You need to be able to know how many people are on the bus, how many total have gotten off, how many total have gotten on, at any particular stop. The class will store all the stops in a Collection.

Mark
 
Mark Spritzler
ranger
Posts: 17347
11
Mac IntelliJ IDE Spring
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
You can also use a Visitor, which stores the total information, and it walks through the LinkedList and calculates at each stop.

Mark
 
reply
    Bookmark Topic Watch Topic
  • New Topic