Cache Abstraction by Spring

Cross cutting concerns

Most developers will acknowledge how implementing crosscutting concerns such as logging, auditing, security and transactionality can adversely affect business logic implementation. Such concerns “seem” to increase the complexity of existing business logic, at times making it difficult if not impossible to clearly distinguish business logic from the crosscutting concern implementation.

Spring is very good at cross cutting concern (CCC) allowing developer to use or implement cross cutting concern as abstract as possible.

i have never thought of cache as cross cutting concern but caching abstraction by spring is really isolating caching and business logic/navigation (screen) logic in such a way that allows developer to only focus on logic rather than caching implementation like transaction.

before we move to usage part difference between cache and buffer needs to be clarified.

Cache vs Buffer

The terms “buffer” and “cache” tend to be used interchangeably; note however they represent different things. A buffer is used traditionally as an intermediate temporary store for data between a fast and a slow entity. As one party would have to wait for the other affecting performance, the buffer alleviates this by allowing entire blocks of data to move at once rather then in small chunks. The data is written and read only once from the buffer. Further more, the buffers arevisible to at least one party which is aware of it.

A cache on the other hand by definition is hidden and neither party is aware that caching occurs.It as well improves performance but does that by allowing the same data to be read multiple times in a fast fashion.

Cache abstraction

The abstraction applies caching to Java methods, reducing thus the number of executions based on the information available in the cache.That is, each time a targetedmethod is invoked, the abstraction will apply a caching behaviour checking whether the method has been already executed for the given arguments. If it has, then the cached result is returned without having to execute the actual method; if it has not, then method is executed, the result cached and returned to the user so that, the next time the method is invoked, the cached result is returned. This way, expensive methods (whether CPU or IO bound) can be executed only once for a given set of parameters and the result reused without having to actually execute the method again. The caching logic is applied transparently without any interference to the invoker.

Obviously this approach works only for methods that are guaranteed to return the same output (result) for a given input (or arguments) no matter how many times it is being executed.

Posted in Spring | Tagged , , | Leave a comment

Web 2.0 Part 2

Let’s look at basic change which has occurred during last 3 decades, “Internet”.

As it reached billions of people, The Internet (aka Web) became dominant platform, fusing, and imposing structure on the majority of other networks.

The Internet is, in fact, a bus-type environment; that is, components may be added or deleted without affecting the system’s overall state or usability.

Internet has changed lot of things the way we do and lead to paradigm shift as below.

We will continue with comparison of web 1.0 to web 2.0 in next post.

Posted in Web 2.0 | Tagged , | 1 Comment

Web 2.0 Part 1

I had presentation last for college student of Vallabh Vidhya Nagar about web 2.0 (i always like to share knowledge and experience and this was one of that platform). A week ago i was asked to present this presentation, i had very little time to prepare it during weekdays but worked on weekend and prepare it. i am going to share my understanding about web 2.0 in next couple post.

Let’s start with Web 2.0 definition, i am sure that most of Indian has watched movie 3 Idiots. In movie (of course 5 point some one also) have one scene where engineering Professor ask machine’s definition and Chatur Ramalingam started talking about defination of machine like parrot. To me below definition looks same for web 2.0

Web 2.0 is the network as platform, spanning all connected devices; Web 2.0 applications are those that make the most of the intrinsic advantages of that platform: delivering software as a continually-updated service that gets better the more people use it, consuming and remixing data from multiple sources, including individual users, while providing their own data and services in a form that allows remixing by others, creating network effects through an “architecture of participation,” and going beyond the page metaphor of Web 1.0 to deliver rich user experiences. O’Reilly

I hope Tim doesn’t sue me for comparing him with Chatur, but while reading above definition this was first thought came to my mind.

It is very hard to define Web 2.0, there millions of Citations are available in Google for web 2.0, Why it difficult to define Web 2.0? The internet is changing so fast that by the time definition was documented it would be out of date. Just like Cloud computing and SaaS. even major company like Google and Oracle have not come up with the clear definition for any of these buzzword.

Let’s look at definition from Rancho’s view (from simple view).

This suggests Web environment and direction to create, share, enhance user’s life, media, business, community easily. It is Second generation of services available on the Web that lets people collaborate and share information online.

Simple!!!

Disclaimer: No formal architecture or specification exists to explicitly define Web 2.0, nor is there ever likely to be one.

Posted in Web 2.0 | Tagged , , | 2 Comments

Design Patterns: Abstract Factory

It’s easy to think of factories in the real world – a factory is just somewhere that items gets produced such as cars, computers or TVs.

The Abstract Factory is known as a creational pattern – it’s used to construct objects such that they can be decoupled from the implementing system. The definition of Abstract Factory provided in the original Gang of Four book on Design Patterns states:

Provides an interface for creating families of related or dependent objects without specifying their concrete classes.

The Abstract Factory pattern is similar to the Factory Method pattern, except it creates families of related objects.

Let’s look at class diagram of Abstract Factory

Benefits:

  • Isolates the concrete classes from client
  • Allows for exchanging product families easy
  • Promotes consistency among products by implementing the common
  • interface

When to Use:

  • The system should be independent of how its products are created, composed, and represented.
  • The system should be configured with one of multiple families of products—for example, Microsoft Windows or Apple OSX classes.
  • The family of related product objects is designed to be used together, and you must enforce this constraint. This is the key point of the pattern; otherwise, you could use a Factory Method.
  • You want to provide a class library of products, and reveal only their interfaces, not their implementations.
Posted in Creational, Design Patterns | Tagged , , , | Leave a comment

Continuous Integration helps?

The founder of javaranch.com, Kathy Sierra, said in her blog, “There’s a big difference between saying, ‘Eat an apple a day’ and actually eating the apple.”

Sometimes I had issue not achieving good software quality having some introspection, I found that some aspects of software engineering were not effectively implemented or it is very time consuming

  • Testing was ineffective.
  • Code reviews were waste of time.
  • Keeping eye on developer’s code and completion at micro level.
  • Developer missed to commit some files.
  • Back track of task and file changes, what files had change for a particular bug and when

From last one year I have started using Hudson as continues integration tool and found extremely helpful even thought very minimal or none automated testing.

According Martin fowler

Continuous Integration is a software development practice where members of a team integrate their work frequently; usually each person integrates at least daily – leading to multiple integrations per day”

CI architecture

CI architecture

Initially I took around 16 hours to setup Hudson server and create build script for my firstproject which includes

  • Compiling source code.
  • Create war and deploy it on staging server.
  • Run findbugs, PMD and CPD.
  • Run Selenium test cases.
  • Setup developer’s accounts.
  • Integration with Jira issue tracker.

Now I can have all above things up and running within 30 min or less for any new project and payback of this time is huge. it resolves all issues listed above.

References:

http://en.wikipedia.org/wiki/Continuous_integration

http://martinfowler.com/articles/continuousIntegration.html

Posted in Continuous Integration, Hudson | Tagged , , , | 2 Comments

Hello Blog!

Welcome to java Rock Star. This is my first post and hope write some good blog for community.

Posted in Uncategorized | Tagged , | Leave a comment