« Django debugging, and MVCP frameworks | Main | ping pubsub.com »

Smalltalk by other means

CollectionClosureMethod is one of the best things Martin Fowler has written in a while. Go read it. I love it when he informs through code snippets.

You do get the feeling sometimes the statesmen of the agile community consider the last 10 years of statically typed container backed middleware a distraction from the real goal - the ability to implement business value faster than the business can think it up.


August 1, 2005 05:24 PM

Comments

Isaac Gouy
(August 1, 2005 07:54 PM #)
managers = employees.select {|e| e.manager?}
Here's some statically type checked "Smalltalk by other means"
let managers = employees.select(Employee e => e.isManager);

{Collection C, T} C{T} select(C{T} coll, T->boolean test){
C{T} result = coll.similarEmptyCollection();
for (T element : coll)
if ( test(element) )
result.add(element);
return result;
}

Nice and Scala and ... (other statically type checked languages) provide anonymous methods, first class functions, closures.

Isaac Gouy
(August 2, 2005 01:24 AM #)

You do get the feeling sometimes the statesmen of the agile community consider...
Not sure who you're thinking of... but Java sure rained on the Smalltalk parade.

Brian McCallister
(August 2, 2005 03:21 AM #)

Scala is a sweet language, I once said, and I stand by the statement, that the next language to be Cobol, er, Java, will look an awful lot like Scala.

Isaac Gouy
(August 2, 2005 04:50 PM #)

Of course, Nice already defines useful collection methods...


employees.foreach(Employee e => e.doSomething);
let managers = employees.filter(Employee e => e.isManager);
let managersOffices = employees.filter(Employee e => e.isManager ? e.office : null);
let offices = employees.map(Employee e => e.office);
let allManagers = employees.all(Employee e => e.isManager);
let noManagers = employees.none(Employee e => e.isManager);
let total = employees.foldLeft((int result, Employee e) => result + e.salary, 0);

Post a comment

(you may use HTML tags for style)




Remember Me?

Trackback Pings

TrackBack URL for this entry:
http://www.dehora.net/mt/mt-tb.cgi/1616