I feel that you are using exceptions. As indicated by name, temptation should be chosen only in exceptional circumstances .
Exceptions should not be used to control the flow of your application. Users entering bad data or not entering the correct username and password will be considered part of the normal flow of your application, and not something exceptional.
You should only throw exceptions in exceptional circumstances that could potentially lead to the non-use of the whole or part of the application, for example, inability to connect to the database.
Thus, you will not get so many exceptions in the system that you need to catch and possibly rebuild.
It is a good idea to have different exceptions, for example, I use RedBean ORM to talk to my database and use these Exceptions:
- RedBean_Exception_Security (when a security exception occurs).
- RedBean_Exception_SQL (when the bad sql syntax occurred or some other problem).
Being too specific regarding exclusion can lead to a lot of confusion. For example, if I have an exception for missing sql column , bad syntax , missing value , etc., It can become completely unmanageable. But if I have SQL_Exception and use this exception for all of the above, then it is much more simplified and easier to manage.
As far as performance is concerned, when loading a large number of classes (I assume that they are in external files), they can be taxed on the application. This can be partially alleviated by using APC to cache the interpreted PHP code in memory. But this is hard to say without any profiling.
source share