Sadek Drobi’s Blog

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…)

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…)

March 28, 2008

Insights: You don’t need your DSL to be English-like

Filed under: Agile Programming, DSL, Domain Driven Design, Useability — Sadache @ 7:49 pm

There is a widespread opinion that a good DSL has to be English-like. Dave Thomas advocates against such approach asserting that DSL are not about getting as close as possible to natural languages and that having this as a guiding principle of DSL design can be rather detrimental. He also highlights what he believes is important in DSL design and provides some examples of successful DSL.

(more…)

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…)

September 29, 2007

Design Driven Testing: Using tests as specifications of system’s invariants and contracts design

Filed under: Agile Programming, Conferences, Domain Driven Design, JAOO, Uncategorized — Sadache @ 4:44 pm

I just got back from JAOO2007. One session of the conference was James Coplien’s “Scrum Architecture”. After this session, a discussion took place about Coplien’s statement that “TDD harms your architecture”! This discussion continued afterwards as an Open Spaces debate. I had the chance then, with the help of Floyd Marinescu, to organize a filmed debate at InfoQ’s studio between Bob Martin and James Coplien on the same topic. I really enjoyed this debate which really showed a high quality spirit of discussion from both sides. Both had their arguments. I will not tell my opinion but rather let you judge yourself once the video is out on www.InfoQ.com .

Recently, I posted about the fact that I always write tests before code, but I don’t do Test Driven Development where I discussed the way I view testing. Yet I don’t guess I’ve been clear enough, so I decided to write few lines trying to better reflect the way I view a testing approach.

When I have a domain problem at hand, first what I think about is partitioning and abstraction, which means dividing the domain into sub-domains. This partitioning procedure is not driven by any tests, but rather by domain knowledge acquired from domain experts. This is extremely important; the architecture/design should reflect the domain/sub-domain problem it is trying to solve. This helps the software be flexible adopting business changes, as it was designed from a business perspective. A book that explains very well this approach is Eric Evans’s Domain Driven Design.

This Up-Front analysis is not defining the full up-front architecture, far from it, rather defining good bases for an architecture that maps to business. It shouldn’t take much time, just enough to help going forward with an iterative approach. This should define, either in code or in a tinny UML sketch, an object structure that forms the basic sub-domain’s components.

After defining the main structure of the sub-domain’s solution, I follow an iterative process as follows:

1: Driven by the business knowledge crunching, I define a component’s contract with its invariants and conditions

2: I write a test that forms the specification of this contract and its invariants

3: I start the implementation to satisfy the specifications I defined in the test

A very important note here is that the contract specifications should be readable, very clear and explicit. This explicitness helps to have a better vision of the whole system while reading the contracts-invariants of its defined components. This also helps spot bugs without the painful debugging: this approach of Design by Contract reflects developers understanding of the business domain in a more explicit way, so it makes it easier to spot misjudgments developers might have done in their implementation. This intention revealing method of development highlights important business rules, rather than letting them hidden behind an abstraction. Abstractions should not hide any important business concern as an implementation details. Explicit contracts and invariants allow business experts to have a look on what is going on inside the software. For an example of bugs that result from developer’s misjudgment see Reganwald’s recent post .

Of course unit tests are not the best tools for this approach. They work fine if we emphasize on methods and class naming for readability and visibility of invariants and rules. Still I prefer tools like BDD or Eiffel/Spec# Design by Contract. Hope we will have some more support for such tools in the industry soon.

A metaphor James Coplien used to illustrate the problem in Test Driven Development approach, which made sense to me, is a test driven course in a school. It’s about a teacher that finds that most of his students fail in the final test. So to make things work better, he decided to ask the students to write themselves their tests by the beginning of the semester, and then to let them pass these tests by the end of that semester! Hence, they might get better grades, but that doesn’t mean they got better knowledge at all.

 

September 24, 2007

Charles Simonyi reveals production use of Intentional Software @ JAOO

Filed under: Conferences, DSL, Domain Driven Design — Sadache @ 10:31 pm

Floyd Marinescu did a good summary of Simonyi’s presentation on JAOO and posted it on IinfoQ

http://www.infoq.com/news/2007/09/intentional-at-jaoo

It seems that guys at Intentional software are having something that works seriously, in real world business.

September 22, 2007

I always write tests before code, but I don’t do Test Driven Development

Filed under: Architecture, Domain Driven Design — Sadache @ 11:35 pm

I am not driven by tests, my code neither. Actually my code is rather driven by design. I do use a test first approach, but I use for a contract first discipline in order to test that my decoupling works. Yes, I think about decoupling first, and then I write tests. I design, and then I write tests. Of course I don’t take a lot of time in my design reflection. But I am not driven by any  force other than my experience and the context at hand. I do abstractions and I validate them with tests. Actually, I use test first approach to specify my design. I don’t write any piece of code without a failed test waiting for it, but still I prefer to call that a test-first approach than the confusing “test-driven development”!

More about this approach to testing in my newer post Design Driven Testing: Using tests as specifications of system’s invariants and contracts design…

September 19, 2007

Domain Specific Languages are technology-agnostic, a more mature representation of their specific domain

Filed under: Architecture, DSL, Domain Driven Design — Sadache @ 7:02 am

One of the most important properties of Domain Specific Languages is that it is an abstraction which is technology-agnostic. We know how often technology changes, adopting new frameworks, discarding old used ones. DSLs keep evolving to be a more and more mature abstraction of the domain. And integration of the new technologies and frameworks becomes nothing more than implementation details behind this abstraction. It forms a kind of specification of the sub domains.

August 7, 2007

DSLs bringing the end of single language development?

My second contribution in InfoQ. An interesting news post about DSLs, and language oriented programming.

http://www.infoq.com/news/2007/08/multi-lingual-programming

Older Posts »

Powered by WordPress