--
You received this message because you are subscribed to the Google Groups "software_craftsmanship" group.
To unsubscribe from this group and stop receiving emails from it, send an email to software_craftsma...@googlegroups.com.
To post to this group, send email to software_cr...@googlegroups.com.
Visit this group at http://groups.google.com/group/software_craftsmanship.
For more options, visit https://groups.google.com/d/optout.
"I believe software design should be taught before TDD. TDD can’t lead to good design if we don’t know what good design looks like."
I don't understand why in his blog post Sandro says the following:
@sandromancuso @RonJeffries just to make sure I understand your point: do you consider the 4Rules PART of TDD?
@sandromancuso @RonJeffries I'm asking because I understand them as one of the many great recommendations from XP. Something you combine with TDD.
@sandromancuso @RonJeffries and I'll believe in whatever you say, since you were at the core of it. ;)
@RonJeffries @sandromancuso no they are the rules of simple design and nearly any design difficulty shows up as a problem with one or more of them
@sandromancuso @RonJeffries OK. I agree with that. Just wanted to make sure they are not part of TDD but definitely important during refactor.
@philip_schwarz @sandromancuso @RonJeffries The link between TDD and 4RSD is step four: "If you ever see the chance to make the design simpler, do it." 2/4
@philip_schwarz @sandromancuso @RonJeffries XP defines the 'best' design as the 'simplest' design that runs all the test cases 3/4
@philip_schwarz @sandromancuso @RonJeffries XP defines 'simplest' as the following four constraints, in priority order: 4/4
Sandro didn't respond. What is also strange (for me) is that Ron Jeffries (who is an XP authority) replied to Sandro's question with a 'no'.
Philip
On May 19, 2015, at 3:49 AM, Philip Schwarz <philip.joh...@googlemail.com> wrote:Sandro didn't respond. What is also strange (for me) is that Ron Jeffries (who is an XP authority) replied to Sandro's question with a 'no'.
In essence, that’s all that TDD is.RED is write a failing testGREEN is make it work.REFACTOR is clean up the design.
Hello Ron,
In TDD we:
- Write new code only if an automated test has failed
- Eliminate duplication
The two rules imply an order to the tasks of programming.
- Red— Write a little test that doesn't work, and perhaps doesn't even compile at first.
- Green— Make the test work quickly, committing whatever sins necessary in the process.
Red/green/refactor—the TDD mantra.
- Refactor— Eliminate all of the duplication created in merely getting the test to work.
Remember, the cycle is as follows:and in the Pluggable Object pattern section of the book (page 172), we read:
- Add a little test.
- Run all tests and fail.
- Make a little change.
- Run the tests and succeed.
- Refactor to remove duplication.
the second imperative of TDD is the elimination of duplication
Dependency is the key problem in software development at all scales
...
If dependency is the problem, duplication is the symptom
I don’t think it matters whether you focus first on removing duplication or on revealing intent/increasing clarity, because these two guidelines very quickly form a rapid, tight feedback cycle. By the time the guidelines guide you to any useful results, you’ll have probably used them both. Therefore, order the rules however you like, because you’ll get to the same place either way.
The Four Elements of Simple Design Revisited
I have been teaching for years about how to reduce the four elements of simple design to two: after several months, I don’t think about writing tests any more—I simply call that “programming”—and I’ve never seen a well-factored code base that had an order of magnitude too many elements. With these two points out of the way, I guide my design with two basic rules: remove duplication and improve names. I’ve started thinking about these guidelines a little differently.
Now, I think of them as a single guideline: remove duplication and improve names in small cycles. When I do this, I produce a higher proportion of well-factored code compared to all the code I write. I use tests to clarify the goal of my code and to put strict limits on how much code I write.
On May 25, 2015, at 1:22 PM, Philip Schwarz <philip.joh...@googlemail.com> wrote:I find that logic dictates that from the above we must conclude that the 4 rules of simple design are part of TDD.What do you think?
On May 25, 2015, at 2:33 PM, Philip Schwarz <philip.joh...@googlemail.com> wrote:So maybe it can be argued that the first of the four rules (passes all test) is clearly part of TDD, and the last rule (as few elements as possible) is part of TDD because no one using TDD to produce well factored code can hope to do so while breaking that rule, and the two middle rules are part of TDD because the third one (remove duplication) clearly is by Kent Beck's definition of TDD, and the second one (expresses intent) is so complementary and tightly related to the other, that it cannot help also being part of TDD.
But but but..... is it always good to remove duplication? For instance, when you have two separate applications or services, os it always a good idea to create a "commons" lib of shared code? I usually find that the shared lib gets in the way, making it more difficult to deploy the apps separately. I think that in some cases it's better to just have two separate copies of some code and let them evolve separately.
I have some support for this idea from Sam Newman's microservices book, and Dan North's motto "DRY is the enemy of decoupled".
What do you all think?
--
Mandata dal telefonino.
On May 25, 2015, at 10:46 PM, Matteo Vaccari <matteo....@gmail.com> wrote:But but but..... is it always good to remove duplication? For instance, when you have two separate applications or services, os it always a good idea to create a "commons" lib of shared code? I usually find that the shared lib gets in the way, making it more difficult to deploy the apps separately. I think that in some cases it's better to just have two separate copies of some code and let them evolve separately.
I have some support for this idea from Sam Newman's microservices book, and Dan North's motto "DRY is the enemy of decoupled".
What do you all think?
On May 26, 2015, at 1:07 PM, Matteo Vaccari <matteo....@gmail.com> wrote:The way they are expressed, they SEEM to imply that"Keep removing duplication and you'll be fine in the end"While they would probably be better expressed as"Keep removing duplication, observe your results, and if they are not good then try something else"or"Removing duplication is usually the good thing to do IN CONTEXTS X and Y"What is often lacking when people speak of DRY or "remove duplication" is the observation that"I remove duplication from A and B into a shared thing C. Now A and B are coupled through C”.
On May 26, 2015, at 1:22 PM, Matteo Vaccari <matteo....@gmail.com> wrote:I hear you say that there are situations (like when working on code of a single service) where removing duplication as far as you can is beneficial; and other situations where it is not, like when you have separate services, especially when one of them sees more active development than the others.
I notice that you seem to be contradicting yourself, because in the first paragraph of your response you say that sometimes, it's OK not to remove duplication. In the last one, you seem to say the opposite. But if I read carefully, I notice that you say "when the code is evolving", by which I think you mean that removing duplication within code that is actively evolving is almost certainly good; while going out of your way to remove duplication from code that works and is not being actively changed may not be a good idea. So I think that you are not contradicting yourself; you are making a statement that removing duplication is almost always good *in a certain context*.
So my question is: why do we need to be so subtle? It's very easy to misunderstand statements like this and think "I heard Ron say that removing duplication is the right thing, 99.999% of the times, period." We miss "... in this context". I think that we as a community could be a bit more explicit in the discussion of the contexts, limits of applicability, examples and counterexamples of our favourite Rules.
A simplistic example ... suppose the following sequence of instructions appears several times in a module or in several modulesA = B + CGET CARDPUT OUTPUTIF B=4, THEN E=0A well-intentioned programmer may analyze the situation and decide to replace all such sequences with a CALL to module X, and then create a module X containing these four instructions.Module X now probably has coincidental strength, since there are no apparent relationships among these four instructions. That is, these instructions probably have different meanings in the original modules.Suppose in the future a need arises in one of the modules originally containing these instructions to say GET TAPERECORD instead of GET CARD. The programmer is now faced with a problem. If the instruction in module X is modified, module X is unusable by all of its other callers. He has another alternative, to place a test in module X to determine the calling module in order to decide whether to issue the GET TAPERECORD or GET CARD instruction. This alternative is equally bad.