Sign up ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free.

This is a question where I seek guidance from fellow/senior developers to get into my dream company - it's a pioneer in OOP and Agile.

I've already failed once to clear an interview. One part I feel most challenging is to come up with a proper Object Oriented design(classes, interfaces, methods, interactions etc.) in a very short time for certain situations like Pacman, Game Of Life and so on. As the problems are unprecedented ones - my approach is mostly to try different things and then make decisions - which they feel is not clear and not what they expect from a developer with 5+ years of experience.

I've already studied a few books on patterns, OOP - it didn't help me much and I think it'll take a bit more than that. Could some one please guide on what specifically shall I practice so that I can do better at design problems as above. I want to refine my approach and have a better thought process.


migration rejected from Jun 26 at 17:33

This question came from our site for professional and enthusiast programmers. Votes, comments, and answers are locked due to the question being closed here, but it may be eligible for editing and reopening on the site where it originated.

closed as off-topic by Snowman, MichaelT, durron597, Dan Pichelman, enderland Jun 26 at 17:33

This question appears to be off-topic. The users who voted to close gave this specific reason:

  • "Questions about what language, technology, or project one should take up next are off topic on Programmers, as they can only attract subjective opinions for answers. There are too many individual factors behind the question to create answers that will have lasting value. You may be able to get help in The Whiteboard, our chat room." – Snowman, MichaelT, durron597, Dan Pichelman, enderland
If this question can be reworded to fit the rules in the help center, please edit the question.

Side note: drop that 'S', it has no meaning. OOP is enough. – Péter Török Aug 12 '11 at 15:15
oops.. done :-) – haps10 Aug 12 '11 at 15:25

2 Answers 2

Woah woah waoh. Before you start name-dropping "Design Pattern X" for your Pac-Man test, take a step back.

You first understand the problem. To get started look at the problem and identify things(objects) and their behaviors. It's that simple.

Now that you have identified things and behaviors you can start looking for a pattern. Here is a "Strategy Pattern" example. Consider implementing behaviors as objects themselves. You identified a "chase pac-man" behavior. Make an interface IChase and implement each way of chasing; DirectChase, RandomChase, etc. (each ghost chases a little differently). The object is like a proxy over the method. So it would call like:;

instead of the traditional;

It's a subtle difference and hard to explain in a post but using a proxy over the direct method gives the ability to easily change behavior at runtime. Maybe there is a power-up that makes all ghosts wander randomly instead of direct chase. You can do this easily with this pseudo code:

for each Ghost: Ghost.ChaseBahavior = new WanderRandomly();;


I recommend Object Thinking by David West. It starts out slow with a bunch of arguments about formalism versus object thinking, etc... But the main idea of behavior driven design seems to work for me. I haven't had many job interviews lately, but I totally bombed one on Object Oriented design about 6 months ago. Fast forward about three months and a company invited me to Seattle to interview in person and they had several object oriented design questions in the phone screen. So I'd definitely say behavior driven design is a great idea.

For getting things done quickly, as was mentioned, the CRC cards are a great idea. But the real power of CRC comes from knowing how to do a behavioral design. One other thing, you won't be an expert in it after that book. i can clear object oriented technical interviews, but when I try to apply that knowledge to real projects, I end up with too complicated a design still. Also refactoring and even Domain Driven Design (I highly recommend the book Domain Driven Design by Eric Evans) sometimes break with pure behavior oriented approaches. But it's definitely a step in the right direction.....

i'd recommend you know what a Domain Driven Design is (more popular in Java but some of the best .NET shops are using it as well) and a table module (often .NET shops employ this by making objects represent database tables and passing around record sets). Some places will go all formal UML and approach object design by modeling the data (E/R Modeling like for a database). Others will just say verbs = methods and nouns = classes. So it depends because there are many different approaches. Others procedural program with objects...e.g. throw some methods and data together splitting apart the program as separate namespaces.

Personally I feel behavioral driven design does seem to simplify a lot of things and to split up the control better. E.g. instead of having one super object/method controlling everything, tasks are delegated more. This also ends up easier to debug and reason about.


Not the answer you're looking for? Browse other questions tagged or ask your own question.