Sadek Drobi’s Blog

June 26, 2009

A monad in C# for simplifying WPF multi-threading for a more responsive GUI

Code included here is over simplified for clarity, I hosted a better implementation code on CodePlex. These modifications change strictly nothing for the client code and are only an implementation detail. I use a continuation rather than a delay, and I chose to design a custom continuation class rather than using a delegate because of a type system limitations.

DSC_2468Most GUI frameworks, including Silverlight and WPF, are shipped with a fundamental problem: long use of the main thread causes the Window to blackout, and using different threads requires you to get your hands dirty with the Dispatcher stuff and freezable objects. Worse, you wont learn the necessity to do so until you get a surprise of “The calling thread cannot access this object because a different thread owns it.” exception when all what you were doing is to use available methods on an object that seemed you have access to, at lease it seemed until runtime! This post illustrates a solution based on Monads abstraction and LinQ syntax.
(more…)

June 10, 2009

DCI in Real World: Domain Context and Interaction with Scala in a Real World Project

Those that follow my twitter @sadache , me @infoQ or my blog have certainly already noticed that I am quite interested in Scala on languages’ axis and in Domain Context Interaction DCI pattern on architecture axis. I always search new ways for delivering quality code which is modular and concise. Modularity offers the opportunity to think about the problem in parts, which is typical of the way brains work, whereas conciseness makes use of imaginary system (reading code blocks like images).

Recently, I’ve been working on a Web Api system where, thanks to support of @jeanlaurent http://morlhon.net/blog/, I used Scala applying DCI architecture in a real world project. This post is about reporting benefits of using this approach. Other posts will follow that will be more focused on the use of Scala and Functional Programming in that project. Code included is a bit simplified and parts of the system that are not of interest are omitted.

(more…)

May 28, 2009

I am speaking in Erlang Factory London 2009

Filed under: C#, Conferences, Erlang, F#, Multi-Paradigm Design — Sadache @ 10:43 pm

May 27, 2009

Multimethod in Clojure: Should I call it first class Pattern Matching? or Pattern Matching in disguise?

from Rich Hickey on Clojure’s Features and Implementation

Clojure multimethods are just another level of that same logic, in fact they are a realization of the last sentence I just said. They are dispatch based upon an arbitrary function of the arguments. You define a multimethod and you say “Here is a function of the arguments I’d like you to use” You could look at the first argument, you could look at the 5th, you could look at all of them, you could look inside them, some member of an argument, it could look at the types or not or the values. Now, you could look at relationships between arguments, you have dispatch based upon an arbitrary function of the arguments and you have a vastly wider set of polymorphic possibilities than you had before and it’s quite powerful. In particular, it allows you to do Runtime dispatch on Runtime attributes. You don’t usually represent something like being hungry as part of something’s type, it’s some attribute that it acquires while the program is running or being outdated or things like that. Now you can access those things and you can do things polymorphically based upon that and take a lot of switch statements out of your code.

Should I call it first class Pattern Matching? or Pattern Matching in disguise?

May 8, 2009

Data, Context and Interaction : a new architectural approach by James O. Coplien and Trygve Reenskaug

James O. Coplien and Trygve Reenskaug have recently introduced a new architectural approach to OOP based on Data, Context and Interaction pattern. It should allow capturing user mental model in terms of behavioral requirements, something that classic OOP fails to do. The article, that triggered many reactions and critics, provides insights into DCI using concrete examples to show its advantages.

(more…)

February 18, 2009

I am speaking at QCon

download (1)

 

(more…)

January 10, 2009

Programming Languages: 2008 Review and Prospects for 2009

In the beginning of last year, Ehud Lamm launched on Lamba the Ultimate a thread about programming languages predictions for 2008. Several subjects popped up: concurrency, functional programming, future of Java, Ruby, C++, and many others… What really happened in 2008 and what are the prospects for 2009? Bloggers have addressed these questions on demand of James Iry, echoing at last year thread.

(more…)

January 5, 2009

You’ve got 100 pages to convince me of your shiny language!

DSC_0150- In the rapidly spanning world of programming languages, I find myself buying and reading a lot of books about new and old programming languages. There are a few interesting concepts in each language, and if you think about employing more than one language in your projects then you better know about the existence of these concepts (see Paradigm based Polyglot Programming).

One thing that annoys me though about most programming language books is how raw they often are.

(more…)

November 10, 2008

RefX:: ORMs, Relational Data, Mismatch, LinQ and DSLs

Raw00078 Raw00170 DSC_0191

Having worked with several Object-Relational mapping frameworks in the last few years, I got to a point where I couldn’t justify their complexity in my project. We often talk about the mismatch between the database and the object worlds, and that is where ORMs are often stated and referenced for “bridging the gap”!

Well I prefer to call it lifting the gap, or highering the gap, to have it now between DAOs and the rest of the code than having it between database and code.But I wouldn’t call this in any way reducing the gap.

(more…)

September 25, 2008

Paradigm based Polyglot Programming

DSC_0172

How many languages are you using on the same project? If you go counting you will see that they are many. I mean XML, Java, XSLT, HTML, CSS… etc. But the reason why you are using almost all of them is that they happen to be mainstream and, oftentimes, they are the only language choice for a needed framework. You are actually almost obliged to use them. The choice is done for you. Style? CSS. Configuration? Often XML. Web interface description? Html. However, if you want to adopt true polyglot programming, you will have to face inevitable decision of language choice.

(more…)

Older Posts »

Powered by WordPress