mateuszac / FIDI

Program for static analysis for shields and plates using finite-difference methods (FDM)
GNU General Public License v3.0
0 stars 0 forks source link

Redundancy #7

Open putanowr opened 5 years ago

putanowr commented 5 years ago

https://github.com/mateuszac/FIDI/blob/162f3b95ec2b35ec7ecbf5143315ac957fe4e23a/src/fidi_fdm_engine/fidi_fdm_algorithm.py#L404-L406

Your code should be DRY (Don't Repeat Yourself). In the definition of the init function you repeat the same information three times. It would be better to write:

class TestMesh():
     def __init__(self, nx_cells=4, ny_cells=4):
          cell_resolution = (nx_cells, ny_cells)
          node_resolution = (nx_cells+1, ny_cells+1)
          self.data = [np.ones(cell_resolution), np.ones(node_resolution), np.ones(node_resolution)]
putanowr commented 5 years ago

BTW: pleas mind that I name my class TestMesh. It is not necessary to say this is a class like TestMeshClass (what more I consider this bad style)