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.
dependency-injection global local
add a comment |
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.
dependency-injection global local
add a comment |
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.
dependency-injection global local
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
dependency-injection global local
edited 2 days ago
lagom
3,18341636
3,18341636
asked Nov 9 at 19:15
jhegedus
8,872752114
8,872752114
add a comment |
add a comment |
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.
add a comment |
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.
add a comment |
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.
add a comment |
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.
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.
edited 2 days ago
answered 2 days ago
Ryan Pierce Williams
42719
42719
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
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
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password