Choosing the right abstractions

Choosing the right abstractions can be hard.   Lets take a good look at the next piece of code. 1: public class WrongAbstraction 2: { 3: public void Execute() 4: { 5: IEnumerable<Product> products = GetProducts(); 6: PrintProducts(products); 7: } 8:  9: private void PrintProducts(IEnumerable<Product> products) 10: { 11: foreach (var product in products) 12: { 13: Console.WriteLine(product.ProductName); 14: } 15:  16: Console.WriteLine("Total number of products {0}", products.Count()); 17: } 18:  19: private IEnumerable<Product> GetProducts() 20: { 21: using (var ctx = new NorthwindEntities()) 22: { 23: return ctx.Products.ToArray(); 24: } 25:  26: } 27: }   That looks quite … Continue reading Choosing the right abstractions

Showing AJAX activity in a AngularJS application

  Showing some kind of AJAX busy indicator is a common thing in web applications. However it is something you don’t want to do with every AJAX start and end of request. First of all writing all that code would be quite tedious but more importantly the might be multiple overlapping requests ongoing at the same time. And in a case like that you only want to show the AJAX busy indicator at the first request and more importantly hide it only when the last of the requests has finished. Fortunately AngularJS has some nice integration points allowing us to … Continue reading Showing AJAX activity in a AngularJS application