Stop Writing Code During Interviews And Do This Instead

With generative AI, writing code during an interview just doesn't make sense anymore.

The reality is we expect that you can code. It’s implied that it's taught in schools to children, and it’s integrated into video games like Roblox. Asking a professional software developer to write trivial coding problems like the Fibonacci sequence during an interview is no longer good enough. We can do better, and here’s how.

Note. 👋 If you like articles like this, read more on my blog or watch me on YouTube!

Introduction

Technical interviews for software engineers are at a crossroads. The traditional practice of having candidates write code is facing new challenges in the age of generative AI. Writing code is becoming easier to automate, raising questions about its relevance in evaluating real-world skills.

In this article, we propose a shift towards code reviews as a better assessment method. Code reviews offer a window into how candidates reason, think, and communicate in a typical workday. They also provide a robust defense against cheating. Join me as we explore the changing landscape of technical interviews and the compelling case for embracing code reviews as the future of hiring software engineers or technical but non-coding engineering managers!

The age of generative AI: Why writing code isn't enough

Generative AI has revolutionized how we approach software engineering. With AI capable of generating code, traditional coding tasks are no longer the exclusive measure of a candidate's skills. This shift calls for a fresh perspective on the evaluation process.

As coding tasks become susceptible to automation, we need to explore alternative assessment methods. Code reviews offer a compelling alternative, focusing on a candidate's ability to understand, evaluate, and enhance existing code. This approach aligns better with the evolving tech landscape, allowing us to identify top candidates more effectively. In the sections that follow, we'll delve into the advantages of code reviews in today's hiring process.

function generateFibonacciSequence(n) {
  const sequence = [0, 1];

  for (let i = 2; i < n; i++) {
    const nextValue = sequence[i - 1] + sequence[i - 2];
    if (nextValue <= n) {
      sequence.push(nextValue);
    } else {
      break;
    }
  }

  return sequence;
}

const n = 100; // Change this value to the desired integer
const fibonacciSequence = generateFibonacciSequence(n);
console.log(fibonacciSequence);

There are you happy now? 🤣

The real-world relevance of code reviews

Code reviews serve as a unique window into the daily life of a software engineer. While coding tasks often resemble academic exercises, code reviews offer a more authentic glimpse of how engineers work in real-world scenarios. They mirror the collaborative nature of software development, where engineers continuously review, improve, and collaborate on existing code.

Note. 🧐 This process of assessing and enhancing code isn't just a mundane task but a vital part of the job, making code reviews a better reflection of the skills required for the role.

Moreover, code reviews showcase a candidate's ability to work with an existing codebase, a task central to the work of software engineers. It's not just about crafting a pristine solution from scratch; it's about comprehending, troubleshooting, and refining an existing system. Code reviews assess a candidate's capacity to adapt, learn, and integrate into a team's workflow, which is an indispensable aspect of modern software development. In this sense, they provide a more accurate portrayal of the demands and dynamics of the software engineering profession.

Demonstrating problem-solving and communication

Code reviews extend beyond technical prowess; they unveil a candidate's problem-solving skills and communication abilities. When evaluating a codebase, candidates must not only identify issues but also propose effective solutions.

This process is a litmus test for their analytical thinking and problem-solving capabilities. It's not just about finding errors; it's about understanding the implications of those errors and crafting solutions that enhance the overall quality of the code.

AI Generated
Of course, this was generated with AI. That's the point here!

Additionally, code reviews are an ideal arena to assess a candidate's communication and collaboration skills. In the realm of software engineering, effective communication is paramount. Engineers frequently work in teams, and the ability to articulate one's ideas, provide constructive feedback, and engage in productive discussions is vital. Code reviews offer insight into how well candidates can express their thoughts, collaborate with colleagues, and, ultimately, contribute to a cohesive and productive team. By incorporating these essential non-technical skills into the assessment process, code reviews provide a comprehensive evaluation that better mirrors the realities of modern software development.

Cheating prevention: The challenge in code reviews

One of the compelling advantages of code reviews in technical interviews is the inherent difficulty in cheating. Traditional coding tasks, while valuable, can be subject to dishonest practices, such as plagiarism or the use of external resources. In contrast, code reviews place candidates in a more controlled environment where they must evaluate and provide feedback on code that is unfamiliar to them. This scenario limits opportunities for dishonesty, making it a more trustworthy and secure assessment method.

Windows Copilot

Windows Copilot is available at all times. A person could be sharing their screen with that portion cropped out. As an interviewer, you wouldn't even know!

The integrity of the interview process is crucial, and code reviews contribute significantly to ensuring a fair and honest evaluation. By minimizing the potential for cheating, they allow candidates to showcase their authentic abilities, fostering trust between interviewers and applicants. This trust is foundational in identifying the best-suited candidates for the role, creating a more level playing field, and promoting transparency in the hiring process.

Implementing code reviews in technical interviews

Shifting the focus from coding tasks to code reviews in technical interviews requires a strategic and thoughtful approach. First, interviewers should craft scenarios that simulate real-world code review situations. These scenarios may involve examining a segment of code, identifying issues, suggesting improvements, and effectively communicating findings. By designing such scenarios, interviewers can ensure that candidates are evaluated in a manner that closely mirrors the skills and experiences they will encounter on the job.

Best practices for conducting code review interviews involve considering the candidate's thought process, the clarity of their feedback, and their ability to engage in constructive discussions about code quality. This approach assesses not only technical expertise but also soft skills like teamwork and effective communication. Combining code review exercises with other assessment methods, such as technical questions and behavioral interviews, creates a comprehensive evaluation process that accounts for a candidate's complete skill set and compatibility with the team and company culture.

Example 1. Finding design flaws in error handling

using System;

class Program
{
    static void Main(string[] args)
    {
        try
        {
            int[] numbers = new int[5];
            int value = numbers[10];
            Console.WriteLine("Value: " + value);
        }
        catch (Exception ex)
        {
            Console.WriteLine("An error occurred: " + ex.Message);
        }
    }
}

The design flaw in this code is related to exception handling. In the try block, the code attempts to access an element at an index (10) that is out of bounds for the numbers array. This will result in an IndexOutOfRangeException being thrown.

The candidate should identify and explain this issue to the interviewer. They should note that catching a general Exception is too broad and not a recommended practice. It's better to catch specific exceptions (in this case, IndexOutOfRangeException) to handle errors effectively. The corrected code should look like this:

using System;

class Program
{
    static void Main(string[] args)
    {
        try
        {
            int[] numbers = new int[5];
            int value = numbers[10];
            Console.WriteLine("Value: " + value);
        }
        catch (IndexOutOfRangeException ex)
        {
            Console.WriteLine("Index out of range: " + ex.Message);
        }
    }
}

The candidate should explain that this change ensures that the correct exception is caught and handled, making the code more robust and maintainable.

Example 2. Issues with multiple EF Core contexts

Here's a code example that involves Entity Framework Core, with a potential issue related to database context management. The candidate should identify and explain the problem to the interviewer.

using Microsoft.EntityFrameworkCore;
using System;
using System.Linq;

public class Employee
{
    public int EmployeeId { get; set; }
    public string FirstName { get; set; }
    public string LastName { get; set; }
}

public class EmployeeDbContext : DbContext
{
    public DbSet<Employee> Employees { get; set; }
}

class Program
{
    static void Main(string[] args)
    {
        using (var context = new EmployeeDbContext())
        {
            var employee = new Employee
            {
                FirstName = "John",
                LastName = "Doe"
            };

            context.Employees.Add(employee);
            context.SaveChanges();
        }

        using (var context = new EmployeeDbContext())
        {
            var employees = context.Employees.ToList();
            foreach (var emp in employees)
            {
                Console.WriteLine(emp.FirstName + " " + emp.LastName);
            }
        }
    }
}

The potential issue in this code is related to how Entity Framework Core DbContext is used. The code creates two separate instances of the EmployeeDbContext in different using blocks. Each context represents a separate database transaction.

While this code snippet is functional, it is not efficient when dealing with multiple related database operations. The use of multiple contexts can lead to issues such as data inconsistencies, unnecessary database calls, and potential performance problems, especially in a multi-user or multi-threaded environment.

The candidate should identify and explain this issue to the interviewer. They should note that in most scenarios, it's better to use a single DbContext instance throughout the unit of work to ensure that changes are tracked consistently. This would be particularly important if this code were part of a larger application with more complex interactions with the database. The candidate might recommend a design change to share the DbContext instance or provide a more cohesive approach for handling database transactions.

Conclusion

Demanding that a professional software developer tackle trivial coding problems during an interview has become an outdated approach. We can and should do better. The rise of generative AI has underscored the need for more innovative and relevant evaluation methods in our technical interviews.

Code reviews, as we've explored, offer a transformative solution. They shift the focus from rote coding tasks to a more meaningful and realistic evaluation of a candidate's abilities. In this paradigm, candidates reveal their problem-solving skills, their adeptness at teamwork, and their capacity for critical thinking. Moreover, code reviews substantially diminish the risk of dishonesty, ensuring that the hiring process remains transparent and trustworthy. Embracing this shift opens a brighter and more insightful path for both candidates and employers. It's time to move away from conventional practices and toward an evaluation process that genuinely reflects the potential of software developers to thrive in the ever-changing tech landscape. Asking more of our interviews is a clear pathway to discovering and nurturing top talent in the field.


Similar Articles