Pages

Sunday, September 1, 2013

Big data - how do organizations choose

Big data is the recent buzz word in the market and many organizations are looking at it to understand what kind of benefits it can provide to their business. Logically speaking, the amount of data generated by any business is huge and analyzing that should provide more insights in to data about your business.

It is important to understand and create use cases relevant to your business before you start embarking on the big data journey as every vendor has a big data product and charging hefty license fees for using the software. Initially big data came in to the picture when search engine providers like google, ask.com needed to store vast amount of web page information to enable searching. When social media started to become mainstream websites like Facebook, twitter & you tube started generating terabytes of data and to store that kind of information some different type of databases were needed. That is how big data came in to prominence and now it is an important technology to solve many different types of issues.

The typical use cases for big data

Big data alone can't do anything apart from providing an infrastructure to store huge amount of data but together with analytics solutions, it can make a big impact. The typical usecases i saw are

For Retail segment

How customers use the business website. For example, websites like amazon.com, continuously monitor how the users use their website and if the customer quit the buying process they need to know why & what happened. So they track each and every user, the demographic area of the user, the browsing history for their website etc and this information is analyzed to see the trend. Say for example, more people are getting in to the buying process after seeing a promo on shoes on the first page but during payment, they are not able to pay with Visa card so they are quitting the process. So amazon can find this out by capturing, storing and analyzing this information.

Personalized content

By tracking the customer usage of the website, they can change the content, look and feel of the website to customer's preference. For example, if customer is searching for books mainly in the website, when he visits the site next time, all the books promos will be made visible to the user so that he can be enticed to buy the books.

Cross selling and up selling

Cross selling is selling different type of products to the customer related to the one he already bought. For example, if the customer is searching for TV and bought it, showing all the accessories related to TV (for example, TV stand, DVD's etc) and making the customer to look at them by providing compelling cost reductions.

For Banking and Financial segments

The above use cases mentioned for retail segment also applicable for banking and financial sector as well. However I am not really convinced that we can bring same kind of impact like a retail business because many of the banking products has to be still bought in branch and not in online. However I do see the below use cases

Risk assessment and fraud detection

Banks generate huge volumes of transaction data and for fraud detection it is important to analyse this data. The current model is to use standard data ware house based solution but with increase in data volumes it will become necessary to use different type of technology and big data and analytic for sure is going to be the future technology stack for this kind of analysis.

How to choose big data vendor or solution provider

This field is still emerging and there is no set of standard best practices on choosing a big data vendor. These are the points I think should be considered for selecting a big data solution provider. The important consideration is always about the licensing costs and support.  The other factors to consider are

1) Define the important use cases for the business and check ability to support these use cases
2) Maturity of the solution stack
3) How easy is to integrate with other technology investments
4) Case studies and other implementations
5) Future road map and support
6) Ability to support multi channel and integration with social media


Saturday, August 17, 2013

Learnings of the first time scrum master

Agile is becoming the de facto standard for enterprise application development. I also decided to join the band wagon so I joined a agile project as a developer with only theoretical knowledge about the agile programming. The team had 3 more developers, 2 testers, 2 BA's (one of them appointed as the product owner by the business) and a project manager. The scrum master managed some other projects as well so he could not spend enough time on this project and I was asked to do scrum master role which I accepted very reluctantly because no one in the team knows agile but for organizational reasons the project is called agile project.

From the beginning the project had many issues. We have used JIRA to track user stories but since the product owner had no idea about agile or how to use JIRA, his user stories tend to be one liners like implement security, implement web service, etc. We had user requirements documents for front end (which details the various requirements, screen mock ups, validations etc), requirements for batch process,
interface specs for web services in word documents etc. Worst of all, we had very tight dead line 6 months as well for the project development. The project manager is a good guy but very soft and also don't know about agile so we had very hard time deciding the scope of the sprint, implementing it and demoing it. After some time it became clear the project is not going well and we are not going to meet the deadlines.
The issue has been escalated to the program manager and he stepped in. The project became smooth in couple of sprints.

He didn't do anything magical but some how he brought the project back on track.

Determine the size of the project:

Determining the size of the project is very important activity. We didn't know how to do it because the requirements catered in various places (JIRA, various requirements documents, white boards, excel sheets, as defects in QC). The first activity to be done is consolidate everything in one excel sheet by listing down all the requirements and creating sub tasks where possible for each requirement. If you don't know the sub-task leave it as it is. Then do a T-shirt planning. You give size for each requirement in terms of small, medium, large, XL, XXL. Take a well known and well understood requirement and give a size for that requirement. For example, creating a web service could be medium sized requirement. Relative to this requirement
decide the size of other requirements. At the end of the exercise, you will have number of requirements of various sizes. For example 10 small, 5 medium, 10 large, 2 extra large and 1 XXL. See the team size and amount of time left to complete the activities and you will get a clear idea when you can finish the project. It will give you insight of the actual size of the project. We found out that,with the current strength it will take 8 months to finish the project (we found this 4 months after the project start) So clear indication that team size has to be increased.

The team:

A very important factor for successful agile project. The team should be cross functional and should be able to handle various functional and technical tasks. The team I worked with, compartmentalized things (I will work only in front end, I will work only in the back end) and wont touch the technical items (like deployment, solving complex technical issues) etc

Politics:

IT projects are not always about technical capability but it is also about organizational politics, background and culture of the team and the challenges it brings to the project. In our case the team is mixture of developers from two different vendors so there was some tension, also the PM and Product owner are internal employees of the organization so they were not too much worried too much about the project status.

Decision Making:

The major hurdles in any IT project is also about the decision making. The stakeholders take too much time to take decisions.Technical architect thinking about whether to use Queue's or Web services, business owners thinking this way or that way. Decisions has to be made after careful considerations but there should be deadline for every decision. If the project manager or scrum master is not able to force the decisions it impacts the team velocity and at the same time, affects the morale of the team because there are simply too many loose ends and too many user stories not completed and pending in various stages. The scrum
master should be able to speed up the decision making and if not possible escalate to the right level to get things moving. Same process applicable for other dependencies (environments set up, services to external systems) deadlines have to be agreed and if not honored has to be escalated and get it done for smooth progress.

Honest feedback to the team members:

The team members though senior people, still make mistakes in terms of creating quality code, solving technical issues. One of the team members code is very bad in terms of quality, no junits & too many defects. Other team member took too much time to solve even trivial issues which should be very simple for a developer with 10 years experience. As a scrum master and with different cultural background, I tend not to discuss the issues with them but try to solve the issues by myself which turned out to be very difficult after some time. After the new scrum master came in, this developer was kicked out immediatly and the
other developer was warned. I should have spoke to these guys and asked them to improve or move out. I didn't have the confidence to do the same. I have spent long nights trying to correct the mistakes others did which is not good in the long term.

The summary of the learning's

1) Set up a good team with good technical people. Strong manager and strong scrum master is essential for team success.
2) Understand the size of the project using appropriate methods (T shirt planning for example) and see whether the team has the capacity to meet the deadlines
3) In agile team though every one is equal, The scrum master and project manager are more equal than the rest of team. They should
1) Control the team and give honest feed back to the team
2) If team member not improving, don't hesitate to replace the team members
3) Identify the impediments and resolve the impediments in reasonable time frames
4) escalate to the right levels and get the impediments out of the way on time for the team to continue
4) Understand the underlying organizational politics and subtle issues and make sure that is not impacting the velocity of the team. If not resolved
1) Teams will be divided and each one will be working as silos not knowing what others are doing
2) Team not jelled well, take more time to complete the tasks because of communication issues
3) Dont hesitate to change the team in case above approaches not working.








Saturday, June 29, 2013

Spring MVC - Utility Project To Download files - Access log files from restricted environments

In development as well as maintenance projects you may have to access the log files to see what went wrong. However in some environments the developers may not have access to these log files. The developers has to request for these log files and it is a time consuming process. So if accessing log files implemented as part of the application itself it will save lot of time for the development team members.

However please note, this functionality should be used only when it is appropriate.

Technologies & Tools used

1. STS
2. Maven

Step 1:

Create Spring MVC project using the steps given here

Step 2:

Add showLogs and handleFileDownload method as shown below.

1:  package com.ravi.springmvc;  
2:  import java.io.File;  
3:  import java.io.FileInputStream;  
4:  import java.text.DateFormat;  
5:  import java.util.Date;  
6:  import java.util.Locale;  
7:  import javax.servlet.http.HttpServletResponse;  
8:  import org.slf4j.Logger;  
9:  import org.slf4j.LoggerFactory;  
10:  import org.springframework.stereotype.Controller;  
11:  import org.springframework.ui.Model;  
12:  import org.springframework.util.FileCopyUtils;  
13:  import org.springframework.validation.BindingResult;  
14:  import org.springframework.web.bind.annotation.ModelAttribute;  
15:  import org.springframework.web.bind.annotation.RequestMapping;  
16:  import org.springframework.web.bind.annotation.RequestMethod;  
17:  import org.springframework.web.servlet.ModelAndView;  
18:  /**  
19:   * Handles requests for the application home page.  
20:   */  
21:  @Controller  
22:  public class HomeController {  
23:       private static final Logger logger = LoggerFactory  
24:                 .getLogger(HomeController.class);  
25:       @ModelAttribute("logFile")  
26:       public LogFile getLogFile() {  
27:            return new LogFile();  
28:       }  
29:       /**  
30:        * Simply selects the home view to render by returning its name.  
31:        */  
32:       @RequestMapping(value = "/", method = RequestMethod.GET)  
33:       public String home(Locale locale, Model model) {  
34:            logger.info("Welcome home! The client locale is {}.", locale);  
35:            Date date = new Date();  
36:            DateFormat dateFormat = DateFormat.getDateTimeInstance(DateFormat.LONG,  
37:                      DateFormat.LONG, locale);  
38:            String formattedDate = dateFormat.format(date);  
39:            model.addAttribute("serverTime", formattedDate);  
40:            return "home";  
41:       }  
42:       @RequestMapping("/showlogs")  
43:       public ModelAndView showLogs() {  
44:            return new ModelAndView("logs", "command", new LogFile());  
45:       }  
46:       @RequestMapping(value = "/logs")  
47:       public void handleFileDownload(@ModelAttribute("log") LogFile log,  
48:                 BindingResult result, HttpServletResponse res) throws Exception {  
49:            try {  
50:                 String fn = log.getLogFileLocation();  
51:                 File f = new File(fn);  
52:                 System.out.println("Loading file " + fn + "(" + f.getAbsolutePath()  
53:                           + ")");  
54:                 if (f.exists()) {  
55:                      res.setContentType("application/text");  
56:                      res.setContentLength(new Long(f.length()).intValue());  
57:                      res.setHeader("Content-Disposition",  
58:                                "attachment; filename=Test.log");  
59:                      FileCopyUtils.copy(new FileInputStream(f),  
60:                                res.getOutputStream());  
61:                 } else {  
62:                      System.out.println("File" + fn + "(" + f.getAbsolutePath()  
63:                                + ") does not exist");  
64:                 }  
65:            } catch (Exception e) {  
66:                 System.out.println(e.getMessage());  
67:                 throw e;  
68:            }  
69:       }  
70:  }  

Step 3

Add the JSP file which allows the user to download to specific log file.

1:  <%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%>  
2:  <html>  
3:  <head>  
4:       <title>Spring 3 MVC - Log Manager</title>  
5:  </head>  
6:  <body>  
7:  <h2>Log Manager</h2>  
8:  <form:form method="post" action="logs.html">  
9:       <table>  
10:       <tr>  
11:            <td><form:label path="logFileLocation">Log File Location</form:label></td>  
12:            <td><form:input path="logFileLocation" /></td>   
13:       </tr>  
14:       <tr>  
15:       </tr>  
16:       <tr>  
17:            <td colspan="2">  
18:                 <input type="submit" value="Fetch Log"/>  
19:            </td>  
20:       </tr>  
21:  </table>       
22:  </form:form>  
23:  </body>  
24:  </html>  

Step 4

Run the application and the application can be accessed in the url http://localhost:8080/springmvc/showlogs


Step 5

Your log files will be downloaded as shown below.










This tutorial is for illustration purposes only. Do not use this in real life scenario without adding specific security measurements as this application will allow you to download all the files for which the user has access to.

Step by step Spring MVC application development using Spring Tool Suite in 2 minutes

In this tutorial we will see creating a Spring MVC application using Spring Tool Suite IDE in 2 minutes

Step 1 : Create new new project by choosing File -> New -> Project


















Step 2 : Choose Spring Template Project


Step 3 : Choose Spring MVC Project

Step 4 : Choose a name for the project - SpringMVCDemo


Step 5 : The project structure should look like the one below

Step 6 : Add the project to Tomcat server integrated with STS and start the server






Step 7 : The application should be up and running and you can access the application in the below URL




Spring 3 Hello World Example

Spring 3 Hello world example

Technologies used

STS
Maven
JDK 1.6

POM file

1:  <project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
2:       xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">  
3:       <modelVersion>4.0.0</modelVersion>  
4:       <groupId>com.ravi.helloworld</groupId>  
5:       <artifactId>Spring3HelloWorld</artifactId>  
6:       <packaging>jar</packaging>  
7:       <version>1.0-SNAPSHOT</version>  
8:       <name>Spring3HelloWorld</name>  
9:       <url>http://maven.apache.org</url>  
10:       <properties>  
11:            <spring.version>3.2.3.RELEASE</spring.version>  
12:       </properties>  
13:       <dependencies>  
14:            <dependency>  
15:                 <groupId>junit</groupId>  
16:                 <artifactId>junit</artifactId>  
17:                 <version>4.8.2</version>  
18:                 <scope>test</scope>  
19:            </dependency>  
20:            <!-- Spring 3 dependencies -->  
21:            <dependency>  
22:                 <groupId>org.springframework</groupId>  
23:                 <artifactId>spring-core</artifactId>  
24:                 <version>${spring.version}</version>  
25:            </dependency>  
26:            <dependency>  
27:                 <groupId>org.springframework</groupId>  
28:                 <artifactId>spring-context</artifactId>  
29:                 <version>${spring.version}</version>  
30:            </dependency>  
31:       </dependencies>  
32:  </project>  

The source code looks like this

1:  package com.ravi.helloworld;  
2:  import org.springframework.context.ApplicationContext;  
3:  import org.springframework.context.support.ClassPathXmlApplicationContext;  
4:  public class App {  
5:       public static void main(String[] args) {  
6:            ApplicationContext context = new ClassPathXmlApplicationContext(  
7:                      "AppContext.xml");  
8:            HelloWorld obj = (HelloWorld) context.getBean("welcomeBean");  
9:            obj.printHello();  
10:       }  
11:  }  

The application context file

1:  <beans xmlns="http://www.springframework.org/schema/beans"  
2:       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
3:       xsi:schemaLocation="http://www.springframework.org/schema/beans  
4:  http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">  
5:       <bean id="welcomeBean" class="com.ravi.core.HelloWorld">  
6:            <property name="name" value="Ravisankar" />  
7:       </bean>  
8:  </beans>  

When you run it the output will look something like this
1:  Spring 3 : Hello ! Ravisankar  



Sunday, June 16, 2013

Testing Spring MVC application - Spring 3

Testing Spring MVC application is always bit tricky because the test support is not that great for MVC. This weekend when I was searching for options to test, I stumbled across this spring-test-mvc framework which is now integrated with Spring-test module from 3.2.3.Release version on wards.

I tested it using a quick example and it looks impressive to start with. Lets see how to use this to test your application.

Add this dependency in your POM file

<dependency>
<groupId>org.springframework</groupId>
<artifactId>spring-test</artifactId>
<version>3.2.3.RELEASE</version>
<scope>test</scope>
</dependency>

Create a new test class for your controller. The sample controller looks something like this.

package com.ravi.springmvc;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

import org.junit.Before;
import org.junit.Test;
import org.junit.runner.RunWith;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.test.context.ContextConfiguration;
import org.springframework.test.context.junit4.SpringJUnit4ClassRunner;
import org.springframework.test.context.web.WebAppConfiguration;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;
import org.springframework.web.context.WebApplicationContext;

@RunWith(SpringJUnit4ClassRunner.class)
@WebAppConfiguration
@ContextConfiguration("classpath:test-servlet-context.xml")

public class HomeControllerTest {

    @Autowired
    private WebApplicationContext wac;

    private MockMvc mockMvc;

    @Before
    public void setup() {
        this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();
    //this.mockMvc = MockMvcBuilders.standaloneSetup(new HomeController()).build();
    }

    @Test
    public void getAccount() throws Exception {
    this.mockMvc.perform(get("/showlogs")).andExpect(status().isOk());
    }

}

There are two options to test 

1) With all your configurations, just like the above code. You can load your spring configuration file so that you can even see whether there are any issues in your configurations. 
2) As a standalone test without loading any configurations.  You can strip away all the configuration loading part and still test the application. Pretty impressive.

MockMvc is the core part of the test framework and as the name suggests mocks the MVC setup. When you call webAppContextSetup by passing WebApplicationContext you get the MockMVC instance. 

        this.mockMvc = MockMvcBuilders.webAppContextSetup(this.wac).build();

In that you can call perform method with the url to mimic the browser behavior of calling a particular URL path. 

     this.mockMvc.perform(get("/showlogs")).andExpect(status().isOk());

After the perform method you can test your expectations and basic one is whether the page returns ok by checking the http status code.

Standalone setup is even pretty simpler.

package com.ravi.springmvc;

import static org.springframework.test.web.servlet.request.MockMvcRequestBuilders.get;
import static org.springframework.test.web.servlet.result.MockMvcResultMatchers.status;

import org.junit.Before;
import org.junit.Test;
import org.springframework.test.web.servlet.MockMvc;
import org.springframework.test.web.servlet.setup.MockMvcBuilders;

public class HomeControllerTest {

    private MockMvc mockMvc;

    @Before
    public void setup() {
     this.mockMvc = MockMvcBuilders.standaloneSetup(new HomeController()).build();
    }

    @Test
    public void getAccount() throws Exception {
    this.mockMvc.perform(get("/showlogs")).andExpect(status().isOk());
    }

}

Sunday, June 9, 2013

SCEA - Sun Certified Enterprise Architect - Oracle Certified Master, Java EE 5 Enterprise Architect

I want to share my experience of becoming an SCEA or now OCM for Java. I guess SCEA was the ultimate goal for many java developers who wanted to become architects.

When I started the preparations in 2010, it was SCEA which had 3 parts

1) Online test
2) Assignment
3) Essay

Now it became OCM - Java EE 5 and they introduced a training as well before online test for a hefty price in the range of $2000-$3000. I am not sure whether people are really interested in this exam any more.

The online test - It is a multiple choice question for 2 hours. It contains 64 questions and passing score is 57%. We need to prepare for 8 topics

1) Section 1: Application Design Concepts and Principles
2) Section 2: Common Architectures
3) Section 3: Integration and Messaging
4) Section 4: Business Tier Technologies
5) Section 5: Web Tier Technologies
6) Section 6: Applicability of Java EE Technology
7) Section 7: Patterns
8) Section 8: Security

This exam can be daunting but I found it rather not very difficult once you really start the preparation. You can prepare with the materials you have in online. Code ranch has a wonderful forum where you can find wealth of information ( http://www.coderanch.com/t/562482/java-Architect-SCEA/certification/suggestions-SCEA-preparation ). I also bought the exam kit from whiz labs ( http://www.whizlabs.com/scea/scea.html ) where you can practice and it will clearly let you know the areas of improvement. It had multiple mock exams and you can try 2 or 3 before the final day of the exam. On the final day or day before that, try the remaining two.

I took the exam in Sep 2010 and I passed the exam with 80% score and then I didn't attempt the essay exam for one year. When I took it up in Jan 2012 I used the book Certified Enterprise Architect Study Guide (http://www.amazon.com/Certified-Enterprise-Architect-Study-Guide/dp/0131482033) and it was ultimate. The reason is, the book is not very big and it was written by the exam authors themselves. So the assignment examples published in the book are pretty simple and neat. I just used this book as guide and prepared for the exam. Once you pay the money for exam, earlier they used to send the assignment in mail which you need to complete and upload in the website. I guess now it is changed.

I was very worried about the assignment but it is not that hard. But it needs time as you need to prepare each and every diagram with enough details.

1) Class diagram
2) Sequence diagram - You have to prepare many for each use case
3) Component diagram
4) Deployment diagram (I found a nice example in weblogic server site but I could not find it now)

I used Enterprise Architect tool to create these diagrams.  You can use Rational tools as well. I am not sure are there any good open source tools also to do this. Again you can get plenty of advice on Code ranch. You can't discuss about your exact problem but you can get the general questions clarified. Finally I completed the assignment after one week of hard work (I took off from office and worked on it for a week) and uploaded.

Then the final essay exam. You need to take the exam in authorized center and it mainly talks about the design choices you made and your deliverables. This one is easy if you take this exam with in a week of your submission. No need to prepare anything you just go to the center and then say it in writing the reasons behind your architecture or design. I did it with in a week and then waited for the result.

Whola, after a week I got the most anticipated mail that I have cleared the exam. But unfortunately I waited for too long to take the assignment exam so I also need to go through the class room training to get my final certification. It is so costly (costlier than all the 3 exam's put together) I am wondering whether to take it or not.

Now everything moved towards Scrum, Agile and Spring so I am wondering whether this exam has the same popularity and respect it used to have once. I am not creating class diagram, sequence diagrams any more and also not using the Java EE stack at all. This training only suitable for people who are 3-4 years experience in Java but not for people who have more than 10 years experience (SE 7 is one training!!!).

 
 
Blogger Templates