- [Instructor] There's a dark side to designing your code
to be super flexible and adaptive,
and that's premature optimization.
Okay, so that's all well and good,
but what exactly is premature optimization?
I like to think of it as the rabbit hole.
The deeper you go, the less likely you are to realize
you've lost sight of the immediate development goals.
Let's keep on going with our color palette analogy
from earlier videos.
If I was trying to think of a flexible way
to create one in code,
I'd start with storing my base colors
and I'd probably add some sort of conversion helper,
then I'd sit back
and being the curious programmer that I am,
I might start to think about
what I might need in the future.
Will I need to put in gradients at any point?
Well, yes, probably.
All right, so let's look at some documentation for that,
maybe some third-party libraries to make things go faster,
and start to flush out
the color palette class to incorporate,
and this is where you need to catch yourself.
Hopefully, you can see where I'm going with this.
I would be at the mouth of the rabbit hole,
about to jump in headfirst and not be seen for hours.
Avoid this like the plague. I'm not kidding.
Looking ahead is a great skill,
but time is your greatest asset
when you're working with Agile.
So be aware of the trade-offs between optimizing your code
and moving forward with sprint tasks.
It's not about solving every problem before it happens.
It's about having a foundation that is adaptable enough
to handle new problems and features as they come.