20
votes
7answers
4k views

Is there a more intelligent way to do this besides a long chain of if statements or switch?

I'm implementing an IRC bot that receives a message and I'm checking that message to determine which functions to call. Is there a more clever way of doing this? It seems like it'd quickly get out of ...
2
votes
1answer
69 views

How to handle errors best addressed in a higher abstraction layer and dependent on state inferred in current layer?

I have a use-case that can be repaired, but the logic for repairing it is best done in a higher level of abstraction. Just throwing exception/failure is ugly because it's hard to pass back up through ...
2
votes
3answers
462 views

Empty virtual method on base class VS abstract methods

I couldn't find a question that was not too specific to some case, so I'll try to make this very generic. We need an extractor base class to a set of documents, for example. Each document has its ...
2
votes
2answers
198 views

I'm struggling with abstracting my animation code in my game using a functional style. How can I do this?

My game is a top down 2D shmup programmed in a functional style. I'm struggling with abstracting the code that is responsible for animating the projectiles. There are many types of guns with many ...
2
votes
2answers
225 views

How does aggregation work when databases are involved?

So I'm reading a book on Design Patterns (Design Patterns Explained 2nd Edition), and all throughout the book it says to "favor aggregation over inheritance". I'm trying to wrap my head around trying ...
4
votes
5answers
719 views

What is the name of this particular kind of over-engineering? [closed]

When faced with (even a small) project, I tend to fall into the following bad practice. I think about the structure of the problem. Then I create some base classes, derive from them and then derive ...
8
votes
3answers
664 views

Refactoring an existing abstract class and its parameters

I have an abstract class A which declares an abstract method doStuff. Currently there are many classes that inherit from A and implement doStuff. The class' instances are initialized at run-time ...
11
votes
6answers
650 views

What changes are too big to be made easy by proper design?

This is a rather vague question, but it's something I've never felt has been answered in a satisfactory way when reading about proper design. Generally, when learning about Object Oriented ...
2
votes
1answer
155 views

How do you handle the problem of abstraction when you learn a techonology / language?

I find that when I am trying to learn say Python for example I end up worrying about problems that are out of scope like how does Python implement this thing etc. For example say I am learning twisted ...