Dependency Injection
Dependency injection (DI) is a technique where one object supplies the dependencies of another object. This has a few benefits:
- It makes it obvious which objects a business object depends on.
- It makes it easier to switch out dependent objects for testing purposes.
MM .NET's Business Layer Generator has a Dependency Injection check box. If you select this check box, the Business Layer Generator creates business object constructors that accept a data access object and a database manager object...the two dependent objects. For example:
/// <summary> /// Constructor /// </summary> public Customer(ImmDataAccessBase dao, ImmDatabaseManager databaseMgr) { this.SetDataAccessObject(dao); this.DatabaseMgr = databaseMgr; }
The act of passing dependent objects to the constructor is called "dependency injection". When objects are passed in this way, the business object's factory methods are not used to create the data access object and database manager object.
© (c) 2026 Oak Leaf Enterprises, Inc., 1996-2026 • Updated: 05/01/18
Comment or report problem with topic
