I use the Test-Driven Development framework to develop my game. Whenever I start off developing, the first thing I have to do is to get a game to work, and skip the visuals until I'm sure the game is working as intended.
Starting from scratch, when I develop a game, I head straight to the game core mechanics. Basically, when I start debugging, I go straight to the game, not straight to the main menu. The game core mechanics are glued tightly together with the outer game framework (i.e., a JFrame object wrapping a GameComponent that envelopes the core game, and nothing in between).
And then after I finish developing the core gameplay, I begin working on the main menu. And this is where I usually end up messing the code structure up. When I try to work on transitioning, the code that was anchored in to the GUI layer (the GameComponent wrapping around the main core game) now becomes hard to separate. I then have to create tons of Boolean flags, add new variables, delete some deprecated codes, and then try to mash them all up without even glancing at how the code structure should be, because I know the structure itself is in shambles from the moment I start adding in the visuals. It's really frustrating knowing that by adding in a middle layer between GameComponent and the core game, I remove the relationships between them two Objects, and tying them up with a temporary container that strings through the middle layer and connect those two Objects.
And that's not all. After stringing the middle layer in-between the two Objects, adding more core games to that mess can make the job tougher than ever. It's so messy, that I don't feel like working on it.
What do you do after that? What do you do that can prevent this from happening?