The lazy-initialization tag has no usage guidance.
5
votes
1answer
181 views
How to populate Lazy object from database
I have these classes:
public class Order
{
private Lazy<IEnumerable<Volume>> _volumes;
long ID { get; private set; }
string Description { get; private set; }
...
0
votes
0answers
73 views
Whats the best way to implement DataMapper design pater and lazy loading (ghost object)
I'm doing a small project and I wanted to keep it simple to mantain.
It is a renting management software. To keep it clean I decided to implement the data mapper patern, to keep the domain objects in ...
1
vote
1answer
265 views
Is “lazy loading” factories in AngularJS using this $q.defer method good practice
I guess I don't believe in myself as a good programmer but I found out this method on my own (not suggestion I'm the first one to do it, but I didn't follow a guide) so it must be broken somehow.
$q ...
2
votes
2answers
208 views
Lazy loaded property signatures in business objects
Let's say I am designing business objects around a poorly optimized database that have no ability to change.
I have a Person object with a ShippingAddress property. The ShippingAddress is very ...
0
votes
0answers
36 views
Dealing with stale data / currency issues when lazy loading related entities
Imagine I have two associated domain entities with a one-to-many relationship. Here is an example with Customer and Order classes:
public class Customer
{
public int ID { get; internal set; }
...
1
vote
2answers
184 views
Is lazy loading always required?
I know lazy loading is required when an expensive database call is being made. It would make sense using lazy loading in this example. The below example is in the context of asp.net so it's thread ...
2
votes
1answer
214 views
Applying initialization-on-demand holder idiom at variable level rather than class
I was looking for the idiomatic way to implement thread-safe lazy initialization for a configuration collection retrieved from the DB inside a Spring bean.
I decided to adapt the ...
0
votes
1answer
82 views
Does a create() method exist as part of a pattern? [closed]
Is there something special(i.e. a design pattern being related) to a method named create()?
Background
The case is, I often make some instances of objects (of the same class/prototype). These ...
6
votes
2answers
735 views
Does laziness yield more race conditions?
I recently ran into a race condition while accessing a configuration setting. After examining what I could of the code, I came to the conclusion that the Configuration class' laziness1 was the source ...
-1
votes
2answers
127 views
Is 'lazy' the correct term for timestamp-based skipping? [closed]
(1)
The oldmakeutility looks at timestamps, and if the output is newer than the input, it skips (pointless, time-consuming) re-compilation of e.g. C files.
The same is true for many languages and ...
0
votes
1answer
163 views
Lazy-initialization vs preprocessing in image-based iOS app
I am making an iOS app which contains museum gallery: user can look through exhibits and then select info about it, etc.
On the exhibit screen I have two ScrollViews that are different, but are being ...
2
votes
0answers
758 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
126 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 == ...
2
votes
2answers
275 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 ...
3
votes
1answer
506 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 ...
3
votes
1answer
622 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
...
24
votes
6answers
6k 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?
5
votes
4answers
1k 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 ...
9
votes
4answers
1k 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 ...
1
vote
1answer
395 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 ...