Book Image

Learning Modular Java Programming

By : Tejaswini Mandar Jog
Book Image

Learning Modular Java Programming

By: Tejaswini Mandar Jog

Overview of this book

Modular programming means dividing an application into small parts and then developing it. It is an approach taken by developers to build applications and helps them add efficiency in their development process, thus making it more effective. The book starts with the fundamentals of Modular Programming. Then we move on to the actual implementation, where we teach developers how to divide an application into different modules or layers (such as presentation, execution, security, lifecycle, services, and so on) for better management. Once readers are well-versed in these modules and their development, the book shows how to create bindings in order to join these different modules and form a complete application. Next, the readers will learn how to manage these modules through dependency injection. Later, we move on to testing; readers will learn how to test the different modules of an application. The book ends by teaching readers how to maintain different versions of their application and how to modify it. By the end of the book, readers will have a good understanding of modular programming and will be able to use it to build applications with Java.
Table of Contents (15 chapters)

Modules


Application development is composed of many interconnected parts which interact with each other. To withstand high market demand and increasing competition, software should have a good look and feel, and ease of use. To develop a compatible solution, the developer has to think about compound structure as well as user perspective. It's quite difficult to develop such a product single-handed. It's teamwork, where the development is running alongside. The team members will build up separate small modules dedicated to part of the actual solution. These small modules will be clubbed together and interact with each other to form a complete solution.

What is behind and in a module?

Each module which has been developed will be performing a unique responsibility. When a module is responsible for a single task, it will be called cohesive. The cohesiveness will make the module more maintainable. Also, it will be less frequently changed. A good design perspective is to try writing a module which will be highly cohesive.

The two modules developed separately will now need to have interaction. To make them interactive, we have to introduce them. This will be done by making them dependent on each other. This dependency is termed coupling. When the code size and number of modules are small, coupling won't be a problem. But in an enterprise application, the code size is huge. Any little change makes a difference and then all of its dependencies should be changed accordingly at a number of places. This makes the code unmanageable. So it's always recommended to have loosely coupled modules.

The practical aspect

Let's take the example of a desktop, the one which we use in our routine. A desktop consists of a monitor, CPU, keyboard, and mouse. If a new monitor with some advanced features is introduced in the market, what we will do? Will we buy a new desktop or just replace the monitor?

As per the convenience and also the cost, it's feasible to just replace the monitor and not the whole desktop; how come this is possible? It's possible because the desktop is assembled with subunits, which are easily replaceable. Each subunit is cohesive for the work and they are not tightly coupled. This happens when we use modularization. When we write an application that uses similar concepts, it is called modular programming.