Sadek Drobi’s Blog

April 20, 2008

And Design Patterns suddenly Degrade!

Filed under: Architecture, C#, Functional Programming, LinQ, DSL, Haskell — Sadache @ 9:25 pm

Lately I’ve been writing some programs with Haskell (a pure functional programming language) and I noticed that I am not using GoF design patterns anymore, and that got me to a question: What are GoF design patterns? And why do we need them?

This actually reminds me of a good definition I read (I can’t recall where) of these design patterns: Resolutions to programming language limitations implemented using the programming language available syntax. When one learns a programming language, he learns to express what he wants to express using a very limited set of expressions of the language. The problem with this is that his imagination in this environment gets boxed! So what are GoF design patterns?

Most of GoF design patterns are inspired from Smaltalk, so what is so special about Smaltalk? Closures! It turns out that Java and C++ didn’t have closures and higher order functions. Some of the Design Patterns came to rescue and provide "alternatives" to these powerful constructs or workarounds  to resolve these limitations. Such an approach requires a kind of object gymnastics and results in an explosion of classes!

I am now on a project where I use C# 3.5 features, and guess what? Suddenly I use much less strategies, much less templates. I write much less code yet being as or even more flexible. Powerful lambda expressions!

Update: DSLs also come from fp paradigm!

March 9, 2008

Obsev:: Mutability is addictive like drugs, Mutation can become a cancer!

This is really crazy!

The first time I got introduced to mutation, I had a bad feeling. How can x:=x+1 be logical at all?

It felt so unnatural, scary, or maybe like a hack. Then, because of society constrains, I got to forget the bad feeling about that. Well, my mind started to tolerate with counter-logic logic. And that is how I became an enterprise developer. I am not sure how proud I am with this title anyway. I feel that tolerating and accepting the counter-logic logic is one, and most important one, of the prerequisite to this title.

(more…)

April 5, 2007

LinQing your processors… In Parallel!

Filed under: C#, LinQ — Sadache @ 10:45 am

Having manipulated references for quite a while, in an imperative style of programming languages, we searched a lot for solutions for deploying our applications and make them run on several processors. We ve been trieng to extract some logic out of the non-logical machine friendly reference manipulation syntax, to be able to distribute it on deffirent processors. And here comes problems of synchronization of deffirent threads accesing the same reference, which is often a quite complex task.

But, what about going stateless? no synchrnization to do, and instead of telling the runtime how to do, we tell what to do, by passing fuctions that explain that. Well thats what Functional Programming is about!

Recently I crossed two interesting posts, the first is demonstrating an implementation of a paralleledList that uses several proccesors for tasks like filtering, implemented in F#, a quite promissing mixed paradigm language based on .net framework.

http://cs.hubfs.net/blogs/tomasp/archive/2007/03/25/fsharp_parallel_ops.aspx

For those of you not familiar with ML driven syntax, the second article is demonstrating PLinq in C# language which “still” looks like java.

http://community.bartdesmet.net/blogs/bart/archive/2007/04/04/introducing-plinq.aspx

Results are pretty interesting, demonstrating the effect of using more threads against limited-large number of records.

Have fun!

March 15, 2007

Live Draft : Democrazing The Cloud : Erik Meijer, Creator, LINQ

Filed under: C#, DOTNET, LinQ, QCon2007, Conferences — Sadache @ 10:46 am

Erik Meijer, Creator, LINQ 

(more…)

February 25, 2007

Obsev :: Implementing Domain Friendly, Predicates-like Specifications with C# 3.0 Expression trees

According to Fowler and Evans, Specification ” is to separate the statement of how to match a candidate, from the candidate object that it is matched against. As well as its usefulness in selection, it is also valuable for validation and for building to order “  .

We might need to secify the state of an object for one of these three purposes.

  • To validate an object to see if it fullfills some need or ready for some purpose (Validation)
  • To select an object from a collection (Selection)
  • To specify the creation of a new object to fit some need (Building to order)  *Quote from DDD / Eric Evans*

(more…)

February 18, 2007

Obsev :: Free Your Mind (Satisfaction Confusion part2)

Filed under: C#, Agile Programming, Domain Driven Design, Functional Programming — Sadache @ 12:49 am

in my previous post http://sadekdrobi.com/?p=25 i listed some  Satisfaction Confusions that we are having in

popular imperative procedural object oriented statically typed C-like syntax programming languages, the question was where the goodness really comes from, and what are the drawbacks to such confusions.

One epression that is lately often used to stegmatise a piece of code is to tell “not object oriented”.  This expression is a good sign of something we always waited, which is the awareness of the majority of today’s developers of  the importance of the Object Oriented programming principiles. But on the other hand, the expression itself highlights another satisfaction confusion. Even myself, i sometimes feel it an insult to be told that my code is not object oriented, so what?!! should it be? or… it is not meant to be !!!

(more…)

February 17, 2007

Obsev:: Satisfaction Confusion

Filed under: C#, Agile Programming, Domain Driven Design, Functional Programming — Sadache @ 2:01 pm

Going back into my memories, it happens to me quite often that i have good memories for a place because something good happened once for me there, or good memories for someone because he delivered me a good news … i guess feelings can be quite distracting sometimes. when i used to be a child, i used to hate fish, i didnt like fish, anykind! i used to quit the table when fish is present.

Lately i relized that what i had problem with is fish’s smell, and specifically well cooked fish meet’s smell. Now i eat fish, one of my favourite plates is Sushi and Sashimi :p

I guess it is quite human thing to hate things as a whole, tagging as bad any set of objects that have one bad property, forgetting about all the universe arround, that might have contributed to that bad, and that can change with time.

In the programming languages paradigm we had - and we are still having - a lot of such a satisfaction confusion. Imperative (procedural) programming had gained a lot of market and as it often happens this was due to a massive marketing of a good property of the product. Imperative programming consists of sets of machine instruction (more…)

January 7, 2007

OBSEV:: Fluent Interface and c# 3.0 Extension Methods : The flexibility of dynamic typing with the powerfull AutoCompletion

Filed under: Architecture, C#, Martin Fowler — Sadache @ 11:12 pm

Fluent Interface  is a pattern discovered by Eric Evans and Martin Fowler.

one problem of this pattern is  ”a mismatch between what a fluent interface needs and our usual guidelines for API design. What works well for a regular API doesn’t work for a fluent one and vice versa .” (Fowler)

So using FluentInterface we start adding setters that have a return value, others that they should not belong to the class in the API terms, but they do in Dsl terms.

Martin suggested an Expression Builder, which is a class that contains these bizar methods, But that means more classes, moreover, returning an interface of that Expression Builder that only contains allowed methods will add even more files and interfaces!

then He stated “dynamic languages work better for DSLs since they tend to have (more…)

January 2, 2007

Joined the NMVP open source project

Filed under: C#, MVP, DOTNET — Sadache @ 10:20 pm

I joined the NMVP open source project on codeplex, i ll be busy in the evenings implementing Convention over Configurations, and Rapid Web NMVP Assembly that will facilates the framework use !

 www.codeplex.com/nmvp

Refx:: DSL Tools, démonstration d’un designer MVP (translation in english follows)

Filed under: Architecture, C#, MVP — Sadache @ 9:52 pm

Depuis quelques temps, je tombe fréquemment sur des articles au sujet des DSL de Microsoft. Je me demande systématiquement : « pourquoi un autre langage de modélisation ? UML remplit bien ses fonctions et quand bien même, non seulement je ne crois pas en une modélisation forward blueprint (une modélisation exhaustive en début de projet), mais en plus, cette pratique va à l’encontre de mes principes d’agilité »

Ces lignes vont vous montrer pourquoi j’ai eu tort de tourner la page. (more…)

Next Page »

Powered by WordPress