lazy-loading

Lazy-loaded singleton: Double-checked locking vs Initialization on demand holder idiom

主宰稳场 提交于 2019-11-29 01:36:38
问题 I have a requirement to lazy-load resources in a concurrent environment. The code to load the resources should be executed only once. Both Double-checked locking (using JRE 5+ and the volatile keyword) and Initialization on demand holder idiom seems to fit the job well. Just by looking at the code, Initialization on demand holder idiom seems cleaner and more efficient (but hey, I'm guessing here). Still, I will have to take care and document the pattern at every one of my Singletons. At least

IQueryable vs. IEnumerable in the repository pattern , lazy loading

假装没事ソ 提交于 2019-11-29 01:26:25
I have read some articles that state that IEnumerable used to mimic stored procedures or restrict your database. Lost lazy loading ability on the external provider. Where as IQueryable to give developers more flexibility. Lazy loading is there. In terms of performance, both consume a significant amount of performance .. so which one is more preferable? Robert Harvey From the perspective of a Repository Pattern, you can think of it this way: Use an eager loading IEnumerable when you want to pass an entire list to the client in one go. They can still add linq clauses, but the client does not

Doctrine2 (Doctrine 2.1) eager loading in Symfony2

拜拜、爱过 提交于 2019-11-29 01:21:59
Let's say I have two entities in my Symfony2 project : Category and Article (a category having many articles). In my CategoryRepository , I have this method: findAllDummy(){ return $this->createQueryBuilder('c') ->leftJoin('c.Articles a') ->getQuery()->getResult(); } If I remember well, in Symfony1.4 (and the corresponding version of Doctrine), the returned objects would have their 'articles' attribute filled by the corresponding Article objects. Now, in Symfony2, Proxy objects are returned. So if I loop through a specific category's articles, As many queries as iterations will be executed.

Is it bad practice to have my getter method change the stored value?

青春壹個敷衍的年華 提交于 2019-11-29 01:21:04
问题 Is it bad practice to change my getter method like version 2 in my class. Version 1: public String getMyValue(){ return this.myValue } Version 2: public String getMyValue(){ if(this.myValue == null || this.myValue.isEmpty()){ this.myValue = "N/A"; } return this.myValue; } 回答1: I think it is actually quite a bad practice if your getter methods change the internal state of the object. To achieve the same I would suggest just returning the "N/A" . Generally speaking this internal field might be

Issue with Casting proxies when using NHibernate table per subclass inheritance strategy

谁都会走 提交于 2019-11-28 23:39:18
I have got an abstract base class and inherited poco entities. I am using table per subclass inheritance with fluent nhibernate 1.1 automapping. The class inheritance looks like follows Node (abstract class) Place : Node Asset : Node Node class is basically a tree structure. public abstract class Node { public virtual int Id { get; set; } public virtual Node ParentNode { get; set; } public virtual ICollection<Node> ChildNodes { get; set; } } Now the problem is when I get an object of Asset from database and do objAsset.ParentNode, I can cast ParentNode to Asset or Place, but if I do something

jQuery Infinite Scrolling/Lazy Loading

瘦欲@ 提交于 2019-11-28 23:15:39
问题 I'm currently redesigning my website and have been looking into using JavaScript and jQuery. Here is what I have so far: http://www.tedwinder.co.uk/gallery2/. My vision is to have all of the photos on one page, which the user can scroll through, like now. However, I understand the limitations and effects of having 50+ large-ish images on one page and have considered using infinite scrolling and lazy loading, which I understand would only load the images when the user gets to them, or when

DTO Pattern + Lazy Loading + Entity Framework + ASP.Net MVC + Auto Mapper

泄露秘密 提交于 2019-11-28 23:06:32
问题 Firstly, Sorry For lengthy question but I have to give some underlying information. We are creating an Application which uses ASP.net MVC, JQuery Templates, Entity Framework, WCF and we used POCO as our domain layer. In our application, there is a WCF Services Layer to exchange data with ASP.net MVC application and it uses Data Transfer Objects (DTOs) from WCF to MVC. Furthermore, the application uses Lazy Loading in Entity Framework by using AutoMapper when converting Domain-TO-DTOs in our

Lazy load Angular 5 error: $$_lazy_route_resource lazy recursive

被刻印的时光 ゝ 提交于 2019-11-28 22:38:29
I'm using angular cli AoT compilation. When I try to make a lazy load component following this tutorial , I got the error below: ERROR Error: Uncaught (in promise): TypeError: __webpack_require__.e is not a function TypeError: __webpack_require__.e is not a function at webpackAsyncContext (eval at ./src/$$_lazy_route_resource lazy recursive (main.bundle.js:13), <anonymous>:15:29) at SystemJsNgModuleLoader.loadAndCompile (core.js:6554) at SystemJsNgModuleLoader.load (core.js:6538) at RouterConfigLoader.loadModuleFactory (router.js:4543) at RouterConfigLoader.load (router.js:4523) at

jQuery LazyLoad do not load images until scroll

百般思念 提交于 2019-11-28 21:27:17
jQuery LazyLoad doesn't load images in open page's visible part until I scroll page even on 1px. When I scroll page all works right Update: CoffeScript jQuery -> $("img.lazy").show().lazyload() $(window).resize() But $(window).resize() helps only if i enter it from browser's console when page have loaded Your images must have width and height set. $("img.lazy").lazyload({ threshold : 50 }); And add this: $(window).load(function(){ $("html,body").trigger("scroll"); }); Try this.... $(function() { $("img.lazy").show().lazyload() window.onload = function() { $(window).resize() }; }); I am too

lazy load iframe (delay src http call) with jquery

假如想象 提交于 2019-11-28 21:24:12
问题 I am looking for something similar to jQuery image lazy load plugin, but for iframe s. 回答1: This worked for me. var iframes = $('iframe'); $('button').click(function() { iframes.attr('src', function() { return $(this).data('src'); }); }); iframes.attr('data-src', function() { var src = $(this).attr('src'); $(this).removeAttr('src'); return src; }); jsFiddle. 回答2: A similar question was recently posted specific to iFrames with Twitter Bootstrap-based tabs, which I answered using a technique I