What are your efficiency gains by removing XML in java projects? [closed]

I have just moved from phase 1 to phase 2 of a project. In this transition we got rid of all of the XML configuration for spring and struts2, switching to a fully annotated regime.

All of the participants are amazed at the actual effect this has on development speed. There are a number of reasons for this:

  • Structured thinking about which roles are needed lead to clear understanding that we needed @StubRepository, @TestService and @NotTestService annotations to facilitate all the different run-time models that our project uses (runtime, unit test, integration test, selenium test)
  • These annotations replaced a large number of duplicate xml definitions.
  • All dependencies are fully trackable in the ide.
  • Simpler to work with code because dependencies are clear

Some of these gains could probably have been realized by re-structuring the xml as well, but that would not have been a trivial task.

I honestly believe this has given somewhere around 10% boost in productivity for our 20,000 man hour project. I almost find it hard to believe.

Anyone else sharing this same experience ? What's your gain, and how do you explain it ?

Asked by: Adelaide860 | Posted: 23-01-2022

Answer 1

Basically, this could be viewed as a question about config files vs. annotation.

If you experienced an amelioration in productivity boost when putting some data as annotations, that means they were not "configuration" material in the first place.

The difference between the two:

  • annotation: everything is in one place and the configuration information is associated directly with the Java component. Many types of refactorings of the source code are transparent to annotations for this reason -- the annotations will always apply to the component they're attached to, even when that component is moved or renamed. For other refactorings that require new or modified annotations, everything is in the same location, assuring that the annotations are visible to the developer and increasing the likelihood that they'll remember to make the necessary changes.

  • Configuration files can provide an organized view of a web of relationships that span different components of an application. Because they're separate from the actual source code, they don't interfere with the readability of the Java source code.

What you experienced is the disparition of the need to maintain config files in parallel with the source code of an application, with no obvious connection between the two.

BUT: annotations have their drawbacks: source code can become cluttered with all sorts of annotations that are irrelevant to the actual program logic, interfering with the readability of the code. And that while annotations are ideal for metadata that relates to a particular component, they're not well suited to metadata with cross-component application.

Answered by: Kelvin799 | Posted: 24-02-2022

Answer 2

(I really didn't mean to respond with a bag of cliches, but XML seems to bring out the proverb collection... ;-)

I have found XML configuration (and config files in general, but that's another question) to introduce multiple levels of your question, because, "To a small boy with a hammer, everything looks like a nail." It is easy to become enthusiastic about a tool (such as XML) and start using it much more widely than it deserves, or to keep adding "just one more" feature until the result becomes too unwieldy.

Also, as the old saying goes, "Everything in programming is a trade-off."

So, to play devil's advocate, have you reached the point where you need to do maintenance or tweaks on the running system? In the new scheme of life, how often do you have to make adjustments by re-building all or part of the system, instead of being able to tweak a config file?

Finally, there's rough equivalent of the "Hawthorne effect" (see below). Sometimes a team gets a burst of excitement when they are allowed to clean up some minor issue, and they achieve a burst of productivity out of proportion to the actual improvement, triggered by the relief at getting rid of a long-standing annoyance.


The Hawthorne effect is named after a study of factory worker productivity relating to changes in lighting. The researchers found that increased light was followed by an increase in productivity. But then they found that decreased light was also followed by an increase in productivity. (Both increases were typically short-term.) The final conclusion was that the workers were more productive because someone was paying attention to them.

So, sometimes an otherwise trivial change triggers a boost in morale (sense of empowerment, etc.) that causes improvements in performance.

There's seldom just one factor.

Answered by: Dainton981 | Posted: 24-02-2022

Answer 3

I don't have productivity figures like you but I have seen significant improvement when moving from xml configurations to annotations. I think its because the configuration information is in the same place with the code.

Before you had to look at a separate file to find configurations and that slowed things down.

Answered by: Edgar634 | Posted: 24-02-2022

Similar questions

java - Move all zero values in a big array to its front portion in a Time Efficiency way

You're given a big array with Integral type value, How do you move all zero values within it to the front portion of the array in a Time Efficiency way? e.g. 0,1,72,3,0,5,9,0,6,51,0,3 ---> 0,0,0,0,1,72,3,5,9,6,51,3 Regards!

c# - Efficiency comparison of recursion and non recursive function in Java

As I understand, recursive functions are generally less efficient than equivalent non-recursive functions because of the overhead of function calls. However, I have recently encountered a text book saying this is not necessary true with Java (and C#). It does not say why, but I assume this might be because the Java compiler optimizes recursive functions in some way. Does anyone know the details of why this ...

java - What is the correct OO design for maximum re-use and efficiency?

Assume I have a Java package (both .jar and source codes). Here are definitions of what some of the classes I would like to re-use. abstract class Tree { public abstract Tree[] children(); public void print(); } class LabeledTree extends Tree implements Label { Label label; Tree[] daughterChildren; public Tree[] children(); } class Demo { public static void main(String[] args) { Parser p =...

java - What's the efficiency of this program?

What's the efficiency (in Big O notation) of a simple program that traverses a 2D array of ints and outputs each element. Take the following code as an example: public static void main(String args[]) { int[] array = {{1,2,3,4}, {5,6,7,8}, {9,10,11,12}, {13,14,15,16}}; for(int i = 0; i < array.length; i++) { for(int j = 0; ...

java - Efficiency problem of writing large messages with different header to multiple receivers

There is a string (message body) and 3 different headers to be sent to 3 users using java nio socket. A way is to create a large byte buffer and put the message body in some postion and put header in front of message boday. In this way, I still need to one copy for message body and rewrite headers. In my project, the message body is around 14 K bytes. If the memory page is 2K bytes, it is not efficient for ...

java - Android Efficiency - Views

Is it better to findViewById(<resource-id>) once and store in the scope of your activity (class-wide) or call the above per use, so that the resources are reclaimed when the current scope/method is exited? I guess it boils down to how expensive findViewById() is compared to how expensive it is to store view objects class-wide.

java - For looping efficiency

I am writing an Android game and trying to be as efficient as possible. I know that a for loop is more efficient than a foreach, but I was wondering if there was a difference in efficiency in the following 2 items: // itemsList is an ArrayList int length = itemsList.size(); for(int i=0; i < length; i++) { // do stuff } VS for(int i=0; i < ite...

selection - Efficiency - Handling singular and plural instances in Java

Here is my homework question: Write a program that asks for a film name and the length of the film in minutes and then the program prints the name of the film and its length in hours and minutes, e.g. the user enters Finding Nemo and 104 then the program would output Finding Nemo runs for 1 hour and 44 minutes. I have completed ...

java - Efficiency problem

i am trying to make my algorithm more efficient but for some reason its not working correctly could someone tell me if my logic is correct. The general problem is that if u have a height of 'x', and you can jump 'u' distance but you fall 'd' distance if you havent cleared the height already. i have to calculate the number of jumps. Initial code works correctly while(x-u>0) { x=x-u+d; i++;...

java - Need inputs about efficiency of my program for finding duplicates in String

I have developed a java program for checking if a string has all unique characters. I am listing it down. I will appreciate if i get inputs about the efficiency of this program as well as any corrections needed to improve this program. Thanks in advance. package com.string.duplicatechars; import java.util.HashMap; import java.util.Map; public class CheckForDuplicateChars { /** * @param ...

Still can't find your answer? Check out these amazing Java communities for help...

Java Reddit Community | Java Help Reddit Community | Dev.to Java Community | Java Discord | Java Programmers (Facebook) | Java developers (Facebook)