Don't ask to ask, just ask | |
PerlMonks |
Re^3: [RFC] Review of module code and POD (TDD)by eyepopslikeamosquito (Archbishop) |
on Apr 01, 2021 at 01:09 UTC ( [id://11130654]=note: print w/replies, xml ) | Need Help?? |
Is it worth also trying to write tests for this - again for practice and learning - if so, where would I start?Before you write the module. :) The main point of TDD is that writing the tests first (or at least early) affects and improves the design of the module! Writing a test first forces you to focus on interface - from the point of view of the user. Hard to test code is often hard to use. Simpler interfaces are easier to test. Functions that are encapsulated and easy to test are easy to reuse. Components that are easy to mock are usually more flexible/extensible. Testing components in isolation ensures they can be understood in isolation and promotes low coupling/high cohesion. Implementing only what is required to pass your tests helps prevent over-engineering. To give a clearer picture of where I'm coming from, a quote from Ten Essential Development Practices:
See also: Re: Winning people over to better development practises (TDD) and On Interfaces and APIs
In Section
Meditations
|
|