Archive for March, 2009

Minimizing all windows in Gnome

The Gnome desktop environment is missing a very convenient feature: Minimize all windows. The “Show desktop” command (Alt-Ctrl-D) does not toggle all windows to a minimized state. Instead, it gives focus to the desktop window. Than, if you press it again, it does not re-minimizes all the windows, in case you opened new ones. It un-focuses the desktop and raises all the minimized windws - Exactly the opposite of what you expect! I got really annoyed by this, since that I keep on my desktop work-in-progress files, and to get to them quickly I want to minimize all the windows, not toggle the desktop focus. But this is not a ranting post - A solution follows.

Continue Reading »

1 Comment »

Guy Wiener on March 26th 2009 in Linux

LaTeX and UML, cont’d

I had to re-write some paper I’m working on that included a good deal of UML diagrams, so I used it as an opportunity to examine Metapost and MetaUML in more depth. Here are the results of the experiment, for those of you who are interested.

Continue Reading »

2 Comments »

Guy Wiener on March 22nd 2009 in Software Engineering

Logic Programming, Models and Bugs

A couple of days ago I finally wrapped up an assignment in the Logic Programming course. It took me some time, since I couldn’t find a nasty bug in it. Very embarrasing.

The assignment itself was a classic case of model-driven development, at least in its raw form: The model was half-a-dozen or so statements in first order logic. Based on this model I wrote about 100 lines of Prolog code. The Prolog program generated several hundreds of CNF clauses. A CNF solver took these clauses as a long list and gave a solution. The only problem was, of course, that the solution was wrong.

I looked for the bug inside my 100 lines of Prolog code, in vein. It wasn’t there. The Prolog program was just a simple CNF generator that worked well. It took some data and generated CNF clauses according to those logic statements that I wrote. That’s it.

The bug was, of course, in the model. The first-order logic formulas were wrong. I used a redundant logic variable that created un-needed constraints. I removed this variable and simplified the formulas, and then re-wrote the Prolog program. It took a couple of hours and, amazingly, worked perfectly from the first run.

The size of the bug was a single letter. My original formulas contained the variables “N”, “E”, “C”, “V” and “B”. “C” was redundant. Removing it and re-writing the statements solved the problem.

Moral: Models matter. Every program is based, explicitly or implicitly, on a set of ideas and assumptions. In this assignment I had to write them down, so I got a glimpse of their power. A single wrong assumption can be the difference between “working” and “not working”.

The Devil’s programer would say: “We, at hell.com, solved this problem. We don’t have a model for our programs, so the model cannot be wrong.” He’s lying, of course. All programs derive from a model. In most cases, it is a mental model. It doesn’t mean that it does not exist or that it cannot be wrong. It just means that it is much more difficult to debug it.

No Comments »

Guy Wiener on March 8th 2009 in Programming

How To Embed UML in LaTeX

I finally found a way to encode a UML diagram inside a LaTeX document! I’ve been looking for something like this for some time now. Usually I resort to using an external tool that has EPS and PDF export, like Umlet or XFig (don’t laugh - XFig has an excellent vector output). It is not too convenient, though, to switch between writing an article (or a lecture) and editing a diagram. Plus, editing the diagram manually takes more time then just typing it in. So I was looking for some tool that would have the following qualities:

  1. Textual
  2. (Relatively) easy to use
  3. Can be embedded directly into a LaTeX document (the text itself, not the image)
  4. Support more then just class diagrams
  5. High quality graphical output: Vector format (not raster), aligned, manhattan and step paths (I.e, squared arrows, like in the GOF book)
  6. Does some of the layout work for you

I ruled out several posibilites. Cumbersome CASE tools, like Rational Rose et. al., were banned: They’re not textual, produce poor output and require too much work to produce a single diagram. Dot-based tools are textual and does all the layout for you, but do not support step paths and require some work to embed in a LaTeX file. Some LaTeX libs, like XyPic, produce amazing vector graphics, but are very difficult to master. However, this is not a ranting post. Solutions follow.

Continue Reading »

8 Comments »

Guy Wiener on March 3rd 2009 in Software Engineering