Should we split up the large classes? #120
Labels
enhancement
New feature or request
help wanted
Extra attention is needed
question
Further information is requested
Problem
GridObject
has surpassed 1000 lines of code, triggering a pylint warning. I am not so worried about the number of lines, but the file is getting somewhat hard to work with. We have not been focused on adding functionality forFlowObject
andStreamObject
, but they will also grow in the future.Context
Our architecture generally follows the MATLAB TopoToolbox v2 architecture, which has a few classes each with lots of methods. MATLAB supports this style by allowing methods to be defined in separate files. We don't use very many object-oriented features like inheritance or sophisticated abstraction techniques -- each class is largely a bag of functions that operate on that class. One feature that is particularly useful, however, is operator overloading, which lets us apply built-in operators like
+
,-
,<
toGRIDobj
s.Originally, pytopotoolbox used mixins, parent classes of
GridObject
with methods but without any data. We had aFillsinksMixin
, andIdentifyflatsMixin
, and some others, which implemented the respective functions, and then hadGridObject
inherit from those classes, which gave it access to the implementation. We switched from that to the current architecture in #39, based on @Teschl's findings (#34) that mixins complicated the documentation and that having large classes is not uncommon in Python packages.Possible options
GridObject.py
better so that it makes more sense.fillsinks
as standalone functions that takeGridObject
s (seegraphflood.py
for an example).GridLike
objects that includes methods likedata()
to return an array with the data values andcellsize()
to return the horizontal resolution. Implement processing functions as standalone functions using this interface, subclassGridObject
fromGridLike
and definedata
andcellsize
appropriately.What other options might help us keep our classes manageable?
The text was updated successfully, but these errors were encountered: