This blog has been moved to http://info.timkellogg.me/blog/

Friday, May 28, 2010

Incidental Inversion of Control

This morning I started reading about the Spring Framework and, as usual, I followed a rabbit hole to learn what the phrase Inversion of Control (IoC) means. IoC is also known as the Hollywood Effect ("don't call us, we'll call you"). A lot of programming frameworks use an inversion of control to take care of the bulk of the work and leave your code to perform its task (and only its task).

Most web frameworks are a good example of IoC. In Java web applications, the framework takes care of all HTTP complexities and turns control over to your servlet or JSP when the time is right. This leaves your JSP to process the request and return a response - easy! The ASP.NET framework has an excellent inversion of control with its postback model. The framework allows for applications to be built very similar to Windows applications - the underlying framework takes care of display issues and calls parts of the applications code when the time is right. A lot of these calls to code are handlers for events like Click, Load, and others.

As I read about this "new" concept I began to realize that it wasn't new at all. ASP.NET and J2EE use it extensively. In fact, I have created such a framework without realizing what I created. In the middle of last year I created a pluggable scheduler interface for our eQube environment that allows the programmer to simply specify report names and filter values via XML, and when it comes time to do something special, the programmer can hook into events and have the framework execute some JavaScript code to do something special.

I stumbled into creating this framework after doing several short projects that required some boilerplate code to interface with the eQube APIs. It all happened quite innocently, but having taken the incidental route to IoC framework I have gotten much more value than I thought I would. For instance, it is suddenly very easy to run a report with 400 different filter configurations. I just put together some XML to spec the report and throw in a block of JavaScript to change the filter values. The inversion of control takes away most of the responsibility and leaves me to do my job, and only my job.

After today's lesson in inversion of control, I'm brainstorming new ways to use it. Perhaps even consolidating my other code into the scheduler framework, or maybe integrating it with the spring framework. As always, there's power in doing less.

1 comment:



  1. Trong lúc cấp tốc phi hành trong hư vô, nỗi lòng Vương Lâm khó có thể yên được.

    Mặc dù nhìn thoạt nhìn bề ngoài thần sắc hắn vẫn như thường, nhưng thực tế trong lòng đang dâng lên một một nỗi kinh hoàng dữ dội.
    đồng tâm
    game mu
    cho thuê phòng trọ
    cho thuê phòng trọ
    nhạc sàn cực mạnh
    tổng đài tư vấn luật miễn phí
    văn phòng luật
    số điện thoại tư vấn luật
    thành lập công ty

    - Điểm cuối cùng của Cực Cảnh là Nguyên Anh Kỳ, nhưng cả đời ta, đầu tiên là gặp được Nạp Đa của Ngũ Hành Tinh, người này có được Cực Cảnh, vả lại cũng từng nói Cực Cảnh này là của người bạn trước khi chết tặng cho. Ngoài hắn ra, lúc này ta lại nhìn thấy Cực Cảnh lần thứ hai !

    Ánh mắt Vương Lâm lộ vẻ trầm tư, xuyên qua hư vô rộng lớn, thẳng đến vị trí trung tâm của phần lớn mảnh vỡ trên Lôi Tiên Giới.

    - Chẳng lẽ… thật sự có phương pháp có thể thăng cấp cho Cực Cảnh… …

    Vương Lâm tim đập thình thịch, thậm chí miệng lưỡi còn cảm thấy hơi khô. Thời gian mấy trăm năm đi cùng với Cực Cảnh, khiến cho hiểu biết của hắn đối với loại thần thông không thể nắm bắt được này vô cùng sâu sắc.

    ReplyDelete