The lazy-initialization tag has no wiki summary.
13
votes
4answers
3k views
Why isn't lazy evaluation used everywhere?
I've just learnt how lazy evaluation works and I was wondering: why isn't lazy evaluation applied in every software currently produced? Why still using eager evaluation?
9
votes
4answers
888 views
Is there any reason lazy initialization couldn't be built into Java?
Since I'm working on a server with absolutely no non-persisted state for users, every User-related object we have is rolled out on every request.
Consequently I often find myself doing lazy ...
5
votes
4answers
801 views
What is a good pattern for combined caching and reinitialization?
I have a situation where I have three requirements:
Lazy initialization - don't create the collection until asked for it
Caching - keep the collection in memory on the object
Reinitialization - be ...
3
votes
1answer
469 views
Lazy loading can lead to stale data, violates IoC?
Trying to be a better programmer
I have an application that keeps track of Roles and Permissions, I had classes for Role and Permission which were just value objects.
class Role
{
int RoleID
...
2
votes
1answer
366 views
Why does this static field always get initialized over-eagerly?
I am looking at this excellent article from Jon Skeet.
While executing the demo code, Jon Skeet says that we can expect three different kinds of behaviours. To quote that article:
The runtime ...
2
votes
2answers
169 views
Lazy loading if collection would have any entries
I often see model classes with properties like this:
public IList<Note> Notes { get; set; }
public bool HasNotes { get; set; }
Where the list is initialized lazy, but the boolean property is ...
1
vote
1answer
325 views
WPF: Reloading app parts to handle persistence as well as memory management
I created a app using Microsoft's WPF. It mostly handles data reading and input as well as associating relations between data within specific parameters.
As a total beginner I made some bad design ...
1
vote
0answers
195 views
Entity Framework - Loading Related Entities Explicitly
I have been using Entity Framework for a few years. I have flip-flopped between calling out to repositories in my business logic or using lazy loading to retrieve data as I work my way through the ...
0
votes
0answers
78 views
Succinct Lazy Initialization Pattern
Background
I often use the following lazy initialization pattern:
public class Clazz {
private Object object;
private Object getObject() {
Object object = this.object;
if( object == ...
0
votes
0answers
77 views
Design of a custom query result array with lazy loading
I have a database that generates a query result array, each position of the array being a hash like object.
Since each array item must be mapped into a well defined class, I decided to implement an ...