KBD

Keith Devens .com

Thursday, November 20, 2008 Flag waving
A society that puts equality -- in the sense of equality of outcome -- ahead of freedom will end up with neither... – Milton Friedman (Thomas Sowell: A Conflict of Visions, p130)

Archive: December 06, 2003

← December 04, 2003December 07, 2003 →

Daily link icon Saturday, December 6, 2003

Yahoo Proposes New Internet Anti-Spam Structure

Yahoo Proposes New Internet Anti-Spam Structure

Survey of OO languages

Via Hans, this Survey of Object Oriented Programming Languages looks pretty interesting. It's important for people to realize that there are a lot of different options for what makes something object-oriented. The biggest distinction I'm aware of is that between prototype-based systems and class-based systems. This paper looks like it covers that and more.

Dog dancing!

Woo, competitive dog dancing! When my friend Justin sent me this video, I expected something bad to happen, like the dog biting its owner during the routine... But no, this video is just a whole bunch of awesome dog dancing

Dean, the left and the use of force, and the war on terror

The ever-excellent Cox & Forkum: Root Causes. There's a lot of great stuff in this post. Just check it out.

I'll quote this bit:

In Dean's announcement for candidacy he alluded to how he thinks America's military might should be used:

"The idea of America using its power solely for its own ends is not consistent with the idealistic moral force the world has known for over two centuries."

In other words, he considers it more "moral" and "idealistic" to use our military self-sacrificially and not to secure our national self-interests. To him it is better when our soldiers risk death for the sake of other countries than for the sake of America. I can think of few foreign policies more morally atrocious than that.

Dean's quote seems to be straight out of Conflict of Visions as an example of an unconstrained approach to politics.

Having fun is sometimes pushing the envelope

Having fun is sometimes pushing the envelope

ProleText

ProleText

Debuggers and logging

Debuggers: a modern 'Dr. Jekyll and Mr. Hyde'. I found this article more interesting than I expected to.

Beside that for certain problems a debugger is a great tool it prevents many developers from focusing on the real problem that their code is plain buggy and that they have no clue where to look for. Stepping through a program only works well when the developer can remember where he came from and where he is heading to. But most of the time people lose that and when they found the problem they do not know how they got there in the first place and so the have to step through multiple times until they understand what caused the problem and how to fix it. A much better way is to look at your code, log output and, if you have, your test cases to localize your problem area and then focus on this area. For me this does mostly lead to a solution and I do not need a debugger anymore. With an AOP framework and a decompiler I can also debug third party library without a debugger.

I've advocated logging before. In particular, now I want to check out log4j and understand how that works.

Choosing Python

An interesting summary of why a particular development team chose Python (and stuck with it). Via Erik, via Chris.

Argument passing runaround

One of the most common recurring problems in software design is how to manage data flow in your code. Unless you use global variables for everything, you have to worry about this problem. Of course, if you do use global variables for everything, you have other problems.

Anyway, consider:

frob(arg1, arg2, arg3)...

Eventually, the number of parameters to a function may get unwieldy, and importantly, you may need to pass a number of those parameters to different subroutines called from frob. That gets hard to maintain, it's ugly, you forget which order the parameters go in, and it's generally a pain. People have probably given guidelines about how many parameters to a function is too many, but you don't need a rule like "7 is too many" to know when you have a problem.

So, the next step is to make arg1, etc. into fields of a record, and then pass the record around to different subs. But then you have a whole set of different problems. It can introduce another compile-time dependency (at least, in languages like C (Pascal too?): see John Lakos.), and you then you wind up writing extra code to initialize and return a record. Sometimes a function doesn't need everything in the record but you still wind up passing the whole thing in, and I could swear there's some "software rule" that explains how this increases the coupling between different pieces of code (can anyone remind me what it is?).

This is one of the things OO is meant to solve. Group pieces of code that need the same data together, figure out what abstraction that represents in your program, and then each method that accesses the data doesn't have to get it from anywhere else but its own object instance. Not that this solves all of your problems, of course, but it helps.

In languages that support further levels of program organization, there are other places to stick things. For instance, consider languages that have modules in addition to classes. There are yet more ways to abstract around data... closures, currying, continuations. What else?

And of course, you often have to figure out where to put your data. Where is the data created and initialized? Who "owns" it (who's responsible for freeing its memory, etc.)?

The problem of what you do with return values is yet another common issue.

This post feels incomplete and without purpose, but this bit from Adam (bottom part of the day) spurred me to write down some thoughts.

Neat for loop idiom

Just came across a neat for loop idiom I don't think I'd ever considered before:

for(long i = 0, m = file.length(); i < m; i++)

As a general rule, it's bad (with varying degrees of badness) to call a function in a loop condition. One of my favorite examples of why is exemplified by this bit of C:

for(n=0; n<strlen(str); n++)
    print str[n];

It turns what should be a Theta(n) algorithm into a Theta(n^2) algorithm.

Usually what I'd do in that case is something like (back to Java):

int length = file.length(); // or str.length, etc.
for(int n=0; n<length; n++){...}

But the idiom above allows you to put it in the loop declaration, which allows you to better associate it with the loop conceptually, and has the added benefit of making the variable scoped to the loop.

Data Binding in .NET

Adam has a really interesting observation on data binding in .NET. Adam, thank you in advance, because you most probably just saved me lots of time at some unknown point in the future. Not only time, in fact, but I'm also saved from having to go through the conceptual discovery he spent the time going through.

I hope he doesn't mind, but I'll quote the whole thing here because the observation is short and not easily excerptable:

Using an object as the DataSoucre for two different ComboBoxes in a Windows Form means that the selection of those two boxes is synchronized. You change one, the other changes too, which is not what I expected. I just wanted to use the same IList in two drop-downs. It appears that in order to do that I need to copy the list into an array, then use .AddRange() on each box.

Why why why?

Because data-binding is conceptually about controls viewing the same record in a database, not conceptually about being MVC.

Larry Wall, Perl 6, mixins, and orthogonality

"I think we deserve a $rubyometer-- for bypassing mixins." - Larry Wall

Piers has some things to say about this message and how Larry is handling Perl 6 design in general.

I remain very optimistic about Parrot and Perl 6.

← December 04, 2003December 07, 2003 →
November 2008
SunMonTueWedThuFriSat
 1
2345678
9101112131415
16171819202122
23242526272829
30 



RSS feed RSS feed for Keith's Weblog
Atom feed Atom feed for Keith's Weblog
Weblog archive
Recent comments
  on 4 posts

Recent comments XML

new⇒Java join function

Meh, don't have null strings in​your string arrays imo, but you're​welcome ...

Keith: Nov 19, 7:51pm

Girls, please don't get breast implants

sorry but another thing i have to​make a comment on about you​men...the men...

happynow: Nov 17, 11:36pm

Books by Vincent Cheung

to all Cheung​fans:

read:

http://www.progin​osko.com/aquascum/cheung.h...

Zamir: Nov 16, 9:07am

Spider solitaire

To undo or not to undo that is the​question.
I'm an undoer. 
My dad​was n...

Can Turk: Nov 15, 2:50pm

Generated in about 0.07s.

(Used 7 db queries)

mobile phone