Results 1 to 3 of 3
  1. #1
    garnaout is offline Member
    Join Date
    Sep 2011
    Posts
    17
    Rep Power
    0

    Default Design pattern question

    I have a java-based simulation model of a floor with a lot of people agents that go on to different floors (I have around 3-5 floors) with several elevators. I am in the process of writing the elevator class and decided to take a step back and ask the big boys which design pattern would they recommend. First thought is state design pattern. The elevators will have a capacity, max load, and different states such as moving, idle, or Needs Maintenance (deactivated).

    Should I create the Elevator.java as an abstract class and have other states extend it?

    thanks

  2. #2
    JosAH's Avatar
    JosAH is offline Moderator
    Join Date
    Sep 2008
    Location
    Voorschoten, the Netherlands
    Posts
    13,655
    Blog Entries
    7
    Rep Power
    21

    Default Re: Design pattern question

    Quote Originally Posted by garnaout View Post
    I have a java-based simulation model of a floor with a lot of people agents that go on to different floors (I have around 3-5 floors) with several elevators. I am in the process of writing the elevator class and decided to take a step back and ask the big boys which design pattern would they recommend. First thought is state design pattern. The elevators will have a capacity, max load, and different states such as moving, idle, or Needs Maintenance (deactivated).

    Should I create the Elevator.java as an abstract class and have other states extend it?
    There is no need to extend anything: an elevator is an elevator; maybe it's its algorithm that can be extended but a simple 'elevator seek' (<--- Google tip) could do the job fine. If you only have one single elevator in your system you can implement the elevator as a singleton (<--- pattern tip)

    kind regards,

    Jos
    cenosillicaphobia: the fear for an empty beer glass

  3. #3
    KevinWorkman's Avatar
    KevinWorkman is offline Crazy Cat Lady
    Join Date
    Oct 2010
    Location
    Washington, DC
    Posts
    3,987
    Rep Power
    9

    Default Re: Design pattern question

    What would extend Elevator? It seems to me there is only one kind of Elevator, each with different attributes. No real need to extend there.

    Honestly though, I really wouldn't worry too much about it. There is such a thing as overthinking a problem. Go with what fits into your head the best.
    How to Ask Questions the Smart Way
    Static Void Games - Play indie games, learn from game tutorials and source code, upload your own games!

Similar Threads

  1. design pattern question
    By urbanleg in forum New To Java
    Replies: 2
    Last Post: 12-18-2011, 12:16 PM
  2. A little design (pattern?) question...
    By raindog308 in forum New To Java
    Replies: 1
    Last Post: 01-26-2011, 09:12 AM
  3. question on j2ee design pattern
    By Minu in forum Advanced Java
    Replies: 1
    Last Post: 01-06-2009, 07:50 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •