paint-brush
Building large scale applications with Joobyby@espina.edgar
1,602 reads
1,602 reads

Building large scale applications with Jooby

by Edgar EspinaAugust 2nd, 2017
Read on Terminal Reader
Read this story w/o Javascript
tldt arrow

Too Long; Didn't Read

<a href="http://jooby.org" target="_blank">Jooby</a> is a <a href="http://jooby.org/modules/" target="_blank">modular</a> micro-framework for building web applications in <a href="http://jooby.org" target="_blank">Java</a> and <a href="http://jooby.org/doc/lang-kotlin" target="_blank">Kotlin</a>. If this is first time you heard about <a href="http://jooby.org" target="_blank">Jooby</a>? Checkout my previous article on <a href="https://medium.com/@espina.edgar/java-micro-frameworks-why-jooby-59f0b346e819" target="_blank"><strong>why you should choose</strong> <strong>Jooby</strong></a>.

Company Mentioned

Mention Thumbnail
featured image - Building large scale applications with Jooby
Edgar Espina HackerNoon profile picture

Jooby a modular micro framework

Overview

Jooby is a modular micro-framework for building web applications in Java and Kotlin. If this is first time you heard about Jooby? Checkout my previous article on why you should choose Jooby.

Micro-frameworks are ideal for building small applications, but are they good for medium or complex applications?

In this article we’ll learn what options Jooby offers to build large scale web applications and keep the source code organized and maintainable.

Initial application development

Let’s say you want to build a HTTP API for users. An initial application might looks like:

Done! Your application is ready. It looks clean and easy to understand. Simplicity is one the Jooby goals.

Large scale application development

Suppose you want to extend your application with:

  • A HTTP API for blogs.
  • A HTTP API for comments.
  • UI for users, blogs and comments.

We can keep what we did before and extend the number of lines in our App.java. It is perfectly fine to do that, after all you own the application :)

But what if you want to better organize your source code? How can you? This is missing feature for most micro-frameworks but not in Jooby.

Jooby provides some features and patterns that let you compose and organize your application.

MVC routes (a.k.a. Controller)

This is well-known pattern in Java frameworks were you annotated methods and make them accessible via HTTP:

We can replace the script routes with our new controller so now our application looks like:

You can apply the same pattern for blogs, comments and UI controllers:

This is how you usually split an application into multiple components using controller classes and annotations.

Wouldn’t be nice if we can keep the script routes and keep source code organized?

Embedded applications

This pattern let you compose one or more applications into one big application.

It’s perfect if you love script routes and want to keep them organized.

We split our application into 4 components, like we did before with controllers. But this time each component is an application by itself:

Time to embedded it as we as we did in the controller example:

This approach let you build standalone applications that can be easily embedded into a major application.

Conclusion

In this article we illustrated how to build large scale applications with Jooby using MVC or script routes.

Some users prefer MVC routes over script routes, but the truth is that you can use both or mix them together. Jooby just make sure to give you the right tools. Like always, decision is yours.

That’s all for now. Thank you for reading! If you are not yet convinced about Jooby here is nice article on why you should give it a try: