WEBVTT

00:00:00.000 --> 00:00:02.860
When working as a developer, when

00:00:02.860 --> 00:00:07.140
writing code, there are certain principles

00:00:07.140 --> 00:00:09.600
you might want to keep in mind and

00:00:09.600 --> 00:00:10.040
follow.

00:00:10.440 --> 00:00:13.220
Something like the DRY principle, the

00:00:13.220 --> 00:00:17.100
don't repeat yourself principle, but also,

00:00:17.400 --> 00:00:20.820
for example, the KISS principle, the "Keep

00:00:20.820 --> 00:00:23.260
it simple, stupid!" principle.

00:00:23.880 --> 00:00:27.560
That's a principle I want to take a closer

00:00:27.560 --> 00:00:31.780
look at today, because it's fairly easy,

00:00:32.180 --> 00:00:34.380
especially if you're maybe a less

00:00:34.380 --> 00:00:37.660
experienced developer, to write

00:00:37.660 --> 00:00:40.500
unnecessarily complex code.

00:00:40.820 --> 00:00:43.820
And it's not just the code complexity, but

00:00:43.820 --> 00:00:46.440
I'll get back to other forms of

00:00:46.440 --> 00:00:48.580
unnecessary complexity later.

00:00:49.020 --> 00:00:51.300
Let's start with the code complexity.

00:00:52.160 --> 00:00:54.920
Especially if you're not that experienced,

00:00:55.040 --> 00:00:58.420
maybe, it can be quite tempting to

00:00:58.420 --> 00:01:01.100
introduce a lot of unnecessary

00:01:01.100 --> 00:01:03.960
abstractions in your code.

00:01:04.099 --> 00:01:07.020
It can be quite tempting to think, well,

00:01:07.320 --> 00:01:11.280
what if I also maybe need to use a

00:01:11.280 --> 00:01:15.040
certain function or a certain piece of the

00:01:15.040 --> 00:01:18.060
code base in a slightly different way in

00:01:18.060 --> 00:01:18.620
the future?

00:01:19.240 --> 00:01:22.300
And all of a sudden, you start making a

00:01:22.300 --> 00:01:25.400
function that did one specific thing in

00:01:25.400 --> 00:01:28.640
the past more generic so that it can do

00:01:28.640 --> 00:01:32.020
more things or accept more types of

00:01:32.020 --> 00:01:33.460
input and so on.

00:01:33.660 --> 00:01:36.160
So it can be quite tempting to make

00:01:36.160 --> 00:01:39.060
your code more flexible so that it can

00:01:39.060 --> 00:01:41.260
handle more use cases and your code

00:01:41.260 --> 00:01:43.460
base gets more modular and more

00:01:43.460 --> 00:01:43.840
generic.

00:01:44.280 --> 00:01:46.040
And that's a good thing, right?

00:01:46.200 --> 00:01:49.180
We want a modular and generic code

00:01:49.180 --> 00:01:49.580
base.

00:01:50.360 --> 00:01:52.520
Well, not necessarily.

00:01:53.180 --> 00:01:56.680
If you're writing some code for a

00:01:56.680 --> 00:01:59.780
package that you plan to distribute as a

00:01:59.780 --> 00:02:02.000
third party package to developers all

00:02:02.000 --> 00:02:04.860
over the world, then you might need

00:02:04.860 --> 00:02:08.600
some generic code or modular code.

00:02:08.860 --> 00:02:11.580
You might need to support a lot of

00:02:11.580 --> 00:02:12.580
different use cases.

00:02:12.700 --> 00:02:14.940
But even then, you might not need to

00:02:14.940 --> 00:02:17.980
support all the use cases you think you

00:02:17.980 --> 00:02:18.760
need to support.

00:02:19.300 --> 00:02:22.300
And especially if you're working on your

00:02:22.300 --> 00:02:23.260
own application.

00:02:23.640 --> 00:02:26.720
So if you're writing code for an app you

00:02:26.720 --> 00:02:30.000
built where you know what it should do,

00:02:30.720 --> 00:02:33.560
it really doesn't make a lot of sense to

00:02:34.019 --> 00:02:37.460
already think of all kinds of possible

00:02:37.460 --> 00:02:40.580
variations at the point of time where

00:02:40.580 --> 00:02:41.660
you're getting started.

00:02:42.020 --> 00:02:45.380
Sure, there always is a trade-off and if

00:02:45.380 --> 00:02:48.240
your code is too specific, you might

00:02:48.240 --> 00:02:51.700
spend a lot of time refactoring that code

00:02:51.700 --> 00:02:54.640
if you eventually need to support

00:02:54.640 --> 00:02:57.680
different use cases or if parts of that

00:02:57.600 --> 00:02:59.820
code need to get more flexible in the

00:02:59.820 --> 00:03:00.180
future.

00:03:00.660 --> 00:03:02.520
But on the other hand, if you write

00:03:02.520 --> 00:03:05.160
everything as generic and flexible and

00:03:05.160 --> 00:03:08.000
modular as possible right from the start,

00:03:08.620 --> 00:03:11.460
you spend a lot of time making your

00:03:11.460 --> 00:03:14.640
code base quite complex and that then

00:03:14.640 --> 00:03:18.120
can actually also lead to problems in the

00:03:18.120 --> 00:03:21.140
future because it's now maybe not so

00:03:21.140 --> 00:03:23.280
easy to use it in the way you want to use

00:03:23.280 --> 00:03:25.780
it because you made it very flexible and

00:03:25.780 --> 00:03:28.140
modular so you need to pass a lot of

00:03:28.140 --> 00:03:30.400
configuration parameters or stuff like

00:03:30.400 --> 00:03:30.680
that.

00:03:31.180 --> 00:03:33.900
So there actually is a trade-off here.

00:03:34.780 --> 00:03:37.700
Modularity and flexibility can make

00:03:37.700 --> 00:03:40.180
sense but it's not always what you

00:03:40.180 --> 00:03:41.040
should go for.

00:03:41.780 --> 00:03:46.060
And I guess you can kind of like draw a

00:03:46.060 --> 00:03:49.280
bell-shaped curve where on the left side

00:03:49.280 --> 00:03:51.600
of the bell where the curve is very flat,

00:03:52.120 --> 00:03:54.660
we have beginners who write very

00:03:54.660 --> 00:03:57.480
simple code that's not very flexible and

00:03:57.480 --> 00:04:00.040
modular because they don't know that

00:04:00.040 --> 00:04:02.360
they might need more modular code or

00:04:02.360 --> 00:04:04.480
they're not able to write more generic

00:04:04.480 --> 00:04:05.580
and flexible code.

00:04:06.020 --> 00:04:09.400
But then we go on top of that bell so we

00:04:09.400 --> 00:04:12.860
go up that curve if that curve depicts the

00:04:12.860 --> 00:04:15.320
complexity of the code base and we

00:04:15.320 --> 00:04:17.380
suddenly start writing pretty complex

00:04:17.380 --> 00:04:19.240
code because we feel smart about it

00:04:19.240 --> 00:04:21.839
because we write code that supports a

00:04:21.839 --> 00:04:23.660
lot of different use cases and input

00:04:23.660 --> 00:04:26.220
parameters and we suddenly end up

00:04:26.220 --> 00:04:30.540
with that very complex code base which

00:04:30.540 --> 00:04:32.720
we don't need for the project or which

00:04:32.720 --> 00:04:34.920
we might not need for the project we're

00:04:34.920 --> 00:04:37.820
working on and we introduce new

00:04:37.820 --> 00:04:40.660
problems along the way and of course if

00:04:40.660 --> 00:04:43.500
we write very complex code we also

00:04:43.520 --> 00:04:46.460
spend more time solving a specific

00:04:46.460 --> 00:04:48.740
problem because we don't just solve the

00:04:48.740 --> 00:04:50.780
problem but we also think of future

00:04:50.780 --> 00:04:52.680
problems which we also try to solve

00:04:52.680 --> 00:04:53.100
already.

00:04:53.420 --> 00:04:56.760
So it takes us more time to write the

00:04:56.760 --> 00:04:59.820
code to get a certain job done because

00:04:59.820 --> 00:05:03.140
we try to make that code as flexible and

00:05:03.140 --> 00:05:04.640
modular as possible.

00:05:05.360 --> 00:05:07.420
Well and then we go down that curve

00:05:07.420 --> 00:05:09.080
again as we get more experienced

00:05:09.360 --> 00:05:11.580
because as you get more experienced as

00:05:11.580 --> 00:05:15.100
a developer you learn that you might not

00:05:15.100 --> 00:05:17.980
need the most generic and flexible code

00:05:17.980 --> 00:05:19.700
base in all situations.

00:05:20.120 --> 00:05:23.200
That in a lot of situations and scenarios

00:05:23.200 --> 00:05:26.700
it's fine if you just write good code that

00:05:26.700 --> 00:05:29.760
solves a specific problem and doesn't try

00:05:29.760 --> 00:05:32.260
to solve all kinds of problems you might

00:05:32.260 --> 00:05:33.480
be facing in the future.

00:05:33.720 --> 00:05:36.940
If you then evolve your code base so that

00:05:36.940 --> 00:05:39.720
you need to solve another problem you

00:05:39.720 --> 00:05:42.580
can still make parts of your code more

00:05:42.580 --> 00:05:45.240
flexible and modular but even then you

00:05:45.240 --> 00:05:47.660
might just make it as modular and

00:05:47.660 --> 00:05:50.860
flexible as needed to solve the original

00:05:50.860 --> 00:05:53.120
problem and maybe now another new

00:05:53.120 --> 00:05:54.560
problem you need to solve.

00:05:54.820 --> 00:05:57.100
So even then you might not go down

00:05:57.100 --> 00:05:59.900
that route to make it as modular and as

00:05:59.900 --> 00:06:03.640
flexible as possible and that is a really

00:06:03.600 --> 00:06:06.800
important lesson to learn that you don't

00:06:06.800 --> 00:06:09.920
need to look smart when writing your

00:06:09.920 --> 00:06:12.880
code that you don't need to try to solve

00:06:12.880 --> 00:06:15.240
all possible kinds of problems with your

00:06:15.240 --> 00:06:18.040
code base and that instead it's often

00:06:18.040 --> 00:06:21.360
better to keep the code simple to keep

00:06:21.360 --> 00:06:24.500
the code base simple and by the way

00:06:24.500 --> 00:06:27.220
simple code does not mean bad code

00:06:27.220 --> 00:06:30.380
not in any way instead simple code

00:06:30.380 --> 00:06:32.920
means that your code solves a certain

00:06:32.960 --> 00:06:35.400
problem and it does that well and of

00:06:35.400 --> 00:06:37.900
course it also does that in a way that

00:06:37.900 --> 00:06:40.580
handles potential errors that might arise

00:06:40.580 --> 00:06:43.040
and so on but it's not getting

00:06:43.040 --> 00:06:46.620
unnecessarily complex and that is a skill

00:06:46.620 --> 00:06:49.240
that simply comes with experience.

00:06:49.740 --> 00:06:52.880
It is something you can learn by always

00:06:52.880 --> 00:06:55.360
questioning your code by always being

00:06:55.360 --> 00:06:59.540
critical and asking yourself do I need to

00:06:59.540 --> 00:07:02.220
make this code more generic more

00:07:02.220 --> 00:07:05.340
flexible or should I keep it simple is it

00:07:05.340 --> 00:07:07.740
simple enough does it do what it should

00:07:07.740 --> 00:07:11.140
do and does it do that well or am I trying

00:07:11.140 --> 00:07:15.340
to do more than I originally planned or is

00:07:15.340 --> 00:07:17.700
the code maybe not doing enough are

00:07:17.700 --> 00:07:19.980
there potential errors that might occur

00:07:19.980 --> 00:07:23.060
that I'm not handling you always have to

00:07:23.060 --> 00:07:25.520
question your code and of course it also

00:07:25.520 --> 00:07:28.400
helps if you're not working alone but in a

00:07:28.400 --> 00:07:30.740
team if you got a colleague or a friend

00:07:30.740 --> 00:07:33.440
who reviews your code and who gives

00:07:33.440 --> 00:07:37.400
you input on your code because there is

00:07:37.400 --> 00:07:39.880
the danger of writing bad code because

00:07:39.880 --> 00:07:43.720
it's too simple too focused on one

00:07:43.720 --> 00:07:46.260
specific problem maybe but in my

00:07:46.260 --> 00:07:48.200
opinion there is an even bigger danger

00:07:48.200 --> 00:07:51.220
of writing bad code because it becomes

00:07:51.220 --> 00:07:55.000
too complex because it tries to do too

00:07:55.000 --> 00:07:58.420
much now as I mentioned originally at

00:07:58.420 --> 00:08:00.540
the beginning here it's not just the

00:08:00.540 --> 00:08:02.780
complexity of the code base that

00:08:02.780 --> 00:08:06.400
matters and that you should keep an eye

00:08:06.400 --> 00:08:10.420
on it's also a complexity regarding the

00:08:10.420 --> 00:08:13.420
technologies you might use because for

00:08:13.420 --> 00:08:16.180
example if you're building a blog website

00:08:16.180 --> 00:08:19.140
your own personal website which should

00:08:19.140 --> 00:08:21.460
contain a blog where you plan on

00:08:21.460 --> 00:08:24.140
sharing some posts about your life or

00:08:24.140 --> 00:08:28.120
some tutorial posts whatever you could

00:08:28.120 --> 00:08:31.700
just create that blog with a content

00:08:31.700 --> 00:08:34.140
management system like wordpress you

00:08:34.140 --> 00:08:36.559
could also build it on your own of course

00:08:36.559 --> 00:08:40.280
with some static site generator with

00:08:40.280 --> 00:08:43.340
something like astro.js for example but

00:08:43.340 --> 00:08:46.280
you could also just build it as a node.js or

00:08:46.280 --> 00:08:50.540
php based website where you store your

00:08:50.540 --> 00:08:52.960
blog post data in a database and you

00:08:52.960 --> 00:08:57.040
render that as html documents then you

00:08:57.040 --> 00:08:58.980
could do all that and that would all be

00:08:58.980 --> 00:09:02.320
fine but you could also start building a

00:09:02.320 --> 00:09:04.800
complex application where you have a

00:09:04.800 --> 00:09:08.000
standalone react or angular or whatever

00:09:08.000 --> 00:09:10.880
single page application front end and

00:09:10.880 --> 00:09:14.580
then a rest api backend or a graph ql api

00:09:14.580 --> 00:09:17.180
doesn't matter you have some caching

00:09:17.180 --> 00:09:20.360
in between a caching layer you set up an

00:09:20.360 --> 00:09:22.920
extra database to which the backend

00:09:22.920 --> 00:09:26.120
communicates you start bringing in a

00:09:26.120 --> 00:09:29.540
ton of extra third-party libraries into both

00:09:29.540 --> 00:09:33.560
ends also in the front end to add lots of

00:09:33.560 --> 00:09:36.460
extra features that might not be too

00:09:36.460 --> 00:09:38.620
important for a blog but that you feel

00:09:38.620 --> 00:09:41.640
like you need to have then you start

00:09:41.640 --> 00:09:45.160
hosting that blog on aws and you want

00:09:45.160 --> 00:09:48.720
to do it with docker and containers and

00:09:48.720 --> 00:09:51.520
also in some kind of serverless way so

00:09:51.520 --> 00:09:53.680
you look into all the services you need to

00:09:53.680 --> 00:09:57.060
do to do that and so on you see what i

00:09:57.060 --> 00:10:00.220
mean you can build a simple blog in a

00:10:00.220 --> 00:10:03.540
pretty complex way and don't get me

00:10:03.540 --> 00:10:06.520
wrong you can do that it can be a great

00:10:06.520 --> 00:10:09.740
exercise if you want to get better at

00:10:09.740 --> 00:10:13.180
working with docker or with aws or react

00:10:13.180 --> 00:10:16.120
or whatever definitely start building

00:10:16.120 --> 00:10:19.020
demo projects build your blog that way

00:10:19.020 --> 00:10:22.680
but only do it if you do want to practice

00:10:22.680 --> 00:10:26.560
certain technologies or services don't

00:10:26.560 --> 00:10:29.280
start building your blog like this if you

00:10:29.280 --> 00:10:31.420
just want a blog if that's the main thing

00:10:31.420 --> 00:10:33.360
you want if you don't care about the

00:10:33.360 --> 00:10:35.920
exercise because you don't need that

00:10:35.920 --> 00:10:38.920
super complex text deck you don't need

00:10:38.920 --> 00:10:42.280
a super complex web application that

00:10:42.280 --> 00:10:45.100
consists of dozens of technologies and

00:10:45.100 --> 00:10:48.540
libraries and frameworks and so on just

00:10:48.540 --> 00:10:51.140
to render some blog posts onto the

00:10:51.140 --> 00:10:54.180
screen of your website visitors you don't

00:10:54.180 --> 00:10:58.000
need that so here again keep it simple

00:10:58.360 --> 00:11:01.440
don't introduce all those libraries and

00:11:01.440 --> 00:11:03.740
packages because you read somewhere

00:11:03.740 --> 00:11:07.060
that you need to use them instead keep

00:11:07.060 --> 00:11:10.140
it simple use the simplest possible

00:11:10.140 --> 00:11:13.000
solution for achieving the goal you want

00:11:13.000 --> 00:11:16.200
to achieve unless as mentioned you

00:11:16.200 --> 00:11:18.260
want to practice working with those

00:11:18.260 --> 00:11:20.340
technologies because then of course

00:11:20.340 --> 00:11:24.240
your goal also isn't to render blog posts

00:11:24.240 --> 00:11:26.620
onto the screens of your visitors or at

00:11:26.620 --> 00:11:28.600
least that's not the primary goal then

00:11:28.600 --> 00:11:30.920
but the goal then is to learn and grow

00:11:30.920 --> 00:11:33.560
and then it's of course absolutely fine

00:11:33.560 --> 00:11:36.540
and the right thing to do to work with all

00:11:36.540 --> 00:11:38.460
those packages and services and

00:11:38.460 --> 00:11:40.880
technologies and so on so then

00:11:40.880 --> 00:11:43.420
definitely do it but if your goal is

00:11:43.420 --> 00:11:45.680
something else if your goal is the end

00:11:45.680 --> 00:11:48.800
product the blog or whatever it is then

00:11:48.800 --> 00:11:51.400
you should keep your tech stack simple

00:11:51.400 --> 00:11:53.580
because in that case if you would make

00:11:53.580 --> 00:11:56.520
it unnecessarily complex you would just

00:11:56.520 --> 00:11:59.340
spend more time unnecessarily on

00:11:59.340 --> 00:12:01.600
working on that project and you would

00:12:01.600 --> 00:12:03.880
also make it harder to maintain because

00:12:03.880 --> 00:12:06.120
if you come back to a super complex

00:12:06.120 --> 00:12:09.260
project in the future it simply takes you

00:12:09.260 --> 00:12:11.940
longer to get back into it and that's the

00:12:11.940 --> 00:12:14.600
case no matter if we are talking about a

00:12:14.600 --> 00:12:17.340
complex tech stack or if we're talking

00:12:17.340 --> 00:12:20.620
about a complex code base so therefore

00:12:20.620 --> 00:12:24.080
in a nutshell keep it simple and don't

00:12:24.080 --> 00:12:27.680
think that it's smart or a sign of

00:12:27.680 --> 00:12:31.100
intelligence to use complex technologies

00:12:31.100 --> 00:12:36.100
or to write complex code it's actually the

00:12:36.100 --> 00:12:39.940
opposite a good developer uses the best

00:12:39.940 --> 00:12:43.800
and simplest code or tool to get a job

00:12:43.800 --> 00:12:47.400
done without doing that job in a bad

00:12:47.400 --> 00:12:50.980
way so without ignoring important

00:12:51.679 --> 00:12:53.480
features the code should have or

00:12:53.480 --> 00:12:55.420
something like that but adding

00:12:55.420 --> 00:12:58.320
unnecessary complexity it's not

00:12:58.320 --> 00:12:59.240
something you want to do