Rule #5: Always Use Parentheses

Tags

, , , , , ,

Enough stories, time for a new rule. Which is to always use parentheses in all except the simplest of math expressions. Languages have a precedence protocol, so the compiler can figure it out, but human readers may be confused.

As always, the underlying motivation involves code clarity for other humans reading the source code — the most important rule of all.

Continue reading

DataCollector Factories

Tags

, , , , , ,

Last time I introduced the DataCollector application, but didn’t have room to get into the use of factory classes. There isn’t often a need for a factory class, but they can be useful when you need to create objects at run-time without knowing their class until then.

The general approach involves a function that returns instances of a class based on run-time information. In some cases the instances are limited to a predetermined set of classes, in other cases it can any class the known to the code.

Continue reading

DataCollector

Tags

, , , , , ,

When I first posted about my DataBridge utility I mentioned the DataCollector, which was a Java-based framework for quickly building apps that interacted via web services with a third-party CRM services provider.

In this post I’ll introduce the DataCollector framework. For obvious proprietary reasons, this will be fairly generic, but I think the basic architecture is worth sharing. It’s a nice example of using factory classes.

Continue reading

DataBridge Drivers

Tags

, , , , , ,

Last time I started the story of my DataBridge application — a Java-based tool for transferring and transforming tabular data, such as TAB, CSV, and XML files. It could also read from and write to ODBC tables.

The app itself was just a framework that implemented a basic IPO model to transfer data. The details were up to the Input, Process (in this case, Mapping), and Output, drivers loaded at run time.

Continue reading

DataBridge

Tags

, , , , , ,

The last story was about PF.EXE, a file-processing utility I wrote for my own uses way back when. That one was a combination of C code and 8086 assembler, written for MS-DOS (worked fine in Windows), that read and wrote disc files. It had a toolkit of things it could do to them, depending on command line switches.

Many years later, using Java, I created more capable versions, the culmination of which was a suite called DataBridge. It turned out to be some of the most valuable work I ever did for The Company.

Continue reading

PF.exe

Tags

, , ,

Programmers, like carpenters, are builders — we make things. The work can be for pay, but carpenters, for example, can build their own bookshelves and doghouses. Programmers also make software for themselves, sometimes to amuse, sometimes to provide a useful function.

A few of the apps I created for myself over the years turned out to be major workhorses for me — tools I used frequently. One of the earliest was PF.EXE, my Process File utility.

Continue reading

OOP versus Imp

Tags

, , , , , , , , ,

This is another note for a friend: a followup to a discussion about how some programmers really hate Object-Oriented Programming (OOP) languages.

Most of those who hate OOP hold up Imperative Programming (IP) as the One True Way to write code. The key difference is the IP is function (or verb) oriented whereas OOP is object (or noun) oriented.

I’ve never really understood that active dislike. It’s just another way to organize the same code you’d write anyway.

Continue reading

The Eight Queens

Tags

,

There’s a fairly simple puzzle, called The Eight Queens, that I’ve long favored as a project for first semester CS students. The problem is simple enough for a beginner to tackle, yet also interesting enough to be engaging. (And just tricky enough to be a nice beginner challenge.)

Due to a discussion on my other blog, I dug out an old Python implementation I had, and, after looking at it, I thought it might be worth writing a post about. If nothing else, as I said, the problem is interesting enough to be engaging.

Continue reading