Found below linked article that provides tips on how to avoid using IF statements, with one of the benefits being readability. The tips largely are based on the concept of using a map to the result, which is essentially a one-in replacement of a switch statement. If's can be rigged in too as the examples show:
https://edgecoders.com/coding-tip-try-to-code-without-if-statements-d06799eed231
Friday, February 15, 2019
Wednesday, March 29, 2017
XML Beans vs JAXB
Seems XML Beans is superior:
JAXB provides support for the XML schema specification, but handles only a subset of it; XMLBeans supports all of it. Also, by storing the data in memory as XML, XMLBeans is able to reduce the overhead of marshalling and demarshalling.http://xmlbeans.apache.org/docs/2.0.0/guide/conGettingStartedwithXMLBeans.html
Tuesday, October 11, 2016
Ruby - Use Struct for "Reification" / OO
http://blog.steveklabnik.com/posts/2012-09-01-random-ruby-tricks--struct-new
Ruby has the Struct construct which author makes use of to "reify" objects to be more Object Oriented. In Java, we'd have to create a separate class for these tiny strongly typed data objects, e.g. by using the "parameter object" pattern.
Ruby has the Struct construct which author makes use of to "reify" objects to be more Object Oriented. In Java, we'd have to create a separate class for these tiny strongly typed data objects, e.g. by using the "parameter object" pattern.
Saturday, July 23, 2016
Refactoring for SOLID
I read the two articles below on refactoring and SOLID principles.
In the OOP section of the above article, the interesting takeaway is the encapsulation of logic in a "policy" class which is used along "doer" classes to be invoked and thus abstract away and remove cyclomatic complexity from methods.
This one lends credence to the notion of the "large set of small classes" to abide by the Single Responsibility Principle. The emphasis is on composition of behavior, and using seams or interfaces to swap out or extend (by using decorators) existing behaviors to add new features.
Wednesday, July 13, 2016
Util Classes and OOP
Suggestions on how to refactor: http://www.yegor256.com/2014/05/05/oop-alternative-to-utility-classes.html
https://lostechies.com/chrismissal/2009/06/01/anti-patterns-and-worst-practices-utils-class/
https://lostechies.com/chrismissal/2009/06/01/anti-patterns-and-worst-practices-utils-class/
Monday, July 11, 2016
Using Spring Mock for TDD
http://chatley.com/blog/2006/01/testing-controllers-with-mocks.html
Illustrates quick iterative test-first development using MockHttpServletRequest.
Illustrates quick iterative test-first development using MockHttpServletRequest.
Friday, July 8, 2016
End to End tests and Unit tests
on E2E vs unit: http://googletesting.blogspot.com/2015/04/just-say-no-to-more-end-to-end-tests.html
Pointed out "gold standard" of unit testing in guava, i.e. https://github.com/google/guava/blob/master/guava-tests/test/com/google/common/base/StopwatchTest.java testing https://github.com/google/guava/blob/master/guava/src/com/google/common/base/Stopwatch.java
Pointed out "gold standard" of unit testing in guava, i.e. https://github.com/google/guava/blob/master/guava-tests/test/com/google/common/base/StopwatchTest.java testing https://github.com/google/guava/blob/master/guava/src/com/google/common/base/Stopwatch.java
Subscribe to:
Posts (Atom)