How To Generate A Valid Credit Card Number For A Bin (First 6 Digits)

There is plenty of generators that can produce numbers that are valid credit card numbers according to the Luhn check and specific rules of the individual issuer companies. However I have not found anything that would generate the missing digits given a bin, i.e. the first 6 digits of a credit card (the “bank identificationContinue reading “How To Generate A Valid Credit Card Number For A Bin (First 6 Digits)”

Most interesting links of September ’12

Recommended Readings Johannes Brodwall: This dependency injection madness must end! – it’s very valuable to hear well-founded arguments against any popular belief and Dependency Injection is one of these. “I have started disliking the consequence of this strategy very much: All coupling in my system becomes implicit and harder to understand. I have instead revertedContinue reading “Most interesting links of September ’12”

Most interesting links of June ’12

Recommended Readings Development Neal Ford: Evolutionary architecture and emergent design: Emergent design in the wild – discusses why not to do Big Design Up Front and how to recognize the “last responsible moment”. Quote: “It’s puzzling that so many organizations continue to use BDUF in the face of so many failures and underachieving projects.“ GojkoContinue reading “Most interesting links of June ’12”

Exposing Functionality Over HTTP with Groovy and Ultra-Lightweight HTTP Servers

I needed a quick and simple way to enable some users to query a table and figured out that the easiest solution was to use an embedded, ligthweight HTTP server so that the users could type a URL in their browser and get the results. The question was, of course, which server is best forContinue reading “Exposing Functionality Over HTTP with Groovy and Ultra-Lightweight HTTP Servers”

Groovy Grape: Troubleshooting Failed Download

If you use the Grape’s @Grab annotation to get dependencies for your Groovy scripts at runtime and their retrieval fails with the exception “General error during conversion: Error grabbing Grapes — [unresolved dependency: …not found]” and a useless stack trace then you migth want to know that you can configure Ivy to log all theContinue reading “Groovy Grape: Troubleshooting Failed Download”

Tips And Resources For Creating DSLs in Groovy

Paul King had a very good presentation (last year’s slides) at JavaZone about why to use Domain-Specific Languages and how to create internal DSLs in Groovy. I’d like to list here few tips that he has mentioned but before we get to that, why would you want to create a DSL? Martin Fowler answers thatContinue reading “Tips And Resources For Creating DSLs in Groovy”

Groovy: Use @Canonical to Get Compiler-generated Equals, HashCode and ToString

Groovy makes it extremely easy to create Java beans with getters, setters, equals, hashCode, and toString: You can then do: As you might have noticed, you may provide your own implementation of toString and reuse the auto-generated toString by calling _toString(). References JavaDoc for @Canonical. You can also use separately any of: @ToString. @EqualsAndHashCode, @TupleConstructor.Continue reading “Groovy: Use @Canonical to Get Compiler-generated Equals, HashCode and ToString”

Groovy: Creating an Interface Stub and Intercepting All Calls to It

It’s sometimes useful for unit testing to be able to create a simple no-op stub of an interface the class under test depends upon and to intercept all calls to the stub, for example to remember all the calls and parameters so that you can later verify that they’ve been invoked as expected. Often you’dContinue reading “Groovy: Creating an Interface Stub and Intercepting All Calls to It”

Only a Masochist Would Write Unit Tests in Java. Be Smarter, Use Groovy (or Scala…).

I like writing unit tests but Java doesn’t make it particularly easy. Especially if you need to create objects and object trees, transform objects for checking them etc. I miss a lot a conscise, powerful syntax, literals for regular expressions and collections, conscise, clojure-based methods for filtering and transforming collections, asserts providing more visibility intoContinue reading “Only a Masochist Would Write Unit Tests in Java. Be Smarter, Use Groovy (or Scala…).”