background preloader

Computing

Facebook Twitter

Programming

Silverlight. Programming tips. Flickr. Implicit invocation. Implicit invocation is the core technique behind the Observer pattern. See also[edit] External links[edit] Hollywood Principle. In computer programming, the Hollywood principle is stated as "don't call us, we'll call you. " It has applications in software engineering; see also implicit invocation for a related architectural principle. Overview[edit] Most beginners are first introduced to programming from a diametrically opposed viewpoint. Programs such as Hello World take control of the running environment and make calls on the underlying system to do their work. As systems increase in complexity, the linear model becomes less maintainable.

What happens if the user resizes the window? It would be much more elegant if the programmer could concentrate on the application (in this case, updating the coordinates of the box) and leave the parts common to every application to something else. Event loop programming, however, is merely the beginning of software development following the Hollywood principle. All of these mechanisms require some cooperation from the developer. Recent paradigms[edit] Inversion of control[edit] Dependency injection. There are three common forms of dependency injection: setter-, interface- and constructor-based injection, where the responsibility of injecting the dependency lies upon the client, the service or the constructor method respectively. Overview[edit] Implementation of dependency injection is often identical to that of the strategy pattern, but while the strategy pattern is intended for dependencies to be interchangeable throughout an object's lifetime, in dependency injection only a single instance of a dependency is used.

[citation needed] Application frameworks such as Spring, Guice, Glassfish HK2, and Microsoft Managed Extensibility Framework (MEF) support dependency injection. Advantages[edit] Disadvantages[edit] Examples[edit] Without dependency injection[edit] Dependency injection is an alternative technique to initialize the member variable than explicitly creating a service object as shown above. Three types of dependency injection[edit] Other types[edit] Constructor injection[edit] Inversion of Control Containers and the Dependency Injection pattern. In the Java community there's been a rush of lightweight containers that help to assemble components from different projects into a cohesive application.

Underlying these containers is a common pattern to how they perform the wiring, a concept they refer under the very generic name of "Inversion of Control". In this article I dig into how this pattern works, under the more specific name of "Dependency Injection", and contrast it with the Service Locator alternative. The choice between them is less important than the principle of separating configuration from use. One of the entertaining things about the enterprise Java world is the huge amount of activity in building alternatives to the mainstream J2EE technologies, much of it happening in open source. Underlying these containers are a number of interesting design principles, things that go beyond both these specific containers and indeed the Java platform.

Components and Services A Naive Example class MovieLister... Inversion of Control. Expression Trees: Why LINQ to SQL is Better than NHibernate. In my last post I described how the Where() function works for LINQ to Objects via extension methods and the yield statement. That was interesting. But where things get crazy is how the other LINQ technologies, like LINQ to SQL use extension methods. In particular it’s their use of a new C# 3 feature called expression trees that makes them extremely powerful. And it’s an advantage that more traditional technologies like NHibernate will never touch until they branch out from being a simple port of a Java technology. In this post I’ll explain the inherent advantage conferred on LINQ technologies by expression trees and attempt to describe how the magic works.

What’s so Magic about LINQ to SQL? LINQ to SQL (and it’s more powerful unreleased cousin LINQ to Entities) is a new Object Relational Mapping (ORM) technology from Microsoft. IEnumerable<Product> products = northwindDataContext.Products.Where( p => p.Category.CategoryName == "Beverages" ); SELECT [t0]. In other words it’s pretty smart. Expression Tree Basics - Charlie Calvert's Community Blog. Newcomers to LINQ often find expression trees difficult to grasp. In this post I hope to show that the subject is not quite as difficult as it might appear at first. Any reader who has an intermediate level understanding of LINQ should find the material in this post easy to grasp. An expression tree provides a method of translating executable code into data. This can be very valuable if you want to modify or transform code before executing it.

In particular, it can be useful if you want to transform C# code such as a LINQ query expression into code that operates on another process, such as a SQL database. But I'm getting ahead of myself. By the end of this post you will find it easy to understand why it is helpful to translate code into data. The Syntax for an Expression Tree Consider the following very simple lambda expression: Func<int, int, int> function = (a,b) => a + b; This statement consists of three sections. public int function(int a, int b) { return a + b; } int c = function(3, 5); Expression Trees in C# 3.0 - C# 3.0 Examples and Tutorials.

LINQ: Building an IQueryable provider series - The Wayward WebLog. LINQ to SQL (Part 3 - Querying our Database) Last month I started a blog post series covering LINQ to SQL. LINQ to SQL is a built-in O/RM (object relational mapping) framework that ships in the .NET Framework 3.5 release, and which enables you to easily model relational databases using .NET classes. You can then use LINQ expressions to query the database with them, as well as update/insert/delete data from it. Below are the first two parts of my LINQ to SQL series: In today's blog post I'll be going into more detail on how to use the data model we created in the Part 2 post, and show how to use it to query data within an ASP.NET project. Northwind Database Modeled using LINQ to SQL In Part 2 of this series I walked through how to create a LINQ to SQL class model using the LINQ to SQL designer that is built-into VS 2008. Retrieving Products Once we have defined our data model classes above, we can easily query and retrieve data from our database.

Visualizing LINQ to SQL Queries in the Debugger Shaping our Query Results Summary Scott. Using LINQPad with Entity Framework. Using LINQPad with Entity Framework LINQPad lets you query Entity Framework models that you define in Visual Studio. Here's how to proceed: Create an ADO.NET Entity Data Model in a Visual Studio project, and build. From LINQPad, click Add Connection (top left) and choose Entity Framework in the bottom listbox. If you're using Entity Framework 4.1/4.2 code-first, choose Entity Framework - POCO).

A few notes: You can return to Visual Studio at any time and rebuild - LINQPad will not lock your assembly. More Information View O'Reilly's detailed video tutorial on using LINQPad with Entity Framework - and LINQPad's other new features. Also, check out Stefan Cruysberghs's blog which provides further information on using LINQPad with Entity Framework and custom LINQ to SQL data context classes. Over 1 million downloads LINQPad Bookmark this on Delicious Follow LINQPad on Facebook More LINQPad Forum LINQPad + Mindscape LightSpeed LINQPad + OData LINQPad + DevForce LINQPad + DevArt AWS with LINQPad Videos. FlickrVIEWR – A flickr viewer in Silverlight – Part 1. I’m back! I’ve had my work up to my eyeballs the last couple of weeks. Apparently moving to the other side of the world and starting a new job takes a lot of time.

So after that excuse, it is time to get started with my new project. My fiancée has this blog where she blogs about our new life in NZ. And this is interesting to you because…? Well, it isn’t, but it is the reason for this blog post as well as a few more coming soon. The final result will look like below. The first step in creating a flickr viewer is obviously to have a look at the flickr API. flickr has several APIs, but I have decided to go for the very simple REST API. To support the 2 different selection modes, I had to get familiar with 3 different methods in the flickr API, flickr.photosets.getPhotos, flickr.photos.search and flickr.photos.getInfo.

As you can see (if you didn’t just skip my url definition above), you need something called an API key. The service will be very simple. If (progressChangedHandler !