Tag Archives: Multitier

The Matrix

Entry 5, Day 8

The first matrix I designed was quite naturally perfect. It was a work of art. Flawless. Sublime. A triumph only equaled by its monumental failure.

– The Architect

Software Architecture is the high level structure of a software system. Now I’m smart, I have Wikipedia.

Sometimes, if you ask a developer what is the architecture of the system he is working on, he would say something like, “Well, we have a JSP view, we use EJB to figure things out, Hibernate to persist and everything sits on top of Weblogic server”. Actually, this is not an architecture description, this is a list of technologies used to create the system (or, if you need a fancy term: the technology stack). Of course, there is a slight hint, that we are dealing with a client – server application with at least three layers.

Architecture might be client – server, peer to peer, event driven, rule based, plug-in based or other. Or the combination of them.

As I said before, I’m aiming for agile, emergent design. It does not imply, that I don’t have some kind of vision of what I want to write. I will probably go with client – server, multi tier application. What does this mean? We know more or less, what is 3 – tier architecture: we have a Presentation layer, Business Logic layer and Data layer. So where is the fourth and fifth or any further layers? Well, you may divide those layers further. Let’s take a look.

Presentation is well… presentation. But if you go beyond simple CRUD, it might turn out, that you need some kind of logic just for managing presentation (fancy drag n drop and dynamic stuff support for example), not really business logic layer, but layer separate from static HTML inputs. So, you may split this into two.

Business Logic might have controllers, which glues together front end and back end. And then, they might have EJBs or Spring Services, which performs actual computations or choices having data and given user input. Or other input for that matter, say JMS messages or WebServices calls from foreign systems. Also, you may split service in as many layers as you need depending on the case. Some systems might be very sophisticated, and saying that there is just one business logic layer would not be an understatement.

Data layer may consists of Data Access Objects, which gives you data in the form of cute little Java objects magically drawn from the database. Then there is the magical Object Relational Mapping Framework at work, preparing and running queries in SQL native to the database, transparently for the user. Database is the, more or less, final layer, and besides table definition it may consists of triggers, scheduled jobs (for partitioned tables periodic cleanup, for example) and some other nasty things. Perhaps there are also other layers in the database department, but well… I’m more like in the Java department, so I won’t dig deep here.

Some developers shun the idea of doing any logic outside of Java code (I’m not talking about external libraries, but I will later). I was such developer once. But I’ve figured out, that some things may be better done outside of Java, even though I cannot put a breakpoint there. I’d love to think about them as Java minions who do some magic yet inferior things, but as long as they do it well, I have no objections. Otherwise I will have to frown my eyebrows, get out of coziness of my beloved Eclipse and step in to figure out why SQL or ant script is behaving badly.




Leave a comment

Posted by on August 9, 2014 in BookSentry, Clean Code, Technology


Tags: , , ,