I am writing software for many years now and always tried to create expressive, clearly readable, maintainable, robust code. Recently I joined a team developing web apps using Spring managed objects. But I feel very uncomfortable with that technology. For me, it feels like all encapsulation and information hiding principles, achievements of decades of software engineering, were just abandoned. I clearly can see the pros of using an Inversion of Control container, for moving system dependencies out of program code into configuration files. But now, I see Spring used in ways that, I feel, are just adding an unnecessary bunch of complexity without producing any benefit.
Using Spring for the creation of webapp backing beans, objects are no longer clearly organized in modules and no longer have smallest possible visibility. Instead, there is now a single, global space of bean names. Because of that, objects tend to get awful names like 'pendingOrderCustomerName' and, to make things worse, such names do not even clearly identify a well-defined entity, because bean definitions can come from various definition sources, gathered from openly specified locations: Instead of being defined simply as a class in a package, Spring beans are assembled from xml files, with free overriding possibilities and loosely defined relationships.
For example, when I have a type "Account" in plain java, in the package "my.webstore", I can usually know about properties, relationships and abilities of that type in a single place, the "my/webstore/Account.java" file. Instances of "Account" exist as references in objects working with accounts, the state of any instance is exactly defined by the class. With Spring beans, however, things get more complicated: An instance of "Account" now exists under a global name, in a container-managed scope, having a state being assembled from xml files, found along a file search path based on naming patterns...
Gone the days when, to understand what an object does and how it behaves, you just had to read its program source. Today, you need the object's java source (which may be complex enough to understand), plus you have to find any configuration files that might alter that object, which is not easy because you have to find out all the ways where configurations might come from and you have to find out in which order they override each other
Maybe it's just a matter of taste, but I also wonder why people prefer the verbose, clumsy xml syntax, as in:
<bean id="p1" class="Point" scope="prototype">
<property name="x">
<value>20</value>
</property>
<property name="y">
<value>80</value>
</property>
</bean>
over this:
p1 = new Point(20,80);
This example may seem exaggerated, but I tell you I have seen worse!
It is not my intent to criticize the Spring framework by itself, it is very strong and an excellent ingredient in many cases. My concerns are about how to prevent misuse, how to keep maintainability, how to guarantee quality and stability, how to find dependencies, how to document code... what is your experience?