Checkpoint: The Code So Far (After SRP)

Everything covered through the Single Responsibility Principle, as real files: still the naive one-class Bird, deliberately not fixed yet.

September 14, 20263 min read4 / 20

This is a running snapshot, not a new lesson: every file below is exactly what the previous posts built, collected in one place so you can see the whole thing at once.

The code here is still broken on purpose. SRP only diagnosed what's wrong with the one-class Bird. It never fixed it. That fix starts with the next principle.

main.cpp
#include <string> class Bird { public: double weight; std::string color; std::string type; std::string name; bool canFly; void fly() { if (type == "sparrow") { // sparrow-specific flying logic } else if (type == "crow") { // crow-specific flying logic } else if (type == "pigeon") { // pigeon-specific flying logic } // ...and one more branch for every bird that gets added } void eat() { /* ... */ } void walk() { /* ... */ } }; int main() { Bird b1; b1.color = "blue"; b1.type = "sparrow"; b1.fly(); }