TDD Survey 2017

TDD Survey 2017

I created a survey on TDD .

The aim was to uncover any patterns in usage, and discover issues that people face.

The survey was sent out via my personal twitter and facebook feeds. It was also sent the link out via codebar slack notifications and to brighton alt.net. The spread of developer experience was fairly mixed. However, it would have been good to add a section to the questionnaire to explore that.

Summary

The most popular opinions were:

  • I use TDD often at work. 42%
  • I find it useful, I wish we used it more. 61%
  • Best when developing a brand new project with no dependencies 8.2 / 10
  • When I code I write a test and then some code to make it pass, refactoring when it passes. 40%
  • It’s a bit slower for me to do TDD, but it saves time in the long term. 61%

 

Full results

The results from 36 responses:

 

1.When have you used TDD?

chrome_2017-06-23_09-47-45

Other:

  • For all production code and other more full-fledged code.

2.How do you rate TDD in general?

chrome_2017-06-23_09-53-26

3.How do you rate using TDD in the following scenarios?

chrome_2017-06-23_09-54-57

 

4.When you code, how do you generally check it works?

chrome_2017-06-23_10-00-24
Other:
  • it varies a great deal, depending on the problem I am trying to solve.
  • It depends on context and language. In Haskell, it’s not much required, but a few tests after the fact are appropriate. Usually, if it compiles, it works. In F#, sometimes test-first works best, but sometimes, again, test-after is better, because the trick is to get the code to compile. In C#, TDD is a must for me. I don’t trust C# without tests.

5.How much longer does it take you to use TDD?

chrome_2017-06-23_10-24-18

6.Describe your own experience of TDD in a few sentences

  • Makes solutions simpler and easier to maintain.
  • I like out side in aproach as it keeps you on things that are important. TDD is a different mindset. People only realise that when they are used to this approach.
  • I find TDD most useful for refactoring.
  • Sometimes it’s hard to do it in a legacy codebase
  • Safety, I know when I broke stuff. I can’t think of details upfront, I discover them as I test drive the code.
  • Ultimately TDD is one tool of many in developing – it’s gone a bit out of fashion with having much faster deployment cycled (with continuous deployment). Hugely useful in terms of documentation and confidence when refactoring, but the biggest curve is having to know what you want to build up front.
  • In my opinion, TDD helps you: – Make incremental progress by slicing things to smaller chunks – Write enough code than coding and keep on coding – Confidently refactor – Communicate the intent of the code, if tests are written well – Lastly, to capture regression issues and deliver confidently
  • I tend to refactor several times to get the types I want, and then add tests at the external interface of the API for cases where the types can’t “make illegal states unrepresentable”. TDD can in contrast be very useful when working with very dynamic data which is not easily described in the exact logic of a type system, such as refactoring legacy code (where the original intent has been lost!) or dealing with “messy” data such as parsing user input.
  • The more logic, the more helpful I find TDD.
  • I’ve found TDD (test-first, one test at a time, writing just enough implementation code to make the test pass, then refactor, then move on to the next test) particularly helpful when working alone, or as a documentation device (reading through a well-written test helps understand the intended functionality of the code). I’ve had some trouble being disciplined enough to apply the “refactor” part of the red-green-refactor cycle, as I’m usually impatient to move on to the next test. This way, refactoring work tends to pile up and become less manageable. Also, while I know that the cycle mentioned above should also include a fourth phase (refactor the *test code*), I rarely if ever do it, so the test code usually remains just how it was written. I also see a problem with tests that were useful during the TDD process itself (to help guide the implementation) but don’t add any value once the implementation is completed. Those tests should be removed, but here, again, I lack the discipline to do so. This can lead to a bloated, slower test suite. Finally, especially with a new language or framework or even a new dependency it can take quite some time before the TDD process feels fluid, i.e. before the test harness is set up properly, such that testing can occur after every tiny change, at the push of a button.
  • It makes you really think about your code.
  • useful but time consuming
  • It’s surprising just how fast I get lost and have seemingly unsolvable bugs when I write code without tests!
  • Its enormously useful for focusing my thoughts on defining the problem I’m trying to solve, on solving the problem and breaking up the problem into small chunks. It’s also very useful when adding new features, changing the code in some way and debugging.
  • I think it’s most useful when you have a specific goal in mind, and you have a good idea what your approach is going to be. If you’re implementing a new feature and have no idea at all how you’re going to do it, I think you’ll spend just as much time (if not more time) editing the initial tests you wrote than the time it took to implement the feature’s code
  • Useful in OOP. Not quite so much in statically-typed functional languages.
  • Good when you know the domain problem enough Can get in the way if not, I like to prototype first in this case
  • I really enjoy it when I do it, but find setting up suitable test data is often a blocker, and needs careful consideration. Often come across tests written by others that are brittle – meaning I end up taking longer to make changes as I have to fix those tests too.
  • Great
  • Reading about it makes me jealous and I want to use it in my job.
  • Very useful for bug fixes. Difficult to encourage others to use + needs to be part of team culture to work

Feedback

Thanks to all that contributed. Please find the survey here if you wish to add to it. Also, feel free to add comments below, perhaps on your interpretation of the results?

Advertisements
Posted in .Net, TDD | Leave a comment

Answers – Annual Geek Christmas Quiz – 2015

Here are the answers to the post from last week – Xmas Geek Quiz!

Films/Sci-Fi

  1. Luke Skywalker’s name was originally written as Luke Starkiller
  2. J.J. Abrams directed the latest Star Wars film
  3. Siths nearly always have red light sabers. 
  4. 2001 A space odyssey was released in 1968
  5. Blade runner was based the book ‘Do Androids Dream of Electric Sheep’
  6. Harry Potter’s Wand is 11 inches

Taglines – what was the film?

  1. In space no-one can hear you scream – Alien
  2. To boldly go where no man has gone before – Star Trek?
  3. An adventure 65 million years in the making. – Jurassic Park
  4. It’s Christmas Eve In L.A. And The Party Action’s About To Explode… On The Fortieth Floor! – Die Hard
  5. We’re all in it together – Brazil
  6. Nothing On Earth Could Come Between Them – Titanic

Computers

  1. EEPROM stands for Electronically Erasable Programmable Read Only Memory
  2. 12 principles in the Agile Manifesto
  3. FORTRAN stands for Formula Translating System
  4. COBOL stands for Common Object Business Oriented Language
  5. Oct 31 = Dec 25 (31 in base 8 corresponds with 25 base 10). The punchline to the geek joke ‘why do programmers get mixed up between Halloween and Xmas’
  6. Moore’s Law – the number of transistors (or the processing speed) in a computer circuit doubles every 2 years

Science

  1. The largest moon in the solar system is Ganymede
  2. The ISS travels at 5 miles per second, or 17,150 MPH
  3. Corn Flakes were invented as part of J. Kellog’s health regimen to prevent masturbation!
  4. up, down, strange, charm, top, and bottom are quarks
  5. The first law of thermodynamics states that heat energy cannot be created or destroyed. Also known as the principle of conservation of energy
  6. Tetris blocks are tetrominoes

People

  1. Ada Lovelace programmed Charles Babbage’s difference engine
  2. Tony Hoare’s ‘Billion Dollar Mistake’ was the Null Reference
  3. Kellogg and Rice invented the dynamic loudspeaker
  4. Cilla Black was 2015’s most googled term in the UK 
  5. The first Briton in Space was Helen Sharman in 1991
  6. Isaac Newton invented the cat flap?

Picture Round

What are the missing country codes?

Europa-1

1 JE

2 SE

3 AT

4 RO

5 BG

6 GI

Famous RegEx

what is it matching?

7) [ -~]

  • All printable ASCII characters

8) ^(.)(.)\2\1$

  • 4 letter palindromes – e.g. ABBA, NOON, BOOB

9) /^#?([a-f0-9]{6}|[a-f0-9]{3})$/

  • Hexadecimals e.g. #0031da- also HTML colour codes

10) /^<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)$/

  • HTML Tags

11) ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$

  • IP Addresses

12) \A(?:[a-z0-9!#$%&’*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&’*+/=?^_`{|}~-]+)*

 |  “(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]

     |  \\[\x01-\x09\x0b\x0c\x0e-\x7f])*”)

@ (?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?

 |  \[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}

      (?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:

         (?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]

         |  \\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])\z

  • Email addresses

Famous phycisists

(with their birth year) rearrange the letters

13) Beginners were here (1901) – Werner Heisenberg

14) A chairlady fame (1791) – Michael Faraday

15) Awaits on acne (1642)  – Isaac Newton

16) Nettle Binaries(1879) – Albert Einstein

17) I Urea crime (1867) – Marie Curie

18) I agile oil legal (1564) – Galileo Galilei

Famous monsters

Name the film

Monsters

19 Star Wars: Episode V – The Empire Strikes Back – (The wampa ice creature that attacked Luke)

20 The Thing – (the thing!)

21 Pan’s Labyrinth – (the pale man)

22 Clash of the Titans – (The Kraken)

23 Monsters, Inc – (Randall Boggs)

24 Beowulf  (The sea monster?)

Posted in Uncategorized | Leave a comment

Annual Geek Christmas Quiz – 2015

Films/Sci-Fi

  1. What was Luke Skywalker’s name in the original Star Wars screenplay?
  2. Who directed the latest Star Wars film – (The Force Awakens)?
  3. What colour are the Sith’s light sabers?
  4. What year was the film 2001 A space odyssey released?
  5. What was the name of the book, written by Philip K Dick, that Blade runner was based on?
  6. How long is Harry Potter’s Wand?

 

Taglines – what was the film?

  1. In space no-one can hear you scream
  2. To boldly go where no man has gone before
  3. An adventure 65 million years in the making.
  4. It’s Christmas Eve In L.A. And The Party Action’s About To Explode… On The Fortieth Floor!
  5. We’re all in it together
  6. Nothing On Earth Could Come Between Them

 

Computers

  1. What does EEPROM stand for?
  2. How many principles are in the Agile Manifesto?
  3. What does FORTRAN stand for?
  4. What does COBOL stand for?
  5. What is Oct 31 in Decimal?
  6. What is Moore’s Law?

 

Science

  1. What is the name of the largest moon in the solar system?
  2. How fast does the ISS travel
  3. Cornflakes were invented to cure what?
  4. up, down, strange, charm, top, and bottom – what are they all types of?
  5. What is the first law of thermodynamics?
  6. What are the blocks in Tetris known as?

 

People

  1. Who got into a ‘quagmire and botheration’ with mutable state when programming Charles Babbage’s difference engine
  2. What was Tony Hoare’s ‘Billion Dollar Mistake’?
  3. Kellogg and Rice invented what?
  4. What name was the most searched term in the UK in 2015 according to google
  5. Who was the first Briton in Space?
  6. Who invented the cat flap?

Picture Round

What are the missing country codes?

Europa-1

 

1

2

3

4

5

6

 

Famous RegEx

what is it matching?

 

7) [ -~]

 

8) ^(.)(.)\2\1$

 

9) /^#?([a-f0-9]{6}|[a-f0-9]{3})$/

 

10) /^<([a-z]+)([^<]+)*(?:>(.*)<\/\1>|\s+\/>)$/

 

11) ^(([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])\.){3}([0-9]|[1-9][0-9]|1[0-9]{2}|2[0-4][0-9]|25[0-5])$

 

12) \A(?:[a-z0-9!#$%&’*+/=?^_`{|}~-]+(?:\.[a-z0-9!#$%&’*+/=?^_`{|}~-]+)*

 |  “(?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21\x23-\x5b\x5d-\x7f]

     |  \\[\x01-\x09\x0b\x0c\x0e-\x7f])*”)

@ (?:(?:[a-z0-9](?:[a-z0-9-]*[a-z0-9])?\.)+[a-z0-9](?:[a-z0-9-]*[a-z0-9])?

 |  \[(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}

      (?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?|[a-z0-9-]*[a-z0-9]:

         (?:[\x01-\x08\x0b\x0c\x0e-\x1f\x21-\x5a\x53-\x7f]

         |  \\[\x01-\x09\x0b\x0c\x0e-\x7f])+)\])\z

 

Famous phycisists

(with their birth year) rearrange the letters

 

13) Beginners were here (1901)

14) A chairlady fame (1791)

15) Awaits on acne (1642)

16) Nettle Binaries(1879)

17) I Urea crime (1867)

18) I agile oil legal (1564)

 

Famous monsters

Name the film

Monsters

Posted in Uncategorized | 1 Comment

STEM Volunteering at Big Bang Fair 2015

So this year, I decided to apply to become a STEM ambassador. This is a scheme run  Brighton University to encourage those in industry to inspire the next generation into these subjects. The great thing about the STEM Net programme is that they do the DBS checks for you and can facilitate in organising attending events. They also can give advice and training.

My first opportunity came last week when I volunteered to help at the Big Bang Fair SE 2015 in Ardingly.

Big Bang Fair South East

The event was well attended by primary schools around the south east. It was the perfect day to get going and help with ushering and directing people around the showground. The kids absolutely loved every minute.

The exhibits and workshops were quite diverse. The Accelerator was a blow up structure which you run through and it measures your speed, it took a bit of setting up but was quite simple in the end. The Mary Rose table showed the physics of the ship and why it sank. There were fun stalls like Noisy toys, which showed how a current can produce sounds – even when applied through children! The part I showed children round had a brilliant science fiction show, some great workshops and a rocket science talk.

For anyone wanting to start with volunteering, even without much science knowledge, it’s a great thing to get into. Definitely Looking forward to helping again next year!

Posted in Uncategorized | Leave a comment

Brighton Codebar

Codebar is a Meetup group in Brighton, London and Cambridge for minorities in Tech. The idea is to make coding exciting for people who have not always been encouraged into tech before. The group is mainly for Women or LGBTQ people – those underrepresented in technology. Currently just one in 20 job applicants for new roles in IT are women so events like this and others are springing up to help redress the balance.

The group is every Tuesday evening in various locations. It’s totally free, very friendly and you even get pizza. It is staffed completely by volunteers and various companies give up their office space to host it. There are enough coaches to take you through the tutorials and give lots of advice on coding. Its social but also very useful training.

I was recommended it by a colleague who wondered if I’d be interested. Having worked in IT for quite a while, I was not sure if I should go in as student or coach. However I thought going as student would be a good first step for me as I had not had opportunity to play with javascript much before and I want to get a feel for the tutorials.

Each week I’ve gone I’ve had one-to-one coaching. The expert has sat back patiently not taking over the keyboard but helping explain the exercises and helping with coding. This works really well, coaches are encouraged to not take over and let the student make mistakes and work things out their own way. There is plenty of great advice to coaches such as – ‘assume that anyone you’re teaching has no knowledge but infinite intelligence’ I think many senior programmers would do well to follow this advice as a better way for interacting with new developers.

If you are interested in joining as a coach or student, you need to register on the codebar website. When you turn up, you do need a laptop with wifi connection, you can download the tutorials and get going straight away.

Posted in Uncategorized | Leave a comment

Netduino – 3. Making sounds

(A post I drafted a while ago. Thought I’d better update it!)

A piezo speaker or buzzer of the sort found in small toys and birthday cards can be powered and controlled by the netduino. They can be bought separately very cheaply. You can rip one out and connect it to an output port in series with a resistor.  A variable resistor (potentiometer) is ideal as you can use it as a volume control but for this example a 1k resistor is used.

Piezo speakers run with a small digital input and so are ideal for taking power from the netduino digital ports. By switching the current on and off very fast, the speaker vibrates. The sound produced by the speaker depends on the frequency the output is switched on and off. This is controlled with something called Pulse Width Modulation (PWM).  In our case, the value of the resistor determines the volume.

You will need to connect the speaker to the netduino. In order to create the circuit without soldering, you can use a small breadboard for this along with some leads. You can buy the leads themselves or make your own from an old cat5 cable sliced up. For this project, the negative lead (black) will run to ground terminal on the netduino and the positive lead (red)  runs in series with the resistor to a digital port with Pulse Width Modulation (PWM) enabled. These are ports x,x,x. I used digital port 5.

piezoschematic

Now some code to make a small sound. The code for playing frequencies is contained within the speaker class. The main program just plays a scale in a loop until we press the button to stop it.

On the netduino forums there is an example of this setup playing a variety of tunes through a piezo speaker. There’s some nicely written classes there for defining notes and frequencies and also a few recognisable tunes. You would need to piece together some of the code in the thread to make the example work.

http://forums.netduino.com/index.php?/topic/831-music-with-a-piezo-speaker/page__p__6044__hl__piezo__fromsearch__1#entry6044

Video tutorial here:

Update:

I have pushed the code for this on github and implemented the missing classes:

https://github.com/octoberclub/NetduinoDemo/tree/master/Netduino.PiezoTest2

Also changed the class below so it calculates the frequencies for the notes instead of hardcoding them into an Dictionary as in the original post


    using System;
    using Microsoft.SPOT;

    public static class NoteFrequencies
    {
        /// <summary>
        /// Static method to calculate the frequency of a note from its name and octave.
        /// </summary>
        /// <param name="octave">Octave number (0-7)</param>
        /// <param name="note">Note to be found: eg. F#, A, Bb</param>
        /// <returns></returns>
        public static float CalculateFrequency(int octave, string note)
        {
            string noteLC = note.ToLower();
            string[] notes = "c,c#,d,d#,e,f,f#,g,g#,a,a#,b".Split(',');

            // loop through each note until we find the index of the one we want        
            for (int n = 0; n < notes.Length; n++)
            {
                if (notes[n] == noteLC // frequency found for major and sharp notes
                    || (note.Length > 1 && noteLC[1] == 'b' && notes[n + 1][0] == noteLC[0])) // or flat of next note
                {
                    // Multiply initial note by 2 to the power (n / 12) to get correct frequency, 
                    //  (where n is the number of notes above the first note). 
                    //  Then mutiply that value by 2 to go up each octave
                    return (16.35f * (float)System.Math.Pow(2, (n / 12)))
                        * (float)System.Math.Pow(2, octave);
                }
            }
            throw new ArgumentException("No frequency found for note : " + note, note);
        }
    }
Posted in Netduino | Leave a comment

The power of the written word

Today, serendipitous events have conspired to help me start writing this blog again.

1) Losing myself in the minutiae of details, when really, I just want to appreciate the bigger picture and help other to do the same.

2) Realising that I have had perhaps the most educational year of my life in terms of working with like-minded & inspirational people and yet I have not blogged about my experience.

3) Reading these posts:

http://erlingwl.wordpress.com/2012/07/23/liberated-devs-dont-blog/

http://www.codinghorror.com/blog/2012/07/but-you-did-not-persuade-me.html

Like Erling, I have passion  for new technology. I often show it, but only in a instant and usually only in conversation or email. Perhaps I am liberated. Perhaps I don’t feel the need to publicise myself.  I often feel a little uncomfortable expressing a hard opinion particularly in public on the web. But I always get excited about technologies or new ideas and that passion should be shared.

If I wrote down some of the things I’m thinking, then perhaps I might come back to it in years to come. Perhaps others might understand where I am coming from. Perhaps I would also discover more about myself in the act of writing my thoughts

So, today marks a new era. I’m planning to start blogging again.

This is more a promise to myself than anything else, but in any case, here are some of the things I’d like to write more about soon:

  • NCrunch
  • Octopus Deploy
  • Approval Tests
  • Raspberry Pi
  • Netduino
  • Code Club
  • Git
  • TeamCity
  • IFTTT
  • RoundHousE database deploy
  • Fitnesse
  • Specflow
  • BDD
  • TDD
  • Approval Tests
  • Educational Software
  • NoSQL
  • AppHarbour
  • NUnit Action Attributes
  • Functional Programming
  • Pomodoro technique
  • UI Testing
  • Removing dead code
  • Logging
  • I’m sure there’s more….!
Posted in Uncategorized | Leave a comment