TDD for those who don't need it - GopherCon SG 2017

Video Statistics and Information

Video
Captions Word Cloud
Reddit Comments
Captions
so of course I don't need TDD right okay pyat can people stretch a bit please after lunch thank you good okay so I'll start with a public service announcement that people who don't write tests write good code also everyone in this room is in the blue circle right the only difference is whether you are blue with a bit of green or blue with a bit of brown so I don't like the TDD community at all I come from the Ruby community and honestly TDD community is a bit suffocating and they do this right yeah yeah you see the same way yes thank you so they are irritating the shame people the most of all they don't have your date line right you don't have different and they then they'll tell you to come to your desk and say you don't write tests but let's give you confidence to refactor I don't have a confidence problem with it helps you write better design API my API is well designed thank you very much so the documentation I have documentation my commit code is awesome right and this one I like this under death untested code is legacy code untested test is like a sequel to okay so but don't listen to me right so what else what does God say once a regression testing what is that okay if it compile is good if we boots up it's perfect okay so TDD community do not understand that we can say we like including you guys we put two we agonize a refactor we write out good comments messages we link github issues to pull request to pivotal tracking all sorts of things so whatever they say about tests all these things I have another principle which is good and it's called you ain't going to need it right so then don't do it and these are actually not my problems when I code these are these are my problems the other God said that he gets paid for code that works not so test so the common thing between me and this other God is that we want to get done oh I said the word sorry okay we want to get things done okay what is getting things done mean it means two things speed it up you get something good to be done and then you do it very simple test is not inside here okay so so to break that down a bit ball this is requirement and that's machinery machinery make things happen okay this is this is the the easy part the technical knowledge you learn you read the docs you 10,000 hours of YouTube videos you watch it you can good at it right and then the other part is requirements is where constipation happens did not this is the problem because a requirement even if it comes from yourself or you are the startup founder what you want to do can be very hand wavy changes from time to time hey Google just launched this or them switch to another product or things like that so this is the problem the requirements so far so good good yes if you don't agree with me and maybe you shake your head or something so so with this background where I don't like the TDD folks and stuff I did go for interesting job interview and they require me to do pair programming for half a day doing TDD sounds good right but I did leave the interview being pleasantly surprised how I liked it I had so there's a bit of cognitive dissonance why do I like it I don't like this thing right but I actually enjoyed the interview it's very nice I couldn't explain it to myself took me a while until I hit my ten thousand video that I watched when I learned this ryan bates he was talking about something and he just had a throwaway comment this is not the main point of this video but you just had made this comment which made me do the rewinding that is against thing so I really like this approach of testing it just walks you through what's next step I have to do to get it working notice that there's no benefits of test here it's not about refactoring and getting about the design this is essentially about getting things done approach to next step to get it working say hey this speaks to me although the benefit doesn't speak to me I never write tests before I did back driven development it was about I thought about so but this speaks to me is I okay I get it this is interesting so if you look at the machinery and requirements again machinery make sure happen we know that for what your screen cast muster your tools we can solve this requirements harder to solve right and if it's Henry we just just write it down but what's better than writing it down in English is write it in code and performance change because suddenly this guy launched a new product you have to change direction your startup is that again so what do you do with changing requirements you version control it version control code requirement sounds a bit familiar now right this is actually text by the way so this is how I imagine it I don't I don't play golf this is my imagination of golf but there is a requirement you plant a flag right there and then you plant the flag before you even reach for your machinery to do it right and then you choose maybe a tree root for this one and then the mechanism delivers towards your firm should that that sales guy come and change your requirement then it's okay it's okay just move the flag remove the flag and then work your mechanism toward it again okay so back to the job interview so what did we do in the half-day of TDD the this is actually very menial code digit we're working on the production system doing some stuff but let's think through what we are doing if we were doing it normally but how we are doing it normally right so first you the point is to change let the user changes email address sends the email and confirms the link so you will create a change email page and open up browser login there you let him change oh it is an error maybe I should throw an error reload again and then you change it okay good send it oh my email should have a link bottom to click on and then do it again and then copy the link put in your browser or now I need the new endpoint to handle this change email confirmation ok handle it and then I need to set my email address to the new one set it ok after reloading your browser for like 20 times hey you got it working or did you not sure okay and maybe a few more times right so that's what we do by work then I deploy to production and that's for ah how you usually do it last time but now I do it in TDD man so how do I do in gdb manner even simpler hey some code ok so there's nothing on this side and you have test and go makes it super simple by putting things side by side with underscore test so just go ahead and describe how what do I need I need all email address and your new email address and I have some error that expect and then you have the boilerplate to look through the scenarios I didn't this is how I actually do it so I don't bother to put the scenarios first putting on my inputs and outputs and ok I'm going to look through all of them and I'll set up the scenario first I have a user with email address and then I'm going to handle this change email address request just about by the way by doesn't matter next I expect the error message to match the error message in my scenario in the table above fine and then I would like to check that I actually send the email to the correct person and not his old email address then I verify that the database but we have just sent the email out so we verify that the email in the database is still the old one and that there's a link that I can visit after visiting the link a check that the email address and database has changed all this code is all error by the way there's nothing on this side right all errors and then our thing about scenario ok maybe I have a full change too and then I have a full change so wrong and maybe I should get the error message and yeah okay add one more full change to a fool and different orbit and I'm done right perfect and you run it or you get cool yeah so at this point we like our sucks but no this is actually good news because you once you get this thing you can go for lunch right this is if you do not know the getting things done tip of the day always leave unfinished works closer laptop go home and then in the next morning when you come back open your laptop you know exactly where you left off yeah yeah it's good so so you can go for your ramen blah blah blah you talk about things and hahaha come back I need to write a function that gets an address from a man as I'm writing the function the whole requirements coming back to my head I'm loading the spec in a different goal routine and I'm writing my coding guru team right so and then as I'm doing it half way I unless I fix that fix that problem and in pager Duty rings Oh what was going on all the building that you're in has a fire drill oh if you are like me when I was working at home and the baby cries in the next door then you have to drop everything and go and you go and you lose track oh where am I that's your problem I don't have the problem because I can go back and look at this Eric all right so the next thing address from DB or visit lingual I just have to solve the next thing so it's very simple is the next thing the next thing the next in the next thing if someone calls change requirement next week next week next week next week is very simple and then you get a nice green puffs chip through whatsit pass path means you are done and this one is inspired by yesterday's workshop pass beam is done and famous fictional character sit before you solve one problem and then you solve the next and then you solve the next and when you solve enough problems you get to go home I like this one I didn't use this photo because I don't know about copyrights so this is a relatively short hop so the point to the title is TDD for people who don't need it so it may be you it may be a colleague or you have been triangle maybe they're TDD folks hiding here but there's failed to spread the gospel why is this guy not listening to me they still don't write tests so what I'm trying to say is that don't talk about the benefit of test talk about getting things done the person you're talking to probably cares about code more than you right and for those who are maybe coming around maybe I should check this thing out don't worry get it just get started don't be distracted by this one trick okay don't worry about testing it right don't worry about testing all the things don't worry about throwing away code don't worry about which test library to use by the way and go don't use any the standard libraries awesome which I'm not sure a software actually actually I don't know and I don't care the most important thing is that you should just stop writing code right yeah Jif works okay so the end thank you any questions or objections everybody be cool
Info
Channel: Singapore Gophers
Views: 36,538
Rating: 4.907032 out of 5
Keywords: go lang, programming
Id: a6oP24CSdUg
Channel Id: undefined
Length: 13min 43sec (823 seconds)
Published: Mon May 29 2017
Related Videos
Note
Please note that this website is currently a work in progress! Lots of interesting data and statistics to come.