Over a million developers have joined DZone.

KISS Your Architecture

· Java Zone

Learn more about the advantages of moving from a monolithic to microservices architecture.  Brought to you in partnership with IBM.


The project I’m working on these days is not properly “legacy” but has seen some twists that renders it less than ideal.

On this project, one of the worst point that has been an obstacle for me to develop a simple feature is layered architecture. “What”, shout all experienced developers, “layered architecture is at the root of maintainability!” and I agree wholeheartedly. So, how could layer architecture be an obstacle?

  1. First, adding too many layers kill layering. I’ve always been a proponent of keeping the layers count low – especially DTO – when not strictly necessary. Too many layers and you will not only add complexity at development time but also performance overhead at runtime.
  2. Second, mapping is extremely important. If you completely change attribute names from one layer to another, newcomers are bound to endlessly scratch their heads.
  3. In all cases, the point of those layers is to separate code. So, keep it that way.
  4. Finally, if you need to do one (or all) of the former point, document it!

In my case, I stumbled upon an aggregation of all 4 points, as well as a previously unknown component (at least to me), jQuery template. This jQuery plugin is used to handle AJAX (but this is just a coincidence, as I suspect you could replace it with any equivalent and still get unmaintainable code).

Though I understand the intent to help with JavaScript by adding one more plugin, I tend to frown on how client-side is actually managed: not at all. Now that we finally have a decent build process including quality metrics (Jenkins + Sonar), developers and architects running like mad toward JavaScript without putting in place equivalent infrastructure – yes, it is possible, is utter nonsense. This is it for point 1.

Server-side, Spring MVC is the framework. A controller returns DTO which are processed through JSON converter. Guess what, JSON sent back by the server is mapped to another JSON entity client-side, one that has all fields of the original, but not all with the same name. Point 2 just makes it harder to understand what happens, and client means full-text search. Welcome into your new home…

I won’t pretend I understand all intricacies of jQuery Template, so I’ll just be factual about code I saw: it’s completely against all I know to create HTML on the fly by aggregating HTML snippets (including div with CSS class attribute) and parameter values. This is even worse if it takes more than 20 lines of strings, even though they are neatly aligned. Now, you’re really asking for pain, because not only is your JavaScript code untested, but it mingles HTML, CSS and JavaScript: I pity the poor maintainers of this application (I’ve done my part). That was point 3.

Point 4: are you kidding?

Now that I’m slightly psychotic because of this feature I had to implement, and since I will know where you live in a not-so-distant future, I suggest you start designing your architecture by respecting KISS! This will render all aforementioned points moot and keep me happy.

From Idea to Application gives you the architecture to quickly build, manage and run a range of applications (web, mobile, big data, new smart devices, etc.) on an open-standard, cloud-based platform. See why developers are using IBM Bluemix. Brought to you in partnership with IBM.


Published at DZone with permission of Nicolas Frankel, DZone MVB. See the original article here.

Opinions expressed by DZone contributors are their own.

The best of DZone straight to your inbox.

Please provide a valid email address.

Thanks for subscribing!

Awesome! Check your inbox to verify your email so you can start receiving the latest in tech news and resources.

{{ parent.title || parent.header.title}}

{{ parent.tldr }}

{{ parent.urlSource.name }}