Conditions | 1 |
Total Lines | 52 |
Code Lines | 32 |
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 | # coding=utf-8 |
||
79 | def bind(self, configurator: Configurator): |
||
80 | # TODO - G.M - 10-04-2018 - [cleanup][tempExample] - Drop static files |
||
81 | configurator.add_static_view('static', 'static', cache_max_age=3600) |
||
82 | # TODO - G.M - 10-04-2018 - [cleanup][tempExample] - Do not rely |
||
83 | # on static file for 404 view |
||
84 | configurator.add_view( |
||
85 | self.notfound_view, |
||
86 | renderer='tracim:templates/404.jinja2', |
||
87 | context=NotFound, |
||
88 | ) |
||
89 | |||
90 | # TODO - G.M - 10-04-2018 - [cleanup][tempExample] - Drop this method |
||
91 | configurator.add_route('test_config', '/') |
||
92 | configurator.add_view( |
||
93 | self.test_config, |
||
94 | route_name='test_config', |
||
95 | renderer='tracim:templates/mytemplate.jinja2', |
||
96 | ) |
||
97 | |||
98 | # TODO - G.M - 10-04-2018 - [cleanup][tempExample] - Drop this method |
||
99 | configurator.add_route('test_contributor', '/test_contributor') |
||
100 | configurator.add_view( |
||
101 | self.test_contributor_page, |
||
102 | route_name='test_contributor', |
||
103 | renderer='tracim:templates/mytemplate.jinja2', |
||
104 | ) |
||
105 | |||
106 | # TODO - G.M - 10-04-2018 - [cleanup][tempExample] - Drop this method |
||
107 | configurator.add_route('test_admin', '/test_admin') |
||
108 | configurator.add_view( |
||
109 | self.test_admin_page, |
||
110 | route_name='test_admin', |
||
111 | renderer='tracim:templates/mytemplate.jinja2', |
||
112 | ) |
||
113 | |||
114 | # TODO - G.M - 10-04-2018 - [cleanup][tempExample] - Drop this method |
||
115 | configurator.add_route('test_manager', '/test_manager') |
||
116 | configurator.add_view( |
||
117 | self.test_user_page, |
||
118 | route_name='test_manager', |
||
119 | renderer='tracim:templates/mytemplate.jinja2', |
||
120 | ) |
||
121 | |||
122 | # TODO - G.M - 10-04-2018 - [cleanup][tempExample] - Drop this method |
||
123 | configurator.add_route('test_user', '/test_user') |
||
124 | configurator.add_view( |
||
125 | self.test_user_page, |
||
126 | route_name='test_user', |
||
127 | renderer='tracim:templates/mytemplate.jinja2', |
||
128 | ) |
||
129 | |||
130 | configurator.add_forbidden_view(self.forbidden_view) |
||
131 |
The coding style of this project requires that you add a docstring to this code element. Below, you find an example for methods:
If you would like to know more about docstrings, we recommend to read PEP-257: Docstring Conventions.