Have you ever wondered how IFs impact on your code?
Lot of developers apply the "IF Strategy" to deal with growth, change and complexity:
IF ( new condition) { new code }
Unfortunately, by doing that regularly, they increase the complexity of their software system. As a consequence, the next changes will cost more and more!
The goal of the Anti-IF Campaign is to raise awareness of the risks of applying the "IF Strategy" and to draw attention to the importance of replacing it with other design techniques, more effective to deal with growth, change and complexity. Defusing the "IF Strategy" enables developers to get a code that is flexible, changeable and easily testable. This will help to avoid a lot of headaches and weekends spent debugging!
What is the Anti-IF Campaign?
The Anti-IF Campaign is a movement of software developers aware of the risks of applying the "IF Strategy" to deal with growth, change and complexity and looking for ways of replacing it with other design techniques able to reduce the complexity of their software system.
Is this Campaign against the use of the IF statement?
NO!
The IF statement can be extremely useful from a design point view (e.g. Guard Clauses).
The Campaign is against the use of the IF statement as a regular design strategy to deal with growth, change and complexity ("Let's Put an IF Syndrome") in an evolutionary context. Despite being an "easy," and apparently effective, way of delivering the value requested by the customer, this "design strategy" has negative repercussions when applied regularly as the main strategy to deal with change, growth and complexity. By applying the "IF Strategy" in an evolutionary context, software systems becomes more complex to be read, tested, even debugged. It becomes easier to duplicate code, accumulate technical debt and spend more time fixing bugs. In the result, the software system become more complex. New features and changes will cost more and more.
How does it work?
The Campaign accomplishes its goals by:
The idea
The Anti-IF Campaign started in 2007 from Francesco Cirillo's idea: "Lots of teams want to be agile but they don't know how to deal with change and reduce the complexity of their software systems. The 'IF Strategy' can compromise the flexibility of a software system and its ability to evolve. Let's begin with something concrete. Let's replace the 'IF Strategy' and its dangerous IFs with more effective design techniques."
Who is it for?
The inappropriate use of IFs is a clear source of increased complexity of a software system. And this has consequences not only for developers' work. All the team can benefit a greater effectiveness by adopting Anti-IF solutions: Software Developers, Product Developers, Business Analysts, Project Leaders, Software Quality Assurance team members.
You're a member of the media and you would like to contact us, send us a message.
Course | The Anti-IF Workshop | More |
Community | The Anti-IF Community | More |
Event | Three Bowling Kata Design Reviews | More |
Course | The Bowling Kata Challenge Solution | More |
Community | The Bowling Kata Community | More |
...about a software developer working in a company who was building up a nice platform. One day the boss calls the developer on the phone and says: "There’s a new task I need you to do for a really important client, and it must be done by the end of the day. All that’s needed," the boss continues "is to add a small piece of functionality to that class method you’ve been working on... it shouldn’t be too complex..."
The days go by...
and that small class, edit by edit, grows into a small code monster: the more you feed it with IFs, the bigger it grows!
Do you think it’s just a fairy tale?
Well, it’s not!
What follows below is a single class method taken from real code that is live on a server somewhere on the Internet right now. And this is just a "baby monster". The more you feed it, the bigger it grows!
calculateWageFor(Person aPerson) { ... IF=> IF(aPerson.type == Person.EMPLOYEE) { ordinaryHourlyWage = 15; overtimeHourlyWage = 20; IF=> IF(aPerson.status == Person.PARENTALLEAVE) { ordinaryHourlyWage= ordinaryHourlyWage * .70; // 70% IF=> IF(aPerson.daysOffLeft() > 10) { ordinaryHourlyWage = ordinaryHourlyWage * 0.9; // 90% } } salary = aPerson.ordinaryWorkHours * ordinaryHourlyWage + aPerson.overtimeWorkHours * overtimeHourlyWage; } IF=> IF(person.type == Person.MANAGER) { fixedWage = 3000; monthlyBonus = lastYearsProfit * .10 / 12; // 10% monthly IF=> IF(aPerson.status == Person.PARENTALLEAVE) { monthlyBonus= monthlyBonus * .60; // 70% IF=> IF(aPerson.daysOffLeft() > 10) { fixedWage = fixedWage * 1; // 90% monthlyBonus= monthlyBonus * 1; // 70% } } salary = fixedWage + monthlyBonus; } IF=> IF(person.type == Person.CONSULTANT) { dailyFee = 300; workHours = aPerson.workHours(); realDays = workHours / 7; salary = realDays * dailyFee; } return salary; }
Pretty scary,huh?
Yes, it is.
And it happens everyday all over the web.
So, what can I do to help?
If you or your team want to join the Campaign, then all you need to do is to publish one of the two banners below on your site. The site can be a personal blog, a company site or a user group’s website.
Add Your Name to the List of Supporters
Send us an email (support@francescocirillo.com) indicating the site where you've published the banner to let us know that you've become a Campaign Supporter, and your name will appear on the List of Supporters.
Thanks to all of our Supporters!
Code for the banner "I've joined!"
<a href="http://www.antiifcampaign.com"> <img height="60" width="120" src="https://i.ibb.co/M9qBPnR/banner-ive-joined.gif" alt="I have joined Anti-IF Campaign"></a>
Code for the banner "My team has joined!"
<a href="http://www.antiifcampaign.com"> <img height="60" width="120" src="https://i.ibb.co/bPzdHZj/banner-my-team-has-joined.gif" alt="My team has joined Anti-IF Campaign"></a>
The following is the report of the first session of the Accounting Adventure. The time is 31 March 2021 at...
The following is the report of the first session of the Accounting Adventure. The time is 27 April 2021 at...
Do you have a question not listed here?
The Pomodoro® Timer Web App will be your time tutor and help you stay focused so you can get more...
To help you get started, check out the official templates of the Pomodoro Technique that you can download and print....
Interruptions and procrastination are one of the most dangerous productivity killers. How to deal with the Predator while we're working...