<div dir="ltr"><div dir="ltr"><br></div><br><div class="gmail_quote"><div dir="ltr" class="gmail_attr">On Mon, Nov 16, 2020 at 8:09 AM Veronica Andreo <<a href="mailto:veroandreo@gmail.com">veroandreo@gmail.com</a>> wrote:<br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div dir="ltr">Then, I'll be working on writing (a bit) better code. Is it recommended to create classes?</div></blockquote><div><br></div><div>Hi Vero,</div><div><br></div><div>Classes can be sometimes useful for writing things like scripts and GRASS modules, but usually in these cases,  just writing functions instead of having everything in one long function does what you need which is understandable and maintainable code.</div><div><br></div><div>A class could be useful to carry some state through your code gluing most related variables and functions together like this:</div><div><br></div><div>p = Process(some, vars, always, needed)<br></div><div>result1 = p.phase_one_of_processing(some, other, vars)</div><div>result2 = p.another_phase_of_processing(result1, and, even, more, vars)</div><div>...</div><div><br></div><div>However, that's nothing you can't do well with just functions or functions and a class which has only data attributes, but no functions. Sometimes, it is a matter of taste. Sometimes, you may see that the functions are somehow not quite fitting to do what you need to do and that's where classes might come in.</div><div><br></div><div>With your current code, I would just run Pylint on in with default settings and try to make it as happy as possible. Pylint usually forces me to split big chunks of code into smaller documented functions with more clear inputs and outputs. You can also run Black on it and forget about details of formatting. I didn't really look into the logic of your code, but I think your code looks good and readable, so you don't have much to worry about even when you start applying some strict tools such as Pylint.<br></div><div><br></div><div>HTH,</div><div>Vaclav<br></div><div><br></div><div><br></div><div> </div></div></div>