Let It Quack!

, ,

Duck Crossing Warning SignAn entire day passed. The repugnant lines sat festering. Finally, their odious stench wafted strong enough to give me a start. What had I done?!

The situation started simply enough. I realized several kinds of transactions shared common logic. Despising duplication as a good programmer should, I placed this shared behavior in a base class which the various kinds of transactions would subclass. Continue reading

Perusing Prolog (Part 2)

In interview style, here’s the conclusion of my reflections after studying Prolog for two months. If you’d like, read Part 1 first.

What did you find unique about the language?

Unification! Prolog works by trying to make terms equal one another. In most languages, the statement “Cost = 100” sets the variable “Cost” to a value of 100. In Prolog, “Cost = 100” means (in effect): “can Cost and 100 be unified?” During execution, Prolog takes into account the entire set of logical rules that have been defined to figure out if Cost and 100 are allowed to equal the same value. While possible, the need for statements manipulating variables’ values within an operation occurs far less frequently in Prolog than in the languages I’m used to. Continue reading

Perusing Prolog (Part 1)

Reading my way through Seven Languages in Seven Weeks this past fall, Prolog caught my attention. The language worked so differently than any I’d used. It offered to solve problems challenging to code in the languages I was familiar with. Intrigued, I started setting aside an hour each workday to study Prolog. Learn Prolog Now! served as my primary tutorial. In interview-style, here are my thoughts after two months of exploring Prolog. Continue reading

Ruby: Case Testing Against Arrays of Values

,

Did you know that a when clause in a Ruby case statement can test against each item in an array? If any item in the array matches the case statement’s comparison (target) value, the when clause will evaluate to true.

In the below example, :express_truck will be returned if country matches any of the truckable_countries.

truckable_countries = ['United States', 'Canada', 'Mexico']

ship_via = case country
           when *truckable_countries
           	:express_truck
           else
           	:supersonic_jet
           end

Continue reading

Refactoring Reflections

In Don’t Make Me Think, Steve Krug presents the premise that the better a web site’s usability, the more brain cycles the visitor is able to focus on the substance (or intention) of the site. Said another way, the less brain cycles a visitor spends figuring out how a site works (e.g. how to navigate around), the more brain cycles he has available to concentrate on site’s substance. Don’t Make Me Think’s goal is to help the reader refine his web site’s usability to the point that visitors don’t need to think about how to use the site and so can focus all their attention on the information the site was built to convey.

While working through a recent refactoring project, it occurred to me that Don’t Make Me Think’s premise closely parallels one of the main motivations behind refactoring. The better the code base’s quality, the more mental energy the code reader can focus on the intention of the program. The less brain cycles a developer spends figuring out how a bit of code does what it does, the more brain cycles he can spend focusing on what the code does. Continue reading

Word of the Day: arity

Here’s a new word for me:

Arity—In a computer programming language, the number of arguments a function or operation accepts. For example, public void FindUser(string FirstName, string LastName) has an arity of two.

I discovered this word recently as I began exploring Prolog. In most programming languages I’ve worked with, the numerical value of an operation’s arity isn’t emphasized. In the Prolog world—in documentation, discussion and in the interpreter’s output— predicate names are always coupled with their arity. For example: reverseList(In, Out) is referred to as reverseList/2 (with the ”/2″ indicating an arity of two).

More Details on Arity

This Blog Has Been Rather Quiet Lately

You may have noticed that this blog has been rather quiet lately. I’ve been super busy with something very exciting. I’m getting married October 5th!!!

Ben & Tiff

During the past couple of months, almost all of my spare time has been spent helping to plan the wedding ceremony and working to build a strong foundation for the marriage that will soon be. There hasn’t been free time for blog posting.

To allow me to focus on the wedding and my bride, I am suspending module sales from now until the end of October.

NetMsmqIntegrationBinding — No Data Being Passed

, ,

Recently, I encountered a strange problem with a simple WCF NetMsmqIntegrationBinding service. The data objects passed into my service contained no data! When a message was received, the service would create an instance of the appropriate DataContract class but then would not populate the just-constructed object with the data contained in the WCF message (i.e. the data object’s fields were all left at their default values—null, 0, empty string, etc.). Continue reading