Thursday, August 21, 2008

Dos and Don'ts

This is much for myself & if it helps others its good :
  1. Code to interface, mmmm still need to get habituated with this.
  2. Write test cases.
  3. Never mutate the object passed by the parameter ie when we get list as an method parameter do not alter the list in that method , and when we need too then just make a local copy of it and work on the locally created object.
  4. When wrapping up the exception do wrap with cause ie try {} catch (SomeException e) { throw new WrapException(e.getMessage()) {}...never do this, we are eating up the actual cause but instead do "throw new WrapException(e)" in the catch.
  5. Avoid String splitting for business logic flow. like String str1 = getSomeText(); if("Target".equals(choice.split("-")[0].trim()) { //do this....} else {// do that...}

Some other things I want to remember and I forget all the time
  1. Apache Tomcat is servlet container, it implements java servlet & jsp spec and provides pure java HTTP web servlet environment.
  2. 'Apache Web Server' is C-Lang based HTTP web server.