• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Tim Cooke
  • Campbell Ritchie
  • Ron McLeod
  • Junilu Lacar
  • Liutauras Vilda
Sheriffs:
  • Paul Clapham
  • Jeanne Boyarsky
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
Bartenders:
  • Jesse Duncan
  • Frits Walraven
  • Mikalai Zaikin

Test Driven Development and UML

 
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Does UML modelling normally happen before or during Test Driven Development ?
Would the path to follow be :
Good OO Design with UML notation of that Design ----> Test ----> Code.
OR
Test ----> Good OO Design with UML notation of that Design ----> Code.

regards
[ September 10, 2003: Message edited by: HS Thomas ]
 
Ranch Hand
Posts: 8944
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
UML->CODE->TEST
 
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Or...
1) Write a test
2) Draw UML (design/refactor a solution)
3) Write code
4) Run test
5) Loop 2-4 until test is passed and you can start over from 1
 
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Pradeep Bhat:
UML->CODE->TEST


Well, that's certainly *not* Test Driven Development! In TDD, both the code and the design are driven by writing unit tests. It's also called Test-First Development.
 
HS Thomas
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator


1) Write a test
2) Draw UML (design/refactor a solution)
3) Write code
4) Run test
5) Loop 2-4 until test is passed and you can start over from 1


Can practices in writing the test guide you towards Good OO ?
regards
 
Lasse Koskela
author
Posts: 11962
5
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Can practices in writing the test guide you towards Good OO?


Writing the test first helps achieving a good design by telling you how the client code wants to access the not-yet-implemented functionality. On the other hand, the test-first thinking often drives your implementation towards a more test-friendly, clear structure.
 
Pradeep bhatt
Ranch Hand
Posts: 8944
Firefox Browser Spring Java
 
Pradeep bhatt
Ranch Hand
Posts: 8944
Firefox Browser Spring Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
https://coderanch.com/t/98351/patterns/TDD-starting-OO
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by HS Thomas:
Does UML modelling normally happen before or during Test Driven Development?


Actually, both.
Imagine an Iteration Planning Meeting:
A: OK, I will do Foo this iteration.
C: How long do you think it will take?
A: I guess I will have to implement a Fabulator to put into the Zork. It's a little bit tricky...
B: Why don't you just tork the Zork with the existing Tofbul?
A: ???
B: (goes to the whiteboard and sketches a collaboration diagram) See, the Zork already has an Uglo (scribble) so if you just get the Tofbul from the Brot (scribble), and tork it...?
A: Of course - why didn't I think of it. Make that a 1, then...
Now imagine some days later, A starts to pair with D:
D: OK, I still remember the diagram from B roughly, so let's just start!
A: Wait a moment - do we really have to zork the Zork?
D: I am not sure - let's start writing a test and see what happens.
[a few tests later]
D: Ah, I think no I see what you mean. (gets pen and paper) Let's see - we currently have this (scribble), so if we just let the Uglo know about the Brot (scribble)...?
A: Yes, that is what I was thinking! Let's see how it works out.
Did that help?
 
Ilja Preuss
author
Posts: 14112
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Lasse Koskela:

Writing the test first helps achieving a good design by telling you how the client code wants to access the not-yet-implemented functionality. On the other hand, the test-first thinking often drives your implementation towards a more test-friendly, clear structure.


And test-friendly actually means well decoupled - a tightly coupled systems is horribly hard to unit test!
 
HS Thomas
Ranch Hand
Posts: 3404
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Did that help?


jIyaj . majQa' . - I understand. Well done!
(HTML now includes a Klingon LANG code,prefixed by x- to indicate it's an experimental language.)
That aside, it is a good example.
At the Iteration planning meeting , you have allocated tasks, scheduled the task , first cut design in UML.
D and A Pair programming days later, D has agilely obtained the UML diagram from B. I suspect D has already started thinking about the tests because he pre-empts A with his comment to start testing first before they waste any time re-modelling the UML.
A lets him get on with it because he knows D likes to code. D realises A's doubts (not only is he a fast coder he is a fast learner) and let's A take control again.
Done and dusted in a matter of minutes.
Cool example, Illja.
regards
[ September 10, 2003: Message edited by: HS Thomas ]
 
Author
Posts: 76
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
UML and TDD are both tools. They have no implied order. I often start with tests, and then break out and do some UML. Sometimes I don't do any UML at all. Other times I will scratch some UML before writing tests. It all depends upon my mood, and my understanding (or lack thereof) of the system I am writing.
Don't look for good software engineering practices in the order of those practices. Look for it in the intelligent use of those practices. Like the song said: "Every hand is a winner, and every hand a loser." So it is with practices. It's not in the hand, it in the way the hand is played.
 
author & internet detective
Posts: 41147
848
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I agree that there is no set order. We have used UML for the high level/architectual design. This sets the API. Then, I would use TDD to actually develop the functionality.
reply
    Bookmark Topic Watch Topic
  • New Topic