Yep, I always buy the domain before I start a project. What happens if you finish it and someone registers the domain name?
Buying your domain before you start your project is always a better idea, as you never know, that someone else might register it before you do...
My thoughts exactly! Make sure to plan out your project (concrete details on what you want to do). If you change minor details along the way, the domain shouldn't be affected. However, if you decide to completely start a new project, then you could try selling the domain at a lower value to get some money back.
If you couldnt be able to snag the domain after setting up all the contents for it, then all the efforts gone waste. So better to check for and regsiter the availability of the domain first before preparing to contentize it.