Sunday, October 5, 2014

Just because you can, doesn't mean you should

Or to put it another way, just because it compiles doesn't mean it's ok

Don't do this:
public DataStore(NHibernate.ISessionFactory sessionFactory)
{
    _transaction = (_session = (_sessionFactory = sessionFactory).OpenSession()).BeginTransaction();
}


Do this:
public DataStore(NHibernate.ISessionFactory sessionFactory)
{
    _sessionFactory = sessionFactory;
    _session = _sessionFactory.OpenSession();
    _transaction = _session.BeginTransaction();
}

No comments:

Post a Comment