Up to Main Index Up to Journal for November, 2016 JOURNAL FOR SUNDAY 20TH NOVEMBER, 2016 ______________________________________________________________________________ SUBJECT: Buffer tests and more bug fixes ready DATE: Sun 20 Nov 22:31:33 GMT 2016 I finally realised why I was having so much trouble writing tests for buffers in WolfMUD. I was trying to look at the big picture and test against it. However, when you are testing and writing tests you need a very narrow view of things and not the big picture. Tests should be as small and as specifically targeted as possible. As a result, I have rewritten all of the buffer tests. At the end of the day has all of this effort been worth it though? I would have to say yes it has been worth it. Simply because testing has discovered not only some bugs but also highlighted a few design issues with some of the buffer methods. I've fixed an additional issue with Append not increasing the message count when it is issued before am initial Send. I've also fixed a corner case when a space was appended when it should not have been. I've reimplemented buffers.Silent and buffers.Len so that they are now usable. Before they were relying on the sequence of ranging over a map. But of course the sequence of elements returned when ranging over a map is deliberately random. Testing has also improved areas I was not even looking at yet. For example, I noticed an issue with state.messenger and an erroneous early bail out check. I also noticed that state.messenger was trying to send messages to more than just players, which resulted in wasted resources. I know writing tests is a good thing. I know that writing tests can seem to be a diversion of effort from the actual project. I'm glad to finally be writing tests for WolfMUD before too much more code is written. Previously I didn't write any tests because the code was evolving very quickly and it would have meant rewriting tests all the time. In hindsight was this a good call? I think it was because my ideas are now implemented in code and I have a sense of how I want things to work. I now have the big picture in place and testing is making sure everything works as intended. I still think some of the tests I have written are overly complex, but my testing seems to be improving. So I'll continue adding more tests, improving as I go. At some point I'll revisit the early tests with more experience and a more critical eye. When working on your own, in a void, the best you can do is go with your gut and experience. Good code is code that works. It may not be pretty, it may not be efficient, it may not be idiomatic. But if it doesn't work then it's no good to anyone. All of the tests and bug fixes are now available in the public dev branch. I'm currently thinking I'll do a v0.0.2 bug fix release at the end of November or start of December. Now, what shall I test next? Eeny, meeny, miny, moe... -- Diddymus Up to Main Index Up to Journal for November, 2016