Delphi-PRAXiS

Delphi-PRAXiS (https://www.delphipraxis.net/forum.php)
-   Delphi-News aus aller Welt (https://www.delphipraxis.net/58-delphi-news-aus-aller-welt/)
-   -   When to pass a dependency to a class? (https://www.delphipraxis.net/216844-when-pass-dependency-class.html)

DP News-Robot 12. Mär 2025 13:20

When to pass a dependency to a class?
 
I was speaking to another developer the other day and he insisted that if a class needs an instance of another class it should always be passed in an 'Init' method and not in the constructor. I disagreed with him on this and thought I should clarify when I think a dependency should be passed.

There are 2 options when passing a dependency to a class:



<ol style="text-align: left;">Passing it as a parameter in the Create constructor.
Passing it in a separate 'Init' method after c

Weiterlesen...


Alle Zeitangaben in WEZ +1. Es ist jetzt 05:21 Uhr.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
LinkBacks Enabled by vBSEO © 2011, Crawlability, Inc.
Delphi-PRAXiS (c) 2002 - 2023 by Daniel R. Wolf, 2024-2025 by Thomas Breitkreuz