functional

Scala style: Side-effect methods with no parameters should be declared with parentheses

As a note about Scala style, this Scala page strongly encourages that side-effect methods that takes no parameters should be declared with parentheses:

“However, this syntax (leaving off parentheses) should only be used when the method in question has no side-effects (purely-functional). In other words, it would be acceptable to omit parentheses when calling queue.size, but not when calling println() (or openGarageDoor()). This convention mirrors the method declaration convention given above.”

“Religiously observing this convention will dramatically improve code readability and will make it much easier to understand at a glance the most basic operation of any given method. Resist the urge to omit parentheses simply to save two characters!”

Interval halving (Bisection) method in Scala (OOP and FP styles)

I just picked up an old college textbook named Applied Numerical Analysis, and curious to see what the Interval Halving method (also known as the Bisection Method) would look like in Scala, I decided to code it up. Considering that Scala is similar to the Java programming language, if anyone else needs the Interval-Halving method in Java, this code can easily be adapted to Java as well.

Java programming best practices - Create interfaces for your Dao classes alvin August 4, 2011 - 3:13pm

One Java programming "best practice" that has been strongly reinforced for me during the last several weeks is making sure you have a declared interface that defines the behavior (signature) of your Dao (data access objects) classes.

A Java email address validation class

I thought I'd share the source code for my Java email address validator class. I'm not sure if there's a big need for it ... I wrote it a long time ago, and I think I created it because Java's javax.mail.internet.InternetAddress class wasn't validating email addresses as deeply as I wanted it to. For instance, I think it would allow the string "fred" to be a valid email address, but on the internet you really want to see something like "fred@foo.bar". So I think that's where this class comes from.