File tree Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Expand file tree Collapse file tree 1 file changed +39
-0
lines changed Original file line number Diff line number Diff line change @@ -405,6 +405,45 @@ compile time constants.
405405
406406* Use `(inc x)` & `(dec x)` instead of `(+ x 1 )` and `(- x 1 )`.
407407
408+ * Use the sugared Java interop forms.
409+
410+ ```Clojure
411+ ; ;; object creation
412+ ; ; good
413+ (java.util.ArrayList. 100 )
414+
415+ ; ; bad
416+ (new java.util.ArrayList 100 )
417+
418+ ; ;; static method invocation
419+ ; ; good
420+ (Math/pow 2 10 )
421+
422+ ; ; bad
423+ (. Math pow 2 10 )
424+
425+ ; ;; instance method invocation
426+ ; ; good
427+ (.substring " hello" 1 3 )
428+
429+ ; ; bad
430+ (. " hello" substring 1 3 )
431+
432+ ; ;; static field access
433+ ; ; good
434+ Integer/MAX_VALUE
435+
436+ ; ; bad
437+ (. Integer MAX_VALUE)
438+
439+ ; ;; instance field access
440+ ; ; good
441+ (.someField some-object)
442+
443+ ; ; bad
444+ (. some-object some-field)
445+ ```
446+
408447## Naming
409448
410449> The only real difficulties in programming are cache invalidation and
You can’t perform that action at this time.
0 commit comments