Angular - Senior developer interview questions

   · β˜• 5 min read
🏷️
  • #development
  • #angular
  • How do you recognize a good developer at interview stage? Are they excited by learning new things or are they tired from it? Do they wake up and realize they still have not yet learnt everything they could? Or do they always know enough to just get by? When technology becomes obsolete every 2 years, 20 years of experience helps little. You are great at writing loops? Sorry folks, now we do functional programming. TL;DR

    This set of questions (1-10) is something I always wanted to come up with, to quickly put any given Senior Angular developer into 2 buckets - good or average. The difference is their learning potential. A good developer will have learning as an idle state of mind. An average developers only learns as much as necessary, because learning is pain.

    But I cannot simply ask someone if they like to learn new things. People can fake it. With so many online courses, one can do 5-10 hours of training and later appear as a genius on the interview. Learning once for 10 hours, and not learning after has no value. Are they spending time to improve themselves every day? Most typical interview questions fail to provide results on this metric. You can tell developer has some basic experience or they are completely clueless. Cannot tell beyond that, in that short time you have with a candidate.

    Now, as a candidate, assuming general programming experience at senior level, you google typical interview questions for Angular, prepare and ace your interview, on the first attempt. Without any knowledge of Angular.

    So what to do

    I have come up with a list of questions, for which an answer cannot be found in google. Even better, if you ask existing senior Angular developers, they might only know a few of them. What is being tested is desire for deep analysis and ultimate understanding of code, before starting to work on it. Measure twice, cut once. A good Angular developer should be able to answer more than half of these questions. If they answer less than half, or none, they still might be capable of delivering code. You decide if you want to hire them.

    Question 1. Seeing property as undefined in debugger

    1
    
    { prop: undefined }
    

    What does it mean regarding code quality? Which practice was not followed? This is a standard Javascript question. It is not specific to Angular, Typescript or any front end framework.

    Hint 1. Code Smell. When cutting corners with code, which typical code pattern would produce the above result? (answer is function body with less than 5 lines of code)

    Question 2. Converting components to OnPush

    When converting components from default change detection strategy to OnPush, when can we skip the conversion and still get decent performance?

    Hint 2. Where in component hierarchy (top, middle, bottom)?

    Question 3. One unit test runs 10ms, another in 1sec, both optimal

    You are using Jasmine for unit test framework and karma as test runner. Some of your tests run in 10ms, and some take 1sec, both unit tests were optimized to contain less than 10 lines of code, all synchronous, and no loops. What's the principal difference between the tests?

    Hint 3. Use of fixture.

    Question 4. How to correctly bind *ngIf, for performance

    When binding *ngIf in the template, which of the class members should be used, to gain maximum performance for the app?

    Hint 4. Class has properties (get, set), methods (functions and procedures) and fields.

    Question 5. Readability and functional programming

    Consider the following pseudocode:

    1
    2
    3
    4
    5
    6
    7
    8
    
    let v = false;
    for (...) {
        if(condition) {
            v = true;
            break;
        }
    }
    return v;
    

    Now compare it with the following, which one is better and why?

    1
    2
    3
    4
    5
    
    for (...) {
        if(condition) {
            return smth;
        }
    }
    

    Hint 5. Readability. Also, if the condition is simple, do we even need a for loop here?

    Question 6. When to use NO_ERRORS_SCHEMA

    When writing unit tests, when is a good reason to use NO_ERRORS_SCHEMA?

    Hint 6. Never. Is there a better way of doing what you wanted to accomplish?

    Question 7. Public service in constructor

    It is common practice in Angular application design to have a bunch of private services in component's constructor for dependency injection. You are seeing a public service in constructor. What's the proper way to implement code author's original intent?

    Hint 7. Why would you make anything public in component? (not just a service)

    Question 8. No additional code coverage with more tests

    When writing unit tests, you measure code coverage for each test one by one and notice that the first unit test covers 70% of component's code, while the second covers no additional code. In fact, all tests beyond the first one do not add to code coverage. This pattern is repeated across many components written by the same developer. What can you say about this developer?

    Hint 8. Does the same developer also like to copy/paste? Is he/she fixing the same bugs over and over again?

    Question 9. Refactoring best practices - typical example of tech debt

    Inside component you are seeing the following pseudocode.

    1
    2
    3
    4
    5
    6
    
    const data = await this.service.makeApiCall(args); // some API call
    const mappedData = this.map(data); // mapping from API model to view model
    
    map(data: Model): ViewModel {
        return { ... };
    }
    

    This is a typical pattern I saw repeated hundreds of times on an enterprise codebase.

    Do you see anything wrong with it? One thing, or multiple?

    Hint 9. Technical debt. Is there a better way to accomplish this?

    Question 10. Knowing your version control system (git)

    You have been tasked to work on a legacy codebase with 100K+ lines of code. You are fixing your first bug. Code is updated with 1000 commits/day. Git is used for version control. You can reproduce the issue. How do know what caused the bug in the most efficient way, in 1 hour?

    Hint 10. Git bisect. When will it fail to point to a bug? What should you do?


    Victor Zakharov
    WRITTEN BY
    Victor Zakharov
    Web Developer (Angular/.NET)