PDFBox customize page size, adding images and custom fonts

In this article, we will look at some of the features offered by Apache PDFBox. In the real world, documents created using PDF libraries may require an additional feature of setting custom page size. Fortunately, PDFBox comes with API to specify page size as per standard units referred in a day to day business. The page sizes are A0, A1, …, A6, LEGAL, and LETTER.
Continue reading

Java 8 streams API

My experience with querying a collection has always been clumsy. Writing iterative loops, adding nested if conditions and above all the hack of maintaining intermediary collection to store results. On top of that the brutal indicators from SonarQube – cyclomatic complexity. During all this, I felt there is a common pattern for filtering, sorting and there has to be an expressive way to achieve this functionality(someone said more like SQL!!!). With my love towards multiple technologies (Ok I accept I am a polyglot coder), I knew .Net already had an answer to this – LINQ. Simply have a collection and write a query to extract data. Something like below
Continue reading

20 AWS Solution Architect Questions

While I was preparing for AWS Solution Architect Associate certification, I went through many video tutorials. The certification covers many services from AWS portfolio. AWS has updated the Associate Solution Architect exam in 2018 to include new services and architectural best practices, including the pillars of the Well-Architected Framework. I have already published my experience in post 1 and post 2.

Based on the knowledge I gathered from the FAQ, tutorial, videos etc. I have crafted 20 AWS Questions. Attempt these questions till you get the perfect score.

Continue reading

Is it right to use container for database?

Container has changed the way applications are developed and deployed. The ease of packaging dependencies and the ability to freeze the contents of the container has given the power of deploying repeatable environments. Developers can now confidently echo “What works on my machine can work everywhere”. Containers go hand in hand with DevOps process. In fact, it is a right fit for the DevOps. With Infrastructure defined as a Code (IaC), an entire application image can be built using a code and deployed on the platform of choice. Since containers require very less time to start compared to the Virtual Machine startup, deploying a new release or rollback can be done easily. But what about a state of an application? A majority of the applications require a state to be maintained for preserving either user data or actions. Due to ephemeral nature of containers, it is recommended for packaging application source code, but what about a database?

Continue reading

What is lambda? and why do we need it?

When I started coding GUI application using Java, I realized my code was cluttered with too many anonymous classes. Each time, I had to handle an event the inlined implementation of ActionListener introduced nested and unreadable lines of code. How many of you have written code like below

signUpUserBtn.addActionListener(new ActionListener(){
  public void actionPerformed(ActionEvent e){
    someDelegate.handleUserSignUp(data);
  }
});

Continue reading

MySQL inside Docker

In the previous article, we learnt how Spring boot application can be packaged inside a docker container. The containerization approach helps to quickly spin up an environment and destroy it when not needed. This approach is not just limited to Programming languages but it can be easily be extended for Databases too! Most of the databases including MySQL, PostgreSQL can be easily be containerized. The configuration can be tuned as per application requirements and developers have total freedom to test the changes without impacting the centralized environment. In this article, we will focus on how MySQL database can be containerized. If you do not have Docker setup yet, please refer to this article for docker installation.
Continue reading

Java 8 – Method Reference – Is it Magic?

Amongst the notable features in Java8, Method Reference adds Shorthand syntax for a lambda expression. In most cases, Lambda expression does nothing more than just calling a single method. If you find yourself doing that most often, its time to look at Method reference. It can be used to replace entire Lambda expression, let’s have a look at following example
Continue reading

Java 8 – What is functional Interface?

Functional interface is a new addition to Java 8. In simple terms, an interface which has one single abstract method is qualified as Functional interface. The built-in classes in JDK are full of examples of Functional Interfaces(Runnable, Callable, ActionListener). Java 8 formalized such interface definition with @FunctionalInterface annotation. FunctionalInterface is also useful while creating lambda expressions. Those who are not familiar with Lambda expression, it was again a new feature introduced in Java 8. Lambda helps developers to write concise code. Its expressive syntax saves developer’s time. Before Lambda, for every single method declaration of an interface, developers had to create Class. Eventually, an application source code is filled with many small classes which just provide an implementation for one single method. FunctionalInterface and Lambda expressions are considered to be best practice for writing neat code. Lets have a look at how JavaDoc describes FunctionalInterface
Continue reading

Spring boot and docker

Spring boot has eased the life of developer by reducing boilerplate configuration and reduced project bootstrap time by declaring defaults. Those who are already working on Spring projects and are leveraging Spring boot must have realized productivity gains. In addition to that, Maven build script (pom.xml) has been shortened due to single dependencies made available by Spring boot for a specific purpose. For example including spring-boot-jpa-starter dependency in Maven script ensures that all the required dependencies for interacting with a database are available with a single declaration. While there are many benefits of spring boot, one of the major benefits is to run the application quickly with embedded tomcat instead of having need of a separate server. This has definitely shortened the development cycle and developers can now focus more on building solution for business requirements. Being able to easily deploy the application and that too with speed container approach is on the rise. Spring boot application can be easily be bundled along with container solutions like Docker.
Continue reading

Failed Architecture – Building medical patient record management

In the last article, we witnessed how a simple task of building a static website can throw some unique challenges. Every application has its own quirks which need special attention and hence an architect must not hesitate to reiterate the solution. An architect must spend rigorous time on investigating the functional aspects of an application. What may sound a brilliant solution for one problem, may not be fit under all circumstances. There was no better era than what we are witnessing now in the architecture space. People are discussing Microservices architecture, Event sourcing, Serverless architecture, Blockchain etc., each trying to solve problems enforced by expectations placed by today’s Problem domain. Choosing an incorrect pattern or architecture style will lead to many problems including rigid systems, unmanageable infrastructures, traceability issues, debugging challenges, upgrade chaos. The list is unending and most of us have already experienced pain at some point in time. With this article, we will raise the expectation bar than the previous problem and look at poor architecture built for Managing Patient Record, Reminder system.
Continue reading