objective/views.py - routine_details #20
Labels
No Milestone
No project
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Dependencies
No dependencies set.
Reference: Sulley/Ultron#20
Loading…
Reference in New Issue
No description provided.
Delete Branch "%!s(<nil>)"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Yop,
Je me suis un peu étouffé en lisant ce morceau de code:
(Si, si, je t'ai vu :
edfb858aa9
)En gros, en lisant la fonction, elle ne fait finalement que deux choses:
En fait, tout se qui se trouve entre le
get_object_or_404
et lecontext = {...}
doit se trouver ailleurs que dans cette fonction.C'est impossible à tester ou vérifier de manière automatique si cela se trouve dans une vue et cela viole tous les principes de structuration logique.
Copie/colle le directement dans une méthode du modèle que tu pourrais appeler
rebuild
que cela fonctionnerait parfaitement 😉Une deuxième amélioration possible concerne la lisibilité du bloc: comme tu appelles à chaque fois 28 fois (si, j'ai compté 😛 'fin pas moi tout seul...)
skill_link.skill
, rien que ceci pourrait être renommé enskill
oucurrent_skill
que tu gagnerais 11 caractères (x28).Ensuite, tu as un pattern qui se répète :
Si cela se répète autant, mets le dans une fonction.
Un truc tout bête hein, mais un truc quand même:
Rien qu'avec ceci, ton code pourrait ressembler à ça:
Un ticket avec 20 milliards d'infos… Hou la la ! t'es un fou toi ! T'as oublié qui je suis :-)
Bon… Premier conseil suivit : j'ai transférer tout dans un méthode de la classe Routine
def compute_informations(self):
Je regarde maintenant pour le reste des conseils.
La deuxième partie avance plus lentement :