Pythonic code review (Red Hat Security Blog)
People coming from Java tend to turn everything into a class. That's probably because Java heavily enforces the OOP paradigm. Python programmers enjoy a freedom of picking a programming model that is best suited for the task. The choice of object-based implementations look reasonable to me when there is a clear abstraction for the task being solved. Statefulness and duck-typed objects are another strong reason for going the OOP way. If the author's priority is to keep related functions together, pushing them to a class is an option to consider. Such classes may never need instantiation, though. Free-standing functions are easy to grasp, concise and light. When a function does not cause side-effects, it's also good for functional programming."
Posted Dec 15, 2016 21:50 UTC (Thu)
by markhb (guest, #1003)
[Link] (7 responses)
Posted Dec 15, 2016 23:52 UTC (Thu)
by lordsutch (guest, #53)
[Link] (5 responses)
Besides which, he specifically prefaces the section discussing for loops with "For folks coming from C."
Posted Dec 16, 2016 0:07 UTC (Fri)
by JanC_ (guest, #34940)
[Link]
Posted Dec 16, 2016 0:26 UTC (Fri)
by tialaramex (subscriber, #21167)
[Link] (3 responses)
Posted Dec 16, 2016 2:24 UTC (Fri)
by smckay (guest, #103253)
[Link]
Posted Dec 16, 2016 12:20 UTC (Fri)
by jtaylor (subscriber, #91739)
[Link] (1 responses)
Posted Dec 20, 2016 18:34 UTC (Tue)
by niner (subscriber, #26151)
[Link]
Posted Dec 16, 2016 15:37 UTC (Fri)
by khim (subscriber, #9252)
[Link]
I don't think he says that Java does not have a "foreach" loop. Of course it does! Who does not? Even C++ have a foreach loop novadays! What he says is that Python only have a foreach loop! It does not include a traditional C/Java for loop! And he's right, of course.
Posted Dec 18, 2016 22:17 UTC (Sun)
by ssmith32 (subscriber, #72404)
[Link]
Senior to Senior - we generally view the other person as doing as a favor, like "please god did I do the right thing in this legacy core business code? Because we really need this fixed, but I have no idea. Yeah? Basically ok, but change this or that? Cool. One less thing to worry me".
Junior reviewing senior code. Train them on the process on reviewing and maintaining, (so I don't have maintain so many things). Train them in an environment where the other engineer isn't going to be overly defensive. Get a feeling for how they think. Challenge them a little to see if they've thought things through, and if they have, they are right, and now the own the decison and what comes with it.
Consistency. There are a million little style ticks that one can have. Sometimes you just need to pick one, and stick with it. Review helps me with that, when submitting PRs against another style, and I just slip up and fall into habits, leaving an inconsistent style.
It seems he wrote far more on "interesting ways Python does things" than he did on more general insights into reviewing code. Also, Java does the exact same foreach loop he says it doesn't:Pythonic code review (Red Hat Security Blog)
for (Object o : Collection<Object>)
//do stuff with o
}
Pythonic code review (Red Hat Security Blog)
Pythonic code review (Red Hat Security Blog)
Java for-each
Java for-each
Java for-each
I still regularly have to regularly flag stuff like C89 un-scoped iteration counters in >= C99 code reviews despite this being standard since 17 years and available even longer in actual compilers.
Java for-each
Pythonic code review (Red Hat Security Blog)
Pythonic code review (Red Hat Security Blog)