Kurser i Domain-Driven Design - VĂ¥ren 2012




Monday, August 10, 2009

Laziness IS a Virtue of a Programmer

As it turns out, laziness is a virtue of a programmer...

It is with particular joy I am rediscovering the programming paradigm that once introduced me to the art of software development: Functional programming. I begun my university studies almost 15 years ago. I initially planned to study biotechnology, but for different reasons I ended up with a M Sc degree in Information Technology Engineering instead. I had not really been doing any serious computer programming prior to my university studies, and the first course they threw at us was this monstrous thing called "Program Construction". It sure was a lot of work, but it built a great foundation for our further studies. And it was all tought in ML. 10+ years of Java followed. March this year I attended QCon London to give a tutorial on the DDDSample app, and also had the opportunity to listen to Rich Hickey give a presentation on Clojure. Since then I have slowly been rediscovering the beauty of functional programming; map, reduce/fold, higher-order functions, recursion, and more.

As an example, let's look at Clojure's lazy sequences:

This gives us a lazy sequence of all whole numbers:
(def numbers (iterate inc 1))

If executed it will define a lazy sequence, i.e. its elements will not be evaluated until needed. This is a good thing in this case since this sequence is infinite.

We can now use this infinite sequence, for example by calling:
(take 10 (drop 1000 numbers))

which will return the following (lazy) sequence:
(1001 1002 1003 1004 1005 1006 1007 1008 1009 1010)

Or why not take all the even numbers by filtering the sequence:
(take 10 (filter even? numbers))

returns:
(2 4 6 8 10 12 14 16 18 20)

I think this is pretty sweet!

For an upcoming PNEHM! article I needed to generate data sets of arbitrary sizes consisting of random letters a-z, so I did this:
(def s "abcdefghijklmnopqrstuvwxyz")

(def data-set
(repeatedly
#(nth s (rand-int (dec (count s))))))

From which I can take whatever number of random characters I like and do something with, for instance write 100 chars to file as a string:
(use 'clojure.contrib.duck-streams)
(spit "data-set.txt" (apply str (take 100 data-set)))

Note that the sequence is cached, so I will get the same characters each time (take 100 ...) is called. This may not be what you want. Converting the def to a no-args function, we can call it repeatedly and get different lazy sequences:
(defn data-set []
(repeatedly
#(nth s (rand-int (dec (count s))))))

And do:
(take 100 (data-set))

One final example, a function to calculate the Fibonacci sequence, from http://en.wikibooks.org/wiki/Clojure_Programming/Examples/Lazy_Fibonacci:
(defn fib-seq []
((fn rfib [a b]
(cons a (lazy-seq (rfib b (+ a b)))))
0 1))

(take 10 (fib-seq))

Gives:
(0 1 1 2 3 5 8 13 21 34)

Tuesday, June 30, 2009

DDDSample Interview Published

At Jfokus 2009, Sweden's largest annual Java conference, Peter Backlund and I gave a three-hour tutorial on DDDSample. DDDSample is a sample application for exploring the building blocks of Domain-Driven Design built in cooperation with Citerus and Eric Evans.

We were also interviewed by Dan Berg Johnson on the topic; that interview is now published.

For more info on Jfokus, including a number of recorded presentations, visit http://www.jfokus.se/.

And don't forget to check out the DDDSample!

Monday, June 22, 2009

Giving Up on Safari 4

It lasted 8 days this time around. After using Safari 4 as my main browser for about a week I decided to let it go. Despite applying the tweaks from this post there are still a few things that just isn't working out for me:

1) The setting to force opening of new windows in tabs is a little too "always" for my taste. I want (allowed) pop-ups to pop-up, but links that request a new window to be opened in new tabs. I believe this is the Firefox default and it works great.

2) Blocking pop-up windows is nice, but I'd like the browser to tell me when this happens, so I can elect to view this particular pop-up if I wish,

3) Once you get used to the Awesomebar, all other URL bars are, well, not so awesome.

So, for now I am running Firefox 3.5 rc2! If you have any ideas on how to fix the things above, please let me know and perhaps I'll try out Safari 5.

Wednesday, June 17, 2009

Them Netbooks

After almost ten years of daily commuting between Uppsala and Stockholm I finally decided that enough was enough, and moved closer to where I work. For my current engagement this cut traveling down from about 80 to 30 minutest. One way. Per day. Much better from a getting-up-early-and-getting-home-late perspective.

However, spending all this time on trains had the side-effect of making time available for writing blog entries and PNEHM! articles (and the occasional nap). So with effective train-time cut down from 40 to 18 minutes there simply hasn't been that many blog entries written, except for the occasional #spam.

Time is one thing, but the smaller, more crowded city commuter trains, also makes it harder to open a full-size notebook to do writing and reading. So after much angst I decide to get me one of them netbooks. I bought an Asus Eee PC 901 with built in 3G modem, it came originally with Windows XP, but now runs eeebuntu 2.0. And it is actually rather nice. Sure, its been hit with the ugly stick, but the total lack of aesthetics is actually somewhat refreshing, the build quality is decent, and you almost get used to the tiny keyboard after a while. It could be a bit more snappy though, so I am looking forward to trying out eeebutu 3.0 with LXDE, hoping that it will speed things up a bit.

The 3G mobile connectivity, Google Docs, Spotify and the excellent Dropbox file sharing service gives you pretty much everything you need to write blog entries, catch up on your RSS feeds, browse the web, listen to your favourite music, process e-mails, read e-books, etc. You do your writing on the train, and as you approach the train station you just save and close the lid. As soon as you're back at the office, or home, or wherever, you can easily pick up where you left off, on the same computer or a different one.

Man, this cloud thing is really great!.

Sunday, June 14, 2009

Making Safari 4 Usable

Updated: It looks like someone from Apple reads this blog, as they finally patched the vulnerability mentioned below, shortly after this entry was published.

So, Apple pushed out the Safari 4 update the other day. And once again I decided to try it out. I do that now and then, but so far it has always ended with me returning back to Firefox for some reason or the other. But this time it feels different. More to the point, it feels fast! Safari 4 is indeed a snappy browsing experience; it runs fairly well even on my old G5 iMac.

Usability-wise its pretty good, but there a a few tweaks needed:

1) Force opening of links in new tabs. Always.
Open the terminal and enter: defaults write com.apple.Safari TargetedClicksCreateTabs -bool true. Restart Safari.

2) Enable the status bar by selecting: View -> Show Status Bar

3) Consider installing Safari AdBlock, same idea as Firefox AdBlock Plus: http://burgersoftware.com/en/safariadblock

4) Disable 'Open "safe" files after downloading' in Preferences -> General. I'd like to decide for myself what is "safe" and not, thank you very much.

5) Disable Java until Apple patches CVE-2008-5353. WTF Apple, it's been SIX months already!

Tuesday, June 09, 2009

DDD classes fall 2009

I am very happy to announce this fall's dates for our Domain-Driven Design classes, offered in partnership with Domain Language, Inc.

The introduction class is a great way to get a good overview of Domain-Driven Design. Morning is spent on tactical design and how to interact with Domain Experts, and the afternoon is all about strategic design, context mapping and distillation.

In the four-day immersion class we really learn how to put the domain model to work. It is highly interactive with programming labs, design discussions, modelling sessions, and much more!

All classes are offered in Swedish in Stockholm. The classes are official DDD classes designed by Eric Evans, Domain Language Inc.

Wednesday, September 24, 2008

One-day DDD Seminar With Eric Evans

Eric Evans returns to Sweden and Citerus to give a one-day seminar on Domain-Driven Design together with myself. It’ll be a day packed with great DDD content, don’t miss it!

One-day DDD Seminar with Eric Evans, November 4 2008, SAS Royal Viking in central Stockholm.

Register now!