Thursday, July 24, 2008

Some wise words on design - I recently was listening to a presentation in InfoQ on design principles of successful large scale enterprise financial application based on Spring & Hibernate. I noted some points while listening to that. Although these are well known established principles I thought it's easier to refer & document when ever we need to come up new design document.
  • Minimize data movement
  • Task Parallel execution where ever possible
  • Physically partition of data
  • Optimized reads & writes of volatile data
  • Minimize contention -- Different connection pooling
  • Asynchronous Decoupling
  • Complete Business Logic performed by data
  • Caching frequently accessed data
Like all popular scalable architecture (eBay, Yahoo) the transaction (distrubuted) & state management were simple (stateless & transactionless for 90% of operations)
JDBCTemplate - fantastic example of Dependency injection
Spring promotes good design - modularity, loose coupling separation of concerns
Testability provides better confidence for refactoring
Hibernate promotes domain driven design - 2'nd level caching is gr8

Contents of design document can be divided into following categories:
  • Architectural review
  • Jumpstart programs
  • Deployment strategy
  • Platform change
  • Proof of concept
  • Performance tuning
  • Development
Capacity Planning questions:
  • How much memory footprint the application requires
  • How many threads the application components need
  • How many connections each application has to handle
  • How many system resources like file handles are required
  • How much parallelism is attainable in a single process
  • How many CPUs can be leveraged at the same time from within the same hardware
  • What are the synchronization primitives available in case of multiple processes and nodes
  • How we coordinate shared accesses and leases
  • The allowable number of nodes that a unit of application job can cross, taking into consideration the performance criterion
I also listened to Joshua Bloch's presentation on design guide lines, Joshua Bloch is currently Java Architect at Google & has great influence on Java's future. He also influenced (JDK5) & wrote many JDK classes as distinguished Engineer at Sun. His assertions carries lot of weight.
Importance of API design for internal and external use.
  • Public APIs are forever - one chance to get it right
  • Good code is modular–each module has an API
  • Thinking in terms of APIs improves code quality
  • Easy to use, even without documentation
  • Don’t let implementation details “leak” into API
  • Make classes and members as private as possible
I guess the most important one was "when in doubt, don't provide the API, leave it".

"There's a natural law in programming language and API design : as backwards compatibility increases, elegance decreases." - Bill Venners
So be minimalist,
because of the compatibility requirement, it's much easier to put things in than to take them out. So don't add anything to the API that you're not sure you need

Sunday, July 13, 2008

Bio-Rhythmic Cycles - I got curious about bio-rhythmic cycles & wanted to try out the the results on my life.

For those who don't know what bio rhythmic cycles are, here is explanation:

The theory of biorhythms claims that one's life is affected by rhythmic biological cycles, and seeks to make predictions regarding these cycles and the personal ease of carrying out tasks related to the cycles. These inherent rhythms are said to control or initiate various biological processes and are classically composed of three cyclic rhythms that are said to govern human behavior and demonstrate innate periodicity in natural physiological change: the physical, the emotional, and the intellectual (or mental) cycles. Others claim there are additional rhythms, some of which may be combinations of the three primary cycles. Some proponents think that biorhythms may be potentially related to bioelectricity and its interactions in the body


I wrote a sample application in swing, which basically takes the date of birth as input & generate the charts.


Here is the sample screenshot, I used JFreecharts & some Date manipulating APIs to create above application. BTW is there any way I can show applet in this blog? Please let me know.

The results were interesting, Most of the events in my life had some kind of correlation with the above graph & explanation:

Physical cycle - 23 days; coordination strength well-being

Emotional cycle - 28 days; creativity sensitivity mood perception awareness

Intellectual cycle - 33 days; alertness analytical functioning logical analysis memory or recall communication

I also tried correlate our god Sachin's best innings with these cycles & surprisingly, cycle behaviour used to match with his best time :-)

Anyway I will try out with some other important figures before coming to conclusion these cycles have any impact or it's just a humbug. BTW, I am little skeptical about all astrology stuff.

So I am planning to develop a RESTful sample as well sample mobile application accepting date of birth & generating the charts possibly using Google charts instead of Jfreecharts

Wednesday, July 09, 2008

GeoNames.org - provides geocoding services. GeoNames provide a huge databases of place names (with coordinates) organized in a hierarchy (eg. country/state/region/province/etc...). Also there is a query that allows to retrieve the geo tags within a range from a specific point. Geonames is integrating geographical data such as names of places in various languages,elevation, population, alternate names, Administrator division type,continent, Address,timezone & weather observation.

Geonames provides RESTful based webservices with both XML & JSON rendering. These seems to defined by seasoned developer & have Style enum (Short,Medium,Long, Full) for defining result verbosity & many such developer friendly criteria APIs.

For off-line applications, geographical database is available for download free of charge under a creative commons distrubution license & can leverage the service by downloading all the data. Geonames.org claims that it has already serving up to over 3 million web service requests per day & has the ability scale.

I guess applications (especially free & open source ones) have excellent opportunity to integrate with this service. Web applications can be relieved from maintaining the huge database of geo services. They can just store the geo-ids & can rely geonames to fetch the details. Hierarchical data is always to difficult store & fetch in standard RDBMS & now there is no need to maintain this data. GeoNames includes the reference implementation in all popular languages. I just checked the java implementation & it was not that good. It could be have been made more easier (or fluent).

The important point to note is that high-profile users of GeoNames include Slide.com & LinkedIn.

Reference
http://www.geonames.org/export/ws-overview.html
http://www.geonames.org/export/place-hierarchy.html
http://en.wikipedia.org/wiki/GeoNames
Bookmark and Share