| Conditions | 1 |
| Total Lines | 91 |
| Code Lines | 69 |
| 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 overwrite all the needed methods.""" |
||
| 58 | @staticmethod |
||
| 59 | def adding_metadata(links): |
||
| 60 | """Add the links' metadata in a a predetermined topology.""" |
||
| 61 | TestPaths.add_metadata_to_link( |
||
| 62 | "User1:1", |
||
| 63 | "S2:1", |
||
| 64 | { |
||
| 65 | "reliability": 3, |
||
| 66 | "ownership": { |
||
| 67 | "B": {"max_utilization": 50}, |
||
| 68 | "C": {"max_utilization": 50}, |
||
| 69 | }, |
||
| 70 | "delay": 30, |
||
| 71 | "bandwidth": 20, |
||
| 72 | }, |
||
| 73 | links, |
||
| 74 | ) |
||
| 75 | |||
| 76 | TestPaths.add_metadata_to_link( |
||
| 77 | "User1:2", |
||
| 78 | "S5:1", |
||
| 79 | { |
||
| 80 | "reliability": 1, |
||
| 81 | "ownership": {"A": {}}, |
||
| 82 | "delay": 5, |
||
| 83 | "bandwidth": 50, |
||
| 84 | }, |
||
| 85 | links, |
||
| 86 | ) |
||
| 87 | |||
| 88 | TestPaths.add_metadata_to_link( |
||
| 89 | "User1:3", |
||
| 90 | "S4:1", |
||
| 91 | { |
||
| 92 | "reliability": 3, |
||
| 93 | "ownership": {"A": {}}, |
||
| 94 | "delay": 60, |
||
| 95 | "bandwidth": 10, |
||
| 96 | }, |
||
| 97 | links, |
||
| 98 | ) |
||
| 99 | |||
| 100 | TestPaths.add_metadata_to_link( |
||
| 101 | "S2:2", |
||
| 102 | "User2:1", |
||
| 103 | { |
||
| 104 | "reliability": 3, |
||
| 105 | "ownership": { |
||
| 106 | "B": {"max_utilization": 50}, |
||
| 107 | "C": {"max_utilization": 50}, |
||
| 108 | }, |
||
| 109 | "delay": 30, |
||
| 110 | "bandwidth": 20, |
||
| 111 | }, |
||
| 112 | links, |
||
| 113 | ) |
||
| 114 | |||
| 115 | TestPaths.add_metadata_to_link( |
||
| 116 | "User2:2", |
||
| 117 | "S4:2", |
||
| 118 | { |
||
| 119 | "reliability": 3, |
||
| 120 | "ownership": {"B": {}}, |
||
| 121 | "delay": 30, |
||
| 122 | "bandwidth": 10, |
||
| 123 | }, |
||
| 124 | links, |
||
| 125 | ) |
||
| 126 | |||
| 127 | TestPaths.add_metadata_to_link( |
||
| 128 | "S5:2", |
||
| 129 | "S4:3", |
||
| 130 | { |
||
| 131 | "reliability": 1, |
||
| 132 | "ownership": {"A": {}}, |
||
| 133 | "delay": 10, |
||
| 134 | "bandwidth": 50, |
||
| 135 | }, |
||
| 136 | links, |
||
| 137 | ) |
||
| 138 | |||
| 139 | TestPaths.add_metadata_to_link( |
||
| 140 | "User2:3", |
||
| 141 | "S4:4", |
||
| 142 | { |
||
| 143 | "reliability": 3, |
||
| 144 | "ownership": {"A": {}}, |
||
| 145 | "delay": 29, |
||
| 146 | "bandwidth": 20, |
||
| 147 | }, |
||
| 148 | links, |
||
| 149 | ) |
||
| 303 |