Matz's talk on Blocksin Ruby
and Memoranda's comparison Smalltalkvs Ruby
You may want to work with some aspect of selected employees;
for example, to collect the spouse names of all managers.
In other words, select the managers from the employees and collect their spouse name
Smalltalk
(employees select: [:each | each isManager])
collect: [:each | each spouseName]
C#
foreach(Employee employee in employees) {
if (employee.IsManager) {
result.Add(employee.SpouseName)
}
}
Which is closer to "english", which represents better our intention (mentally)?
I find the C# solution a little bit low level: we have to many implementation details.
Smalltalk is more abstract, it says exactly what it does.
ps.
Anothe nice approach is the Smalltalk project: where:
employees
project: [:each | each spouseName]
where: [:each | each isManager]
Credits to RichardA. Demers
Thursday, September 29, 2005
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment