Skip to main content

You are not logged in. Your edit will be placed in a queue until it is peer reviewed.

We welcome edits that make the post easier to understand and more valuable for readers. Because community members review edits, please try to make the post substantially better than how you found it, for example, by fixing grammar or adding additional resources and hyperlinks.

Required fields*

8
  • 5
    What's wrong with what you currently have? Are the requirements likely to change for this functionality? IE, are there likely to be new if statements? Commented Jan 1, 2016 at 14:33
  • No, I'm looking at any other solution to improve the code. Commented Jan 1, 2016 at 14:35
  • 47
    You're going about this backwards. You don't find a pattern then write code to fit the pattern. You write the code to fit your requirements, then optionally use a pattern to describe your code. Commented Jan 1, 2016 at 14:43
  • 1
    note if you believe that your question is indeed a duplicate of this one, then as an asker you have an option to "override" recent reopen and singlehandedly close it as such. I did that to some of my own questions and it works like a charm. Here is how I did it, 3 easy steps - the only difference with my "instructions" is that since you have less than 3K rep, you will have to go through flag dialog to get to "duplicate" option Commented Jan 1, 2016 at 20:40
  • 9
    @LightnessRacesinOrbit: There's some truth in what you say, but it's perfectly reasonable to ask if there's a better way to structure one's code, and it's perfectly reasonable to invoke a design pattern to describe a proposed better structure. (Still, I agree that it's a bit of an XY problem to ask for a design pattern when what you want is a design, that may or may not strictly follow any well-known pattern.) Also, it's legitimate for "patterns" to affect your code slightly, in that if you're using a well-known pattern, it often makes sense to name your components accordingly. Commented Jan 2, 2016 at 7:42