Archive for the 'software' Category

MySQL Query Browser in Ubuntu 12.04

I going to outright say it: MySQL Workbench completely sucks. It is a convoluted, complicated, steaming pile of bloated nonsense. It is hard to perform a simple query. Worse, the damn thing keeps crashing. I missed the simplicity of MySQL Query Browser. Yet, Oracle deprecated it a while back and Canonical removed the package in Ubuntu 12.04.

After some searching, I found that Tyler Wagner maintains an APT repository containing MySQL Query Browser ported from Oneiric.

I summarize the installation here:

sudo apt-add-repository 'deb http://www.tolaris.com/apt/ precise main'
wget -q http://www.tolaris.com/apt/tolaris-keyring.gpg -O- | sudo apt-key add -
sudo apt-get update
sudo apt-get install mysql-query-browser

So, a big shout out to Tyler for doing this work!

Edit: You do need to execute sudo apt-get update before install. Thanks, Steve!

Chromium Tricks for the Lazy Programmer

One of the cool time-saving features in Chromium (better known as Google Chrome) is the custom search engines. It’s not a new concept. Mozilla Firefox has similar capabilities, but it feels like a hassle sometimes. You have to physically select the custom search engine in a separate combo box, then enter your search terms. That takes up extra time with all that mouse action, especially for a lazy programmer like me. Chromium goes on step further. The address box has a secondary function as a search box. If you were to enter anything but a URL or a domain name in the box, Chromium treats it as a search term and uses the default search engine. Google is default on mine, but any search engine that uses HTTP GET query parameters can be used.

If I was not a programmer, I may use my default search engine to do general searching. But, when I want to search programming language documentation, I would normally have to add the programming language name as a search term.  Given that a lot of programming languages have fairly common words as their names (python, ruby, lisp), you may waste some brain cycles filtering.  Again, for a lazy programmer, I want my information correct as well as fast.

So Chromium allows me to create a custom search engine to query a specific web site. In my example, I will be using lispdoc to search Common Lisp documentation. First, you need to go to the site and examine how a query is done. For lispdoc, the query is very similar to Google. However, there is another time-saving feature in Chromium. If you performed a search on the target site, there is a good chance that Chromium has already added a custom search engine for you:

Manage Search Engines

Wicked awesome! For lispdoc, the Chromium recognized that I searched on that site and added an entry for me. I don’t think there was anything special the site did, but you can add a search engine on your own if Chromium did not detect it for some reason.  The only issue that I have with it is the keyword property that Chromium selected. It put the domain name as the keyword, but why is that important?

The keyword is how you tell Chromium that you want to use a custom search engine instead of the default. It’s almost like what you would do if you went to the search engine directly with one important difference. If I entered the keyword (currently “lispdoc.com”) in the address box, space bar, then tab key, Chromium selects the custom search engine matching that keyword:

Using custom search

Then, I can enter more search terms. Unlike Firefox, I do not need to stop typing to tell Chromium what I want. The mouse is not even involved. Perfect for the lazy programmer? Not just yet. Since the keyword defaulted to the domain name (“lispdoc.com”), it has two usability problems.  Since I visited lispdoc.com, the URL shows up in my browsing history and will probably be the first selection. So, a chance a mistake can occur.  The second problem is that the name is too long for a lazy programmer.

The solution to both problems is quite simple: change the keyword to something else.  For lispdoc.com entry, I would change the keyword to “cl” for “Common Lisp”, which makes it less characters, no ambiguity, and easy to remember. Now, I can search documentation very quickly now. I have specific searches for other popular sites and assign them to shorter keywords, also. Here are some examples:

Try it out and let me know what you think!

Installed Kubuntu Today

For the longest time, I have always had a goal to be Windows-free. Many people I work with feel that it is pure apostasy, because I have worked in Microsoft shops in the past 10 years or so. But frankly, I am particularly sick of Windows as a whole. If I can still continue doing my work without having Windows on on my HP Pavillion dv9008nr laptop, then I think I am set.

So, I installed Kubuntu 9.04 (Juanty Jackalope) today. It was the most painless installation of Linux that I had… ever. It was even less painful that my initial installation of Ubuntu 8.10 (Intepid Ibex) on the family desktop (recently auto-updated to Jaunty).

My laptop wireless has the ever painful Broadcom chipset, which historically has been a problem on both 32-bit and 64-bit systems. But I found out that they got off their butts and started to provide drivers for Linux. So, after enabling the closed source drivers, my wireless just worked period. There was no manual configuration that I had to do, no driver to look for, and no searching through outdated documentation for clues on configuring everything.  Do you have any idea how refreshing that is?

Here are other refreshing things:

  • The NVidia chipset for graphics acceleration worked with zero configuration.
  • All of my external devices worked.
  • Even though I like the GNOME interface in Ubuntu, I absolutely love the KDE interface in Kubuntu.  I am ecstatic that I went in that direction.
  • BZFlag looks / feels much better on Linux that on Windows.
  • The best system for tools I already use on Windows: Pidgin, GNU Emacs, Steel Bank Common Lisp, Mozilla Firefox, and others.
  • Even Adobe Flash has decent performance, even though there is no 64-bit native version for Linux. Most YouTube videos do work, even in full screen mode. So, I can deal with it for now.  (Adobe is now the new Broadcom, IMO).
  • The default Remote Desktop (RDP) client allows me to connect to my Windows desktop at work, basically completing my minimum requirements for total conversion.

So, I look forward to writing more about my experiences on Kubuntu.

Groovy Baby, Yeah!

groovybabyWorking in mostly M$ shops in the past 10 years or so, coupled with my home projects in the functional languages, I don’t get to do much with Java or the JVM anymore.  But today, it was treated to my first experience in programming in Groovy.  The tool that I use to test SOAP web services, SoapUI, is built upon Java and uses the Groovy as embedded scripting language to manipulate the testing environment.

I must say that it is a pretty neat.  Just using it as a scripting language seem to be natural, almost like Python or Ruby. Even though I did not use any advanced features such as closures, builders, or regular expressions, I hope that I can give it a try some time.

Design Smell: Violating LSP

Sometimes a framework impedes on development so bad, it makes you somewhat angry and feeling helpless. I encountered something today that gives me headaches just thinking about it.

Suppose I have framework in C# 2.0 that models document folder that contains one or more documents. The framework defines an abstract base class, Document:

public abstract class Document {
// Implementation removed.
}

And concrete document types:


public class PurchaseOrder: Document { ... }
public class Quote : Document { ... }
public class Invoice : Document { ... }

And a DocumentFolder class, the have properties for retrieving each of the concrete document types:

public class DocumentFolder {
  public List<PurchaseOrder> PurchaseOrders { get { ... } }
  public List<Quote> Quotes { get { ... } }
  public List<Invoice> Invoices { get { ... }}
}

Let’s say I want to collect every PurchaseOrder, Quote, or Invoice document in a DocumentFolder to perform work on them.  Since all these documents derive from Document, I should be able to create a generic list of type Document and use List<T>.AddRange() to collect  them all.

DocumentFolder folder= LoadFolder(id);
List<Document> docs = new List<Document>();
if (folder.PurchaseOrders != null)
  docs.AddRange(folder.PurchaseOrders);
if (folder.Quotes != null) docs.AddRange(folder.Quotes);
if (folder.Invoices != null) docs.AddRange(folder.Invoices);

Then, use the List<T>.ForEach() operation to perform common work on
my Documents, using an anonymous delegate:

docs.ForEach(new Action<Document>(
  delegate(Document d) {
    DoSomething(d.LineItems);
  }
));

But, I get an error upon compiling. After troubleshooting it, I found that the LineItems property is declared as protected internal, and therefore not available to classes outside the executing assembly:

protected internal List<LineItem> LineItems
{
  get{
    /* Implementation removed. */
  }
}

Each of the three concrete documents override the LineItems property using
the new keyword and calls the base class’ version, effectively crippling
the whole point of having abstract base classes to begin with:

public new List<LineItem> LineItems
{
  get { return base.LineItems; }
}

*sigh*

After pounding my head against my computer,  I accepted this design smell and moved on. This example is a  violation of the Liskov Substitution Principle (LSP), which states in a nutshell:

Methods or functions that use references to base classes must be able
to use objects of derived classes without knowing it.

I could not store a list of the base class, populate the list with instances of the derived class, and perform useful iteration. The workaround resulted in three blocks of iterative code that looks almost alike.  So, I will be addressing this problem with my peers in the near future.  In the meantime, back to coding. Later.

Beautifully Lean Documentation

Your development team spends a lot of time creating formal functional specifications, design documents, and general documentation. They create a nice class diagrams, sequence diagrams, or flowcharts to be included. Sounds like your team did everything it should, right?

Well, not exactly. Where is the software? Documentation is nice, but one thing that I learn is that creating developer documentation is seriously overrated. The documentation end up being practically worthless in the end, mainly because of simple, organic growth of your software.

In many organizations, any documentation that does exist are most likely out of date, because no one wants to update them. The documents end up in some hole on your company’s intranet and will stay there forever. Even if your documentation is current, there is *no* guarantee that anyone would read or understand any of it. Other developers, QA analyst, business analysts and management don’t really want to read a 50-page document on your favorite piece of code. They will often skim it, with often a small subset of knowledge how it really works. As time passes, the amount of trust in documentation diminishes because the audience knows that the software changes.

I am not saying that there should be *no* documentation, but your documentation should be like a good book. It should captivate your audience and more importantly, be relevant to the current situation. The most valuable documentation has correct context and has need. Creating documentation for the sake of documentation will doom your project.

So, beautifully lean documentation is key to success. What does this mean? Well, there are many strategies for agile or lean documentation. However, to have beautifully lean documentation, I take a more minimalistic approach:

  • The source code itself is probably the most valuable documentation any developer can have. Therefore, I make it a point to create meaningful comments and use documentation generation systems wherever possible.
  • I think that the user stories provide better context for the software than any other written documentation. In essence, user stories detail what the software is suppose to do. Couple user stories with acceptance tests, the system becomes validated.
  • If the software has external service interfaces, then those need services need explicit documentation. There is no real way around it. However, the documentation is used as reference at this point and it usually only documents the service interface.
  • I normally document just the design decisions that I made. This gives developers an understanding of what I considered and, more importantly, what did *not* work. This will save other developers some time on research.

So, when I am working on a new product architecture, creating beautifully lean documentation allows me to concentrate on the software.

The Wayback Machine : What I Did 10 Years Ago

The Internet is a wonderful thing, but it has a serious flaw. It has a memory. An unrelenting memory, in fact, that seems to remember things that I have long forgotten. Today, it is common knowledge that you should not publish things on the Web that you would not publish in a novel. Ten years ago, though, the Web was as wild as the American Old West. People were doing some pretty wild things.

So, what brought me to think about what I was doing ten years ago? Well, I found out today that Borland finally sold its CodeGear software tools division after two years of trying. Back in 1998, Borland offered a IDE called C++ Builder. When first introduced C++ Builder was the revolutionary step in Windows application development. That tool help me create some tools quickly that Microsoft C++ could never do.

As great as C++ Builder was, it had limit support for DirectX, the relatively new high performance graphics API from Microsoft. Since multimedia was a hobby of mine, I started experimenting with DirectX in C++ Builder. I started a small site using my ISPs personal web pages and thanks to the Wayback Machine, you can see it for yourself and all its splendor.

As my interests in Free Software grew, OpenGL became my dominate graphics environment on Linux. The site was discontinued sometime in late 2000. It seems that the popularity of Free and Open Source software increase, C++ Builder could not compete. Borland later offered a free (as in beer) command line version of the BCC, the same compiler in C++ Builder, but it was the C++ Builder IDE that made it special. I am sad the unfortunate demise of this product. I wish that Borland would have open sourced C++ Builder to let the community decide its fate. It certainly would have been interesting.