The Anti-IF Campaign

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!

Less IFs, more power

About the Anti-IF Campaign

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:

  • Supporting free initiatives and holding free events
  • Gathering supporters
  • Sharing experiences on how to improve design effectiveness

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.

Press Center

You're a member of the media and you would like to contact us, send us a message.

Related Solutions

Here's a little story...

...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!

The Code Monster

	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?


Join the Campaign

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!

Get the banner

Code for the banner "I've joined!"

banner-ive-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!"

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>

Who's joined

Giorgio Sironi
Brice Dutheil
Łukasz Sutkowski
Pierpaolo Pitocco
Mark Levison
Michael Romer
Tomasz Nurkiewicz
Johan Andersson
Cédric Menzi
Scott Sparkman
Clavius Tales
Felipe Benevides
Giordano Scalzo
Jean-Michel Garnier
Ron Cotton
Matteo Collina
Claudio Cardozo
Xavier Bourguignon
Tomas Johansson
André Baldo
Caio Proiete
Fahad Nari
Jeff Niblack
Bishow Paudel
Maurius Mathiesen
David Lawton
Mauro Bellati
Mauricio Aniche
Tiago Fernandez
Santosh Gokak
Phil Bootha
Ludovic Dubois
Lukas Domagala
Hong SeGi
Gabriel Mullen
Diego Scataglini
David Laribee
Dale Henrichs
Anders Jönsson
Matt Wynne
Kent Beck
David Vilchez
Mike Polen
Tommy Bryntse
Davide Angelocola
Kevin Rutherford
Nunzio Fiore
Jose M Beas
Piero Bozzolo
Giorgio Vinci
Alessandro Dimasi
Alberto Silva
zhangheli
Johan Martinsson
Michael Silbermann
Alban Dericbourg
Florian Schroeder
Matteo Regazzi
Andrew Starodubtsev
Fernando Godóy
Łukasz Antoniak
Lorenzo Barbagli
Riderman de Sousa Barbosa
Ioan Vintoiu
Kevin Poalses
Giuseppe Di Pierri
Julian Pustkuchen
Luciano Lima
Chris Eargle
Bill Craun
Dmytro Lapshyn
Mogens Heller Grabe
David Perfors
Marcelo Schmidt
Ricart Monachesi
Darioush Jalali
Flavio Percoco
Felipe Teixeira
Roger Knapp
Raffaele Garofalo
Joseph Bergin
Jakub Milkiewicz
Amol Jadhav
Tom Peplow
Ulrik Sandberg
Jean-Baptiste Dusseaut
Guilherme Silveira
André Faria Gomes
Stefano Ricciardi
Rogerio Coimbra
Marcin Bialon
Leandro Braçaroto
Lasse Koskela
Jonhnny Weslley
Ed Sumerfield
Derick Bailey
David Dossot
Bill Wake
Tunca Bergmen
Julian Maughan
Juan Macias
Jug Ancona
Jug Roma
Java Italian Portal
Roberto Valenti
Andrea Chiarelli
Matteo Vaccari
Pietro Di Bello
Antonio Scatoloni
cuberick
Alessandro Vincelli
Luigi Viggiano
Nirav Kamani
Max Pawlidi
Hans Zhang
Luca Lo Re
Kenny Shen
Luiz Fagner Zordan
Houston McClung
Rohit Vaidya
Barry Demchak
Carlos Racancoj
Rob Brown
Chris Geymo
Sudhin Varghese
Denis Ferrari
Wouter Lagerweij
Juan Jose Zapico
Antonio Pelletri
Dumitru Vechiu
Pascal Leclercq
Guilherme Cardoso
Osvaldo Ortega Martinez
Ratheesh Narayanan
Eduardo Silva
Eric Rizzo
Hildeberto Mendonça
Israel Alcazar
Franco Lombardo
Ciro Borrelli
Emanuele Del Bono
Mauro Mosca
Martino Vallara
Danilo Tucci
Daniele Di Bartolomei
MrBlue73
tonyxst-it
cstadvising
Perl.it
Andrea Gervasini
Alessandro Coscia
Ugo Landini
Andrea Basile
Fabrizio Giudici
Teo Ambrogio
Rocco Zanni
Federico Gobbo
Luca Guidi
toastedtech
thediracsea
drunkenbyte
rvinside
JUG Torino
Andrea Schiavini
Carlo Bertini
Giuseppe Capodieci
Gian Carlo Pace
Stefano Paluello
Blog2j
Luca Maistrello
Matteo Baglini
Enrico Zupo
Andrea Maietta
Alessandro Dionisi
Antonio Pierascenzi
Gustavo Nobrega
Amila Silva
Michal Paszkiewicz
Stéphane Labbé
José Luís Vaquero
Ogun InfoTech
Adrian Iftode
Mikel Berdufi
Raphael Oliveira Neves
Kaan Ersan

Useful Resources

The Accounting Adventure Journal - Episode 01: The Challenge

The following is the report of the first session of the Accounting Adventure. The time is 31 March 2021 at...

The Accounting Adventure Journal - Episode 02: Emergent Design

The following is the report of the first session of the Accounting Adventure. The time is 27 April 2021 at...


FAQ

Do you have a question not listed here?

Pomodoro® Web App

The Pomodoro® Timer Web App will be your time tutor and help you stay focused so you can get more...

Pomodoro® Sheets

To help you get started, check out the official templates of the Pomodoro Technique that you can download and print....

Pomodoro® Training Programme

Interruptions and procrastination are one of the most dangerous productivity killers. How to deal with the Predator while we're working...