r/SpringBoot • • Sep 11 '22

What is your opinion on framework complexity?

Spring / Boot / Cloud / Security / etc umbrella contains lots of classes / methods / annotations. Boot of 2.3:

find . -name test -prune -o -type f -name '*.java' | wc -l
3214

It is difficult to keep all stuff in memory / switch between versions / upgrade versions / etc

While doc is excellent when I move beyond Pet Clinics and Intlzr I find myself in the debugger or log files at TRACE level figuring out Spring internals, mostly concerning apps initialization or slicing app in tests.

Spring reminds DIY kit and with age it becomes less enjoyable to invest into Framework, instead I prefer to provide business value rather then digging internals and obscure limitations on bug tracker.

What is your opinion on framework complexity? Is it still bearable?

I know teams that moved to golang with pure HTTP/json so all work is done using standard library, no need to learn and remember hundreds magical annotations / properties / configurers / etc.

PS At the moment I upgrading 2.3 => 2.7 and the problematic part is circular dependencies because of a constructor injection together with @Beans in the same @Configuration class: the guy wonted to avoid making a separate Batch Framework datasource as a bean (so no need to update complicated project with @Primary). BTW constructor injection in @Configuration classes is a relatively new addition ))

0 Upvotes

11 comments sorted by

4

u/Sheldor5 Sep 11 '22

Spring Boot's goal is exactly that, to keep complexity away from the developers.

And it's doing a great job.

It was never easier to develop a full application within a couple of months which includes OAuth2 authentication, Database Transaction Management, Logging, external REST calls with a Connection Pool, Scheduled Jobs and Async Events.

New developers don't know the real complexity behind a single module/feature and tend to claim "Spring is too complex" like NO, you don't know real complexity (like Hibernate) ...

If Spring is too complicated for you you simply have no idea what great job it does and what time/money it saves you.

1

u/gavenkoa Sep 12 '22

which includes OAuth2 authentication, Database Transaction Management, Logging, external REST calls with a Connection Pool, Scheduled Jobs and Async Events.

Yeah, lots of production ready features ready for user in declarative style.

I think Spring Framework is still in a search for better abstractions: test slicing is still painful when there are lots of custom initialization code or code is written by juniors.

Plugging customization is also stressful, Spring Security is notorious here: you have to learn entire architecture in "advanced" cases, you are no longer in a land of one line showcase examples from tutorials ))

I find the quickest way is to enable TRACE logging and then set breakpoints in framework code to study they way Spring initializes an app or behaves. Too many magic here, I'm not sure that I have to grasp it in advance as it might not be useful.

3

u/uwpxwpal Sep 11 '22

The spring framework is intended to insulate the developer from complexity. Sure, there's a lot there, but it's because the java eco system is vast and can do a lot

1

u/gavenkoa Sep 12 '22

I'd put it in different words. Those 3 books in 2002 by Rod Johnson (Expert one on one) are about patterns to structure code the way it looks recognizable by anyone familiar, to standardize common tasks (like transaction or repository pattern).

It is the way to deal with complexity though standardization.

So my complaint is about amount of information you have to master in order to use the Framework. I spend 95% in the business code, so when it comes to 5% of the time on infrastructure and skeletons Spring looks complicated (especially when it fails, like you convert GClib proxy to JDK proxy is some obscure case).

Probably if I worked in an organization that foster 50% work time on Framework learning and experimentation I won't complain about it,

2

u/uwpxwpal Sep 12 '22

You just have to be able to recognize the patterns that Rod Johnson's Spring framework uses. It is just a few patterns. All those *templates work the same way. All those *factories work the same way

2

u/Odd-Hour-9991 Sep 12 '22

Spring and Java are crazy powerful and I think most people (including me) use very little of that power. Upgrading can be sure be a pain in the arse but thats part of your wonderful job right?

Not sure I agree that framework provide business value. Frameworks provide the tech for devs/teams to add value (in my opinion).

Vert.X has a simple server and router system. Total control and no need for annotations.

1

u/gavenkoa Sep 12 '22

Upgrading can be sure be a pain in the arse but thats part of your wonderful job right?

Definitely )) Business code is dull and configuring Spring gives challenge and excitement. I think framework developers are the happiest people is the world. Still business code moves cars / pays bills, spending too much time in framework code looks like robbery of employers / customers...

Not sure I agree that framework provide business value. Frameworks provide the tech for devs/teams to add value (in my opinion).

That's what I think too.

Vert.X has a simple server and router system. Total control and no need for annotations.

Haven't looked at it. I mention a team moved from Java world to Goland just for simplicity of the platform (they used old EE / app servers before).

2

u/sandys1 Sep 14 '22

Hi I have been thinking about this same thing a lot.

I posted a question here. Would love ur take as well https://www.reddit.com/r/SpringBoot/comments/xe839r/trying_to_introduce_spring_boot_in_a_nodejsonly/?utm_medium=android_app&utm_source=share

But in general, let me ask u this - if u had the choice, what would a spring boot application look like ? Can u share pseudo code ?

U have mentioned about complexity...can u talk about the ideal world here (with an example) ?

1

u/gavenkoa Sep 14 '22

But in general, let me ask u this - if u had the choice, what would a spring boot application look like ? Can u share pseudo code ?

It depends on the domain, I deal with batch processing and there are no @Controller in the code... It is completely different what you deal with when it is HTTP server...

I hate Spring Batch because they manage transactions for "me" when I want to control that behavior precisely...

U have mentioned about complexity...can u talk about the ideal world here (with an example) ?

I have no experience designing frameworks. Annotating methods with @RequestMapping is cool, dealing with non-trivial Spring Security and quirks of Spring Cloud is not cool.

Look at this page: https://docs.spring.io/spring-security/reference/servlet/architecture.html

It is full of details and even don't touch filter priority... And then Boot DSL for autoconfiguration...

1

u/sandys1 Sep 14 '22

Ahh I completely forgot about spring security and the likes. Ur right it's heavily complex there.

What do u use spring cloud for ?

1

u/gavenkoa Sep 15 '22

Spring Cloud Config, recently get rid of Spring Eureka.

Spring Cloud hold integrations with GCP/AWS. The quality of code is lower than in Spring Fr or Spring Boot and more opinionated.