I like Conway's game of life for this.
I like Conway's game of life for this.
On May 9, 2011 1:21 PM, "Nieve" <niev...@gmail.com> wrote:
--
You received this message because you are subscribed to the Google Groups "software_craftsmanship" group.
To post to this group, send email to software_cr...@googlegroups.com.
To unsubscribe from this group, send email to software_craftsma...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/software_craftsmanship?hl=en.
--
Matteo,
Thanks a lot for you thoughts!
Funny that you say that this is something you can add as a restriction to your kata- that's something I've been thinking of lately.
The way I'm starting to see this lately is that in order to respect SRP you *would* want to extract certain responsibilities from your kata object into other object that will collaborate with the object in question, so that your object would have optimally only one reason to change; I do believe the kata, as well as my TDD usage will demand me to do these extractions in the 'refactor' of my red, green, refactor, since green would be just writing the code the way it will just work. Or am I missing something here?
Regards,
n
> I expect JB Reinsberger would point out that if you *really* do the
> "refactor to remove duplication" step, you will end up separating
> responsibilities. So yes, in fact you are right; when I'm facilitating a
> dojo I often have to point out that until you remove all duplication you
> should not write the next test.
> The fact is that most TDD beginners, including at times me, don't see how
> important it is to remove every tiny bit of duplication, even when it seems
> you're overdoing it! So the reason for the additional rules is to push
> learners to strive harder. For instance, after doing the OCP Dojo for a
> while it's become more natural for me to extract functionality to new
> methods and then to new classes.
+ SomeLargeConstant;
I am continually surprised at how much improvement in my code comes
from a constant focus on removing duplication. I'm sure there are
more sophisticated checks and refactorings to be aware of, but even
those, to me, are more and more driven by simply observing and
removing duplication.
Thanks!
Ron Jeffries
www.XProgramming.com
It is better to attempt something great and fail that attempt,
than to attempt to do nothing and succeed.
--Cookie, Garden Court Chinese Restaurant, Hamburg, MI
Steve
I TDD because I can not yet reliably predict the perfect design for
the problem I'm solving. Given this handicap, I've found TDD to be the
best coping mechanism. When I can reliably and perfectly predict the
optimal design, I'll probably abandon true TDD as well.
Also, given there is no shortcut for experience, I find TDD to be the
best way for novices and advanced beginners to learn about design and
what makes a design good. That moment when you get a new requirement
and you see the code in your brain and realize all you need to do is
change this one line and the new requirement will fit right in is the
epiphany you need to get from Advanced Beginner to Proficient, IMHO at
least :)
I also get the design wrong a lot because I don't really know what's
coming next, so honing my refactoring skills seems appropriate and
necessary.
--
Curtis Cooley
curtis...@gmail.com
blog:http://ponderingobjectorienteddesign.blogspot.com
===============
Leadership is a potent combination of strategy and character. But if
you must be without one, be without the strategy.
-- H. Norman Schwarzkopf
>>I find TDD overrated because it puts refactoring on a pedestal: red -green - refactor.
--
You received this message because you are subscribed to the Google Groups "software_craftsmanship" group.
To post to this group, send email to software_cr...@googlegroups.com.
To unsubscribe from this group, send email to software_craftsma...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/software_craftsmanship?hl=en.
>>I find TDD overrated because it puts refactoring on a pedestal: red -green - refactor.I wouldn't say that I find TDD overrated, but I agree, it is good to step back and think about the problem a bit more before starting to hack away...< personal experience >I did the "alpha-end converter" kata in TDD manner. Description of the coding problem here http://www.thycotic.com/codetest.txtDuring doing this Kata I got into this "brute force coding" mode, where I didn't think too much, but I just wanted to get the test to green. It took me a while to get over this hurdle and I couldn't solve the kata in that 1 hour session...This annoyed me a lot, so I stepped back, thought about the problem on paper for a couple of minutes and had the solution there...</ personal experience >
--
You received this message because you are subscribed to the Google Groups "software_craftsmanship" group.
To post to this group, send email to software_cr...@googlegroups.com.
To unsubscribe from this group, send email to software_craftsma...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/software_craftsmanship?hl=en.
> I find that this is a problem with kata that drive towards an algorithm, wrt
> katas that push me to write a maintainable solution. I don't think that
> getting folks to recognize that we're asked to convert from base-10 to
> base-13 is particularly interesting. It gets more interesting if you start
> asking yourself: can I change base? Can I change the symbols? Can I also
> support Roman numerals? Hours and angles (base-60 but with more than one
> symbol per "digit")? Babylonian? Can I support different number systems
> in the same program? Without introducing IFs?
A kata is not a free-form fight. It is an exercise to practice one
small set of things. Some of Uncle Bob's adhere more closely to this
notion than others that are out there. I prefer to solve a small
problem in a new way, rather than repeat a solution the same way
again and again.
Strictly speaking, that sort of thing, and the ones Matteo mentions
above, are not katas, despite how enjoyable and helpful they can be.
They are more of a free-form dance with the devil in the pale
moonlight. Or something.
Ron Jeffries
www.XProgramming.com
Make it real or else forget about it -- Carlos Santana
Since I only had one real implementation, I got it mostly wrong. Not
only do I now have to rebuild the framework, I wasted a week building
it in the first place. In short, I was lazy and jumped to the
framework without at least two example implementations.
Had I been on my game, I would have hacked the feature into the new
application then refactored out the commonalities into a framework
that can be reused in the next application that requires this feature.
I tried design up front and got it terribly wrong. I wasted my time
and the company's money. No model of the two implementations would
have helped me see the common pieces, because I would have gotten the
model wrong. Only the code would have shown me the common pieces and
what could be refactored out.
You say that you don't have to get the model right the first time, so
what do you call it when you get the model a little wrong and then
have to improve the design of the existing code?
Additionally, I do not wander blindly into TDD without doing some
analysis of the problem and design of the solution. Which is why
kata's are not a great barometer of TDD's effectiveness given how a
kata is usually algorithm discovery which usually can be done on a
whiteboard.
TDD is not a silver bullet to perfect systems, but it's the best way
I've found so far to build highly maintainable, loosely couple, highly
cohesive systems. I believe that it's much more difficult to build a
tightly coupled, low cohesion system while doing TDD. As you start to
depend on more and more objects, TDD gets harder. As your class starts
to do more and more things, TDD gets harder. It has built in viscosity
that works in your favor.
After 25 years of doing this sort of thing, you have an intuition into
design that others do not. When I stare at and empty flip chart and
start to feel anxious about what to write, I can often relieve my
anxiety by writing the simplest test that fails and going from there.
> --
> You received this message because you are subscribed to the Google Groups "software_craftsmanship" group.
> To post to this group, send email to software_cr...@googlegroups.com.
> To unsubscribe from this group, send email to software_craftsma...@googlegroups.com.
> For more options, visit this group at http://groups.google.com/group/software_craftsmanship?hl=en.
>
>
--
> I call it "change" or "refactoring" if you will. But it�s refactoring
> of a model first.
> So, yes, refactoring is needed as you improve your understanding of a
> problem or extend a solution.
> But this mostly happens within the model, not within the code.
I'm going to offer here a different way of looking at the model /
code question than seems to be in your text.
What seems to be missing in the above is that the code /is/ a model.
In fact it is the /only/ model that completely represents the code.
To be useful, a model, including the code, has to represent
something (I'll just say "something") that we want to think about.
Sometimes a drawing or some other form is easier, for some people,
to think about.
> With the sample I�ve given (alpha-end kata) this might not be obvious.
> I translated the model to methods.
> But that was just for simplicity�s sake and because it was an
> algorithmic problem.
I don't understand what you're saying here. It sounds to me as if
you are saying the model is real and the methods are not. The
opposite is the case. The program is what we want, the model is a
means to the program.
Can it be easier, for some people, at some times, to think in terms
of another model? Yes. Does that make it best for them or for
everyone? That's not so clear.
> Still, though, you sure will agree the methods are very small. So if
> changes are needed, not much refactoring can even take place. What do
> you want to extract from a 3 line method to go into another class?
If the program wants the other class,and we pay attention to it, it
will tell us so. If we have an idea in our head, we can put it into
the code, or extract it from the code, as seems best. If we do not
have an idea in our head, it doesn't matter what form of modeling we
use.
It is possible that thinking in some other "format" will help some
people, sometimes, get a new and better idea.
> Again: I�m not saying refactoring is not needed. I just claim (code)
> refactoring is the wrong tool to arrive at a design. Don�t use code
> refactoring to plan (!) software.
I think you're saying that for you, sometimes, you do not reach a
good design using code and refactoring. I can understand that. I can
identify with it. And yet your conclusions, "wrong" and "don't",
seem to me not to follow.
> This is not BDUF I�m talking about. No, I�m thinking very short
> iterations each starting with a "thinking phase" aka design.
> Model a little, code a little...
No one is opposed to thinking, as far as I know. Personally, I would
not think it ideal to think sometimes and then code sometimes, as
the words above suggest. It seems to me to be better to be thinking
about design all the time.
The code /is/ a model. The code is /the/ model. I find many ways of
thinking to be useful, cards, pictures, text. Of them all, I find
the code to be particularly useful, in the sense that it represents
what actually is.
I understand that it can be difficult to look at what is and think
about what ought to be. I would suggest that that's not some
inherent difference between "code" and "model", because there is no
inherent difference between "code" and "model".
What you have discovered, I suggest, is something about your own
mental skills, abilities, preferences, not something about the
universe. That's the good news. We can do something about ourselves,
adjusting and changing our skills. The universe seems not so ready
to accommodate.
For me, I find that more and more I can work in the code and get
from one design to another, often quite different (and often much
better). And I can think about the code / design / model in other
ways with my fingers still on the keyboard. That's useful, because
it tends to keep my program always working as its design improves.
And sometimes, I still like to take a few minutes and draw a
picture. I think that's about me, not about the reality of pictures
and code.
Ron Jeffries
www.XProgramming.com
Know what I pray for? The strength to change what I can, the inability to
accept what I can't and the incapacity to tell the difference. --Calvin and Hobbes
> But that to me also means: coding is not (!) designing - with regard
> to source code. Coding is translating a design for source code into
> source code.
Honestly, even if all you can do when writing code is translate an
existing design, that does not imply that is all that anyone can do.
Naturally the design we move to has to be in our head ... at least
somewhat. But for god's sake sit down with any good refactoring
person and watch what they do. They can evolve the design all over
without turning to some other form of "design".
Ron Jeffries
www.XProgramming.com
Ron gave me a good suggestion once. -- Carlton (banshee858)
> Hm... "no one is opposed to thinking" is not the reality in the shops
> I visit for consulting or when I participate in a coding dojo.
> Maybe there is no opposition to thinking before coding - but this does
> not show in the process of software development.
You are supposed to learn to think while you code. It seems that may
be the element that has eluded you so far.
> On a regular basis teams have a very hard time to not talk in terms of
> implementation details about a solution.
I don't have that difficulty. And I can talk about design by showing
code or by other means. So I know it is possible. You speak as if it
isn't. But it's not impossible if people can do it.
> They mostly lack shared concepts, methodology, and terminology to do
> other than code (and maybe draw a class diagram).
They, who? Some people you know? I'm not sure who "they" is in this
sentence.
Ron Jeffries
www.XProgramming.com
Knowledge must come through action;
you can have no test which is not fanciful,
save by trial. -- Sophocles
I use one in my courses that I haven't written up yet. Maybe I should.
Removing duplication leads to a structure emerging, then improving
names leads to moving responsibilities to more sensible places.
--
J. B. (Joe) Rainsberger :: http://www.jbrains.ca ::
http://blog.thecodewhisperer.com
Diaspar Software Services :: http://www.diasparsoftware.com
Author, JUnit Recipes
2005 Gordon Pask Award for contribution to Agile practice :: Agile
2010: Learn. Practice. Explore.
> I expect JB Reinsberger would point out that if you *really* do the
> "refactor to remove duplication" step, you will end up separating
> responsibilities. So yes, in fact you are right; when I'm facilitating a
> dojo I often have to point out that until you remove all duplication you
> should not write the next test.
In problems that want MVC-style solutions, I find that removing
duplication creates the classes to which reponsibilities will
eventually move, but improving names helps identify which
responsibilities should move where.
I don't find this pattern to match the definition of "multitasking".
0. Write out a list of things you might do.
1. Decide what to do next.
2. Do it. If, in the process, something jumps into your mind that
doesn't help with the current task, then write it down.
3. Go to 1.
I believe this is "Getting Things Done". It's also TDD.
> Hm... "no one is opposed to thinking" is not the reality in the shops
> I visit for consulting or when I participate in a coding dojo.
> Maybe there is no opposition to thinking before coding - but this does
> not show in the process of software development.
> On a regular basis teams have a very hard time to not talk in terms of
> implementation details about a solution.
> They mostly lack shared concepts, methodology, and terminology to do
> other than code (and maybe draw a class diagram).
This sounds really frustrating, Ralf, and I understand why it would
get you down. I recently spent time with a group of well-meaning
programmers whose code made it look like it was written in 2000, just
judging by their use of the language. In that situation, TDD seems
years away.
When I started practising test-first programming -- even before my
tests really drove my design -- I spent about 1 year before I felt
that I really began thinking of code in terms of input/output rather
than algorithms and implementation details. I spent that 1 year
practising an average of 4 hours/day. That means 1,000 hours of
practice. Do you think the teams with whom you consult consist of
people who have practised 1,000 hours yet?
It's not easy, it takes time, and we must have patience if we want to
see people improve.
> Yes, refactoring is an activity which does not add customer value by
> itself.
> It's definition says, you must not change functionality while
> refactoring.
>
> Thus refactoring should be avoided - unless it is necessary to make
> adding functionality aka customer value easier.
This sounds to me like saying "you should avoid exercise, unless it is
necessary for you to keep your metabolism efficient enough to burn
excess fat and avoid heart disease". While strictly true, the condition
is so close to universally true that stating it explicitly in most
contexts obscures the truth, rather than helps to reveal it.
I prefer to say "the point of exercise is to increase one's metabolic
efficiency in order to burn excess fat and avoid heart disease", which
is the same statement made in a way that doesn't risk misleading the reader.
Similarly, the point of refactoring is to simplify the design to reduce
the marginal cost of features and to stop the cost of delivering a given
feature from rising quickly over time.
Refactoring /done well and for a sensible purpose/ adds customer value
that most customers with whom I work have difficulty seeing and
therefore that I have learned to articulate clearly.
I don't know many things that, /not/ done well nor for a sensible
purpose, help a business realise more profit, so don't do any of those
things.
--
J. B. Rainsberger :: http://www.jbrains.ca ::
http://www.thecodewhisperer.com