Skip to content

Development

Spring Autowiring by Example

Spring is a Java library which delivers a useful feature: Inversion Of Control. Basically, instead of instantiating your Java services with new, Spring does it for you.

You may be wondering:

  • That's nice, but isn't new already enough?
  • How does the @Autowired annotation work?
  • How does Spring instantiated and lookup the right beans and services for me?

Good news! We've got you covered. I know how difficult Spring is to understand, I've been there. These carefully crafted real-world examples should speak to you.

We are Obsessed With Quality

As mentioned in our previous article, Are You Buying Quality Software, we aim to deliver features at fast pace while maintaining the highest possible code quality. Our last article about our code quality has been written more than one year ago, how are we doing today? The following sections get you an insight about the code quality of our backend server written in Java.

So you’re saying you have no bugs?

We're not saying our software doesn't have bugs. Every single piece of software has glitches or bugs. But, it's quite usual for us to fix a bug and release a patch the same day. We thoroughly test our software entirely to make sure most of the bugs get caught before going into production.

Ask one of our competitors reports about their code quality. We are pretty sure no one will ever give you that information. We think you must know what you pay for.

Sonarqube Analysis

Quality Profile

Our code quality analysis is based on Sonarqube, using a custom quality profile with more than 750 rules enabled.

Sonarqube Quality Profile

Our profile used last year had a little over 700 rules enabled. We try to slowly increase the number of rules checking the code to further improve code quality. Feel free to use our own quality profile inside your company to check their code against our coding rules. I'm pretty sure you will be surprised by the results.

Upgrade to AngularJs 1.6

When we started developing our load testing solution we had to choose a technology to create the UI. Most of us had previous experiences with GWT or Vaadin but we were not satisfied with it. It took us too much effort to create a sketch of the application and it didn't even look good.

So, we gave a try to AngularJS, even though none of us knew a bit of JavaScript. It felt really productive and a few weeks later we had a nice first version of OctoPerf that could start performance tests and display reports.

Three years later we added lots of features to our load testing solution and the code base reaches almost 10K lines of JS. In the meantime, Angular2 came out and AngularJS evolved to close the gap.

So, during the past months we took some time to upgrade our frontend to AngularJS 1.6 and to prepare the ground for Angular2:

Impl classes are evil

Like Martin Fowler said in TwoHardThings:

There are only two hard things in Computer Science: cache invalidation and naming things.

I've just seen too many times developers using Dependency Injection frameworks like Spring or Guice or Dagger the wrong way. Naming classes with Impl suffix is an Anti-pattern and i'm going to explain why.

Why Impl is Bad

ServiceImpl is a common practice

Many developers, including myself years ago, are using the Interface + Impl pattern to create services which are injected by their interface. This usually looks like this:

Impl pattern