Have you ever wondered how IFs impact on your code? Avoid dangerous IFs and use Objects to build a code that is flexible, changeable and easily testable, and will help avoid a lot of headaches and weekends spent debugging! Share how to write effective code the easy way!
The goal of the Anti-IF Campaign is to raise awareness of the effective use of software design principles and practices, by first of all removing bad, dangerous IFs.
The goal of the Anti-IF Campaign is to raise awareness of effective use of software design principles and practices, first of all removing bad, dangerous IFs.
The Campaign accomplishes this by:
- Supporting free initiatives and holding free events
- Gathering supporters
- Sharing experiences on how to improve design effectiveness
The Campaign started in 2007 from Francesco Cirillo's idea:
"Lots of teams want to be agile, but have difficulty cutting down on code complexity. Let's begin with something concrete: Knowing how to use objects in such a way that enables developers to eliminate bad IFs, those that most often compromise software's flexibility and ability to evolve. Let's start with these!"
The inappropriate use of IFs is a clear source of increased complexity of a software system. And this has consequences not only on developers' work. All the team can benefit a greater effectiveness by adopting the Anti-IF method.
DEVELOPERS
BUSINESS
ANALYSTS
PROJECT
LEADERS
SOFTWARE
QUALITY
ASSURANCE
TEAM MEMBERS
about a developer working in a software 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..."
and that small class, edit by edit, grows into a small code monster: the more you feed it with IFs, the bigger it grows!
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!
public ArrayList eseguiAnalisi() { ArrayList listaSegnalazioni = new ArrayList(); List domande = null; List risposte = null; Domanda domanda = null; DAOReques req = new DAOReques(); DAOArea ar = new DAOArea(); ar.setIdQuestionario(getIdQuestionario()); boolean quizDomandaNonForzata = false; // warning 7 try { //set Aree e if (getArea() == 1) { List aree = ar.getAree(); Area area = null; for (int i = 0; i < aree.size(); i++) { area = (Area) aree.get(i); domande = req.getDomande(getIdQuestionario(),area.getIdArea()); if (domande != null) { for (int j = 0; j < domande.size(); j++) { domanda = (Domanda) domande.get(j); risposte = req.getRisposteDomanda(getIdQuestionario(),domanda.getIdDomanda()); if (risposte != null) domanda.setRisposte(risposte); } } } area.setDomandeArea(domande); if (aree != null) setAreeDomande(aree); } //else { // set ListaDomande domande = req.getDomande(getIdQuestionario()); for (int i = 0; i < domande.size(); i++) { domanda = (Domanda) domande.get(i); risposte = req.getRisposteDomanda(getIdQuestionario(),domanda.getIdDomanda()); if (risposte != null) domanda.setRisposte(risposte); } if (domande!=null) setDomande(domande); //} } catch (DAOException de) { de.printStackTrace(); }
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.
To add your name to the list send us an email indicating the site where you've published the banner you can 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="https://francescocirillo.com/pages/anti-if-campaign"> <img height="60" width="120" src="http://cdn.shopify.com/s/files/1/0257/1675/t/147/assets/banner_ive-joined.gif" alt="I have joined Anti-IF Campaign"></a>
Code for the banner "My team has joined!"
<a href="https://francescocirillo.com/pages/anti-if-campaign"> <img height="60" width="120" src="http://cdn.shopify.com/s/files/1/0257/1675/t/147/assets/banner_my-team-has-joined.gif" alt="My team has joined Anti-IF Campaign"></a>
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