• 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
  • Tim Cooke
  • Liutauras Vilda
  • Jeanne Boyarsky
  • paul wheaton
Sheriffs:
  • Ron McLeod
  • Devaka Cooray
  • Henry Wong
Saloon Keepers:
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Tim Moores
  • Mikalai Zaikin
Bartenders:
  • Frits Walraven

state pattern question

 
Greenhorn
Posts: 14
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi,
I have a process that lends itself nicely to the state pattern. However, in my case I have 2 very general concerns regarding its implementation:
a) The number of polymorphic methods I have in the base class is steadily growing, and I'd prefer to keep this interface nice and succinct. Is there any pattern someone could point me to regarding this?
b) I'm concerned that some of the state instances methods will become god-like. Once again is there a pattern I could look to regarding this?
thanks in advance,
Rowan
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I'd think we need to know a little bit more about your code before we can give sound advice.
For example, *why* does the number of polymorphic methods in the base class is steadily growing? Why would some of the state instances methods will become god-like?
Can you show us some of your code?
 
Ranch Hand
Posts: 8945
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Is JDBC connection an example of State Pattern. The 2 states are Open and Closed. I dunno whether driver vendors implement it that way. What about Java sockets?
In the state pattern, the client will have pass State instances to the Context..This means that Client has to know all the state Classes ?
One more question who codes the transition from one state to another?
 
We should throw him a surprise party. It will cheer him up. We can use this tiny ad:
Gift giving made easy with the permaculture playing cards
https://coderanch.com/t/777758/Gift-giving-easy-permaculture-playing
reply
    Bookmark Topic Watch Topic
  • New Topic