00:00:00
famously Kent Beck has said I'm not a
00:00:04
great
00:00:04
programmer I'm just a good programmer
00:00:07
with great habits now Kent Beck actually
00:00:11
is a great programmer but his point is
00:00:14
that the way you write code when you're
00:00:16
stressed or tired or overwhelmed is a
00:00:19
measure of how good a programmer you
00:00:21
actually are and habits are those
00:00:24
behaviors that you fall back on when you
00:00:26
need to conserve mental energy like when
00:00:28
you're stressed
00:00:30
code Carters help you to improve your
00:00:33
habits so this video is about the best
00:00:36
code Carters that will help you to
00:00:38
become a great
00:00:44
[Music]
00:00:47
programmer hi I'm Emily B I'm a software
00:00:50
developer and creator of saman coaching
00:00:53
welcome to the modern software
00:00:55
engineering Channel where you can find
00:00:57
worldclass advice on the tech technical
00:01:00
aspects of software engineering how to
00:01:02
build software using modern approaches
00:01:05
and wider commentary on our industry
00:01:08
good developer habits include taking
00:01:11
small safe steps running tests often and
00:01:15
being suspicious of your own ability to
00:01:17
write Flawless code coding as a process
00:01:21
involves hundreds of minute-by-minute
00:01:23
decisions about how to spend your time
00:01:25
and attention and habits are your
00:01:28
default decisions should I write another
00:01:30
line of code should I run the test
00:01:32
should I tidy up the design the choices
00:01:35
you make will directly affect how good
00:01:38
your code is you will still need to make
00:01:41
good decisions even when you're stressed
00:01:44
and that's when you fall back onto your
00:01:47
habits code Carters are interesting
00:01:51
problems to solve yet they're simple
00:01:54
simple enough that it doesn't take all
00:01:55
of your brain power just to get to a
00:01:57
solution which means you've got some
00:02:00
capacity left to think at this meta
00:02:02
level about the way you're working and
00:02:04
what your habits actually are and then
00:02:07
of course you do a code Carter
00:02:09
repeatedly and deliberately to build up
00:02:12
new
00:02:14
habits I first learned about code
00:02:16
Carters from Dave Thomas he's one of the
00:02:19
pragmatic programmers he's written lots
00:02:21
of books and he's one of the signatories
00:02:23
of the agile
00:02:25
Manifesto so he got the idea when he was
00:02:28
watching his son practice karate they
00:02:31
were doing these Carter exercises where
00:02:33
they they train moves all together with
00:02:36
the whole class doing the same
00:02:38
thing Dave Thomas thought about how
00:02:41
programmers train or mostly don't and he
00:02:45
realized that we could do with some of
00:02:47
this disciplined practice away from
00:02:50
production
00:02:51
code at the time I was fairly Junior as
00:02:54
a developer I was just learning about
00:02:56
unit testing and test driven development
00:02:59
I was was very keen to improve so I
00:03:02
began to work through some of these code
00:03:04
Carters and looking at solutions to them
00:03:07
I found on the internets by other people
00:03:10
and I realized that studying like this
00:03:12
actually helped me a lot to rapidly
00:03:14
improve my skills for Designing new code
00:03:17
and tests so I'm a huge fan I've been
00:03:21
using these exercises personally for
00:03:24
more than 20 years at this point and I
00:03:27
still get value from practicing
00:03:30
let me help you to find a good code
00:03:32
Carter for your situation and I'm also
00:03:35
going to tell you about a common
00:03:37
situation where code Carters do not help
00:03:41
at
00:03:43
all we'd like to thank our Channel
00:03:45
sponsors who help to support this
00:03:47
Channel and bring you excellent free
00:03:49
content equal experts transic tupal and
00:03:54
honeycomb please do check out their
00:03:56
links in the description of this video
00:04:00
most developers spend a lot of time
00:04:02
building new functionality in complex
00:04:05
systems and the best approach in my
00:04:07
opinion is to use test driven
00:04:09
development if that's not yet your
00:04:12
default style you'll want to build some
00:04:14
habits so it will become your default
00:04:17
style and that means habits like running
00:04:19
the tests often building functionality
00:04:22
in small slices test by test and code
00:04:25
Cutters can really help you to learn to
00:04:27
do that there are loads of descriptions
00:04:31
of code Cutters all around the internet
00:04:33
but I suggest you start on the saman
00:04:35
Society website saman coaching. org and
00:04:39
if you've never done a code cartter
00:04:41
before I recommend you start with one of
00:04:43
the simplest ones leap years or
00:04:46
fizzbuzz so here you can see you get a
00:04:48
description of the functionality you're
00:04:50
supposed to build and some examples of
00:04:53
the expected
00:04:55
results don't be put off by just how
00:04:57
small these problems are the challenge
00:05:00
is not actually to solve the problem and
00:05:02
write the code the challenge is to solve
00:05:04
it using test driven development you're
00:05:06
trying to make that way of working feel
00:05:09
normal so when you can do leap years and
00:05:12
fizzbuzz really smoothly I suggest you
00:05:15
then go on to tennis or Christmas song
00:05:19
or file name range they're only a little
00:05:22
bit more complex than fizzbuzz and leap
00:05:25
year there's a bit more logic bit more
00:05:27
sophisticated output you might need to
00:05:29
designed several different functions to
00:05:31
complete and you'll need to use some
00:05:33
more different aspects of test and
00:05:35
development in your
00:05:37
solution if you head over to my other
00:05:39
YouTube channel I've recently put out a
00:05:41
video demonstrating the Christmas song
00:05:44
and I go through some of the most
00:05:45
important heris in test driven
00:05:48
development for a slightly harder Carter
00:05:51
I would suggest trying Mars Rover or
00:05:56
yatsi or fractions
00:05:59
or Monty
00:06:02
Hall so pick one of those try the one
00:06:05
with the backstory that appeals to you
00:06:07
most you fancy exploring Mars playing
00:06:10
dice games mathematics or a game show
00:06:14
dilemma all of those Carters are
00:06:16
slightly more challenging you'll need
00:06:18
more code more structure and although
00:06:21
they're all self-contained problems they
00:06:23
are fun to solve and you'll want to try
00:06:25
them more than once with different
00:06:27
designs using test driven development
00:06:31
because that's what you need to do you
00:06:32
need to repeat the same Carter more than
00:06:35
once because you're training the habits
00:06:37
for developing new code with test driven
00:06:39
development habits come from
00:06:42
repetition you'll need to remember to
00:06:44
run the test often use the test to drive
00:06:47
the design and it's it's a bit like
00:06:49
musicians use scales and they play udes
00:06:52
throughout their career actually not
00:06:55
because they want to perform those
00:06:57
things but to make those things smoo and
00:06:59
when they come to a
00:07:01
performance all of the code Carters that
00:07:03
I've mentioned so far are for training
00:07:06
new development skills there's a whole
00:07:08
class of code Carters designed to help
00:07:10
you to train refactoring
00:07:13
skills I've got loads of those and I'm
00:07:15
going to talk about them in a future
00:07:17
video because it's a big topic and
00:07:19
they're also really fun and useful but
00:07:21
they deserve their own
00:07:24
video I'll get to when code Carters
00:07:27
don't help in a moment but first Beyond
00:07:30
pure coding skills a well-rounded
00:07:32
developer also needs to be able to
00:07:34
design
00:07:36
collaboratively hair programming
00:07:38
Ensemble these are important skills in
00:07:41
their own right and code Carters can be
00:07:44
really useful for training them by
00:07:46
working together with others on a
00:07:49
straightforward constrained problem
00:07:51
well- defined requirements you free up
00:07:54
more of your brain power for thinking
00:07:56
about how you're communicating with the
00:07:58
other people when you're choosing to
00:08:00
speak how often you're rotating the
00:08:01
roles and what else you can do to
00:08:04
improve your
00:08:05
collaboration if you've never done
00:08:07
Ensemble coding before I recommend start
00:08:10
with a relatively small code Carter like
00:08:14
calc stats or shopping
00:08:17
basket put all of that Focus you can
00:08:20
onto the people and the interactions
00:08:23
rather than trying to understand a
00:08:24
difficult domain and solve a different
00:08:26
difficult coding
00:08:27
problem I mentioned earlier there is a
00:08:30
common situation where code Cutters
00:08:33
don't help and I'm talking about when
00:08:35
you want to learn how to use AI coding
00:08:38
assistants like co-pilot or chat
00:08:41
GPT using these tools well definitely a
00:08:45
skill but you do not want to use code
00:08:47
Carters to train it if you ask an AI
00:08:50
tool to implement a code Carter like
00:08:52
fizzbuzz they do the entire thing
00:08:55
immediately and get it right one step
00:08:57
and you're done which is not not a
00:08:59
useful way to do a code Carter the whole
00:09:01
point is to practice taking small safe
00:09:04
steps not this giant leap code Carters
00:09:07
are not a good way to learn about what
00:09:09
generative AI tools are capable of
00:09:12
either people usually upload their
00:09:14
solutions to a Carter to a public
00:09:16
hosting service like GitHub or gitlab
00:09:19
and large language models have been
00:09:21
trained on all of that code so they'll
00:09:24
have seen hundreds of Solutions in the
00:09:27
training data and it is well known that
00:09:30
large language models are more capable
00:09:32
in situations that are better
00:09:34
represented in their training data you
00:09:36
may be aware they are generally better
00:09:38
at Python and JavaScript than less
00:09:40
common languages like rust or
00:09:43
Haskell your AI coding assistant is not
00:09:47
likely to behave the same way in a code
00:09:49
Carter as they will in your close Source
00:09:52
proprietary production code so you could
00:09:55
use a gen assistant to do a code Carter
00:09:58
easily and think that you're perhaps
00:10:00
learning about how to write really good
00:10:02
prompts and get the best solutions from
00:10:04
it but I think you're just fooling
00:10:07
yourself my advice is when you're
00:10:09
training coding habits with a code cter
00:10:12
go to your IDE settings and just turn
00:10:15
off your coding assistant instead work
00:10:18
on learning great habits with your
00:10:21
old-fashioned deterministic tools and
00:10:24
then when you get back to your
00:10:25
production code and you turn the AI tool
00:10:27
back on you get get a
00:10:30
bonus if you carry on with your new
00:10:33
habits working in small steps doing test
00:10:35
dur development slicing up the problem
00:10:37
with tests I think you'll find that the
00:10:40
generative AI tool will give you more
00:10:43
help because you'll be asking it to
00:10:45
solve a series of smaller problems which
00:10:48
I think is a better workflow for both
00:10:51
your brain and the AI tool one more
00:10:54
thing I've written a short guide to code
00:10:57
Cutters for learning test driven
00:10:58
development with lots more ideas and
00:11:01
advice follow the link to get your free
00:11:03
copy I hope that you will give code
00:11:06
Carters a try and become a great
00:11:08
programmer like Kent Beck there are
00:11:11
plenty of Carter descriptions on the
00:11:13
saman Society website plus we have a
00:11:16
newsletter and events that you can come
00:11:17
along to you could also consider
00:11:20
supporting us through patreon there's
00:11:22
one for both this Channel and I have my
00:11:24
own as well there are almost no
00:11:27
downsides to repeating a code Carter
00:11:29
that you've done before the second or
00:11:31
the third time you already know
00:11:33
basically how to solve it which frees up
00:11:36
more of your brain capacity for working
00:11:38
on the way that you solve it which is
00:11:41
the important part the only time it
00:11:44
could be bad to do a Carter again is
00:11:46
when you've done it so many times you've
00:11:48
got bored with it and then there are
00:11:51
plenty more code Carters to choose from
00:11:54
Happy coding
00:11:58
[Music]