Do not unnecessary load session or other scopes
Scenario:
settings file:
database_conn = instantiate.object
session_scope.conn_obj = database_conn or
application_scope.conn_obj = database_conn or others
script file:
object.init(application_scope.conn_obj)
You should not do that. It’s easy, indeed, because you can forget now about where and how is defined the object and you always have it handy in your application/session/other scope. BUT you will load your scope with unnecessary data and it’s a bad practice.
Instead, you should give the objects/variables as arguments wherever you need (in a good MVC framework you need to do things only once as in the module controller or settings file).
object.init(database_conn)
No comments yet
Leave a reply