If you're going with a test-first kind of approach, then start by planning the UI and what you want from the game, and then go through the cycle of test-implement-refactor-update_design-test.
In general, though, I look at the two processes as parallel, and interacting. Design the UI without paying attention to the technology, early on, and work on the code in parallel, also early on. The UI design will help shape your target, your "user stories" and inspire your coding. Your coding, on the other hand, will impose limits on what you can hope to accomplish reasonably, based on the complexity of the program and your skills/abilities. Take turns thinking of each independently, and then take time to integrate your ideas and discuss them with others.