OOP Problems to use for Coding Tests during interv

2019-03-09 02:58发布

问题:

As a second interview I get people to sit down and write code...I try to make the problem really technology independent.

My programming problems that I have don't really exercise peoples OO abilities. I tend to try and keep the coding problem solvable within 2 hours ish. So, I've struggled to find a problem small enough and involved enough that it exposes peoples OO design skills.

Any suggestions?

回答1:

This is a problem that I use with some trainings, looks simple but is tricky OOP-wise:

Create model classes that will properly represent the following constructs:

  1. Define a Shape object, where the object is any two dimensional figure, and has the following characteristics: a name, a perimeter, and a surface area.
  2. Define a Circle, retaining and accurately outputting the values of the aforementioned characteristics of a Shape.
  3. Define a Triangle. This time, the name of the triangle should take into account if it is equilateral (all 3 sides are the same length), isoceles (only 2 sides are the same length), or scalene (no 2 sides are the same).

You can go on and on with quadrelaterals (which include squares, rectangles, rhombi, etc) and other polygons.

The way that they would solve the above problems would reveal the people who understand OOP apart from those who don't.



回答2:

ideally, you want to present a problem that appears difficult, but has a simple, elegant, obvious solution if you think in OO terms

perhaps:

  • we need to control access to a customer web site
  • each customer may have one or more people to access the site
  • different people from different customers may be able to view different parts of the site
  • the same person may work for more than one customer
  • customers want to manage permissions based on the person, department, team, or project

design a solution for this using object-oriented techniques


one OO solution is to have a Person, a Customer, an Account, and AccountPermissions, where the Account specifies a Person and a Customer and an optional Parent Account. the use of a recursive Account object collapses the otherwise cumbersome person/team/department/project structure a direct ERD solution might yield



回答3:

I have used the FizzBuzz Programming Test. And shockingly can corroborate the claims made by the article. As a second follow up I have asked candidates to compute the angle(s) between the hands on an analog clock. We set up a laptop with VS 2008 installed and the stub in place. all they have to do is fill in the implementation.

I am always stunned at how poorly candidates do on these two questions. I really am.



回答4:

Designing Social Security Application is something which I ask a lot of people during interviews.

The nice thing about this is everyone is aware of how it works and what things to keep track of. They also have to justify their design and this really helps me get inside their head :) (As there is lots of flexibility here)

Kind regards,



回答5:

Whether or not people do some coding in the interview, I make it a point to ask this: Tell me about a problem you solved recently using object oriented programming. You'd be surprised how often people cannot answer that simple question. A lot of times I get a blank stare, or they say something like "what do you mean? I program in .NET, which is all object oriented."



回答6:

These aren't specifically OO Questions, but check out the other questions tagged interview-questions

Edit: What about implementing some design patterns? I don't have the best knowledge in the area but it seems as if you would be getting two questions for the price of one. You can test for both OO and Design pattens in the one question.



回答7:

How about some sort of simple GUI. It's got inheritance, overriding, possibly events. If you mean for them to actually implement as part of the test then you could hand them a blank windows-form with an OnPaint() and tell them to get to it.



回答8:

You could do worse than ask them to design a MapReduce library with a single-process implementation. Will the interface still work for a distributed implementation? What's the exception-handling policy? Should there be special support for chaining MapReduce jobs in a pipeline? What's the interface to the inputs and outputs? How are inputs chunked up? Can different inputs in one job go to different mappers? What defaults are reasonable?

A good solution in Python takes about a page of code.



回答9:

I've got a super simple set. The idea is mainly to use them to filter out people who really don't know their stuff rather than filtering in the rock stars.

These are all 5 minute white-board type questions, so they are really not that hard. But the act of writing up code, and talking through it reveals a lot about a candidate - and is brilliant for exposing those that can otherwise BS through the talk.

  • Write a method that takes a radius of a circle as an argument, and returns the area of the circle (You would be amazed how many people struggle on this one!)
  • Write a program that accepts a series of numbers as arguments from the command line. Add them up, and print the sum
  • Write a class that acts as a keyed counter (basically a map that keeps track of how many times each key is "counted")


标签: oop