DEV Community

Volodymyr Pavlyshyn
Volodymyr Pavlyshyn

Posted on

Open Question Coding Interviews

I deeply believe that Developers should write code on interviews.

The most critical part of the coding interview is the thinking and communication process.

So how does a person interact with you, and what kind of questions person asks?

Designing small and, most importantly, open interview challenges suitable for multiple levels is hard.

One of the interesting forms of coding interviews could be a code review.

I like this code review task from my ex-colleague.

/***
* Select Last 10 Orders  
*/
public class RecordController {
  RecordRepository r;
  public RecordController() {
  }
  public RecordController(RecordRepository repository) {
    r = repository;;
  }

  public ArrayList<Record> get_forPage(String query) {
    List<Record> l = r.findByQuery(query.toLowerCase());
    ArrayList<Record> rrr = new ArrayList<>();
    for (int i = 1; i < 10; i++) {
      rrr.add(l.get(i));
    }
    Collections.sort(rrr, new RecordSorterByDateAsc());
    return rrr;
  }

  public class RecordSorterByDateAsc implements Comparator<Record> {

    public int compare(Record a, Record b) {
      return b.getOrderDate().compareTo(a.getReturnDate());
    }
  }
}
Enter fullscreen mode Exit fullscreen mode

It is broken into many dimensions, from architecture and layer abstraction to the most important part.

The first question I expect to get — is what it should do.

I got so many quite interesting results out of this task

some candidates ignored the original request for code review and tried to rewrite a code,
some folks did not try to ask questions about logic, etc
The best part of this task — it is open so many cool topics to talk about

AWS Q Developer image

Your AI Code Assistant

Automate your code reviews. Catch bugs before your coworkers. Fix security issues in your code. Built to handle large projects, Amazon Q Developer works alongside you from idea to production code.

Get started free in your IDE

Top comments (0)

Postmark Image

Speedy emails, satisfied customers

Are delayed transactional emails costing you user satisfaction? Postmark delivers your emails almost instantly, keeping your customers happy and connected.

Sign up

👋 Kindness is contagious

Please leave a ❤️ or a friendly comment on this post if you found it helpful!

Okay