Skip to content

Section 3.3: Code Decoupling & Abstractions #12

@tomneep

Description

@tomneep

I like the spirit of Section 3.3 but not so much the delivery.

In the first exercise we separate out the data loading from the analyse function (good!), so we end up with two functions

def load_inflammation_data(dir_path): ...
def analyse_data(data_dir): ...

I would think it would make some sense to completely decouple these two functions so that when they are used, a user would do something like

data = load_inflammation_data("/path/to/data")
result = analyse_data(data)

but instead the example leaves the load_inflammation_data call inside analyse_data. This isn't the worst thing in the world to do but I would think that separating them would be better?

Then in the next example they suggest going more towards this approach, but by introducing a class CSVDataSource. This seems a little pointless to me, and in fact Pylint would complain about this class having too few methods (R0903)! And in the end they still pass that class to the function and rely on duck typing to load the data...

Metadata

Metadata

Assignees

No one assigned

    Labels

    questionFurther information is requested

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions