| Conditions | 21 |
| Total Lines | 54 |
| Code Lines | 39 |
| Lines | 0 |
| Ratio | 0 % |
| Changes | 1 | ||
| Bugs | 0 | Features | 0 |
Small methods make your code easier to understand, in particular if combined with a good name. Besides, if your method is small, finding a good name is usually much easier.
For example, if you find yourself adding comments to a method's body, this is usually a good sign to extract the commented part to a new method, and use the comment as a starting point when coming up with a good name for this new method.
Commonly applied refactorings include:
If many parameters/temporary variables are present:
Complex classes like de.tudresden.inf.lat.jcel.coreontology.expressivity.ExpressivityName.getName(OntologyExpressivity) often do a lot of different things. To break such a class down, we need to identify a cohesive component within that class. A common approach to find such a component is to look for fields/methods that share the same prefixes, or suffixes.
Once you have determined the fields that belong together, you can apply the Extract Class refactoring. If the component makes sense as a sub-class, Extract Subclass is also a candidate, and is often faster.
| 1 | /* |
||
| 72 | public String getName(OntologyExpressivity expr) { |
||
| 73 | StringBuffer sbuf = new StringBuffer(); |
||
| 74 | if (isAL() && isC() && expr.hasTransitiveObjectProperty()) { |
||
| 75 | sbuf.append("S"); |
||
| 76 | } else { |
||
| 77 | if (isAL()) { |
||
| 78 | sbuf.append("AL"); |
||
| 79 | } else if (isEL()) { |
||
| 80 | sbuf.append("EL"); |
||
| 81 | } |
||
| 82 | if (isC()) { |
||
| 83 | sbuf.append("C"); |
||
| 84 | } else { |
||
| 85 | if (isU()) { |
||
| 86 | sbuf.append("U"); |
||
| 87 | } |
||
| 88 | if (!isEL() && isE()) { |
||
| 89 | sbuf.append("E"); |
||
| 90 | } |
||
| 91 | } |
||
| 92 | } |
||
| 93 | if (expr.hasSubObjectPropertyOf()) { |
||
| 94 | sbuf.append("H"); |
||
| 95 | } |
||
| 96 | if (expr.hasNominal()) { |
||
| 97 | sbuf.append("O"); |
||
| 98 | } |
||
| 99 | if (expr.hasInverseObjectProperty()) { |
||
| 100 | sbuf.append("I"); |
||
| 101 | } |
||
| 102 | if (isQ()) { |
||
| 103 | sbuf.append("Q"); |
||
| 104 | } else if (isN()) { |
||
| 105 | sbuf.append("N"); |
||
| 106 | } |
||
| 107 | if (expr.hasFunctionalObjectProperty()) { |
||
| 108 | sbuf.append("F"); |
||
| 109 | } |
||
| 110 | if (expr.hasSubPropertyChainOf()) { |
||
| 111 | sbuf.append("R"); |
||
| 112 | } |
||
| 113 | if (expr.hasDatatype()) { |
||
| 114 | sbuf.append("(D)"); |
||
| 115 | } |
||
| 116 | if (expr.hasTransitiveObjectProperty()) { |
||
| 117 | sbuf.append(" [transitive]"); |
||
| 118 | } |
||
| 119 | if (expr.hasBottom()) { |
||
| 120 | sbuf.append(" [bottom]"); |
||
| 121 | } |
||
| 122 | if (expr.hasIndividual()) { |
||
| 123 | sbuf.append(" [individual]"); |
||
| 124 | } |
||
| 125 | return sbuf.toString(); |
||
| 126 | |||
| 197 |