DDD Part I – Introduction

The first time I heard about DDD (stands for Domain Driven Design, not Deadline Driven Design ^_^), that was when i was still working as a Senior Java Developer for Hewlett-Packard on its Development Center at Cyberjaya, Malaysia. I wasn’t quite interest with the topic since it was difficult to get a good resource during that time. My technical lead (Hi Fadzlan, howdy man ? ^_^) just told me to find the Eric Evan’s book (“the blue book”), and gotcha..i got the book and added it to my PDF collection 🙂. However, i was merely read the first chapter and never got any chance to finish the book due to my workload.

Few months ago, i started to join Bhinneka.com (i.e. one of the pioneer for e-commerce in Indonesia), and guess what.., as the new head of architecture and backend in Bhinneka, i decided to implement Domain Driven Design in our reengineering process (yes, you hear me right, we’re going to build Bhinneka’s software from scratch, not merely refactoring).

During this time, DDD is quite new (especially in Indonesia), thus only few companies have successfully implemented this DDD. And somehow IMO, i found that many DDD resources were too difficult to be grasped by most of the readers (i.e. they are too abstract and lack of good examples). Therefore, i’m planning to pick up this awesome topic and write it in a series, equipped with an application sample to be followed step by step.

This is the first part of another series those are still in my head as follow:

  1. DDD Part I, Introduction –> You are here
  2. DDD Part II, DDD Application (coming soon)
  3. DDD Part III, DDD and Microservices (coming soon)

In this first part of Introduction, i would like to start with some basic concepts as written below:

  1. What is DDD all about ?
  2. How do we get started ?
  3. What should we avoid in DDD ?

Let’s get started 🙂.

1. What is DDD all about ?

To start this section, I’d rather took the definition from one of DDD’s community (i.e. dddcommunity.org), that describes DDD (Domain Driven Design) as an approach to developing software for complex needs by deeply connecting the implementation to an evolving model of the core business concepts.
As the definition implies, DDD is suitable for you if you’re building a software that has complexity on its business process (business domain). So, not every software is suitable for DDD (e.g.: CRUD application doesn’t suitable for it since it’s not quite complex).
Eventually, team work is very important within DDD since you need to keep in touch with the users/clients (a.k.a Domain Experts). Moreover, you build the software for them, not for you (you got the point right). Just like someone said: “the software can fail either in two ways, you build the things wrong or you build the wrong things”. In that case, you have to ensure that you understand correctly the business that you’re going to build. This is DDD all about.

We’ll continue later with the next point soon as I can. It’s already late now. Just stay tuned..

Why do I choose Gradle Over Maven ?

Hi guys, it’s been long-long time since last time i wrote about JAXB (that was about 2+ years ago😮 ).

Ever since that time, after leaving Hewlett-Packard (HP) in Cyberjaya, Malaysia, I had moved and being stucked here in Jakarta again when I received good offering from one of the DJARUM group’s company, PT. Global Digital Niaga which can be recognized from their product, known as blibli.

I was working for them as a permanent employee for almost 2 years since then. But now, I’m working as a freelance consultant and trying to create my own startup company.

For those of you that ever lived here (Jakarta), I strongly believe that You would agree with me if I say that Jakarta’s traffic is really horrible. In my opinion, if you live in Jakarta, working from home is more productive than working at the office. That’s one of the primary reason for me to choose working as a freelance consultant, because i don’t have to go to the office everyday and spent many hours on the road without doing anything (probably this will be different if you have your own driver ^_^. You can sit and coding with your laptop while you’re stuck with the traffic).

OK, enough with the chit-chat. Now, as mentioned in the subject, I will be quickly describing here several things why i won’t use maven and prefer to use Gradle as my project automation tools.

I’ve been using Maven for quite long. I ever heard gradle before, but never had the chances to try it until two months ago when I got an offer to develop KPI’s application in GMF Aeroasia (Garuda Indonesia Group). There are several issues which I’ve just noticed from Maven :

1. Maven promises “convention over configuration”, nonetheless it also promises about custom configuration such we found in Ant. However, writing custom extensions (plugins) in maven is overly cumbersome. You’ll need to know about MOJOs, including how to provide a plugin descriptor (XML based).

2. Sometimes, the default structure and lifecycle in maven can be restrictived and may not fit our project’s needs. Indeed, I don’t like the way of maven in customizing their lifecyle.

3. As i’ve known so far, Maven doesn’t automatically update their own core plugins. e.g. : support for unit tests (junit) to the latest version. Let’s say, if you’re trying to create new maven project from console by using command mvn archetype:generate…, you’ll get default maven pom which will be pointing to junit version 3.x (currently it’s already in version 4). so you’re gonna need to replace it’s version mannually.

Those are the reasons why I’d prefer to use Gradle now. Overall, Gradle was borned to addresses all of the issues which we found in Ant and Maven.

And for those of you, that having a plan to migrate your existing Maven’s project into gradle, You don’t need to be worried since Gradle has the ability to import any existing Ant/Maven build scripts and translate into Gradle rule set. How do you think ?

Using JAXB to dealing with your XML

Here i’m going to write down about how to deal with XML by using Java, especially with JAXB as you can see from the subject title.

Why JAXB ?

Of course, there are many ways to handle XML in Java. You could use JAXP API (Java API for XML Processing) which comprises DOMParser and SAXParser (old fashion style and complicated in my opinion ^_^), or XMLBeans which convert and transform your XML file to POJO class or vice versa. I thought the last one (i.e. XMLBeans) is much better compared to JAXP (this is my opinion, maybe you have different opinion). But…, nowadays, i think i would like to choose JAXB rather than XMLBeans. Why ? because (in my private opinion again ^_^), configure JAXB is much simpler than XMLBeans. Because its already become standard of Java EE. Starting from Java 6, its already bundled inside the JDK. So, you don’t need to include external libraries/APIs to use this API. That’s the reason why i choose JAXB instead of XMLBeans.
However, in some IDE (e.g. Oracle Weblogic Workshop), you can see there, that the IDE has already bundled XMLBeans as its standard API to dealing with XML. That’s why, i’m still using XMLBeans for some of my projects that using Oracle Weblogic Workshop as the IDE. However, i’m not talking about XMLBeans here. I will talk about JAXB here. Yes, sure you could find anywhere from the internet (just need to ask uncle google ^_^) about this JAXB. But, I will show you here by example (a simple example), about how easily configure and play with JAXB in order to handling your XML stuffs.
Continue reading

My note about Grails

I am writing this just to share a little bit about my findings while playing with Grails. Hopefully, this could be a good note for me too.
By the way, I’m using Grails 2.0.4 at the time of this writing. You could download it from Grails official site.
Ok, lets start then.
There are 3 errors/exceptions that I’ve just found while playing with the Grails as you can see from the following:

1. java.lang.SecurityException occured while running grails command

I was trying to create new Grails app with grails create-app command, and i’ve got such an error. See the image below:

Click the image to enlarge

Continue reading

Generic Feature in Java

Java is getting bigger and popular now. I think the OpenSource is one of the reason that influence it. People always look for something that are free and powerful. One of my friends who’s currently working as PHP developer told me that he’s trying to switch to Java. He came to me yesterday and has asked me about Generic.
In order to answer his question, i’m gonna write some explanation here about Generic. Hopefully this could help him and the others (including me :-)).

What is Generic ?

Generic is one of the java’s feature/extension that starting from Java 5 (Tiger). In my opinion, Generic helps your code more stable by trying to reduce as many as possible any exception that could be raised in runtime. This could be done by trusting the compiler to check our code in the compile time. Generic helps you to detect your program bugs at compile time as many as possible. So, it’s guarantee that our running code is less of any error.
Generic allows you to abstract over types. The most common examples are container types, such as those in the Collection hierarchy. Overall, Generics are heavily uses by these classes (i.e. Collection classes).
Continue reading

PostgreSQL 9 installation for UBuntu 11.04

I’ve remembered that several weeks ago my laptop couldn’t boot the OS while I was using Ubuntu 10.04 for about 1 year. I was trying to boot with my Ubuntu 10.04’s bootable CD. But it always gave me the same result, I saw blank screen with blinking cursor😦.
I have a thought that the problem could be one of the:

  • memory card,
  • harddisk, or even worse
  • the motherboard (I was hoping not the motherboard X_X).

First, I checked the harddisk by removed it from my laptop, then restart again with the same bootable CD. Yupi, It was working (ye…ye..ye..ye..ye..:-D). I was glad, because at least i knew that the motherboard is still working🙂.
So, the problem was on the harddisk. I thought that maybe the harddisk had some bad sector in it. So, without thinking too much, I’ve decided to backup all of the data to my PC’s harddisk, then performed low level format from my PC.
After finished, I had an idea to gave that harddisk new OS. So, I was choosing Ubuntu 11.04 (Natty Narwhal) instead of Ubuntu 10.04 (Lucid Lynx).
It’s all working now🙂. But, I have to install again all of my development tools from the beginning. One of them is PostgreSQL 9.

Continue reading

Facebook Chat XMPP Services

Since 2 months ago, I’ve got my second remote job as Java EE Developer for Telco Company in Singapore named Hub9. So, currently now I’m working for two Telco’s Company in Singapore (i.e. CoreSDP and Hub9) as Java EE Developer. Both of them are remote jobs (which means working from home :-D), and I’ve got monthly payment for these jobs. This is what i’ve been dreaming for a long time🙂.
Start from here I’ll write some notes about anything what i’ve been doing for over the last 2 months with Hub9.
As my first assignment, they’ve asked me to develop facebook chat (IM/Instant Messaging) application via SMS (known as Facebook SMS Chat). As you’ve already known, there are many chat (IM) application now, such as Yahoo Messenger, GoogleTalk, eBuddy, Jabber, etc. Even Facebook has provided it’s application with IM service, so every user on facebook could have a conversation via this chat (IM) service.
Every IM service need communication protocol in order to be working correctly. There are many protocols around can be used for this purpose. Some of them are under commercial (propietary) license, and some of them are not (means ‘free’, and this is what i’m going to use :-D).
One of the protocol that is free to be used is XMPP.
XMPP (stands for eXtensible Messaging and Presence Protocol) is an open-standard communication protocol for message oriented middleware based on XML (eXtensible Markup Language). This protocol was originally named Jabber, and was developed by the Jabber open source community in 1999 for near real-time, extensible instant messaging (IM), presence information, and contact list maintenance. The software implementation and client application based on this protocol are distributed as free and open source software (looks nice to me ^_^).
I think, you should read by your self later about XMPP, so I won’t give you the detail explanation about XMPP here (b’cause I’m not the kind of person who’s enjoy to talking to much about the ‘philosophy’ behind the ‘theory’ #:-s). So please googling or read the “RTFM”🙂.
One thing that I think is important for us to know before we jump into the XMPP implementation is: basically, there are 2 implementations of XMPP. i.e. XMPP Server and XMPP Client.

In order to work, we should have those 2 implementation in our software.
Continue reading