3 TDD Techniques Most People Don’t Know

  Рет қаралды 1,399

Gui Ferreira

Gui Ferreira

Күн бұрын

⭐️ Use the coupon code GUITDD to get a 20% discount course on my new TDD course: dometrain.com/course/from-zer...
There are 3 techniques to get you from Red to Green on Test Driven Development (TDD). In this video, I apply all of them to the same problem, so you can see how to use them.
💎 Be a Patreon to get the source code: / gsferreira
🚨 KEY LINKS
🤝 Support me on Patreon (and get access to source code) here: / gsferreira
👋 HEY FRIEND
If you're new to my Channel, my name is Guilherme, but you can call me Gui if Portuguese pronunciation is not your thing.
I see myself as a Minimalist Software Craftsman. That says a lot of what I talk about here.
So, why this KZfaq channel? To share with you to simplify your life as a Developer through knowledge, technology, and practices.
If you are into those things as I do, don't forget to subscribe for new videos.
🔗 GET IN TOUCH
LinkedIn: / gferreira
Twitter: / gsferreira
GitHub: github.com/gsferreira
Visit my blog: gsferreira.com
#dotnet #csharp #tdd #testdrivendevelopment

Пікірлер: 19
@kostasgkoutis8534
@kostasgkoutis8534 Жыл бұрын
Hmm these approaches remind me of curve fitting, like you do in excel. Basically finding the underlying model of the curve based on the observation data you have. The danger of course is that you have to be sure your data are representative enough to cover all edge cases otherwise you might overfit the curve, satisfying the observations you have but missing on others you don't have.
@gui.ferreira
@gui.ferreira Жыл бұрын
I was not aware of the concept of curve fitting. Thanks for adding that 🙏
@matheusaugustodasilvasanto3171
@matheusaugustodasilvasanto3171 Ай бұрын
Fake It -> Evolve code incrementally, don't necessarily evolve tests as a way to drive that evolution Triangulation -> Evolve test case and in response evolve the code to match Obvious -> Well, it's obvious, isn't it? haha; But seriously, I feel like in this case you're writing the test just as a means to avoid regression. Excellent video, thank you for the explanations.
@gui.ferreira
@gui.ferreira Ай бұрын
Not only to avoid regression but also to document behaviour. However, Obvious Implementation can also be used in something a bit more complex. I feel confident I can go for it, and once it goes wrong I adopt other Driving Pattern
@marna_li
@marna_li Жыл бұрын
For beginners of TDD: Simply make sure that you create a unit test for every unit of code that tests it behavior properly. As I wrote in my earlier comments, how TDD has been portrayed in the past is not how you really write code - Like Gui said, it is just one technique that might suit a certain scenario. If you are confident in how to write the code, just go on implementing it without the "Green, Red, Refactor". The point is that you think about testing while you design or write your code. You may already have the requirements, but you want to test the implementation so that it stays consistent, at any level, in any unit. For your own sake, mainly. 🙂
@gui.ferreira
@gui.ferreira Жыл бұрын
Absolutely, I would only rephrase and say "make sure that you create a unit test for every unit of behavior". Otherwise, people may misunderstand the Unit of Code with Methods/Functions.
@marna_li
@marna_li Жыл бұрын
@@gui.ferreira Agree. I was thinking about what word to use while writing. "Behavior" is what I would say. Defaulted to "Unit of Code" when talking about programming in general. Yup. Programmers unfortunately are technical people and start out learning about technical concerns - that classes and methods are what matters while the experience developer knows that they don't. It is what they represent, the abstractions, and behaviors. Our mental model of the problem encoded in classes and methods that matter.
@m_a_r_bin_siddiqui_mamun
@m_a_r_bin_siddiqui_mamun Ай бұрын
Would you please mention the three techniques first. Then you can implement in code. I think it will be the better approach. Anyway thanks for sharing.
@marna_li
@marna_li Жыл бұрын
The problem with TDD (as it is viewed by many) is that testing always preceeds or eliminates design entirely. All the focus is seemingly on creating stubs adhoc.
@gui.ferreira
@gui.ferreira Жыл бұрын
That is true. TDD is primarily a design practice, so that's a sign that is being done wrong.
@marna_li
@marna_li Жыл бұрын
@@gui.ferreira to clarify, I meant that it is often portrayed like the only deist that you do is creating stub classes at the spot. They miss the steps about thinking it through and doing the actual design. As so often happens in videos where devs supposedly show how to apply TDD. The way they show TDD might scare some devs away. The mindset is so much more important, and that is sadly missing.
@gui.ferreira
@gui.ferreira Жыл бұрын
@@marna_li do you mean that design and refactoring are not correctly demonstrated? Am I right?
@marna_li
@marna_li Жыл бұрын
@@gui.ferreiraYes, I guess. I am all for TDD when it means actively using Unit Tests as a test bed for classes and their behavior. TDD to me says nothing about how the Software Design process is. Most videos that are demonstrating the procedure of TDD don’t focus on that and it might lead beginners astray thinking design is done ad-hoc in every test case with stubs. There are usually thoughts behind how you structure code before writing the actual code and test cases.
@AboutCleanCode
@AboutCleanCode Жыл бұрын
I get the point you are trying to make but I think the example you have chosen is just too simple to clearly illustrate that point. To motivate developers to try out these techniques instead of jumping right into what they think might be the correct implementation, a more complex example would have been better - maybe some where you try to "triangulate" the solution with a bunch of if-then-else statements and then develop that towards some "calculation"/"algorithm".
@jpalvis86
@jpalvis86 Жыл бұрын
Agreed. As the example doesn't have enough complexity, these techniques don't feel like something an expert would do because the logic itself is trivial. On the contrary, it might dissuade developers from using TDD if they feel they have to go over several steps just for such a basic operation. I like how Uncle Bob describes the TDD cycle: "As the tests get more specific, the code gets more generic."
@gui.ferreira
@gui.ferreira Жыл бұрын
Thanks for the feedback. I will consider that next time. Sometimes is hard to balance the effectiveness of the scenario with the needed complexity. I tried to avoid unneeded complexity in the explanation, but I can see your point. Thanks once again. It is valuable feedback.
@gui.ferreira
@gui.ferreira Жыл бұрын
Thanks for the feedback, Juan. It's hard to find the balance between required complexity, simple terms, and effectiveness. I will for sure keep this in mind next time.
@vladislavhorbachov5332
@vladislavhorbachov5332 Жыл бұрын
I think the example it bad.
@gui.ferreira
@gui.ferreira Жыл бұрын
Thanks for the feedback, Vladislav. It's hard to find the balance between simplicity and required complexity. I will try to do a better job next time.
I Paired Programmed with ChatGPT using Test-Driven Development
11:41
Is TDD Worth It? 😅
0:45
Philipp Lackner
Рет қаралды 13 М.
DO YOU HAVE FRIENDS LIKE THIS?
00:17
dednahype
Рет қаралды 54 МЛН
버블티로 체감되는 요즘 물가
00:16
진영민yeongmin
Рет қаралды 99 МЛН
He sees meat everywhere 😄🥩
00:11
AngLova
Рет қаралды 10 МЛН
Building Complex Objects in a Simple Way with C#
12:19
Gui Ferreira
Рет қаралды 6 М.
TDD?! I can't imagine writing tests first...
0:53
Changelog
Рет қаралды 856
C++ Weekly - Ep 435 - Easy GPU Programming With AdaptiveCpp (68x Faster!)
15:30
C++ Weekly With Jason Turner
Рет қаралды 10 М.
Former Experimental Test Pilot Explains CSIRO Modelling On Cost Of Nuclear
15:11
Coupling and Cohesion Explained
11:43
Gui Ferreira
Рет қаралды 3,2 М.
The BETTER Raspberry Pi? // ZimaBlade Review
13:41
Christian Lempa
Рет қаралды 10 М.
DO YOU HAVE FRIENDS LIKE THIS?
00:17
dednahype
Рет қаралды 54 МЛН