Marten Deinum - header image

Marten Deinum

The Spring Interviews

Last updated on July 27, 2020 -

Who the hell am I?

I'm @MarcoBehler and I share everything I know about making awesome software through my guides, screencasts, talks and courses.

Follow me on Twitter to find out what I'm currently working on.

This interview is an excerpt from The Confident Spring Professional course.

Marco: Hi Marten! Would you mind quickly introducing yourself?

Marten: Hallo Marco. I work for a company called Conspect as a Java/Spring Consultant. I’ve written several books on Spring related topics and once upon a time I was employed by Interface21/SpringSource as a consultant.

I’m an occasional speaker at conferences or in-company events and I like to share knowledge, which I also avidly do on StackOverflow (since the shutdown of the Spring Forums).

When not immersed in technology, I can be found near (or better yet in) the water with my scuba gear on, either diving myself or teaching others how to dive or become better divers.

Marco: Since when do you program with Spring and how did you get into it? Do you still remember your very first Spring project?

Marten: I have been using "Spring” since I read "J2EE Design and Development” from Rod Johnson somewhere in 2003/2004. I was already using some utilities I build myself to make it easier to work with JDBC and to have a common ServiceLocator for J2EE (as it was called back then).

However, what Rod provided in his book was much better than what I had. The code from the book later became the Spring Framework.

So, the ideas I have used since 2003/2004 and it helped us simplify the J2EE applications we were building back then. The first real Spring version I used for an application was Spring 1.1 and it was mainly used to simplify the JDBC and JMS usage in the J2EE application. It was a joy to use compared to the plain JDBC and JMS APIs.

Marco: For people new to the Spring ecosystem, what Spring projects would you recommend having a look at and in which order? Why?

Marten: Spring Boot for sure as that really helps you get started and Spring Data as that gets you up and running fairly quick with data-access and probably solves your 80% cases already.

That being said one should also know something about the core concepts used in Spring and Spring Boot like dependency injection and aspect-oriented programming.

After the core concepts I always suggest to teammates to learn the technologies that frameworks/libraries are built on. So, if one uses JPA, one should also understand JDBC/SQL and for Spring Boot it would be Spring Framework itself.

Marco: What would you say is the one thing where most developers go wrong with Spring?

Marten: That would be in general working around the framework instead of working with the framework. Spring Boot for instance can configure your data-access with just a few properties, but then I see lines and lines of configuration classes trying to mimic what Spring Boot does.

Part of this is not only due to the users not reading the documentation of following a guide, but there is also a lot of confusing and old blogs, guides out-there which users try to follow.

And some parts of the Spring ecosystems are hard(er) to configure like Spring Security or Spring Batch.

Marco: What project(s) would you recommend to build in order to get more practice with Spring?

Marten: Take a look at the PetClinic, now that it has been revamped to use Spring Boot if you want a full-blown application. Otherwise, I recommend the guides on the spring.io website as those are very focused on explaining a single part of a vast ecosystem.

Marco: Would you still invest time in learning Spring based on servlets and JDBC, or go straight into reactive Spring?

Marten: The vast majority of companies and projects I see still use servlets and JDBC (mostly through JPA), so investing and understanding those technologies is still a must. Not all companies can (or should!) move to reactive Spring as it is a vastly different paradigm.

Next to that to be fully reactive you have to be reactive all the way down and the relation database is still used in most places and that isn’t really reactive.

So yes definitely invest in those technologies but that doesn’t mean you shouldn’t look into reactive programming. Always keep learning new and other ways as that will improve your skills as a developer.

Marco: With the advent of client-side frameworks (React, VueJS, Angular), what’s your take on writing web applications with server-side template rendering, like Thymeleaf? Is that now legacy?

Marten: I’m a firm believer that for a majority of the things build today, the client-side frameworks are overkill. For a lot of projects, it would be better to stay with server-side templates with just a touch of JavaScript. So no I don’t think it is legacy it is still a very valid approach.

Marco: What is your favorite way to connect your Spring application with a database? Would you recommend plain JPA? Hibernate? Spring Data? Any other of the 500 available choices?

Marten: I tend to recommend Spring Data JPA and use that at my clients when I can, in a lot of cases it solves the 80% case and gets you up and running very quickly.

However, I believe you should be pragmatic and write custom SQL queries (or JPQL if feasible) for the other 20% cases like a heavy reporting query. A database is a very nice and good piece of technology, use it what it is good at.

Marco: There are some misconceptions that Java or Spring might be slow, bloated or simply too legacy. What do you think about other choices, like Micronaut, Quarkus or even other languages like Kotlin or Scala?

Marten: I don’t think Java (or Spring for that matter) is slow, a lot depends on the proper usage and tuning of the JVM for the purpose you are using it. I have used Spring in several applications which had high-performance requirements without any big issues, most issues we had was due to badly written queries.

That being said I think competition in this area is good, there have been quite some improvements in both Spring and Spring Boot to make it start quicker, reduce garbage creation and to make it easier to use it with GraalVM.

I’ve never been a fan of Scala but it is years since I really looked into it. Kotlin however I do like, especially the fact that several frameworks added support for it. The multi-language support on the JVM is something I like a lot, I can write Ruby, Python or even Cobol and run that on a JVM. I think it shows the excellence and flexibility of the JVM.

Marco: Is there something you would say that Spring could do better and needs some improvement?

Marten: I tried to think of something, but the whole Spring team does a great job in creating good code and documentation.

If I would have to name one thing, the documentation for the Spring Framework, although great, can be overwhelming for new-comers. Although the documentation has already improved as well in the last couple of releases.

Marco: What is the best way to follow you and learn more about your work and what you do?

Marten: I’m on Twitter (@mdeinum) and write the occasional blog on https://deinum.biz.

Marco: Thank you, Marten!

There's more where that came from

I'll send you an update when I publish new guides. Absolutely no spam, ever. Unsubscribe anytime.


Share:

Comments