Posts

Domain Modelling Patterns

Image
There are two main patterns for organizing business logic: the procedural Transaction script pattern, and the object-oriented Domain model pattern. 1. Transaction script pattern: An important characteristic of this approach is that the classes that implement behavior are separate from those that store state. When using the Transaction script pattern, the scripts are usually located in serviceclasses, which in this example is the OrderService class. A service class has one method for each request/system operation. The method implements the business logic for that request. It accesses the database using data access objects (DAOs), such as the OrderDao. The data objects, which in this example is the Order class, are pure data with little or no behavior. This style of design is highly procedural and relies on few of the capabilities of objectorientedprogramming (OOP) languages. This what you would create if you were writing the application in C or another non-OOP language. Neverthe

Guice Tutorial

Below is a short & crisp tutorial on Guice and the functionalities offered by it What is Guice? Guice is framework in Java to inject dependencies to configure Java Objects. The dependency injection pattern leads to code that is more modular & testable. Consider an interface BillingService as below: Consider below implementation of the BillingService Class: It is easy to see the problems with above solutioning as it would make testing the code impossible! Let's model the BillingService implementation by including its dependencies in constructor: It is now possible to send mock Object or FakeCreditCard Object using a custom FakeCreditCardProcessor. But it still has a problem that BillingService's client need to lookup it dependencies , basically you will need to construct dependencies recursively while you need to use a service. This is where Guice comes for rescue! Dependency Injection with Guice To Use Guice for dependency injection in above examp

Spring Framework Tutorial

Please go through the below points to have a thorough understanding of basic functionalities offered by the spring framework. 1. Spring IOC container:  IoC is also known as dependency injection (DI). It is a process whereby objects define their dependencies (that is, the other objects they work with) only through constructor arguments, arguments to a factory method, or properties that are set on the object instance after it is constructed or returned from a factory method. The container then injects those dependencies when it creates the bean. This process is fundamentally the inverse (hence the name, Inversion of Control) of the bean itself controlling the instantiation or location of its dependencies by using direct construction of classes or a mechanism such as the Service Locator pattern. 2. In Spring, the objects that form the backbone of your application and that are managed by the Spring IoC container are called beans. A bean is an object that is instantiated, assembled,

Ruby Syntax Cheat Sheet

In this post I am sharing out a short and concise cheat sheet to help you learn or reminisce ruby syntax and constructs. 1. To print multiple Lines print <<EOF    This is the first way of creating    here document ie. multiple line string. EOF 2. To run in the beginning of program BEGIN {    puts "Initializing Ruby Program" } 3. To run at the end of the Program END { puts "at end" } 4. Class in Ruby class Customer end cust1 = Customer.new 5. Local variable start with lowercase or _ instance variable start with @ class variables start with @@ global variable start with $ 6. When you plan to declare the new method with parameters, you need to declare the method initialize at the time of the class creation. The initialize method is a special type of method, which will be executed when the new method of the class is called with parameters. Here is the example to create initialize method − cla

DropWizard Tutorial

Image
In this article I will discuss about dropwizard , how to implement a simple application using dropwizard. Dropwizard is a simple tool to develop reliable web applications with minimal maintainance and is easy to learn,implement. It includes: Jetty, a high-performance HTTP server. Jersey, a full-featured RESTful web framework. Jackson, the best JSON library for the JVM. Metrics, an excellent library for application metrics. Guava, Google’s excellent utility library. Logback, the successor to Log4j, Java’s most widely-used logging framework. Hibernate Validator, the reference implementation of the Java Bean Validation standard.   Moving head on to the implementation part ; each dropwizard application must have below components to expose rest api(s): 1. Configurations in yaml format 2. Application configuration (This contains all the configuration files required by your application ) 3. POJOs required for data transmission 4. Resource Files to expose your apis

About Docker

In this post we are going to give a short introduction to docker. This post will probably help you in getting to know about the gist of docker as a developer. Why docker? Problems before docker: Without docker we had to deploy our webservice on Virtual Machines which required 1 Virtual Machine per each microservice ; wastage of ram,disk space for each virtual machine In docker there is a single VM, there are docker containers on top of it. Docker Containers are lightweight and requires no pre-allocation of resources unlike Virtual Machines. You might be thinking that why use VM here with docker containers? To segregate the required amount of memory and disk space for the containers and also if its a windows machine we need to provide linux environment though VM as docker runs on linux. Provides consistent development environment for dev,test throughout SDLC On top of host OS there is docker engine and top of it there are multiple docker containers. Docker does not have own OS

GraphQL Introduction

Image
In this post I will give a brief introduction to graphQL.Please go thoroughly with the introduction shared in a short and concise manner below as in the next post we will have a look at actually implementing a server using graphQL in Java. What is GraphQL? GraphQL is a new API standard which provides more powerful and flexible alternative to REST. It Enables declarative data fetching (Client can tell exactly what fields to fetch). Exposes a single endpoint and responds to queries unlike REST It solves below problems :                  underfetching: An endpoint doesn't return sufficient information; need to send                                                     multiple requests to server                  overfetching: Downloading unnecessary data Let's say you have an entity called product with attributes productId, productname ,price,productSeller No need to adjust api if product requirement or design changes Fields which are not required by client also easily v