WAAAAAAH!

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.

What is this?

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.

How to get it?

The Campaign accomplishes this by:
- Supporting free initiatives and holding free events
- Gathering supporters
- Sharing experiences on how to improve design effectiveness

The idea

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


Who's it for?

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




Here’s a little story...

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

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.


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();
  }

Pretty scary,huh?


Yes, it is.
And it happens everyday all over the web.
So, what can I do to help?




How to 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.

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!



Get the banner


Code for the banner "I've joined!"


<a href="http://cirillocompany.de/pages/anti-if">
  <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="http://cirillocompany.de/pages/anti-if">
  <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>

Who's joined



Follow the Campaign



Ready to learn more?