Trusted answers to developer questions
Trusted Answers to Developer Questions

Related Tags

delphi

Createables vs. injectables in Delphi

Hammad Nasir

What are createables?

Createables are classes that must be created. These classes are usually created inside other classes that require their functionality. Classes have a short life span that are usually equivalent to the life span of the method call they are initialized in. In Delphi, these can be classes like TStack<T> or TQueue<T>, which are part of the standard library.

What are injectables?

Injectables are classes that are passed to the constructor of the class that requires their functionality. This allows our program to be loosely coupled, meaning those classes that we inherit from our injectable class can be passed as well.

Moreover, it is preferred for injectable classes to be hidden behind an abstraction, which is usually an interface. Normally, classes written for business logic are classified as injectable classes.

RELATED TAGS

delphi

CONTRIBUTOR

Hammad Nasir
Copyright ©2022 Educative, Inc. All rights reserved
RELATED COURSES

View all Courses

Keep Exploring