Closed qcgm1978 closed 7 months ago
The issue may be relevant for other projects, but I'm not planning to adopt it for this project.
The sequence a ? A : b ? B : c ? C : ...
is simply an else-if chain and is quite straightforward. It should be distinguished from evil nests like a ? b ? X : Y : Z
.
This is my hobby project, and I enjoy my favorite style here, even though it doesn't align with typical coding standards of JavaScript.
As background, I mainly use huge fonts to avoid eye strain on my small notebook PC, which severely limits the number of visible lines. So, I generally prefer long lines with dense logic over the popular style of many simple lines.
This is indeed a trade-off between pros and cons, between ensuring code readability or conciseness. Whichever approach taken may not be able to reduce the inherent complexity of things. Perhaps in this refactoring process, it is more important to understand the internal logic of things.
The
draw_pv
function is overly complex and difficult to debug compared to thedraw_main
function. The current code uses nested ternary operators, which makes it difficult to read and maintain.Refactor the
draw_pv
function usingswitch
statements andobject mapping
to improve readability and maintainability. Refer to the code example for refactoring: