Java Capriccio: Scenario_1 (Java随想,第一部分)

Followings are my personal thought bubbles on java programming

1. Just don't put any instance variables into your Runnable
2. Be carefull when you're using 'valotile'
3. Use annotation as far as possible
4. If possible,anyway,use annotation to substitude of configuration file
5. Would Some cohesive functions within your domain scope should be coded in your domain object [For migration || Reuse]

--------- period

6. Try your best to cache your object with the modifier
      'private static'

7. Make the utmost use of 'Component'
   [For Reuse || migration ]
      Such as 'Judge Component'. 'Code Logical Component'
8. Some big or long-standing object should use
      the Keyword 'SoftReference'

9. One class should provide simplified task,
         so that you can avoid of high-co-relation [避免耦合]
10.Use proxy/adapter/decorator/template/command/ DPs
      as far as possible

--------- period

11.Avoid of Hard-Code in your code:
  • Use interface [such as GlobalConstants]
  • Use file      [such as properties and xml files]

12.There should be serialization and De-serialization  method
      within any of Exception class

13.Your code should be robust:
  • catch every exception [in order to do some special process  
  •          according to the detail Exception]
  • you must take runtime Exception into account:
  •          such as MathException [ => multiplying two big int]

14.closure of object:
  • if an object will never be used = > obj = null; then return;
  • close connection
  • close file

15.Every method should check-up the parameters , when check-up failed
      the method should throw some particular Exception

  • the parameter should be final as far as possible
  • consider the class casting


--------- period:  09/02,2010 11:30 am

你可能感兴趣的:(java,xml,cache,UP)