| Conditions | 1 |
| Total Lines | 56 |
| Code Lines | 39 |
| 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 | import inspect |
||
| 5 | @pytest.fixture |
||
| 6 | def client_pandas_tabular_implementation(): |
||
| 7 | """Client code that defines an Engine Backend""" |
||
| 8 | from so_magic.data.interfaces import TabularRetriever, TabularIterator, TabularMutator |
||
| 9 | |||
| 10 | class TestPDTabularRetrieverDelegate(TabularRetriever): |
||
| 11 | |||
| 12 | @classmethod |
||
| 13 | def column(cls, identifier, data): |
||
| 14 | return inspect.currentframe().f_code.co_name |
||
| 15 | |||
| 16 | def row(self, identifier, data): |
||
| 17 | return inspect.currentframe().f_code.co_name |
||
| 18 | |||
| 19 | @classmethod |
||
| 20 | def nb_columns(cls, data): |
||
| 21 | return inspect.currentframe().f_code.co_name |
||
| 22 | |||
| 23 | @classmethod |
||
| 24 | def nb_rows(cls, data): |
||
| 25 | return inspect.currentframe().f_code.co_name |
||
| 26 | |||
| 27 | @classmethod |
||
| 28 | def get_numerical_attributes(cls, data): |
||
| 29 | return inspect.currentframe().f_code.co_name |
||
| 30 | |||
| 31 | class TestPDTabularIteratorDelegate(TabularIterator): |
||
| 32 | |||
| 33 | def columnnames(self, data): |
||
| 34 | return inspect.currentframe().f_code.co_name |
||
| 35 | |||
| 36 | @classmethod |
||
| 37 | def iterrows(cls, data): |
||
| 38 | return inspect.currentframe().f_code.co_name |
||
| 39 | |||
| 40 | @classmethod |
||
| 41 | def itercolumns(cls, data): |
||
| 42 | return inspect.currentframe().f_code.co_name |
||
| 43 | |||
| 44 | class TestPDTabularMutatorDelegate(TabularMutator): |
||
| 45 | |||
| 46 | @classmethod |
||
| 47 | def add_column(cls, datapoints, values, new_attribute, **kwargs): |
||
| 48 | return inspect.currentframe().f_code.co_name |
||
| 49 | |||
| 50 | BACKEND = { |
||
| 51 | 'backend_id': 'test-pd', |
||
| 52 | 'backend_name': 'test-pandas', |
||
| 53 | 'interfaces': [ |
||
| 54 | TestPDTabularRetrieverDelegate, |
||
| 55 | TestPDTabularIteratorDelegate, |
||
| 56 | TestPDTabularMutatorDelegate, |
||
| 57 | ] |
||
| 58 | } |
||
| 59 | |||
| 60 | return BACKEND |
||
| 61 | |||
| 98 |