Conditions | 11 |
Total Lines | 13 |
Code Lines | 9 |
Lines | 0 |
Ratio | 0 % |
Changes | 0 |
Complex classes like osm_poi_matchmaker.libs.compare_strings.compare_strings() 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 | # -*- coding: utf-8 -*- |
||
14 | def compare_strings(string1, string2=''): |
||
15 | # New string |
||
16 | if (string1 is '' or string1 is None) and (string2 is not '' and string2 is not None): |
||
17 | return 'N' |
||
18 | # Deleted string |
||
19 | elif (string1 is not '' and string1 is not None) and (string2 is '' or string2 is None): |
||
20 | return 'D' |
||
21 | # Modified string |
||
22 | elif str(string1) != str(string2): |
||
23 | return 'M' |
||
24 | # Equal string |
||
25 | elif str(string1) == str(string2): |
||
26 | return 'E' |
||
27 |