示例#1
0
  /**
   * Évalue la cohésion interne d'une interface.
   *
   * @param itf L'interface à évaluer
   * @return Un double entre 0.0 et 100.0
   */
  public double internalCohesion(final Facade fcd) {
    double result = 0.0;

    Set<Function> fcdFcts = fcd.getFunctions();
    Set<GlobalVariable> fcdVars = fcd.getGlobalVariables();
    Set<ComplexType> fcdTypes = fcd.getComplexTypes();
    int nbEntities = fcdFcts.size() + fcdVars.size() + fcdTypes.size();

    if (nbEntities > 1) {
      if (fcdFcts.size() > 0) {
        int n = 0;

        if (fcdFcts.size() > 1) {
          result += cohesionFcts(fcdFcts);
          ++n;
        }

        if (fcdVars.size() > 0) {
          result += cohesionFctsVars(fcdFcts, fcdVars);
          ++n;
        }

        if (fcdTypes.size() > 0) {
          result += cohesionFctsTypes(fcdFcts, fcdTypes);
          ++n;
        }

        result /= n;
      } else if (fcdVars.size() > 0 && fcdTypes.size() > 0) {
        result += cohesionVarsTypes(fcdVars, fcdTypes);
      }
    } else if (nbEntities > 0) {
      result = 100.0;
    }

    return result;
  }
示例#2
0
  /**
   * Évalue la cohésion entre 2 façaces d'un connecteur.
   *
   * @return Un double entre 0.0 et 100.0
   */
  public double facadesCohesion(Facade itf1, Facade itf2) {
    double result = 0.0;

    Set<Function> functions1 = itf1.getFunctions();
    Set<Function> functions2 = itf2.getFunctions();

    Set<GlobalVariable> variables1 = itf1.getGlobalVariables();
    Set<GlobalVariable> variables2 = itf2.getGlobalVariables();

    Set<ComplexType> types1 = itf1.getComplexTypes();
    Set<ComplexType> types2 = itf2.getComplexTypes();

    int nbPairs = 0;

    for (Function fct1 : functions1) {
      for (Function fct2 : functions2) {
        result += cohesion(fct1, fct2);
        ++nbPairs;
      }

      for (GlobalVariable var2 : variables2) {
        result += cohesion(fct1, var2);
        ++nbPairs;
      }

      for (ComplexType t2 : types2) {
        result += cohesion(fct1, t2);
        ++nbPairs;
      }
    }

    for (Function fct2 : functions2) {
      for (GlobalVariable var1 : variables1) {
        result += cohesion(fct2, var1);
        ++nbPairs;
      }

      for (ComplexType t1 : types1) {
        result += cohesion(fct2, t1);
        ++nbPairs;
      }
    }

    if (nbPairs > 0) {
      result /= nbPairs;
    }

    return result;
  }