Generative Testing, Java 8, Modular Architecture and OSGi at NFJS Fall 2013

NFJS Fall 2013 had a series of very interesting sessions, with topics ranging from the new features in Java 8, Modular Architecture and OSGi, Event Sourcing, and various testing technologies and frameworks.

In this post I will present some of the highlights of these technologies and their features and advantages.

Java 8 features:

One of the important features of this Java release is the introduction of Lambda expressions and functional style of programming. Functional style of programming allows us to code the logic expressively (a developer should be able to understand what is being done by looking at the code) and is aimed at increasing productivity. Many coding errors are introduced due to incorrect and unintended use of mutability and concurrency in the code. With the introduction of this Java 8 feature, inline method calls are immutable and help reduce errors due to concurrency and synchronization. Java 8 also introduces the ability to have default methods in the interface. This feature is especially valuable, as it makes adding more methods to the interface easier without breaking any existing implementations. Streams for manipulating collection is another powerful feature in Java 8, which enables parallel processing of elements in a collection.

Event Sourcing and Disruptor:

Current business requirements not only require us to model and persist domain objects, but to also capture any event information. This requires architectures that have very low latency. One such architecture is LMAX-Disruptor, which can handle about 6M transactions a second. As described in detail within an article by Martin Fowler, this architecture separates out the Core Business Logic processor from the I/O components that need to take care of concurrency and persistence.

Modular Architecture and OSGi:

The main goal of Modular Software Architecture is to design and organize software modules into extensible, reusable, maintainable, and adaptable modules. Kirk Knoernschild discussed the following patterns that can be used as guidelines for designing and implementing modular architectures. He covers these patterns extensively in his book “Java Application Architecture: Modularity Patterns with Examples Using OSGi” I am highlighting some of the patterns that should guide us while creating modular software architectures.

Base Patterns: Module Reuse, Module Cohesion.

Dependency Patterns: Acyclic Relationships, Container Independence, Independent deployments of modules.

Usability Patterns: Published interface, Externally Configurable modules, available Default Implementations, Module Façade for coarse-grained functionality.

Extensibility Patterns: Separation of Abstract Classes from Implementation, Implementation using factories.

Utility Patterns: Exception and Test should be co-located with the modules.

OSGi provides a framework for organizing and implementing modular architectures like these. Each OSGi bundle has its own ClassLoaders and exposes a set of micro services (via a well-defined interface) that it offers. This allows for the system to be dynamic and independent of other bundles.

Generative Testing

Stuart Holloway discussed the concept of generative testing and demonstrated use cases using Clojure for generating and analyzing results. Example based testing is a main part of testing any software development module. But example based testing provides coverage only for the examples defined. In order to scale better, we need to generate data for many different scenarios. Generative testing does this by modelling the input data, which enables us to generate different loads based on the input. This allows us to make testing scenarios that are much more comprehensive.

Have additional questions about the technologies I covered? Ask me in the comments below.

Leave a Comment