Being a noob I have proudly sort of finished my first project from the ground up without it being a codealong, tutorial or similar.
Now I have a moment of reflection and I realize I might have several unused urls, views and other “forgotten” parts of ghe code, maybe from testing, failed tries and so forth.
Is there any way to spot these “can be deleted” snippets? Should I even bother?
I know of no automated way of doing this.
If you have a url, it refers to a view. The view needs to exist, otherwise the url definition is invalid. And, with a url, you can’t programmatically determine whether or not it’s being used, because someone can always enter a url directly in the address bar.
So only someone familiar with the code can do that sort of clean-up - and yes, I do recommend it be done. It can create a lot of confusion if you come back to this code after six months to try and figure out what’s going on.
Check in your current code to the repository-of-your-choice to ensure you have a working version, then start cutting away. (If you have tests for that code, make sure you remove those as well.)
Side note: In the future, when you’re doing this sort of experimentation, you may find it worthwhile to create branches for that purpose. If the work is good, merge it into your main branch. If not, you can always go back to main and ignore (or remove) that branch. It may seem to be a bit much at first, but my experience has been that I wouldn’t want to do it any other way now.
Thank you. I will try to learn git branching. And I will also do some manual cleanup. Thank you
Man, that’s pretty cool, you finished up on a project! Congrats!
Something that helps with this sort of thing is to use git, use branching (as someone mentioned) and make use of merge requests (even if you’re a one man project). This way you can get to do your own code reviews and only merge what you think is relevant and remove anything that’s not useful to the issue of the branch.
It’s also good to later have a few branches (as an issue branch) where you go back and tidy up your code one unit at a time if need be. Also, writing unit tests for each branch helps you determine what’s needed or not at that time. It will help you become even more efficient.
Anyways, that’s awesome you got something going here with your project. Good luck!
Thank you for the extra feedback. I really appreciate it!