ajkluber / model_builder

Represents coarse-grain models for easy simulation and parameter fitting.
4 stars 4 forks source link

__init__ files should only contain comments and import statements? #8

Closed TensorDuck closed 8 years ago

TensorDuck commented 8 years ago

So, I have always believed init files should be relatively bare, and primarily for directing Python to know what files and methods exist. I think we should reorganize the init files so that we put the classes we want to make in a separate file, and import the classes we need. For example:

classes.py

class Model
    ...

class StructureBasedModel
    ...

__init__.py, same level

from classes import StructureBasedModel

Advantages:

  1. Clearly delineate what methods we think are important for the user to access, and what methods are meant to be handled in the background.
  2. Cleaner Layout with code. Everything is more compartmentalized and is conducive to making more modular code.
  3. Easier to work with: every file is better named, and methods are better organized for future editing.
  4. User still has access to Model, it's just harder and they'll have to know it's there (expert user). i.e., just do: from model_builder.models.classes import Model.
ajkluber commented 8 years ago

Yeah, I agree that init.py should be bare except for some import statements. I think the current implementation was more a matter of convenience.

I agree that the code in init.py files can be moved into separate file(s) (but something more informative than classes.py : p ).

ajkluber commented 8 years ago

This is done.