I'm wondering what more experienced developers think about how to handle almost identical processes, such as a user creating a profile and a user editing their profile. At the moment I have a single controller method and single view which handle the distinction between a new user and existing/editing user, just by passing around an $editing flag, so i know to handle any slight differences between the two. Having these conditionals throughout my controller method and view feels a little messy, but then it also feels like a lot of duplication to create a distinct view and controller method for each situation. What do people tend to do in this situation?
When I set up a system which can create new users, I tend to require only minimal information on registration - email and password for instance.
Then, the "profile" section of your site can then handle all the editing of the remaining user details, without having to worry about whether or not this is a new or existing user.
In my experience, people tend to get put off when registering for something if too many questions are asked right at the beginning! Delay what is not really necessary, and collect that information later!
I think you should always consider the long-term aspects of design decisions.
It may be cleaner to separate these functions, but then you have two clean functions. So in terms of aesthetics you could argue either way. There is the age old trade-off between clean duplicated code and maintainabilty.
However in the long term other considerations come into play, and you start to think about risks. The risk of duplicating the code is that the two code parts become out of sync, potentially in subtle ways that are hard to detect (e.g. able to add data that is rejected on update). This can be much worse if you are not the person maintaining the code, or you have not touched the code for a long time.
So IMHO keep the editing flag. You have everything in one place, messy though it is.