Thursday, January 17, 2008
Good Engineering Practices
Here are a few things that I believe are common to good engineering practice. These are not necessarily the most important issues for engineering a product, but they are a good things to consider. More important, they can be applied in most (probably all) development situations.
Make solutions as general and flexible as possible
About 25 years ago, I consulted to one of Ray Kurzweil’s companies. Ray Kurzweil is a futurist and luminary in the computer industry. One of the things I remember him saying was that he was really good at pattern recognition and that all of the products he developed (at that time they included a reading machine for the blind, a music synthesizer and a speech recognition system) were all based on pattern recognition. I believe that Kurzweil’s approach to computing let him see many problems in the general terms of pattern recognition. His approaches are flexible enough that he was easily able to apply his expertise to a solution.
When I was starting my career in the software industry, I wanted to write an operating system. (A lot of us did in those days.) At some point, I took a job working on a compiler. One of the things my boss told me was that developing a system and developing a compiler were very similar. In the general sense, he was right. While there are differences, there are lots of similarities. Both parse commands. Both track information about their activities—systems control processes and hardware, compilers control code generation and optimization. Both process errors. And lots more.
If one were to look at a database system, there are also more similarities than differences to compilers and operating systems. Similarities would include things like language processing for the query language and differences would include things like more complex data storage algorithms.
If one were to look at a browser like Internet Explorer or Firefox, it’s possible to view the application in the same light. Browsers are very much like a compiler—it’s actually an interpreter. The languages being interpreted include HTML, JavaScript and CSS among others.
The point is that a good engineer develops the ability to see similarities across applications and to understand the flexibility of their solutions so they can apply those solutions to new problems and in new environments.
Generalization and flexibility are applicable in the non-engineering world too. Since my blog includes a section on cooking, I'll give an example here. About month ago, I made an oven barbecued brisket. I decided a few days ago that I could make the same recipe with salmon and teriyaki sauce. The similarities: season a hunk of meat/fish; slice it thinly; cover the meat/fish in sauce and finish cooking. The differences: the brisket cooks a few hours before getting sliced and the salmon is sliced before it cooks (because cooking makes it flake apart); the brisket gets a strongly flavored barbecue sauce and the fish gets a milder flavored sauce; the brisket cooks for 1 hour/pound and the fish cooks for about 25 minutes total. In terms of generality and flexibility, I would say that these recipes are essentially the same with a few differences.
Plan for the required efficiency of the application
How efficient does a piece of code have to be? I believe that depends on what it’s doing and how it’s being used.
Notice that I said “piece of code” and not program. That’s because some parts of a program may have to be more efficient than other parts. If a user is typing into a text field on a form, the code handling the interaction does not have to be any faster than the typist. On the other hand, if the user is editing a database record and saving it, the save operation should be fast enough that the user’s wait time is kept to a minimum.
When my father began programming in 1951, computers were very expensive relative to employees. The computers of the time were also not very powerful and had very little memory or mass storage (like disks). So it was important to write programs that were as small and fast as possible.
Over time, hardware became better and cheaper and employees became much more expensive than the computer systems they and their end users would utilize. So writing the most efficient programs became less important. There was also the notion that if a program was too slow that the next generation of hardware would solve the problem. That approach got the world past decades—with lots of notable failures when the next generation of hardware was not enough faster to make the software perform well. If you want a modern day example, think about whether your fancy new computer running Vista is really performing better than your old clunker running XP.
I think that one of the problems some programs face is that the software designers and developers don’t examine the question of efficiency closely enough…or at all…or perhaps come to the wrong conclusions. A few months ago, I spoke with a manager in a company that develops real-time applications (applications that have a time-critical aspect to them). He asked me how I would speed up a stubbornly slow piece of code. I told him that after looking at the algorithms and making sure that there weren’t unexpected code paths being followed, that in the old days we might rewrite some critical code in assembler (machine language) but that I did’t think anyone wrote in assembler any more. He laughed and said that they still did that sometimes and that they were about to do some rewriting.
Imagine a developer is building an application that examines transactions in a credit card database. There is an enormous amount of data being processed in that case. Now imagine that the code is optimized so that it is 10% faster. 10% over a million transactions is a significant of time and is very probably a worthwhile thing to do.
Imagine the user I mentioned above who is typing into the text field of a form. If the user doesn’t perceive any lack of responsiveness, then a 10% improvement in performance will not be noticed and won’t make any difference.
To summarize, I don’t believe there is a single answer to the question of how efficient an application needs to be.
I hope you find these thoughts interesting and worthwhile and that they give you something to consider as you develop engineer your solutions.
Sunday, January 13, 2008
Visual Creativity: My First Photosurrealistic Picture

I remember looking at a picture I took in 1977 of Toronto’s New City Hall with a sundial in the foreground (the picture on the left). I always liked that picture. I decided to scan the slide and bring the image into the digital age. As I looked at it though, I also remembered a Hubble picture that I had seen of the galaxy M51 (the picture on the right).I began to wonder what it would be like to have the galaxy in the sky. Perhaps it was the globe of the sundial. Perhaps it was the building rising to the sky. In any case, the bright center of the galaxy seemed to me to be a potential “sun” in the sky.
In the end, I decided to place the galaxy in the sky with the results you see here.I hope you enjoy the picture and the thought processes and I’ll be interested in your comments.
Sunday, January 6, 2008
Improv Cooking: Best Rice Ever…and More
My daughter was visiting and wanted Cornish hens for dinner. Since there’s no way I could tell her no, I thawed a couple of birds that were in the freezer. When we ate dinner, she told me that she couldn’t say it was the best rice she had ever eaten because she didn’t remember every rice dish she’d eaten, but it had to be in the top rung. These are the recipes for the dinner—the hens is integrated into the preparation of the rice so I can’t separate the preparation of the two. Incidentally, this also works just fine with whole chickens instead of Cornish hens.
This dinner serves 3 or 4 people.Glaze for the Hens
When I started making this recipe around 1970, I used an inexpensive tawny port (not nearly as sweet as ruby port) and undiluted orange juice concentrate. Since we don't usually have orange juice concentrate around any more, I just triple the amount of OJ.Combine 1 part tawny port with 3-4 parts orange juice.
Since about 1/2 cup of the glaze will be used for cooking the rice, I wanted about 1 1/2 cup total. That's about 1/3 cup of port and 1 1/3 cup of OJ.Rice
Ingredients:Rinse the rice and put it into a small pot. Add the water, oil and seasonings to the rice and bring to a boil. Cook uncovered, stirring frequently until the liquid is reduced to the level of the rice in the pot. Reduce the heat to low, cover and cook for about 20 minutes—until the rice is done.
Cornish Hens (or Chicken)
Preheat the oven to 400.Pour a little olive oil in your hand and rub the hens all over on both sides. Put the hens on a rack over a baking pan breast side up. Sprinkle seasonings over the hens (I usually use pepper, garlic powder, turmeric, ground cinnamon, ground coriander and cumin). Turn the hens over and season the back the same way. If you're so inclined, rub the seasonings into the skin. (If you find a way to do that without having the seasonings clump up and stick to your hands more than the bird, please let me know.) Leave the birds on the rack breast side down.
Take the rack out of the baking pan and put the rice into the baking pan. Spread it around but try to keep as much of the rice as possible under where the hens will be. Put the rack back in the pan. Put the hens and rice into the oven and turn the temperature down to 350.After cooking for about 20 minutes, take the baking pan out of the oven and pour some of the glaze over the birds. (If you're using the concentrate use a basting brush to apply the glaze.) After another 15-20 minutes, turn the hens over breast side up and make sure the seasonings are still on. Make sure the rice is mostly under the bird. Pour on some more glaze. Cook for 20 minutes more. Pour the rest of the glaze on the hen and cook until the hens are done.
Green Beans and Mushrooms
To finish dinner, we had green beans and mushrooms. Clean two or three mushrooms and slice them. Wash some fresh parsley (I use flat leaf not curly parsley) and cut it up. Sautee the mushrooms in a little olive oil and grind some pepper over them. Add the cut up parsley and cook a bit more.Wash the green beans and break the stem end off them. Microwave the beans for 60-90 seconds. Mix the green beans with the mushrooms and parsley and you’re done.
You’ve got dinner!
Wednesday, January 2, 2008
Engineering: "Innovation" as a Cover for Bad Ideas
Most people, myself included, tend to think that innovation will improve things. In computer engineering, that might mean you could do things more easily or do new things with your computer, or that you computer would run faster.
About 5 months ago, I bought a new computer. It came with Windows Vista installed on it. Based on everything I had read and heard, I was lukewarm about getting Vista. Initially, I was under whelmed with Vista, but didn't see anything really bad about it. Since that time, I have become less impressed with Vista the more I use it. In particular, the system utilities are a definite step down from their counterparts in XP and their "User Account Control" that is designed to protect the system is SO annoying that I eventually turned it off (the only choice other than incredibly annoying).
As I was installing software on my new system, I had problems with Microsoft Office 2000, specifically with Word. So I decided that I'd break down and buy a new version and bought Office 2007. After suffering with Office 2007 for more than 2 months, I went back to Office 2000.
Microsoft likes to say that people, like me, who think that they have really done a bad job on their new software are against innovation. I think that they are being fatuous and supercilious--although that's nothing new for Microsoft.
Let's look at the "innovations" in Vista. As near as I can tell, the biggest thing is a slightly slicker user interface with translucent window borders. For this, they had to take years and disrupt millions of users?!? A programmer I knew years ago said that whenever a new Unix system programmer was introduced to the system, he would rewrite the terminal driver. I have the feeling that Microsoft gave in to a bunch of programmers who said essentially that they could do a much better job than the guys who wrote XP if they could start from scratch. In my opinion, they failed. Let's look at some specifics.
Windows Explorer:
They tried to make Windows Explorer be smart about what kind of files are in the directory and display things that are appropriate for that kind of directory. Unfortunately, it seems to guess wrong most of the time.
In some kind of cruel joke, Microsoft decided to include a "Favorite Links" area above the "Folders." There does not seem to be a way to get rid of it, which would allow more "Folders" to be seen. Nor does there seem to be any way to change the "Favorite Links" that are displayed. My question is who's favorite links are they. Certainly not mine--except for "Documents." Congratulations Microsoft. You got one of six of my favorites.
Although there is an option to make a directory style apply to all folders and subfolders, it doesn't seem to work and Windows Explorer applies its settings in place of the ones I tell it to use.
I'm sure that a fair amount of time went into rewriting a basic facility that worked well in XP. If there were some innovative new features, I'm sure it would have been easier to add them to the existing code than to rebuild the utility from scratch.
Disk Defragmenter:
The defragmenter in XP would analyze a disk or partition and tell the user how much fragmentation there was. It also had a cute and somewhat useless display to show the user it was working. It also attempted to give the user a clue about how far along it was in the process. The defragmenter is Vista is much simpler. It tells the user nothing except that "performance can be improved by defragmenting the disk". I tried running the defragmenter. I let it run for more than 24 hours and it was still cranking away with no indication of how much more there was for it to do. I never did discover if the defragmenter was working on both of my disks or only worked on one at a time.
I'm sure that a fair amount of time went into rewriting this tool that worked well in XP. If there were some innovative new features, I'm sure it would have been easier to add them to the existing code than to rebuild the utility from scratch.
User Account Controls:
This is really a new feature and had some potential. Unfortunately, the developers make this so intrusive that it becomes tempting to shut it off (the only option). A large number of programs that I run on a regular basis cause the UAC to warn me that the program is dangerous and insist that I explicitly allow the program to run. That's great--once. I have not found any way to tell the program that a particular program is ok and it doesn't have to ask me every time I run it.
Power Options:
When I was setting my system up, I installed Avast!, the anti-virus software I use. Avast! has an option to run a scan at boot time. Running a virus scan on a system takes a long time. It seems that some design genius decided that the monitor shutdown features of the Power Options should be applied before Vista was fully up. So after about 20 minutes, the screen went blank. Unfortunately, they didn't include the code that caused the monitor to come on again if a key was pressed. It took a while to figure out that this is what was happening and I believe that shutting power down in the middle of my first attempted scan damaged the system--which I think led to Word 2000 not working correctly. When I figured out what was happening, I restored Vista and started installing my software on a clean system.
Windows Mail:
Since Outlook 2000 won't work in Vista, I was forced into using Windows Mail. This is a poor substitute for Outlook Express found in XP.
Initiating a new mail message takes about 15 seconds. If I turn off automatic address completion, the message window is immediately available for use, but that's a major loss. XP was much faster in this regard.
I use more than one email address. The new Windows Mail program only allows one to send a new message from the default email address. In Outlook Express XP, I could choose the address the mail was sent from.
If these are innovations, they seem like bad innovations.
There's more I could write about Vista and its utilities, but I want to move on to Office 2007.
Office 2007:
As I mentioned in my comments on "Power Options," I decided to try to solve my problems with Word by buying a new copy of Office. I bought Office Home and Student 2007. The Vista problems didn't go away until I reinstalled Vista, but I had already opened the package so decided to keep it.
The "ribbon":
Since most laptop computers are now wide screen and the ribbon takes up a fair amount of vertical space across the top of the window (reducing the available space for the document in the more limited dimension), I started looking for a way to move it to the side (where there is a lot of unused space). I discovered that the ribbon could not be moved.
I tend to operate my computer from the keyboard as much as possible. I had shoulder problems a number of years that were exacerbated by using the mouse a lot. I also find using the keyboard faster and surer than using the mouse. The ribbon pretty much forces the user to use the mouse. If you happen to remember the entire keystroke sequence for a command in Office 2003, you can use the keyboard; otherwise, you must use the mouse.
I spoke with someone who works at Microsoft who told me that after about 6 weeks people decide they really like the ribbon. After fighting with it for about 10 weeks, I went back to Office 2000. Unfortunately, Outlook doesn't work under Vista so I was forced to use Vista's poor quality Mail and Calendar programs.
I tend to think of innovations as providing more, not fewer, options for users and making things better not worse.
The next thing I noticed was that the title bar on all of the windows stated something to the effect of Not for Commercial Use. My first reaction was that was really chintzy! My second reaction was that if Microsoft was going to put that on the software, they should warn users before they purchased the product that would be the case.
If you are ever tempted to defend an idea that people don't like, be careful about claiming the detractors are opposed to innovation. You might find yourself laughed at.