Quacken8 / MagneticDisconnectSimulator

Python simulator of disconnection of solar magnetic field from its roots inpsired by Schüssler and Rempel (2018)
1 stars 0 forks source link

Relative imports and aliases #3

Closed mejroslav closed 1 year ago

mejroslav commented 1 year ago

https://github.com/Quacken8/MagneticDisconnectSimulator/blob/faef3bd8e65fb5808206e7455553f4014a215acd/main.py#L11-L12

I think this is a beautiful, straight asphalt road straight to the gates of hell of spaghetti code. The alias is completely different from the original name. Since you call these objects only once, https://github.com/Quacken8/MagneticDisconnectSimulator/blob/faef3bd8e65fb5808206e7455553f4014a215acd/main.py#L69-L71 it's not a big deal to write the full name here:

 newTs = solvers.oldYSolver(currentState, dt) 

Common abbreviations like import numpy as np is something different, because everyone knows what you're talking about.

Again, imagine yourself being totally drunk at 3:00AM after 32 hours without sleep, looking into your own code. code-quality-measurement

mejroslav commented 1 year ago

(this is unrelated, but not completely) Also, maybe the constants in constants.py deserve their own class Constants or UPPERCASE_NAMES?

Quacken8 commented 1 year ago

This alias structure is deliberate becuase it allows me to implement different solvers and state equations in the future with minimal changes of the code or even without looking for where these modules were used. Everything is neatly close to the top of the file. Also for the user it is not necessary to know whether my particular Y solver is runge kutta of fourth order, all they need to know is it solves for Ys and if they wish to use a different solver, they can just look for where the Y solver is imported