Reputation
587
Top tag
Next privilege 1,000 Rep.
See votes, expandable usercard
Badges
2 5
Newest
 Yearling
Impact
~9k people reached

  • 0 posts edited
  • 0 helpful flags
  • 49 votes cast
Apr
22
comment Extracting and generalizing “repeated” methods with similar functionality
In places where I've needed to do similar tasks, the configuration step always has to be done somewhere, whether it's in a data file or in a Class that hard-codes each association per need (that sounds terrible, but it's actually really flexible). For example, in an ActionScript project, I would hard-code which Factory to use for each question type into a hash, then just pull that factory out of the hash when asked to make the question. In JavaScript with AngularJS, each factory is registered with questionType+'Factory', and we pull it out of the injector by that convention.
Apr
21
comment Extracting and generalizing “repeated” methods with similar functionality
I was specifically referring to Erik's answer. But yes, I don't think your rules should take on the responsibility for adding themselves to the list. They have no reason to even know they are part of a list.
Apr
21
comment Extracting and generalizing “repeated” methods with similar functionality
Static classes and methods are death to testability, and if the rules are responsible for adding themselves to the list, this adds an unnecessary dependency to the rules and an extra responsibility.
Apr
21
comment Extracting and generalizing “repeated” methods with similar functionality
Can I just say before you worry about this kind of thing you need to clean up where you're passing in the game just to get the rulesManager and then each rule is pushing itself back in rather than having a third component external to either (like a Builder) handle that.
Apr
6
comment How can I promote the use of the Builder pattern in my team?
A lot of time the consistent thing is "we don't think too hard about any of this." If you're the type of person who thinks about design, it can really hard to fake not thinking too hard about things. It winds up not being intelligible to anyone.
Apr
6
comment How can I promote the use of the Builder pattern in my team?
The way I use builder is more like ordering from Amazon. The builder contains references to a lot of factories that know how to build similar objects. The builder mainly just figures out which factory to use and then calls factory.buildThing(data). The builder doesn't directly build the things, it just knows where the suppliers live.
Apr
5
comment How can I promote the use of the Builder pattern in my team?
The Builder is going to need to set values somehow. So it doesn't solve the basic problem.
Apr
5
comment What kind of development am I doing?
You don't know what unit tests are, yet you're really sure your code is clean? :-/
Oct
2
answered How is an interface used in Dependency Injection?
Oct
2
comment How is an interface used in Dependency Injection?
The main place interfaces are useful is in strongly typed languages. If you know you have an object of that type, you don't have to waste a lot of code looking to see if the properties and methods you need are available. This is one reason many people prefer strongly typed languages--they don't want to waste their time writing and maintaining unnecessary code for this kind of thing.
Sep
3
comment Class design, responsibility granulation, efficiency and performance
Like I said, for most programmers, the flexibility and extensibility of the system is far more important than CPU time. You didn't specify what language you were writing it in, so the specifics of what you need to do to get additional Classes aren't really relevant. One thing you might want to consider is that poorly organized code can lead to poorly organized thoughts, which can then lead to extra CPU cycles when the computer runs through lines you wrote that you didn't need to write. Not saying that's happening here, with you, just that it can.
Sep
2
comment Class design, responsibility granulation, efficiency and performance
If performance is that critical, maybe. But CPU time gets cheaper and cheaper every day. Programmer time, not so much. Also, the idea that it's more legwork to create separate Classes only holds in the initial writing phase, especially if you have a need for a lot of flexibility. It sounds like you don't, but I was pointing that out as a case where the granular approach would be more appropriate. Patterns don't exist because no one ever benefitted from doing it according to the pattern :).
Sep
2
answered Class design, responsibility granulation, efficiency and performance
Dec
20
awarded  Yearling
Mar
20
answered Why should one subclass instead of composite when using the Factory Method design pattern?
Mar
18
comment Do Design Patterns Stifle Creativity
IMO the creativity is in finding an implementation of the pattern that exactly suits your particular problem, plus, on an application-level scale, gluing all those patterns together in a way that's maintainable and somewhat legible.
Mar
18
comment Do Design Patterns Stifle Creativity
But isn't learning about design patterns a great way to see concrete examples of how to think about code? What things would you look at to learn how to think about code if not problems + general solutions that solve the problems and example code that implements the solution?
Feb
6
comment Choosing the right Design Pattern
I agree with @pdr. I think about what I need to do, and remembering the name of the pattern helps me name the Class so others know what it does as well.
Jan
5
comment Scrum decision making versus maintainability and development time?
+1 for sometimes it's true. It's horrible to be on a project with iterative requirements but a waterfall deadline.
Dec
20
awarded  Yearling