2008-12-27

Lockhart's Lament

Lockhart seems to agree with Dijkstra, that problem solving can be taught. But my mind fixed on something else in the paper. The much criticised geometry proofs mentioned on page 21 looks very much like programming. Why not use Haskell notation? Or even better, Coq? The proofs could be type checked and evaluated automatically. The students would learn to program at the same time they were learning geometry. They are learning to program now as well, they just don't know it, and would probably have difficulties to apply their newly gained knowledge in programming, due to the special notation used.

The programming approach would also allow the students to create theorems of their own to be used in future proofs, building a library of geometry as they go.

Even though I agree with Lockhart that problem solving should be emphasized instead of mechanical application of rules, by not using a formal system, he relies too much on human intuition in the proofs created. The informal proof on page 21-22 is elegant, but relies on the intuitive understanding of rotation and that rectangles have diagonals of equal length alternatively that rectangles have corners with right angles (both can not be the definition of a rectangle).

2008-12-15

Connect to Internet with a Bluetooth 3G Phone

There are many tutorials available that describe how to connect to Internet using a 3G phone with bluetooth, but none of them worked for me. I had to use a combination of several sources. This is what worked.

I want to connect to Internet with my Asus Eee PC 901 using my SonyEricsson W880i. The operator I use is Tele2 in Sweden. I have installed Ubuntu Eee on the netbook.

First I used Blueman to configure the bluetooth connection using this tutorial. This should result in a /etc/bluetooth/rfcomm.conf looking something like this:

rfcomm0 {
bind yes;
device AA:BB:CC:DD:EE:FF;
channel 2;
comment "W880i";
}

The device is the mac address of your phone and the channel is the same as your phone's Dial-up Networking channel. You can find out your channel using Properties in Blueman. The Serial Port channel also worked for me.

Then I wrote the following in /etc/wvdial.conf, found in this tutorial.

[Dialer defaults]
Modem = /dev/rfcomm0

[Dialer tele2]
Modem = /dev/rfcomm0
Baud = 115200
Init2 = AT+CGDCONT=1,"IP","internet.tele2.se"
Phone = *99#
Username = *
Password = *
New PPPD = yes
Auto DNS = 1

I start the network with the following command.

wvdial tele2

2008-11-06

Language and Abstraction

'Hell, one of the lessons of Structure and Interpretation of Computer Programs is that a "language" is a natural way of abstraction...', says ivdkleyn on Reddit. I agree and make an even stronger statement. Language is the only way of abstraction.

2008-10-27

Reading Fielding - Software Architecture

In the first chapter of his dissertation Architectural Styles and
the Design of Network-based Software Architectures
, Roy T. Fielding defines software architecture.

A software architecture is an abstraction of the run-time elements of a software system during some phase of its operation.
A software architecture is defined by a configuration of architectural elements...

From this I draw the conclusion that a software architecture is a configuration of abstract run-time elements. Abstraction is the process of removing irrelevant details. A software system can be abstracted in many ways, depending on what you want to show. This means that a software system has many architectures. I must object to this definition. To say that a building has many architectures just sounds strange. Perhaps what is meant is that the design of a building is influenced by many architectural concepts. Despite this, the building only has one architecture, its own.

My definition of software architecture adheres more to the traditional meaning of architecture as the documentation for a specific software system as a whole. Fielding makes software architecture synonymous with configuration, which is just one of many abstractions of the whole system. This also have consequences for his understanding of the term architectural view. In Fielding's definition, it is the configuration that can be viewed from different angles, when it should have been the architecture as a whole, with the configuration as one view.

More interesting is Fielding's definition of architectural style.

An architectural style is a coordinated set of architectural constraints that restricts the roles/features of architectural elements and the allowed relationships among those elements within any architecture that conforms to that style.

Styles exist to make it easier "to directly compare architectures for different types of systems". This is a good definition that I can agree with, except that I would have written "to directly compare architectures for different systems", to be more true to my definition of software architecture. But this is a minor complaint. It is worth noting that Fielding does not use the term pattern due to its altered meaning within OOP as compared to Alexander's original definition.

When I look at the definitions as a whole, I get the feeling that Fielding, in his desire to define architectural style, has pulled the definitions of software architecture, configuration and style together, almost making them the same. It would have been better to differentiate them more, making each of them clearer as a consequence.

Lets proceed with connectors.

A connector is an abstract mechanism that mediates communication, coordination, or cooperation among components.
Internally, a connector may consist of a subsystem of components that transform the data for transfer, perform the transfer, and then reverse the transformation for delivery.

I don't use connectors when I describe my own architectures. I think it is better to connect components directly with a use relation. If transformations are necessary, they are better handled by an additional component, implementing languages for the communicating components to use.

Finally I want to say something about data. Lets see how Fielding defines them.

A datum is an element of information that is transferred from a component, or received by a component, via a connector.

I agree with Fielding that data is important. But I choose to include them in the definition and design of languages, subsequently used and implemented by components. I get a feeling that he likes the notion of data being transmitted over connectors because this closely mimics his own main interest, the design of network-based software architectures.

P.S.
Yes, behind every component and connector there can be a large architecture that has been abstracted away. In this sense Fielding is correct when he talks about "the many architectures within a system". But this definition is not useful when analyzing the architecture of a system, precisely because all the uninteresting architectures have been abstracted away.
D.S.

P.P.S.
In one of his blog posts, Fielding says "Compare that to the Atom architecture within my blog, which consists of just the externally observable behavioral abstraction." In my view, externally observable behavior is a language or interface, not an architecture. Perhaps this is not what he meant, but it is easy to draw that conclusion.
D.S.

2008-10-04

Robotics - Motor Driver

As a hobby project, I build an autonomous LEGO robot controlled by an Arduino Nano with assorted sensors and actuators.

I use two electrical motors powered by a 7,2V racing accumulator pack. To control the direction of and power to the motors, I use two Allegro UND2916B motor drivers in parallel, one soldered on top of the other. See the image below for the complete circuit layout.


Unfortunately, there is an error in the schema. To correct it, the Arduino Nano connections should be shifted one step down, so D8 connects to D7 instead, D7 to D6, and so on.

I do not use the PWM capabilities in the 2916. Instead I use the PWM outputs on the Arduino.

In the Arduino Development Environment, I define the meaning of the different signals.
byte leftDirectionPin = 7;
byte leftSpeedPin = 6;
byte rightSpeedPin = 5;
byte rightDirectionPin = 4;

2008-09-28

Robotics - Telemetry

As a hobby project, I build an autonomous LEGO robot controlled by an Arduino Nano with assorted sensors and actuators.

Using a simple radio link between the robot and a PC, I can monitor the current state of the software running on the Arduino.

The radio link is based on the circuits TX433 and RX433 from Velleman. The receiver is connected to the PC with a TTL-232R cable from FTDI. See the image below for the complete circuit layout.



To transmit data from the Arduino, I open the serial link and write tagged data to it.
Serial.begin(4800);

Serial.print("acc:");
Serial.println((long)fwdAcc);
Serial.print("speed:");
Serial.println((long)fwdSpeed);

The various tags and values are collected and displayed by a Processing application on the PC.
import processing.serial.*;

String tty = "/dev/ttyUSB0";
Hashtable data;
Serial port;
PFont font;

void setup() {
size(300, 600);

data = new Hashtable();
port = new Serial(this, tty, 4800);
font = loadFont("Dialog.plain-14.vlw");
textFont(font);
fill(0, 0, 0);
}

void draw() {
background(255);

while (port.available() > 0) {
String line = port.readStringUntil(10);
int pos = 0;
if (line != null &&
(pos = line.indexOf(":")) > 0 &&
pos < 30) {
data.put(line.substring(0, pos+1), line.substring(pos+1));
data.put("time:", "" + hour() + "." + minute() + "." + second());
}
}

int y = 20;
for (Enumeration e = data.keys() ; e.hasMoreElements() ;) {
String key = e.nextElement().toString();
String value = data.get(key).toString();
text(key, 4, y);
text(value, 104, y);
y += 20;
}
}

You need to create the font Dialog.plain-14 in Processing GUI for the program to work. The end result looks something like this.



The time parameter is there to show when the last message was received.

2008-08-12

Components, Software Architecture and Product Structure, part II

In the first part about Components, Software Architecture and Product Structures, I did not go into the details when a natural component defined as a binary sequence should be an explicit part of the software architecture. I will do it now.

First I want to clarify that all natural components in the software system are part of the architecture, the question is if they can stand on their own or must be part of a bigger collection of components.

A good software architecture requires that its components are reusable. This is achieved when the components implement well defined languages. Languages are the foundation for reusability.

When a natural component is not independent enough to implement a language by itself, it is put in a collection of components, that together implement a language. This can for example be a collection of classes in an object oriented language that implement an API. Single classes are often not reusable by themselves, because they have too many dependencies to other classes in the API. It is the entire API and its implementation that is reusable. Therefore, it is the API as a whole that is interesting to show in the software architecture.

Debugging with Popper