<?xml version="1.0" encoding="utf-8" standalone="yes"?><rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>En |</title><link>http://ambientalanalytics.com/tag/en/</link><atom:link href="http://ambientalanalytics.com/tag/en/index.xml" rel="self" type="application/rss+xml"/><description>En</description><generator>Hugo Blox Builder (https://hugoblox.com)</generator><language>en-us</language><lastBuildDate>Sat, 30 Mar 2024 00:00:00 +0000</lastBuildDate><image><url>http://ambientalanalytics.com/media/icon_hu7c1917ae855170f5d843310bb86f2adf_19652_512x512_fill_lanczos_center_3.png</url><title>En</title><link>http://ambientalanalytics.com/tag/en/</link></image><item><title>Lessons Learned during the developtmen of `corssfire` Python package</title><link>http://ambientalanalytics.com/post/lessonslearnt/</link><pubDate>Sat, 30 Mar 2024 00:00:00 +0000</pubDate><guid>http://ambientalanalytics.com/post/lessonslearnt/</guid><description>&lt;p>The &lt;a href="https://pypi.org/project/crossfire/" target="_blank" rel="noopener">crossfire&lt;/a> package was first developed in 2021, during the &lt;a href="https://felipesbarros.github.io/post/hacktoberfest21/" target="_blank" rel="noopener">#Hacktoberfest&lt;/a>. Since this first version I have recieved support from &lt;a href="https://cuducos.me/" target="_blank" rel="noopener">@cuducos&lt;/a>.
Last year, the crossfire API was updated, and thus the package should be updated as well. Again, I asked for Cuducos&amp;rsquo; help, and he kindly accepted to mentor me during the development of the new version of the package. This time, I can see that I have learned a lot of things that I would like to share here, in a not so structured form&amp;hellip;. My idea here is to write down some thoughts, notes, and comments about the process of developing the package.&lt;/p>
&lt;h2 id="debuging-in-test">Debuging in test&lt;/h2>
&lt;p>I already knew about the importance of debugging, althought I never used it. But something that I didn&amp;rsquo;t know is that I could debug the test, also.
This can be done by importing &lt;code>pytest&lt;/code> to the source code, and adding &lt;code>pytest.set_trace()&lt;/code> before the line that I want to debug. Then, we can run the test with the &lt;code>-k&lt;/code> parameter, which will run only the test that I want to debug.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-python" data-lang="python">&lt;span class="line">&lt;span class="cl">&lt;span class="n">poetry&lt;/span> &lt;span class="n">run&lt;/span> &lt;span class="n">pytest&lt;/span> &lt;span class="o">-&lt;/span>&lt;span class="n">k&lt;/span> &lt;span class="n">test_client_load_states&lt;/span>
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div>&lt;p>The &lt;code>set_trace&lt;/code> makes the test stop and leave the terminal so we can call the objects and functions to confirm if they are as expected.&lt;/p>
&lt;p>&lt;a href="https://github.com/FelipeSBarros/crossfire/pull/74#discussion_r1407879899" target="_blank" rel="noopener">here (in Pt-Br)&lt;/a>&lt;/p>
&lt;h2 id="tdd-is-about-exploring-issues-rather-than-a-solution">TDD is about exploring issues rather than a solution&lt;/h2>
&lt;p>At some point during the package development, I was facing an issue when trying to set a return value for a mocked function. After a long time analysing my code and not identifying the issue, I found in &lt;em>Stack Over Flow&lt;/em> (yes, I still using it :) a suggestion of setting the &lt;code>autospec&lt;/code> parameter to &lt;code>True&lt;/code>. Of course I looked up at the &lt;code>pytest&lt;/code> documentation to [try to] understand what does it do, but all I got was some glue about it. I decided, anyway, to use it and commit the code beliving I have solved [apparently] the issue. So, then, Cuducos adviced me:&lt;/p>
&lt;blockquote>
&lt;p>Ok, so never add code you don&amp;rsquo;t understand. Never. You can use it to ask: hey, I noticed that when I add that, it works for you. But this is a way to explore the issue rather than a solution. (&lt;a href="cuducos.me">@cuducos&lt;/a>)
&lt;a href="https://github.com/FelipeSBarros/crossfire/pull/103#discussion_r1509013934" target="_blank" rel="noopener">here&lt;/a>&lt;/p>
&lt;/blockquote>
&lt;h2 id="flat-path-to-success">Flat path to success&lt;/h2>
&lt;p>o &lt;a href="https://www.vinta.com.br/blog/flat-success-path" target="_blank" rel="noopener">flat path to success&lt;/a> foi mencionado no processo de &lt;a href="https://github.com/FelipeSBarros/crossfire/pull/103#discussion_r1599016800" target="_blank" rel="noopener">revisão do código&lt;/a> e básicamente se refere a:&lt;/p>
&lt;blockquote>
&lt;p>escrever o código de forma clara e direta, evitando aninhamentos e complexidades, onde o propósito principal do código é facilmente discernível sem mergulhar em estruturas aninhadas.&lt;/p>
&lt;/blockquote>
&lt;h2 id="instalando-versão-pacote-python-a-partir-do-github">Instalando versão pacote Python a partir do GitHub&lt;/h2>
&lt;p>No processo de desenvolvimento é importante sempre testar o código em um ambiente diferente daquele no qual se está desenvolvendo a solução. Para isso, podemos instalar a versão do pacote diretamente do GitHub, especificando a branch a ser usada, conforme o exemplo abaixo.&lt;/p>
&lt;div class="highlight">&lt;pre tabindex="0" class="chroma">&lt;code class="language-bash" data-lang="bash">&lt;span class="line">&lt;span class="cl">pip install git+https://github.com/username/repo.git@branch_name
&lt;/span>&lt;/span>&lt;/code>&lt;/pre>&lt;/div></description></item></channel></rss>