Structuring whiteboard code

New
jwz_hzs

New

jwz_hzs
Mar 23, 2019 5 Comments

I like writing my solution top down for whiteboard coding - i.e. breaking down my solution into a few component parts, and:

- first write the main function using the (undefined) subfunctions (an 'outline'), and then,
- complete the implementation of the sub-functions

This adds clarity to my thought process, ensures the interviewer sees the larger picture even if I can't complete my solution - in fact some have asked me to skip uninteresting sub-functions altogether, and also allows me to budget my time better.

Is this top-down approach a good idea? Would you expect a candidate to write code bottom-up?

comments

Want to comment? LOG IN or SIGN UP
TOP 5 Comments
  • This is what most people suggest doing. Makes modifying parts of the code way easier, and it also organizes your thoughts nicely. Also lets you skip trivial functions and come back to them later if you have time. Less likely to get lost in the weeds.
    Mar 23, 2019 0
  • Daimler
    SbXE81

    Go to company page Daimler

    SbXE81
    Sounds like a great idea. If you run out of time to implement some helper functions it's not that bad.
    Mar 23, 2019 0
  • Sina.com / Eng
    WLB

    Go to company page Sina.com Eng

    PRE
    Facebook, Apple, Amazon, Netflix, Google
    BIO
    Software Engineer and former phd candidate in biophysics
    WLB
    good hand writing helps a lot
    Mar 23, 2019 0
  • Dropbox
    systest

    Go to company page Dropbox

    systest
    Great idea even for phone interviews
    Mar 23, 2019 0
  • New
    jwz_hzs

    New

    jwz_hzs
    OP
    Thanks!
    Mar 23, 2019 0