OlgaRabodzei / conditional_fields

Drupal 8 Conditional Fields
6 stars 5 forks source link

Use services instead of global functions #7

Open Sutharsan opened 7 years ago

Sutharsan commented 7 years ago

One great major difference between procedural code versus object oriented code is the use of services instead of global function. Please convert as many global procedural functions to services.

All functions in .module and .inc files are candidates for services. Hook implementations are the exception, they can remain in .module, but can use services to do the work. Using services has several advantages: Code is decoupled; Dependencies will be made explicit by means of Dependency Injection; Services can be overridden (by other modules); Average memory footprint is reduced.

OlgaRabodzei commented 7 years ago

Thank You, Erik! It's a really good remark. We'll rebuild code.