Each java developper has a bag of tricks, full of java idioms.
Most of them are common to all of us (min, max, iterate an array, ..)

The current version of the Live Templates helps us write only the simplest one (see 
below).


***********
request : support java idioms of a higher level of complexity. 
************

 
If you sort them by the code size they require, you could distinguish 6 levels.

  1 - 1 line           :  obtain the maximum of 2 values
  2 - 2+ lines         :  visit all the element of an array
  3 - 1 method level   :  implement equals() for a non primitive object
  4 - 2+ methods       :  make a class canonical (equals(), hashCode(), ..)
  5 - 1 class          :  create a junit test case for a given class
  6 - 2+ classes       :  ...

The current Live Templates helps us write code for the first two.

For the higher level, you just need a - very well - trained monkey, 
better LiveTemplates, or an open API plus a plug-in.


Here are some real live scenarios, for using higher level idioms.


level 3 : 1 method level   -   overwrite equals()
----------------------------------

Each time I overwrite equals(), I apply the same recipe. Over 5 fields, it becomes 
boring.
Over 10 fields, typos can introduce error.



level 3 : 1 method level   -   overwrite hashCode()
----------------------------------
This one is more complex. I need my copy 
   "Effective Java Programming Language Guide" 
to build a non-trivial one.


level 5 : 1 class level   -   create a TestCase
----------------------------------
Selectable class template would do the trick


level 5 : 1 class    -   create an enumaration class 
----------------------------------
Not so trivial. Could benefit from a very simple wizard.




level 6 : 2+ classes :   create a pair class / TestCase 
----------------------------------
I tend to create classes by pair.
If I need a new "User" Class, I must 
  - create  "User"
  - create "Test_User", with 
         . import   mypackage.User ;
         . a default failing test method, 
  - add Test_User to the "AllTests" TestSuite.

A - well - trained monkey could write this code. I hate playing the monkey.



Alain Ravet


This mail has been checked by exiscan.
To be safe, please scan the mail attachements with your local virus scanner !

_______________________________________________
Eap-features mailing list
[EMAIL PROTECTED]
http://www.intellij.com/mailman/listinfo/eap-features

Reply via email to