the high level understanding of the problem/code comes first. once you have that, implementation becomes quite easy. then you go to the lower level details like the language constructs and the apis needed for the implementation.

while writing code we start with high level functions and break them into smaller helper functions doing the low level stuff. we don't mix high level functions with low level operations. this doesn't mean you start out with some design or write a lot of boiler plate code. read delay design decisions and refactoring code to know more about design and refactoring.