Warning: Declaration of LJXP_Walker_Category_Checklist::start_lvl(&$output, $depth, $args) should be compatible with Walker::start_lvl(&$output, $depth = 0, $args = Array) in /home/victorsergienko/victorsergienko.com/wp-content/plugins/lj-xp/lj-xp-options.php on line 796

Warning: Declaration of LJXP_Walker_Category_Checklist::end_lvl(&$output, $depth, $args) should be compatible with Walker::end_lvl(&$output, $depth = 0, $args = Array) in /home/victorsergienko/victorsergienko.com/wp-content/plugins/lj-xp/lj-xp-options.php on line 796

Warning: Declaration of LJXP_Walker_Category_Checklist::start_el(&$output, $category, $depth, $args) should be compatible with Walker::start_el(&$output, $object, $depth = 0, $args = Array, $current_object_id = 0) in /home/victorsergienko/victorsergienko.com/wp-content/plugins/lj-xp/lj-xp-options.php on line 796

Warning: Declaration of LJXP_Walker_Category_Checklist::end_el(&$output, $category, $depth, $args) should be compatible with Walker::end_el(&$output, $object, $depth = 0, $args = Array) in /home/victorsergienko/victorsergienko.com/wp-content/plugins/lj-xp/lj-xp-options.php on line 796

Warning: Cannot modify header information - headers already sent by (output started at /home/victorsergienko/victorsergienko.com/wp-content/plugins/lj-xp/lj-xp-options.php:796) in /home/victorsergienko/victorsergienko.com/wp-content/plugins/wp-super-cache/wp-cache-phase2.php on line 60
code name / Why I don’t like GMock
Skip to content

Why I don’t like GMock

16-Feb-11

I don’t like GMock. It’s not as if it was badly written or designed. But it lets you to unit-test dirtier code, tying to method call structure instead of resulting data. For instance, this GMock code can be rewritten:

Groovy Comparator for class field names

15-Feb-11

I wonder why this was not in JDK/Groovy Collections. Just put together a Comparator for StackOverflow question – a Groovy Comparator that would sort class field names in the declaration order. Feel free to use: class PropComparator implements Comparator { private Class clazz PropComparator(Class clazz) { this.clazz = clazz } int compare(Object o1, Object o2) […]

Couple of Grails tricks to remember: reload scaffolding and fieldValue formatting

14-Dec-10

Grails doesn’t reload scaffolding on-the-fly if you change local templates. But you can open a Groovy console inside application and run in it: org.codehaus.groovy.grails.scaffolding.view.     ScaffoldingViewResolver.scaffoldedViews.clear() In order to change default g:fieldValue formatting for, say, BigDecimal, have a CustomEditorRegistrar in your resources.groovy, and register custom PropertyEditor: registry.registerCustomEditor(BigDecimal.class, ‘myProperty’,     new OurBigDecimalEditor(BigDecimal.class))

Prim’s allgorithm in Groovy: inspired by Fortran and Java versions

18-Oct-10

A friend of mine defended Fortran against half-literate coders on an example of Prim’s allgorithm. Good pretext for another language comparison. Let’s see Groovy vs Java vs good old Fortran. Great Fortran implementation Great Java implementation by Bruno R. Preiss, P.Eng. and scientist. Some beginner’s C+ implementation (or is it just a link farm? Whatever). […]

Hibernate join bug

03-Sep-09

Hibernate bug 1895 seems to be still there since 2006. If, for instance, in Grails, such a syntax won’t work for you (it won’t): def books = Book.findAll(“FROM Book AS b JOIN Chapter AS c WHERE c.active = :isActive”) with a NullPointerException in “HqlSqlWalker.createFromJoinElement” — just use alternative join syntax, via WHERE: def books = […]

Grails: mocking domain objects in unit tests

13-Jul-09

We’re trying Grails, Rails-like web application framework for Java. It’s fine, just that Groovy debugger support is, er, imperfect, even in the best Gruoovy IDE – IDEA. And, if you want to unit test, you won’t have fancy domain class methods addTo* – like Customer.addToOrders(). They’re generated by Grails on startup. In order to have […]