Re: Design Pattern thoughts
- From: "Ed" <iamfractal@xxxxxxxxxxx>
- Date: 17 Nov 2006 16:14:50 -0800
Laurent Bossavit skrev:
Here's a poll for the group: what is the smallest, most legible piece of
code (with significant functionality) you've ever seen ? Preferably
source code that is published so we can all learn from the masters.
Surprising, the answers you've received for this.
I like Aloha's answer that gave an SQL query, "sets /
project_set#(Sets)," without giving database source code, but this
raises a valid question: where does one piece of code end, and another
begin? No code exists in isolation. No SQL query will get very far
without an application behind it to interpret the query. No Java code
has any meaning without the megabytes of JVM source code to support it.
No application gets very far without the millions of lines of
Windows/Linux/Solaris code supporting it. I suppose even a nuclear
power station's code can be reduced to, "station.start()".
So, we're talking, "Levels," of code, in some sense. It's ok to post an
SQL query without the necessary database code, because SQL is, in a
sense, above that code. We all know and use it everyday without
worrying about the underlying application. And it's ok to post the
database code without the operating system code, because the database
is an application and, "Above," the operating system.
So this is all taken with a bit of subjectiveness.
Which is fine.
But never conclusive.
So I'm going to wade in with my own Java code.
Not that I'm a master, or I think it's the smallest, most legible
piece of code (considering the millions of lines of JVM and OS behind
it) but I just like the way it looks.
It's the method that ranks poker hands in a poker game I wrote:
http://www.edmundkirwan.com/servlet/fractal/cs1/code/package101.html#getWinningHands
What I like about it, is that the hands are actually ranked by one
line:
Collections.sort(sortedHands);
Given that I'm ignoring the millions of lines of code that are
necessary before this line can execute, I just like that using one of
Java's abstract mechanisms - sorting elements of a group - can be so
specifically applied to something like a set of poker hands. There's
just something appealing about that.
And - above the level of the JVM at least - you can see all the source
code that supports how this is done.
I'd be interested to see what results you harvest if you post your
challenge on the Eclipse of JBoss fora: those folks really know how to
code, surely they'd have some great examples.
..ed
--
www.EdmundKirwan.com - Home of The Fractal Class Composition
.
- Follow-Ups:
- Re: Design Pattern thoughts
- From: Laurent Bossavit
- Re: Design Pattern thoughts
- References:
- Design Pattern thoughts
- From: robjoel
- Re: Design Pattern thoughts
- From: Phlip
- Re: Design Pattern thoughts
- From: AndyW
- Re: Design Pattern thoughts
- From: Laurent Bossavit
- Design Pattern thoughts
- Prev by Date: Re: Events
- Next by Date: Re: Events
- Previous by thread: Re: Design Pattern thoughts
- Next by thread: Re: Design Pattern thoughts
- Index(es):
Relevant Pages
|