Cause and Effect – Foundation of TDD
James Grenning's Blog
by jwgrenning
4y ago
Virtually every line of code is written in response to some failure. It often is a test failure, but might be a compilation failure, or a web page that does not exist. Through my 16 years of practicing TDD, I have come to discover that establishing cause and effect is critical to getting every line of code right. I’ve done most my TDD in embedded C and C++. Over the last couple years, with the help of a couple friends, I built my ruby on rails website. I did not know ruby (or rails obviously). I know it a little bit now. I used to follow the several step procedures to bring up a new feature o ..read more
Visit website
Wrestle Legacy C and C++ into a Test Harness – Linker Errors
James Grenning's Blog
by jwgrenning
4y ago
Getting started with TDD in C and C++ is challenging. On top of that, you have your whole product’s code base to start adding tests to. You don’t have time to stop all development and add tests to your code, so you need a pragmatic approach. As you drag your legacy code, kicking and screaming into a test harness, take your time and solve one problem at a time. It is the fast way. This article is about getting past a boat-load of C and C++ linker errors. I’ve got a method and a tool to help get through that challenging step. You can find the tool, gen-xfakes, here on my GitHub account ..read more
Visit website
Self-Paced Training: TDD for Embedded C/C++
James Grenning's Blog
by jwgrenning
4y ago
Hello Friends I am developing a series of self-paced training modules for Test-Driven Development for Embedded C and C++. The training modules will have exercises to cement the learning. I’ll offer them individually or in a couple bundles. Each module will take six or more hours to complete. The modules follow the flow of my on-site and live-via-the-web formats found on wingman-sw. Present a problem — problems motivate change Present a potential solution — the idea that may help Demonstrate part of the solution — remove ambiguity Participant does an exercise — learn by doing Experience debri ..read more
Visit website
In the beginning, there was no code…
James Grenning's Blog
by jwgrenning
4y ago
…and it was good. Why is it that code starts out nice and deteriorates over time? What happened happened to make the code badness grow? Probably something joyous like the first order for a new product or adding people to the team. Or maybe something sad like losing a key employee. I see a lot of legacy C code. How does a function get to be 1000 lines long? How did that file get to be 40 KLOC or 100 KLOC? A friend showed me a 27 page C function in some telecom code. Amazingly enough, it worked! How does code get that way? One Copy/Paste at a time! Long functions often contain deep nes ..read more
Visit website
Responsibilities of the Test-Driven Developer in a Legacy Code Base
James Grenning's Blog
by jwgrenning
4y ago
This is a follow-up question from an attendee of a recent TDD for Embedded C++ training course. What exactly is a person’s responsibility for unit testing when they go into existing untested code? Like all good questions in software development, the answer is “it depends”. The Boy Scout rule kind of sums it up. Leave the campground better than you found it. You also have to be practical. Each iteration (or story) should include some improvement work. Do something reasonable that supports people learning the place for unit tests, TDD, and refactoring. For example: A given story requires cha ..read more
Visit website
Thoughts on TDD (After almost 20 years)
James Grenning's Blog
by jwgrenning
4y ago
I used to think I was good at programming (1976–1999), then I started doing Test-Driven Development. Since then I discovered that I make mistakes regularly. TDD puts your mistakes in your face, immediately. With this kind of feedback and a focus on small steps you can prevent many defects in you code from getting past you to your co-workers, QA or your customer. — For me, it means very little time hunting down mysterious behavior, a.k.a. bugs! The best you, a programmer, can do with TDD is get code to do what you think the code should do. This simple concept, a confirmation that your code is ..read more
Visit website
Is SAFe safe for your organization? I don’t know.
James Grenning's Blog
by jwgrenning
4y ago
If your definition of safe, is like “no one has even been fired for choosing IBM”, SAFe may be safe. Though, you really need to consider, will it help your organization improve? I hoped that Scrum would help the world discover iterative and incremental engineering practices and principles. It seems to me, it has failed. Maybe SAFe can be different; I don’t know. I have not spent any time looking into SAFe. I cannot make an informed opinion. I would make my opinion based on the message of SAFe and how it is being adopted. Generally, I am critical of what most Agile adoptions have become, Agile ..read more
Visit website
Damn, I used to think I was good at programming
James Grenning's Blog
by jwgrenning
4y ago
I used to think I was good at programming. Since I started doing TDD in 1999, I’ve come to discover that I am not so good. I make a lot of little mistakes. Copy-paste is a specifically error-prone activity for me. When I copy and paste and N changes are needed, on a good day I can usually get N-1 on the first try. When I’m almost done, I get a little careless. I’m not the only one! Take a look at this analysis of the Last Line Effect. He show lots of copy-paste bug examples from real code from products you know. In the article the author also mentions this may not be just programming. m ..read more
Visit website
Linker Substitution in C – Limitations and Workarounds
James Grenning's Blog
by jwgrenning
4y ago
Let’s say you have code that in some test cases you want the real code and other test cases you want a test double. In C, using link-time binding, you only get to have a single function with a specific name. I’d suggest that most the time this comes up you want to directly test some module (or function) and you want a substitute when testing code that depends on the module’s interface. What options do you have? Create multiple test runners, where one test runner would use the real function and the other test runner would use the test double. Function pointer substitution. #include the .c fil ..read more
Visit website
TDD Guided by ZOMBIES
James Grenning's Blog
by jwgrenning
4y ago
Have you had a hard time figuring out where to start with Test-Driven Development. What if ZOMBIES could help you build code that does exactly what you think it is supposed to do? What if ZOMBIES at the same time help you to build a test harness that can help you keep your code clean and behaving properly for a long and useful life? What if ZOMBIES could help! I’m not talking about those zombies! ZOMBIES is an acronym. One of the seemingly odd things I saw back in 1999 when Kent Beck, Ron Jeffries and others demonstrated Test-Driven Development, was how they always started with the simples ..read more
Visit website

Follow James Grenning's Blog on FeedSpot

Continue with Google
Continue with Apple
OR