Your DI framework is killing your code

Actively Lazy

I read a really interesting post recently looking at the difference between typical OO code and a more functional style. There’s a lot to be said for the functional style of coding, even in OO languages like Java and C#. The biggest downside I find is always one of code organisation: OO gives you a discoverable way of organising large amounts of code. While in a functional style you might have less code, but it’s harder to organise it clearly.

It’s not Mike’s conclusion that I want to challenge, it’s his starting point: he starts out with what he describes as “typical object oriented C# code”. Unfortunately I think he’s bang on: even in this toy example, it is exactly like almost all so-called “object oriented” code I see in the wild. My issue with code like this is: it isn’t in the least bit object oriented. It’s procedural code haphazardly organised…

View original post 1,065 more words


Don’t use DAO, use Repository

Thinking in Objects

Data Access Object (DAO) is a commonly used pattern to persist domain objects into a database. The most common form of a DAO pattern is a class that contains CRUD methods for a particular domain entity type.

Assumes that I have a domain entity class “Account”:

Follow the common DAO approach, I create a DAO interface:

The AccountDAO interface may have multiple implementations which use some kind of O/R mapper or executing plan sql queries.

The pattern has these advantages:

  • It separates the domain logic that use it from any particular persistence mechanism or APIs.
  •  The interface methods signature are independent of the content of the Account class. When you add a telephone number field to the Account, you don’t need to change the AccountDAO interface nor its callers’.

The pattern has many questions unanswered however. What if I need to query a list of accounts having a specific last…

View original post 938 more words

Nice tutorials I bumped into recently

Python Tips

Hi guys! I am in the USA right now. I am here to attend a Hackathon at the University of Michigan called MHacks 6. This is my first ever Hackathon so I am very excited. So now without wasting any time let’s get down to business. I recently came across a lot of nice tutorials which I believe might be useful for you guys. I am listing them below in no particular order:

View original post 249 more words