Closed Sigmanificient closed 1 year ago
I'm sorry, but it is a nop for this one, there's no need for so many functions in the __main__.py
, sometimes "Simple is better than complex" as the The Zen of Python says. Even if you look on ncurses examples you will most likelly see these sttuff listed in main()
HEIGHT
WIDTH
don't really indicate that there is a constant variable awaiting inside the class but just that those specific variables won't change during the main loop (which... whatever I mean :P )
Yeah kinda missleading to be on caps, so this specific change is acceptable indeed
there's no need for so many functions
Well this is not a lot of function to be honest. "Simple is better than complex" - This allow applies to functions themselves. Having more sparse functions doing less jobs is always better are it makes debugging often easier and improve organization / readability (btw, zen of python says: Sparse is better than dense. and Readability counts., ).
Even if you look on ncurses examples
Not to be pessimistic, but a lot of code bases aren't good quality code. Moreover, as they are meant as example, there is a lot of thing (and in code quality too) cut to focus on the library functionalities. I believe my school you drive you crazy, as they will give a flat zero if you have any function longer than twenty lines in your whole project delivery.
You should look at the kiss (keep it simple, stupid) principles. Each function shall have a single purpose and small responsibility.
As torvals said once: The maximum length of a function is inversely proportional to the complexity and indentation level of that function. case-statement, where you have lots of small things for a lot of different cases, it’s OK to have a longer function.
As torvals said once: The maximum length of a function is inversely proportional to the complexity and indentation level of that function. case-statement, where you have lots of small things for a lot of different cases, it’s OK to have a longer function.
The thing is that there's no if
or complexity
of more than 2 levels of indentation at all in the main()
to be considered as something in need for breaking in smaller pieces. This is an overexaggeration and it adds more complexity instead of less
Levels of indentation are not the only thing to checks for. If your function does too much thing it becomes obviously complex. In this case, the main function does the TUI initialization, the file manager initialization and the main loop. Function should only have a single purpose.
I don't thing this is over-exaggeration, especially here. And you would have to makes way more function, in a way more disorganized manner to make it complex to follow. this isn't the case there
HEIGHT
&WIDTH
being in caps within a function despite not being constants