Repository with sources and generator of https://larlet.fr/david/ https://larlet.fr/david/
Você não pode selecionar mais de 25 tópicos Os tópicos devem começar com uma letra ou um número, podem incluir traços ('-') e podem ter até 35 caracteres.

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122
  1. title: Inclusive Python
  2. slug: inclusive-python
  3. date: 2017-05-29
  4. lang: en
  5. chapo: Making your code resilient requires empathy.
  6. > After 12 years of hacking in Python, what did I learn the hard way? From biology to the web, across startups and now French government, I realized one thing: making your code resilient requires empathy.
  7. *It is the subject of a [talk](/david/talks/) ([slides](/static/david/talks/inclusive-python.pdf)) I gave at the [Montreal-Python](http://montrealpython.org/en/) [meetup](https://www.meetup.com/fr-FR/Montreal-Python/events/240094945/).*
  8. I’ve been using Python for more than a decade now. Such a ride. And still, time doesn’t really matter. It’s more the diversity of projects and interactions that made me who I am [as a developer](/david/blog/2016/inclusive-developer/). As such, I’m more and more concerned about the life of the code than ever. The transmission of the associated knowledge is the key to success of a project and to achieve this you have to think as a team. **Lone wolves are burning out with their products.** And it’s a real loss of energy. And happiness. And that sucks.
  9. But first, let’s define *inclusive*. Given the [Wiktionary](https://en.wiktionary.org/wiki/inclusive) the first definition is:
  10. > Including (almost) everything within its scope.
  11. For this article, I would like to slightly rephrase that definition:
  12. > Including (almost) every*body* within its scope.
  13. I prefer that definition because **coding is a social and political act.** As such, each and every line of Python you produce should be put into that context. With whom. And why.
  14. So, how do you make everybody capable of working with you(r Python code)?
  15. ## Include yourself
  16. > Yesterday I was clever, so I wanted to change the world. Today I am wise, so I am changing myself. — Jalaluddin Rumi
  17. That might seem obvious but do yourself a favour and do not reject yourself from your own code! We all have (please confirm :p) a project with no tests, no docs and yet critical and running in production that you have to maintain. Reshaping the project is not an option because you are short on attention/budget so it became a patchwork of ugly bug fixes. At that point, even you are unable to fix something without a week of procrastination to avoid that painful task. **The challenge is not technical but the amount of motivation required is tremendous.**
  18. Try to be empathetic with a <strike>older</strike> wiser self. Ease the installation process, reduce dependencies, have fixtures. Document, automate, speed up the feedback loop when you are modifying something. All [basic things](/david/blog/2015/collaboration-technique/) that I rarely saw well implemented (including my projects).
  19. ## Include your colleagues
  20. > — “But if all of our programmers are pairing, won’t they write half as much code?”
  21. > — “No, hopefully they’ll write even less than that.”
  22. >
  23. > <cite>*[Ben Rady](https://twitter.com/benrady/status/817430925176958977)*</cite>
  24. Being part of a team is a way to duplicate the knowledge around the project. And that’s clearly not a lack of time or energy when you see the turn-over within our profession. I see three ways to do it:
  25. 1. **before**: discussing strategies all together regularly, your mileage may vary on the frequency. The whole team needs to have a clear picture of what will be developed and *why*.
  26. 2. **during**: pair-programming and/or quick sessions to discuss a particular issue mainly focused on the *how*.
  27. 3. **after**: performing code-reviews and user-testing on each and every pull/merge-request. Check that the “why” of point 1. has been addressed and tested. Do not hesitate to trash everything at that point if it’s not relevant anymore.
  28. Besides that, newcomers are a chance to rethink together a better process to onboard people. It only happens once per people, do not miss it and block at least half a day dedicated to that task. *Observe* them installing your project and trying to figure out how to make it run. **Observe, do not help, do not say anything, let them find out alone.** It’s not a user-testing session but a developer one. Collect everything to improve the developer experience later. Once the task is performed or worse your colleague is stuck, it’s time to discuss of the improvements. Is that a documentation issue? Or an environment one? Are you really explaining the purpose of your project? Which are the communication channels? And so on. We all have an *illusion* of the simplicity of our processes until they confront the diversity of others’ experiences.
  29. **The knowledge of your product is in your team, not in your code.** We probably need new practices to get rid of that situation, it’s still too hard to find the right cursor between documenting and delivering value. Not only sharing how it works but why it failed and how do we addressed it at that time.
  30. ## Include your (re)users
  31. > My suggestions can be expensive in time, money and energy. When you're building something for the first time, all of this comes down to you. Focus on the documentation in the beginning. By doing that, you'll create a welcoming place for others and then they can start helping you with the rest of it.
  32. >
  33. > <cite>*[Lowering the barriers](https://the-pastry-box-project.net/charlotte-spencer/2015-september-16)* ([cache](/david/cache/3cfbe249e4ec23ee28c6c3af7633e5b1/))</cite>
  34. This is a particular case that might be biased by my situation but when you are open-sourcing your developments and working for <strike>a government</strike> citizens you want people to be able to contribute to your work one way or another. Lowering the barriers of the contributions is still very hard.
  35. [Labelling some easy-picking issues](https://medium.com/@kentcdodds/first-timers-only-78281ea47455) ([cache](/david/cache/51ba770c8e8142bac33da33354fad29b/)) might be worth it and your reactivity to answer to declared issues is key. Especially by people who just created an account just to submit them. Which does happen more than I expected in my case! Performing pedagogic reviews might be worth it on the long term to help contributors level up and produce better code with you.
  36. Note: if your project only runs on top-of-the-market computers and requires to download megabytes of dependencies, you are closing the door to a lot of potential contributors.
  37. ## Include maintainers
  38. > While I empathize with maintainers burning out and asking for support, trying to tackle sustainability from a maintainer centric view is a to paddle against the flow of the river. We continue to see barriers to adoption and participation fall away, enabling a new generation of contributors to be involved as long as we can view them as part of the solution rather than the problem itself.
  39. >
  40. > Developers like to think they code their way out of any problem. We know how to scale servers but most of us are inexperienced with scaling people.
  41. >
  42. > <cite>*[Maintainer vs. Community](https://medium.com/open-source-communities/maintainer-vs-community-97edc28387ad)* ([cache](/david/cache/4d5851d18f4b3e893490b3910de2597f/))</cite>
  43. Each and every time you contribute to an open-source project, you give your technical debt to a maintainer. Sad but true so help them with tests and documentation too! Lowering the barriers to other contributors is a way to increase the sustainability of the project which directly benefits to you.
  44. As a maintainer, try to involve more people in the governance and maintenance of your project (I’m terrible at this…). This is somehow your escape lane because interest in projects will vanish from time to time. If you are the only one keeping the keys it will be lost forever once abandoned. At least, be a [Minimally-nice Open Source Software Maintainer](https://brson.github.io/2017/04/05/minimally-nice-maintainer) ([cache](/david/cache/f86b54bf25411c04eb538befd6ebc856/)).
  45. ## Include beginners
  46. > Write code for complex logic so elegantly simple that it won’t make you look smart.
  47. Think about it each and every time you plan to add a metaclass, a signal, a decorator or introduce the latest hyped lib to name a few. The beauty of your code is somewhat ugly to somebody having a hard time understanding these concepts. Really, nobody will blame you for writing dumb code that anyone understand at first sight. Not to mention yourself when you are stressed by a deadline or reopening this code six months later.
  48. **The best programmers write code beginners understand.** It is as simple as this. You can write idiomatic Python and still be readable by a developer using another programming language. Make it a target and enjoy [crossed code-reviews](/david/blog/2016/code-reviews-croisees/) to identify these issues.
  49. Document tools you use for your project ([pycodestyle](http://pycodestyle.pycqa.org/en/latest/), [isort](http://timothycrosley.github.io/isort/) to name a few), you can even add pre-commit hooks or automated checks *via* the pull/merge-request.
  50. ## Include citizens
  51. > In an ever-more intricate and connected world, where software plays a larger and larger role in everyday life, it’s irresponsible to speak of coding as a lightweight activity. Software is not simply lines of code, nor is it blandly technical. In just a few years, understanding programming will be an indispensable part of active citizenship.
  52. >
  53. > <cite>*[Coding is not ‘fun’, it’s technically and ethically complex](https://aeon.co/ideas/coding-is-not-fun-it-s-technically-and-ethically-complex)* ([cache](/david/cache/8b81a17dd00142dd98a251d2ca723716/))</cite>
  54. I’m not only talking about fixing typos in documentation here. How do you include people in the process of building the product? How do you make them aware that they can have a direct impact on what is done with their taxes? That part is yet to be experimented because it requires a shift in minds. A [nation is a cooperative that scaled](/david/blog/2016/delivery-values/) and as such each individual should act as part of a community.
  55. Maybe some day, micro-payments will be available to remunerate the time spent by citizens on collective projects but — apart from the technical issue — the complexity to evaluate the value of each contribution is a real problem.
  56. ## Include conclusion
  57. > An important point of maturity as a developer is realizing that writing code is a relatively insignificant part of software development.
  58. >
  59. > <cite>*[Steven R. Baker](https://twitter.com/srbaker/status/831990107586646018)*</cite>
  60. Embrace the diversity of others point of views, make them count. **Your code is not a book, it’s a continuous discussion on a given goal.** You are maybe familiar with the concept of [progressive enhancement](https://en.wikipedia.org/wiki/Progressive_enhancement), you can push the first draft of your code/documentation as a proof of concept and then progressively enhance the inclusivity of your project too. As for [Web literacy](https://learning.mozilla.org/en-US/web-literacy), it’s a matter of Python literacy. We have the chance to use a language that is easy to learn, let’s be worthy of it.
  61. I had to confess that I’m not doing half of the things I described, it is mostly self-criticism here. And that’s OK, really, because **inclusiveness is a journey**. Just be sure to keep moving toward a direction that makes you feel good at the end of each and every day.
  62. ## Include discussions
  63. > What makes a good pull-request for a developer and a good code review from a maintainer?
  64. On the developer side, documenting clearly what is the aim of your contribution is key. It looks obvious but that’s not always the case. Adding clean code, tests and documentation is great. We use to add an entry in the changelog with every pull-request nowadays to ease the communication with our international team.
  65. A good code review is a one that is both respectful and engaging. You can [be inspired](https://blog.alphasmanifesto.com/2016/11/17/how-to-perform-a-good-code-review/) ([cache](/david/cache/4f5f1314047ae271ac5f080f6c43bff4/)) by [a checklist](http://blog.fogcreek.com/increase-defect-detection-with-our-code-review-checklist-example/) ([cache](/david/cache/3177652e7a1a4808cc303cb58246cbf3/)) but once again, don’t take it too dogmatically. It’s up on your team to define its own check points.
  66. > How do you handle technical debt and contributions?
  67. We actually (and sadly) don’t have pull-requests related to technical debt clean up. We mostly initiate that kind of change during workweeks (about twice per year) when everybody is in the same room to coordinate and evaluate alternatives together.