The Only Pattern for Data Access is - There Are No Patterns for Data Access

Over the years of software development, one thing that has eluded most developers is Data Access. Yes, I mean writing code that accesses a database from your application. It is an age old problem since the days when data storage and computing were invented.

We would have thought that by now we would have been able to come up with a clean universal pattern for data access such as the M-V-C pattern for User Interfaces or the Singleton pattern or the Factory pattern. Yet, today we find ourselves with a plethora of technologies and patterns that are constantly struggling to survive to the next release. Just ask yourself, how many iterations of the ORM paradigm have come and gone?

J2EE with EJBs and Hibernate must be the answer!

In the JAVA world the creation of EJBs, Hibernate and its adoption into the J2EE spec surely would have put an end to the Data Access Layer misery developers faced. But it soon got notorious for being overly complicated, bloated and expensive to develop and maintain. Developers found that it was easy to run queries or stored procedures straight against their databases and get their data directly. Many of them did so in shame and said to themselves, this is hack but ORM way is really the true way. It became obvious when they ran their applications that that their apps ran better, faster and were easier to read without using the full EJB functionality.

The notoriously heavy datasets

At one time it seemed like Microsoft with their DataSets had won over the Database access world by providing simple disconnected objects that were easily bound to UI’s and were able to do queries to the database or even in memory when they were loaded. But alas they became notoriously heavy, hard to maintain and transport and had to be revamped. Microsoft has dabbed with many iterations of Data Access Layers including Object Spaces, Active Recordsets, LINQ to SQL and Entity Framework. Some of these are still in the market trying to survive like LINQ to SQL, some have become part of history like Active Recordsets and some never made it into sight like Object Spaces and some claim to take over the future like Entity Framework!

Why do none of the Data Access Layer Patterns work?

In my opinion after having used and worked on many projects that use the above mentioned technologies, the only pattern I see is a pattern of failure. The reason is that these technologies try to mimic the database. They make it look like the user is abstracted from the database by doing what a database does instead of abstracting what a database should do. They completely miss the concept of abstraction. When I abstract something in my code, the job of that abstraction is to hide the internal complexity of something, not repeat the actual work of what I am abstracting.

Failed data access layers abstract the database by repeating the work of databases. That is the number one rule of failure. How so you maybe asking. You may say, I love writing my LINQ queries and not having to worry about SQL. The problem begins right there. ORM data access implementations have to implement their own query language! If you have to implement your own query language you are venturing into the complex world of set theory and relational tuples. You better be as good and as fast as a database engine on that or else you will soon be history.

The Pattern of Redundancy instead of Abstraction

Caching database data in memory is another database copy-cat feature. You better provide better caching, latency, and redundancy algorithms than the database or you are going to face the wrath of the Database Engine pretty soon! I doubt any Data Access technology can beat the caching of query execution plans and caching recently used data provided by the leading database engines such as the commercial engines like Oracle and SQL Server or even the free ones like MySql. Database caches work better even over the network in the long term than the most powerful Object caching providers I have worked with.

These features of database access patterns or technologies do not do justice to the database engines they try to tame and therefore soon get bypassed and blown away to their competitor: the no data access layer pattern.

What is the no data access layer pattern?

The no data access layer pattern is simple; access or persist your data through the native database provider, using the native query language of database engine (SQL). If you stick to this pattern you will be more successful than not in your applications! The only rule of abstraction that you should follow is use data access to populate only application objects that need to be populated or persisted from your application and you should be good. Nothing more nothing less!

Let’s take an oath to ourselves and say, Thou shall not be fooled by another Data Access Pattern or technology!”. It is like looking for the Abominable snowman. If there was any truth to it we would have found it by now.

kick it on | Shout it!


  1. Bạn cần sử dụng dịch vụ giao hàng thu tiền hộ. Bạn cần giao hàng nhanh đến tay khách hàng. Nếu vậy bạn có thể tham khảo bảng giá giao hàng nhanh của chúng tôi. Khi bạn cần vận chuyển hàng đi đà nẵng hay giao hàng hà nội. Thì hãy nhớ đến chúng tôi, đảm các dịch vụ của chúng tôi sẽ khiến bạn hài lòng. Điển hình như dịch vụ chuyen hang di da nang đang được sự ủng hộ đông đảo của người dùng.

  2. Dịch vụ ship hàng là nhu cầu không thể thiếu của các bạn đúng không ạ? Nhưng để có cước phí vận chuyển rẻ, hợp lý thật sự và an toàn hàng hoá thì ít có Công ty vận tải tại Đà Nẵng nào uy tín. Bên mình chuyên cung cấp dịch vụ van chuyen Ha Noi, van chuyen hang hoa Da Nang hơn 10 năm nay rồi với giá cả thấp nhất thị trường hiện nay.

    Ngoài ra bên mình cũng lo trọn gói cho bạn từ nhà xưởng chuyển hàng đến Hải Phòng, vận chuyển hàng Bình Dương đi Đồng Nai .v.v..

    Rất mong các bạn ủng hộ giá chuyển phát nhanh đi Mỹ bên mình nhé. Cảm ơn rất nhiều.

  3. Supreme Fucoidan 95 còn có khả năng hỗ trợ điều trị các loại bệnh ung thư, ngăn chăn sự di căn của các tế bào ung thư. Đồng thời, với thuốc Fucoidan bạn sẽ vô cùng ngạc nhiên khi tác dụng của thuốc còn giúp cho những hệ miễn dịch trong cơ thể không những không bị suy giảm mà nó còn được tăng cường đến mức khả quan nhất, thuốc chống ung thư Fucoidan giảm thiểu sự tham gia của những quá trình hóa trị, xạ trị. Ngoài ra, thuốc Supreme Fucoidan 95 còn giúp phục hồi các chứ năng đã và đang có chiều hướng suy giảm do bệnh ung thư mang đến cũng như giảm thiểu hiện trạng các choleaterol hình thành trong máu.
    Fucoidan là một chiết xuất siêu nhờn từ tảo nâu Mozuku, Fucoidan có màu nâu đậm, trong Fucoidan có chứa nhiều chất dinh dưỡng quý giá, nhiều nguyên tố vi lượng và những khoáng chất, và giàu polysaccharide.

  4. Hi, Great.. Tutorial is just awesome..It is really helpful for a newbie like me.. I am a regular follower of your blog. Really very informative post you shared here. Kindly keep blogging. If anyone wants to become a .Net developer learn from Dot Net Training in Chennai. or learn thru ASP.NET Essential Training Online . Nowadays Dot Net has tons of job opportunities on various vertical industry.
    or Javascript Training in Chennai. Nowadays JavaScript has tons of job opportunities on various vertical industry.