What is it meant by local vs global objects in this article about dependency injection?











up vote
1
down vote

favorite












What do the words local and global mean in this article about dependency injection ?



Please see the quote below :




Data objects, on the other hand, are created dynamically, either in
response to user interaction, API invocation, scheduled tasks, etc.
They usually have a short, local lifespan. They carry and
manipulate the data that the application processes. They might combine
data and behavior, or be pure, “thin”, data structures.



The crucial property of the service/module graph is that it is created
statically. Only when the graph of services is wired, the application
is usually ready to serve user requests. Hence the service
objects/modules are static and global, as well as typically
stateless.











share|improve this question




























    up vote
    1
    down vote

    favorite












    What do the words local and global mean in this article about dependency injection ?



    Please see the quote below :




    Data objects, on the other hand, are created dynamically, either in
    response to user interaction, API invocation, scheduled tasks, etc.
    They usually have a short, local lifespan. They carry and
    manipulate the data that the application processes. They might combine
    data and behavior, or be pure, “thin”, data structures.



    The crucial property of the service/module graph is that it is created
    statically. Only when the graph of services is wired, the application
    is usually ready to serve user requests. Hence the service
    objects/modules are static and global, as well as typically
    stateless.











    share|improve this question


























      up vote
      1
      down vote

      favorite









      up vote
      1
      down vote

      favorite











      What do the words local and global mean in this article about dependency injection ?



      Please see the quote below :




      Data objects, on the other hand, are created dynamically, either in
      response to user interaction, API invocation, scheduled tasks, etc.
      They usually have a short, local lifespan. They carry and
      manipulate the data that the application processes. They might combine
      data and behavior, or be pure, “thin”, data structures.



      The crucial property of the service/module graph is that it is created
      statically. Only when the graph of services is wired, the application
      is usually ready to serve user requests. Hence the service
      objects/modules are static and global, as well as typically
      stateless.











      share|improve this question















      What do the words local and global mean in this article about dependency injection ?



      Please see the quote below :




      Data objects, on the other hand, are created dynamically, either in
      response to user interaction, API invocation, scheduled tasks, etc.
      They usually have a short, local lifespan. They carry and
      manipulate the data that the application processes. They might combine
      data and behavior, or be pure, “thin”, data structures.



      The crucial property of the service/module graph is that it is created
      statically. Only when the graph of services is wired, the application
      is usually ready to serve user requests. Hence the service
      objects/modules are static and global, as well as typically
      stateless.








      dependency-injection global local






      share|improve this question















      share|improve this question













      share|improve this question




      share|improve this question








      edited 2 days ago









      lagom

      3,18341636




      3,18341636










      asked Nov 9 at 19:15









      jhegedus

      8,872752114




      8,872752114
























          1 Answer
          1






          active

          oldest

          votes

















          up vote
          1
          down vote













          The author is differentiating the service objects that compose an application vs the data objects used in an application. Services are global since they are commonly accessible (via injection) to the entire application. An object graph of such services are created when bootstrapping your application with DI. After this object graph is created, your application will use these same services throughout the application for the entire life of your application.



          Data objects, on the other hand, have a local scope. They are created dynamically as needed, used, and then disposed.



          For instance, supposed you have a UserRepositoryService and you want to register a new User. The UserRepsitoryService is configured and injected throughout your application (and thus global), but the User object is created dynamically in response to the request to create a new User. After the operation is complete, the User object can fall out of scope and be disposed.



          public class Application {
          private IRepository<User> _userRepo = null;

          // UserRepositoryService injected through DI here
          public Application(IRespository<User> userRepo) { _userRepo = userRepo; }

          ...
          public void CreateUser(String userId) {
          User newUser = new User(userId); // Data Object Created
          _userRepo.Insert(newUser);
          } // Data Object falls out of scope here
          }


          This is a simple example, but hope that helps.






          share|improve this answer























            Your Answer






            StackExchange.ifUsing("editor", function () {
            StackExchange.using("externalEditor", function () {
            StackExchange.using("snippets", function () {
            StackExchange.snippets.init();
            });
            });
            }, "code-snippets");

            StackExchange.ready(function() {
            var channelOptions = {
            tags: "".split(" "),
            id: "1"
            };
            initTagRenderer("".split(" "), "".split(" "), channelOptions);

            StackExchange.using("externalEditor", function() {
            // Have to fire editor after snippets, if snippets enabled
            if (StackExchange.settings.snippets.snippetsEnabled) {
            StackExchange.using("snippets", function() {
            createEditor();
            });
            }
            else {
            createEditor();
            }
            });

            function createEditor() {
            StackExchange.prepareEditor({
            heartbeatType: 'answer',
            convertImagesToLinks: true,
            noModals: true,
            showLowRepImageUploadWarning: true,
            reputationToPostImages: 10,
            bindNavPrevention: true,
            postfix: "",
            imageUploader: {
            brandingHtml: "Powered by u003ca class="icon-imgur-white" href="https://imgur.com/"u003eu003c/au003e",
            contentPolicyHtml: "User contributions licensed under u003ca href="https://creativecommons.org/licenses/by-sa/3.0/"u003ecc by-sa 3.0 with attribution requiredu003c/au003e u003ca href="https://stackoverflow.com/legal/content-policy"u003e(content policy)u003c/au003e",
            allowUrls: true
            },
            onDemand: true,
            discardSelector: ".discard-answer"
            ,immediatelyShowMarkdownHelp:true
            });


            }
            });














             

            draft saved


            draft discarded


















            StackExchange.ready(
            function () {
            StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53232000%2fwhat-is-it-meant-by-local-vs-global-objects-in-this-article-about-dependency-inj%23new-answer', 'question_page');
            }
            );

            Post as a guest
































            1 Answer
            1






            active

            oldest

            votes








            1 Answer
            1






            active

            oldest

            votes









            active

            oldest

            votes






            active

            oldest

            votes








            up vote
            1
            down vote













            The author is differentiating the service objects that compose an application vs the data objects used in an application. Services are global since they are commonly accessible (via injection) to the entire application. An object graph of such services are created when bootstrapping your application with DI. After this object graph is created, your application will use these same services throughout the application for the entire life of your application.



            Data objects, on the other hand, have a local scope. They are created dynamically as needed, used, and then disposed.



            For instance, supposed you have a UserRepositoryService and you want to register a new User. The UserRepsitoryService is configured and injected throughout your application (and thus global), but the User object is created dynamically in response to the request to create a new User. After the operation is complete, the User object can fall out of scope and be disposed.



            public class Application {
            private IRepository<User> _userRepo = null;

            // UserRepositoryService injected through DI here
            public Application(IRespository<User> userRepo) { _userRepo = userRepo; }

            ...
            public void CreateUser(String userId) {
            User newUser = new User(userId); // Data Object Created
            _userRepo.Insert(newUser);
            } // Data Object falls out of scope here
            }


            This is a simple example, but hope that helps.






            share|improve this answer



























              up vote
              1
              down vote













              The author is differentiating the service objects that compose an application vs the data objects used in an application. Services are global since they are commonly accessible (via injection) to the entire application. An object graph of such services are created when bootstrapping your application with DI. After this object graph is created, your application will use these same services throughout the application for the entire life of your application.



              Data objects, on the other hand, have a local scope. They are created dynamically as needed, used, and then disposed.



              For instance, supposed you have a UserRepositoryService and you want to register a new User. The UserRepsitoryService is configured and injected throughout your application (and thus global), but the User object is created dynamically in response to the request to create a new User. After the operation is complete, the User object can fall out of scope and be disposed.



              public class Application {
              private IRepository<User> _userRepo = null;

              // UserRepositoryService injected through DI here
              public Application(IRespository<User> userRepo) { _userRepo = userRepo; }

              ...
              public void CreateUser(String userId) {
              User newUser = new User(userId); // Data Object Created
              _userRepo.Insert(newUser);
              } // Data Object falls out of scope here
              }


              This is a simple example, but hope that helps.






              share|improve this answer

























                up vote
                1
                down vote










                up vote
                1
                down vote









                The author is differentiating the service objects that compose an application vs the data objects used in an application. Services are global since they are commonly accessible (via injection) to the entire application. An object graph of such services are created when bootstrapping your application with DI. After this object graph is created, your application will use these same services throughout the application for the entire life of your application.



                Data objects, on the other hand, have a local scope. They are created dynamically as needed, used, and then disposed.



                For instance, supposed you have a UserRepositoryService and you want to register a new User. The UserRepsitoryService is configured and injected throughout your application (and thus global), but the User object is created dynamically in response to the request to create a new User. After the operation is complete, the User object can fall out of scope and be disposed.



                public class Application {
                private IRepository<User> _userRepo = null;

                // UserRepositoryService injected through DI here
                public Application(IRespository<User> userRepo) { _userRepo = userRepo; }

                ...
                public void CreateUser(String userId) {
                User newUser = new User(userId); // Data Object Created
                _userRepo.Insert(newUser);
                } // Data Object falls out of scope here
                }


                This is a simple example, but hope that helps.






                share|improve this answer














                The author is differentiating the service objects that compose an application vs the data objects used in an application. Services are global since they are commonly accessible (via injection) to the entire application. An object graph of such services are created when bootstrapping your application with DI. After this object graph is created, your application will use these same services throughout the application for the entire life of your application.



                Data objects, on the other hand, have a local scope. They are created dynamically as needed, used, and then disposed.



                For instance, supposed you have a UserRepositoryService and you want to register a new User. The UserRepsitoryService is configured and injected throughout your application (and thus global), but the User object is created dynamically in response to the request to create a new User. After the operation is complete, the User object can fall out of scope and be disposed.



                public class Application {
                private IRepository<User> _userRepo = null;

                // UserRepositoryService injected through DI here
                public Application(IRespository<User> userRepo) { _userRepo = userRepo; }

                ...
                public void CreateUser(String userId) {
                User newUser = new User(userId); // Data Object Created
                _userRepo.Insert(newUser);
                } // Data Object falls out of scope here
                }


                This is a simple example, but hope that helps.







                share|improve this answer














                share|improve this answer



                share|improve this answer








                edited 2 days ago

























                answered 2 days ago









                Ryan Pierce Williams

                42719




                42719






























                     

                    draft saved


                    draft discarded



















































                     


                    draft saved


                    draft discarded














                    StackExchange.ready(
                    function () {
                    StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53232000%2fwhat-is-it-meant-by-local-vs-global-objects-in-this-article-about-dependency-inj%23new-answer', 'question_page');
                    }
                    );

                    Post as a guest




















































































                    Popular posts from this blog

                    Bressuire

                    Vorschmack

                    Quarantine