I’m building a social networking website. I’m the only coder on it.
Right now, Im’ the only one touching the code.
Assuming I know what the users’ will input into the website, I catch them all with IF ELSE…do I really need try/excepts?
I went through my code and realize that I have almost 0 try/except blocks…because I catch all the cases with IF/ELSE…However, I do log every error (and sends me an email when there’s an error, which never happens)
I’ve done a lot of user testing and can’t find any bugs.
I feel like I’m doing something wrong because I don’t have any try/excepts in my code.
Using try/catch blocks isn’t required (well…depending upon language, which you didn’t specify), and certainly isn’t related to how many people are touching the code. Generally speaking, however, you should never assume that you know everything that a user might input into your website (unless perhaps you have implemented a very restrictive
Filter/equivalent construct that discards anything that does not match an expected pattern).In fact, in my experience being the only person working on and testing the code makes it much more difficult to discover issues because you know exactly how the code works and what it is expecting, so you subconsciously feed it values that you know it can handle. Usually as soon as you get another person to test it/try and break it they will come up with a scenario that you didn’t think of which breaks the system in about 5 minutes or so.
Anyways, if the accepted way of dealing with unexpected input in your implementation language/framework/paradigm is to use try/catch blocks, then it follows that you should have some. If not, then don’t worry about it. The correctness of a piece of code is not measured by which language constructs it uses and which it does not.