| Conditions | 1 | 
| Total Lines | 60 | 
| Code Lines | 51 | 
| Lines | 0 | 
| Ratio | 0 % | 
| Changes | 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:
| 1 | """Module to test the KytosGraph in graph.py.""" | ||
| 106 | @staticmethod | ||
| 107 | def generate_topology(): | ||
| 108 | """Generates a predetermined topology""" | ||
| 109 |         switches = {} | ||
| 110 |         interfaces = {} | ||
| 111 |         links = {} | ||
| 112 | |||
| 113 |         TestResults.create_switch("User1", switches) | ||
| 114 | TestResults.add_interfaces(3, switches["User1"], interfaces) | ||
| 115 | |||
| 116 |         TestResults.create_switch("S2", switches) | ||
| 117 | TestResults.add_interfaces(2, switches["S2"], interfaces) | ||
| 118 | |||
| 119 |         TestResults.create_switch("User2", switches) | ||
| 120 | TestResults.add_interfaces(3, switches["User2"], interfaces) | ||
| 121 | |||
| 122 |         TestResults.create_switch("S4", switches) | ||
| 123 | TestResults.add_interfaces(4, switches["S4"], interfaces) | ||
| 124 | |||
| 125 |         TestResults.create_switch("S5", switches) | ||
| 126 | TestResults.add_interfaces(2, switches["S5"], interfaces) | ||
| 127 | |||
| 128 |         TestResults.create_link("User1:1", "S2:1", interfaces, links) | ||
| 129 |         TestResults.create_link("User1:2", "S5:1", interfaces, links) | ||
| 130 |         TestResults.create_link("User1:3", "S4:1", interfaces, links) | ||
| 131 |         TestResults.create_link("S2:2", "User2:1", interfaces, links) | ||
| 132 |         TestResults.create_link("User2:2", "S4:2", interfaces, links) | ||
| 133 |         TestResults.create_link("S5:2", "S4:3", interfaces, links) | ||
| 134 |         TestResults.create_link("User2:3", "S4:4", interfaces, links) | ||
| 135 | |||
| 136 | TestResults.add_metadata_to_link( | ||
| 137 |             "User1:1", "S2:1", { | ||
| 138 | "reliability": 3, "ownership": "B", "delay": 30, | ||
| 139 | "bandwidth": 20}, links) | ||
| 140 | TestResults.add_metadata_to_link( | ||
| 141 |             "User1:2", "S5:1", { | ||
| 142 | "reliability": 1, "ownership": "A", "delay": 5, | ||
| 143 | "bandwidth": 50}, links) | ||
| 144 | TestResults.add_metadata_to_link( | ||
| 145 |             "User1:3", "S4:1", { | ||
| 146 | "reliability": 3, "ownership": "A", "delay": 60, | ||
| 147 | "bandwidth": 10}, links) | ||
| 148 | TestResults.add_metadata_to_link( | ||
| 149 |             "S2:2", "User2:1", { | ||
| 150 | "reliability": 3, "ownership": "B", "delay": 30, | ||
| 151 | "bandwidth": 20}, links) | ||
| 152 | TestResults.add_metadata_to_link( | ||
| 153 |             "User2:2", "S4:2", { | ||
| 154 | "reliability": 3, "ownership": "B", "delay": 30, | ||
| 155 | "bandwidth": 10}, links) | ||
| 156 | TestResults.add_metadata_to_link( | ||
| 157 |             "S5:2", "S4:3", { | ||
| 158 | "reliability": 1, "ownership": "A", "delay": 10, | ||
| 159 | "bandwidth": 50}, links) | ||
| 160 | TestResults.add_metadata_to_link( | ||
| 161 |             "User2:3", "S4:4", { | ||
| 162 | "reliability": 3, "ownership": "A", "delay": 29, | ||
| 163 | "bandwidth": 20}, links) | ||
| 164 | |||
| 165 | return (switches, links) | ||
| 166 |