Understanding strategy pattern by designing game of chess

Today we will try to understand Strategy Pattern with the help of an example.
The example we will consider is The Game of Chess. The intention here is to explain strategy pattern and not to build a comprehensive Chess Game solution.

Strategy Pattern : The Strategy pattern is known as a behavioural pattern – it’s used to manage algorithms, relationships and responsibilities between objects. The main benefit of strategy pattern is to choose the algorithm/behaviour at runtime.

StrategyPattern

Lets try to understand this by implementing this to design the chess game.

Read more ›

Tagged with: ,
Posted in design patterns

Pizza problem- builder vs decorator

Problem Statement :
We need to build the software for a pizza company who wants to prepare different types of pizzas, e.g Chicken Pizza, Flat Bread, Pepperoni Pizza with Extra Cheese, put add on toppings on it.

Lets try to see which design pattern suits this problem statement and under what scenario.
Traditionally, for pizza problem, builder pattern is most commonly used. However there are some examples using decorator as well, both the approaches are correct but there is difference in use case.
Builder is an object creation pattern whereas decorator is used to change the already built object at runtime.
Lets try to understand this by the examples :
Read more ›

Posted in design patterns

Converting JSON to XML to Java Objects using XStream

XStream library can be an effective tool for converting JSON to Java to XML translations to and fro.
Lets explore each one of them one by one, and see which driver is used.

Handling JSONs

To convert JSON to Java objects all you have to do is initialize XStream object with an appropriate driver and you are ready to serialise your objects to (and from) JSON.
Read more ›

Tagged with: , , , ,
Posted in java, WebServices, XML

Configuring chef Part-2

Lets recap what all we have done in the last blog :

1.) Setup workstation and chef-repo.
2.) Registered on chef to use hosted chef as the chef-server.
3.) Bootstrapped a node to be managed by the chef-server.
4.) Downloaded the “apache” cookbook in our chef-repo.
5.) Uploaded the “apache” cookbook to the chef-server.
6.) Added the recipe[apache] in the run-list of the node.
7.) Ran the chef-client on the client to apply the cookbook.

Now lets continue, and try to understand some more concepts around chef and see them in action.
Read more ›

Tagged with: ,
Posted in chef, continuous delivery, devops

Configuring Chef part 1

Below are the first steps in getting started with using chef.
The three main components of chef are :
1.) Work station
This is the developer’s machine will be used to author cookbooks and recipes and upload them to the chef-server using the command line utility called knife.
2.) Chef-Server
This is the main server on which all the cookbooks, roles, policies are uploaded.
3.) Node
This is the instance which would be provisioned by applying the cookbooks uploaded on the chef-server.

So, lets get started:
Read more ›

Tagged with: ,
Posted in chef, continuous delivery

How to mock HTTP endpoints in Mule Functional Test?

Mule is an enterprise service bus (ESB) and integration framework. In Mule, we define flows and sub-flows in order to integrate applications and orchestrate services.These flows contain endpoints to integrate different applications or services. These endpoints can be HTTP, VM, JMS, etc. More details about development in mule can be found here. Below is a sample flow.
Screen Shot 2014-03-18 at 1.12.54 PM

In order to write unit test cases for mule flows, mule provides an abstract JUnit test case called org.mule.tck.junit4.FunctionalTestCase that runs Mule inside a test case and manages the lifecycle of the server.More details about can be found here.
Read more ›

Tagged with: , , ,
Posted in ESB

Vagrant – a swiss Army knife for every developer

Whenever we move to a new project, or we want to explore a new stack of technologies; we face the problem of environments. Being a developer we generally have a tendency to install everything on our local environment; which many times proves to be a disaster.

Today, modern web applications involve a lot of moving parts, numerous underlying technologies and a lot of complexity. Read more ›

Tagged with: , ,
Posted in continuous delivery, devops

Enter your email address to follow this blog and receive notifications of new posts by email.

Join 152 other followers

Blog Stats
  • 10,194 hits
Follow

Get every new post delivered to your Inbox.

Join 152 other followers