Showing posts with label programming. Show all posts
Showing posts with label programming. Show all posts

Friday, May 1, 2009

Decoupling the UI from Backend

The "minimal change prorogation" can be used as a verification test for loose coupling. I've been struggling to handle changes in a core component when it suddenly occurred to me that, "dhhaa tightly coupled". The changes propagated to the UI. The problem is that I have used the information experts to send data to the UI.

So I added a new rule to my experience. Use another set of classes called "Data Transfer Object" to transfer data to the UI. Problem solved!

Wednesday, April 29, 2009

Tabs vs Spaces - Code Formatting

Do you format code with tabs or spaces? It is not an a question of what is pretty. There is more to the story. I would like to quote from[1]

"On defaultly-configured Unix systems, and on ancient dumb terminals and teletypes, the tradition has been for the TAB character to mean move to the right until the current column is a multiple of 8. This is also the default in the two most popular Unix editors, Emacs and vi.

In many Windows and Mac editors, the default interpretation is the same, except that multiples of 4 are used instead of multiples of 8."

The code formatted on Windows using tabs look hideous on Unix, while if you use spaces it will be uniform on all operating systems.

[1] http://www.codinghorror.com/blog/archives/001254.html

Wednesday, January 21, 2009

Java Caching Implementations

I had to do some database improvements by caching user permissions. Java caching is covered by JSR 107. I started looking at java opensource caching implementations. I found couple of products.

These are the first impressions I got while evaluating different implementations.
  • Apache JCS - Still requires EDU.oswego.cs.dl.util.concurrent
  • Ehcache - I managed to get it running on the first poc

So I settled down for Ehcache and right now I am very happy with it.

Sunday, November 9, 2008

How to setup a System Property?

There is a huge difference between system property and environmental variable. Environmental variable has a global effect on the operating system while system property has more local effect. System property can be different from program to program. So it is a best practice to use a system property instead of environmental variable in your code. You can always ask the user to setup the system property.

Running a program with system property is done as follows.

java -Dapplication.home="c:/myapp" MyApplication.java