A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Spot false dilemmas now, ask me how!
(If you're not on the edge, you're taking up too much room.)
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Mr. C Lamont Gilbert:
maintainable means that its easy to fix bugs you find.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Originally posted by Stan James:
Changes in requirements might just sound like more stories. Do they really need a special name?
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Ricky Clarkson:
When you have good tools that don't make mistakes, like IDEA and Eclipse, then it is easy to change code when new requirements come in.
When you don't have that, say, because you're using a dynamically typed language (without Bracha's optional typing), then it is not easy to change code when new requirements come in.
It might be beyond your skills/permissions to integrate the pattern into the language (such as Java 5 did with the typesafe enum pattern), but it's always worth recognising that there's something missing from your skills/language if you're writing in patterns.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Originally posted by Ricky Clarkson:
I only said that the tools don't make mistakes, not that the users don't.
The strategy pattern would better be done by adding a method to the class, or to use the opposite, but equivalent, technique, by adding a generic method that can operate on instances of the class.
The latter is explained here: http://anthonyf.wordpress.com/2006/04/07/strategy-pattern-in-lisp/
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
You also said that "it is easy to change code when new requirements come in" using those tools. I'm just saying that in my experience the more important factor is a good test coverage. A good refactoring tool is nice, but not necessary - let alone static typing.
Can you shortly explain what exactly "would be better" means to you?
Originally posted by Ricky Clarkson:
Given that changing, say, the name of a method, has O(n) time, where n is the number of uses of that method, it is harder to change code that has high test coverage than code that doesn't.
Good tools make changing the name of a method have O(1) time, at least until n is 10000 or so, I'd imagine.
Certainly, however, good tests make verifying the correctness of the change easier, but they don't actually make the editing tasks easier.
If you have reliable refactoring tools, and a style of code that fits them, i.e., no reflection, then you can know that the refactor hasn't broken anything.
In that respect, given strong enough static typing, you need less tests.
In a language where a method parameter cannot be null, you don't need to test for what happens if you pass null to the method. In a language where method parameters are typed, you don't need to test what happens if you pass an int to a method that expects a String.
In Lisp, you get a Turing-complete environment at compile-time too, so you could, in theory at least, do all your automated tests as part of compilation - in that case there would be no difference between static typing (well, static testing) and automated testing. Hence, I think that automated testing and static typing are just two flavours of the same medicine.
Haskell programmers aim for complete static testing - by making their type system as strong as possible, they can prove things without having to write dull, repetitive tests.
Sure. Take some code, which has some repeating portions. Change it in some way so that it does the same thing, without the repeating portions. It is now better.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
A good question is never answered. It is not a bolt to be tightened into place but a seed to be planted and to bear more seed toward the hope of greening the landscape of the idea. John Ciardi
Originally posted by Stan James:
Someplace I found a list of "Seven Deadly Smells" attributed to Uncle Bob: Complexity, Fragility, Rigidity, Repetition, Imobility, Opacity and Viscosity.
Originally posted by Ricky Clarkson:
The strategy pattern would better be done by adding a method to the class, or to use the opposite, but equivalent, technique, by adding a generic method that can operate on instances of the class.
The latter is explained here: http://anthonyf.wordpress.com/2006/04/07/strategy-pattern-in-lisp/
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
By "adding a method to the class", are you talking about something like the Template Method pattern?
What had you do in the Lisp example when you want to introduce another Strategy instance?
Originally posted by Ricky Clarkson:
Imagine that you could, with Java, at any time, add a method to a class.
Common Lisp does it in a reverse way - rather than the method belonging to the class, the implementation of the method to run is chosen based on the types of the arguments. This is similar to how Java works with instance methods, except that Java only 'dispatches' based on the type of 'this'. Because the method is not tied to the object in Lisp, what we'd normally call 'this' in Java may be the third or fourth parameter in Lisp - and dispatch can occur on any parameter.
That's one reason why Lisp doesn't need the visitor pattern.
The next reason is that any good Lisp programmer would encapsulate the visitor pattern, probably in a macro, and reuse it. It's no longer a pattern, but a utility. The repeated code is hidden, unless there's a problem with the macro.
Add another (defmethod) with the new type. This can be done at any time, including runtime. Looking again at that blog, I can see that it would benefit from being based around a real example, rather than choosing algebraic names.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
You seem to imply that a design pattern is always repeated verbatim. That's simply not the case. Every design pattern is a template that needs to be adapted to the situation at hand
The longer I look at the code, it seems to me that it just is a Lisp version of the Strategy pattern, not a substitute for the pattern. It looks similar in intent to me to a C function pointer.
Originally posted by Ricky Clarkson:
Most of the time, the adaptation is simply in changing the names used to match the current domain.
You might find this presentation by Peter Norvig useful, if you have an open mind: http://norvig.com/design-patterns/
He seems to address Strategy better than the blog I pointed at, and he's not using syntax, which probably helps.
In other words, what is trivial in Lisp needs a name in Java/OO because of the amount of extra code that it needs.
So now you can see that I've taken a pattern, finished abstracting, and now all I have is a fairly trivial method.
The soul is dyed the color of its thoughts. Think only on those things that are in line with your principles and can bear the light of day. The content of your character is your choice. Day by day, what you do is who you become. Your integrity is your destiny - it is the light that guides your way. - Heraclitus
Don't get me started about those stupid light bulbs. |