22nd
2009
Jun
permalink

Setting Up Clojure

Notes I made back in April for setting up Clojure on my MacBook. Kyle is planning a workshop on this soon.

# get Clojure and clojure-contrib library
cd ~/projects
svn checkout http://clojure.googlecode.com/svn/trunk/ clojure
svn checkout http://clojure-contrib.googlecode.com/svn/trunk/ clojure-contrib

# build Clojure
cd clojure
ant

# make a clojure executable on your path
echo 'java -cp ~/projects/clojure/clojure.jar clojure.lang.Repl' > ~/local/bin/clojure
chmod a+x ~/local/bin/clojure

# setup env
cd ~/projects
git clone git://github.com/mdelaurentis/env.git
cd env
git submodule update --init
cd
ln -s projects/ src
echo '(load-file (expand-file-name "~/projects/env/emacs/dot-emacs.el"))' >> .emacs

# slime and swank
cd projects/
git clone git://github.com/jochu/swank-clojure.git
git clone git://git.boinkor.net/slime.git
16th
2009
May
permalink

Knowledge Representation

When I write a program, what I’m essentially doing is writing down my best understanding of how to solve a problem or accomplish a task. My best understanding.

For the sake of this discussion, let’s say the problem I’m trying to solve is how to best peel an orange for eating.

An interesting thing happens, though, when I spend hours and hours talking about the problem, thinking about it, drawing diagrams of it on the whiteboard, relating it to other problems I’m familiar with, and coding it: I begin to understand the solution better. But not only that, I begin to understand the problem and its entire domain better.

With this deeper understanding of the domain, comes more precise terminology. For example, in my study of orange peeling, I discover that when there is a breach in the skin, the juice squirts out when I put pressure on it. But when the skin is perfectly intact, the juice doesn’t squirt out; it kind of oozes out from all over. So I might call these spots on the orange “squirt points” and “ooze points” from now on. But as soon as someone new to the domain of orange peeling hears the phrase “squirt point”, that person probably won’t know what I mean.

To me, the same statement using the term “squirt point” is much clearer than the one that says “the points on the orange where juice tends to squirt out when pressure is applied to the skin, usually implying there is a breach in the skin”, even though they technically mean the same thing. Someone unfamiliar with the term, on the other hand, will probably think the exact opposite.

Yes, the term “squirt point” is a reference to this longer, more descriptive definition, and it can just about always be replaced by its definition without changing the meaning of a sentence. But the fact that I’m using the term has more information. It means that when I say “squirt point” over here, and “squirt point” over there, I’m referring to the same exact thing. What if over here I use the full definition inline, but over there, I use the full definition except I say “when pressure is applied to the orange” instead of “when pressure is applied to the skin”. Is that the same thing? Is it a mistake? Did the person who wrote it (whether that be another physical person, or me years ago) actually mean to write “skin”? On top of that, even if the full definition is used exactly alike in both places, it takes significantly more work for the human mind’s limited pattern matching ability to recognize that similarity, compared with the short term.

We have to be careful though. It’s not as simple as making a rule that says: everyone should always use the term.

What if there are thousands of terms specific to this domain? Does everyone seriously have to learn them all before writing a single thing about orange peeling? What if there is a similar concept that overlaps 90%? Should a new term be coined? Or should the original term be modified? Say I want to talk about the points on the orange that juice squirts out when pressure is applied after the skin is already peeled. It’s essentially the same as “squirt points”, where the orange’s skin is not present. If I know the term “squirt point”, then I will be tempted to use that term, slightly modified. But if I overload that term, essentially creating a new definition for it, I’ve just changed the meaning of every other thing that refers to it, whether that be pieces of writing, learning material, documentation, code references, project plans, issues, or even other people’s mental references to the term.

In the worst case, I could have just broken something, making what made sense before no longer make sense. Regardless, making the definition of a term more general implicitly makes everything that refers to it more complex, because in the more general version of “squirt point”, the fact that pressure is being apply to the skin is no longer contained within the term. So when relevant (which itself may not always be clear), things referring to “squirt point” now must also say whether the skin is present or not.

For those that haven’t already been doing this, I encourage you to imagine what happens with this discussion when you replace the word “term” with “function”, because this problem constantly arises when more than one person are involved in a software project. Because developers are literally writing down their understanding of the solution to the problem in code, the resulting software can only be as good as the developers’ understanding of the problem domain.

This means that if you are a developer, you should do everything in your power to understand everything about your problem domain. Not just the specific task at hand, but the big picture where it all fits in. Not just how to fulfill the requirements given to you, but what requirements were probably missed completely because the people writing the requirements have less understanding of certain domains related to software.

But this also means that if you are running a company, and you are not a developer, you should do everything in your power get the developers to understand everything about your problem domain — because the software that they produce, can only be as good as their understanding. If you simply give them requirements, they will do their best to interpret those requirements in the context of everything they understand (just like anyone else). That isn’t enough. There are 53.2 million ways to skin a cat. You won’t get the way that you want unless in addition to saying what you want, you also say why you want it. This is essential for a developer. Because every developer is a designer, whether they like it or not. They are constantly making decisions that affect the business as a whole. If developers don’t understand why end-users want a feature, for example, it’s likely they will misjudge the importance of the feature and make an unacceptable trade-off in the design process.

12th
2009
Apr
permalink

Good Design = Balance

Good design is all about balance.

  • Aesthetics makes your product attractive and approachable. It makes people want to try it.
  • Usability makes your product pleasant to use to get a job done. It makes people want to continue to use it.
  • Economy makes your product practical. It makes people willing to pay for, and thus, support you making it.

Without any one of these things, your product will struggle. But a lot of the time, increasing one can only be done by trading another.

For example, say you were designing a door. Yes, a door in a building that people walk through. You could make it aesthetically pleasing by making it symmetrical and blending into the wall around it. But the symmetry hides which side the hinges are on, so people end up trying to push or pull the wrong side. Blending into the wall may make people not even be able to find the door at all. These both decrease usability. So you decide to install weight sensors under the floor to detect when someone approaches, and open the door automatically. Now you need motors to open and close the door and wiring to link it to the sensor, increasing cost, in materials, the design of the mechanism itself, and the installation. So you could use a motion sensor above the door instead, reducing installation costs. But now the sensor is visible, decreasing the aesthetic appeal. You could use a smaller invisible sensor, but that costs more. So say you figure out the right combination of sensors and motors. You just decreased usability of the door. What happens when the power goes out? Suddenly your door doesn’t do the one thing it was designed to do! Open. You could fall back to a manual push or pull, but this makes it inconsistent for users. In a building with many windows, it may not even be clear to people trying to walk through your door whether there is power. You can fix this usability problem with some kind of battery backup. This not only increases the initial cost, but maintenance cost too. And where do you put that battery? Unless the exact building you’re putting this door in is conveniently set up with big access panels, you’ve done a number on the usability for the maintenence staff. The motors also introduce noise pollution and the possibility of opening a door and hitting someone. Unless, of course, we spend more on sensors and the intricacy of the mechanism. And on and on and on and on…

Design is not purely opinion. Good design is about finding the right balance. Like anything, this is something you can get better at with practice.

Learnability is a combination of other aspects that work together to help turn new users into experts. Experts spend less time to do the same tasks, have the ability to help others, and can fix things when they go wrong. Some things that increase learnability are a simple approachable appearance, context-sensitive tips, and giving users the ability to explore when they choose. Big, oversized things feel simpler and more approachable, even though they’re really the same. Game aspects built into your most boring app can make people want to use it. And the more people use it, the more of an expert they become.

Providing help on how to fix a problem when something goes wrong, without the user having to know how the thing works, is essential; because without this, you’re basically forcing users to be dependent on experts when something goes wrong. And something will go wrong. Many times it’s not the user’s fault. How many times has your boss told you to do one thing, only to tell you to do the exact opposite the next day? Every action should be undoable.

Emacs is a good example of a program that is usable and cheap, but not pretty or learnable. Some developers swear by it and use nothing else. But to do anything besides basic typing and saving, you literally have to stop and learn it. Even accessing the help requires a significant amount of knowledge. Ditto for Linux and git.

Eclipse, on the other hand, is more aesthetically pleasing and approachable. Instead of inventing all of its own keyboard shortcuts that have to be learned, it uses the convention of other editors. It’s usable, but usable for a different audience than Emacs.

Everything is a trade-off. Balance is everything.

Extensibility is another important aspect that allows users to add on to or extend your product in ways that you either don’t have the resources to do yourself or are very specialized for a small group of users. Extensibility is important because no product exists in a vacuum. Users will use your product alongside all the other things they already use now. Having your product play nicely with all those other apps is something that users often can’t live without. Empower your users, even if it’s just the experts. Allow the forces of nature to take your product where you alone couldn’t have imagined.

The only reason Emacs still exists is because of its extensibility. In Eclipse, the barrier to extension is higher. True, both editors require you to learn a programming language, but in addition, Eclipse requires you to learn and use another language — the XML configuration language that allows the editor to actually use the extension. In Emacs, it’s just two keystrokes away. And since Emacs’s interface is only text, it’s easier for programmers (the ones making the extensions) to fit their extensions in with the rest of the editor’s conventions. One-off scripts can be born, which have the ability to evolve over time. But with Eclipse, you have to stop, decide you’re going to make an Eclipse plug-in, and learn how to do that.

When it comes to extension, Emacs and Eclipse are exactly the opposite of what they are for learnability of their regular interface. The choices each made for one aspect, traded something, and thus determined the other aspect.

Balance is everything.1


1. On a side note, the “good design = balance” equation goes the other way too. When something is perfectly balanced, there’s almost no question that it was designed. This applies to products, but also the Universe. It’s funny how people argue over intelligent design vs. evolution as if they were mutually exclusive. If you think like a designer, there is as much evidence for one as there is for the other. One is the cause, and the other is the mechanism.