Showing posts with label design. Show all posts
Showing posts with label design. Show all posts

13 February 2008

Two gripes about the Java library, and what they say about language design

So, as far as programming languages go, Java is far from the worst.
However, it's nowhere near the best either. Here are a few grips
which popped into mind right now:

(1) java.io.OutputStream is a class. It should instead be an
interface. Why? Because there are a trillion things which act like
an OutputStream, but which don't share any code with it.

So why does java make a distinction between interfaces and classes?
Because multiple inheritance is hard to implement--you don't just need
a virtual table for each of the methods, but also for each of the
fields. Yech.

The ultimate failing here is that Java lacks mixins. Class
java.io.OutputStream is a class because they want to be able to
implement OutputStream.write(byte[], int, int) in terms of
OutputStream.write(byte), or maybe the other way around. A minor
savings at a great cost.

Interfaces are not allowed to have any code. A mixin is an interface
that's allowed to have code, but no fields. But mixins are still
really easy to implement, so there's no reason to not include them.

(2) java.lang.StringBuffer does not implement java.io.OutputStream.
Why not? As far as I can tell, it is a sink into which I dump bytes,
chars, strings, etc. But no, I have to wrap it in a trillion adaptor
classes instead.

Sure, it implements java.lang.Appendable, but who ever heard of
Appendable? Despite my casual language, I more specifically mean: who
ever wrote something that requires an Appendable? Everyone wrote
something that requires an OutputStream, and an OutputStream is not an
Appendable!

Why I think bamboo bikes fix the wrong problem

I've been seeing a lot of posts all over the interweb about wooden and bamboo bikes. Hey, that seems clever! Solves the world's problems! Right? I'm not so sure.

So, I agree it would be a great world if everyone who wanted a bike had one. And, I agree that bikes are better for developing nations (and all nations) than cars, since they provide mobility and portability with few/no recurring costs. They even have nice side effects, like physical fitness and zero pollution.

What I don't buy is whether a bamboo bike is any more accessible to the developing world than a steel bike. Here is why I think that.

My criticisms could apply to any bamboo bike, but for argument sake I'll pick one. Let's pick on Bamboo Bike Project, a joint venture between the Earth Institute at Columbia University and Calfee Design.

First of all, let me thank them for trying to do good in a world where so many don't do squat. My criticism is to encourage you to seek a more realistic design, not to discourage you.

My first observation is that the bike is not made entirely out of bamboo. All of the components are normal components (and note that componentry is generally more than 50% of the cost of a complete bike). Suspend your disbelief and assume we can get all of the sundry components to put a bike together; let's focus on the frame itself.

On the bamboo frame, the following pieces cannot be made out of bamboo:
  1. The head tube, since it must support the bearings in the headset,
  2. the bottom bracket shell, since it must support the bearings in the bottom bracket, and
  3. the dropouts, since they must support the wheel.
The photo gallery confirms all of these constraints. One could presumably make these pieces from scap, if one had a machine shop. But machine tools are expensive (a cheap milling machine costs $525, a cheap bike costs $50), so let's assume that we don't have one.

The only other solution is to scavenge them from metal bike frames, and then bonded to the bamboo frame. So where do those parts come from? In this case, those parts must be taken off of broken bike frames. In this case, we do accomplish reuse of a small fraction of trash frames.

However, I think we could accomplish more by attempting to repair those bike frames. The cheapest, most common bike frames are made of steel, and improvised welders are not too difficult. Also, Sheldon Brown gives instructions to repairing bent frames via cold setting.

What could be done to improve this design? I have no concrete points here, only general guidelines:
  1. Consider the context in which these will be built. Does it ever make sense to saw off 99% of a bike frame and replace it with bamboo?
  2. Focus on the consummables. Assume that bike frames are pretty easy, and instead figure out a cheap hack to replace burst tubes or tires, rusty chains, broken cables and worn brake shoes. In other words, follow the 80-20 rule for bike repair.
  3. Make the bike more useful. I see that they added a large rack on the rear for carrying cargo or additional passengers. That's golden! Pursue this further, design bike trailers, or figure out how to use a stationary bike as a motor to drive tools, feed generators, or purify water.

05 February 2008

Bombproof gadgets at CNET : I am validated


For many years, I have used an old Nokia phone. It's black and white, lacks camera, internet, mp3 player, but is the most reliable phone I have ever used. It seems that CNET agrees with me (finally, I have some back!)

I like it because (1) the battery lasts forever, (2) the firmware is simple, reliable and well-designed, (3) it is virtually bullet-proof, and (4) it gets great reception.

[1] is true mostly because it lacks camera, internet, mp3 player, etc. For each of those devices, we add to its power consumption. Additionally, if any of those peripherals require a different voltage, we need to add additional regulators, and suffer a conversion loss for each. Because it is a black and white, low resolution screen, the video update clock can operate at a lower speed (which reduces switching losses) and less video ram is needed (also reducing power consumption).

[2] speaks for itself. No bells and whistles, no stupid animations, but a sleek menu driven interface that takes advantages of hotkeys.

[3] needs elaboration. Whenever I drop the phone, the battery cover pops off, and the battery pops out. I can't be sure, but I think this acts to absorb most of the shock from dropping it. I might also add that it is reliable because it is NOT a flip phone. The problem with flip phones is that the processor is at one end and the screen is at the other. A lot of data travels from the processor to the screen via a "flex circuit" which coils through the hinge. Flex circuits are... dinky, and prone to failure.

[4] is a result of its mixed digital/analog receiver. If I'm outside of a digital coverage area, it will switch to analog.

If this thing should ever break, I'll go to ebay and find another one. I've already turned down free phones from my service provider 'cause I like this one. My only problem? Whenever I pull this thing out at a business meeting, I need to explain why I use a ten year old phone.