Skip to content

the DIP example seems wrong to me #31

Open
@valentind24

Description

@valentind24

hi,

I would have expected, that in the ‘good’ example, the function will take a parameter of type ‘EchoIf’

You could have showed that there is an ‘Echo’ class with the actual implementation, and an ‘EchoIf’ interface class that abstracts the ‘write’ method.

this is basically the whole point, your function depends on an abstraction. it is clear that in order for that function to work, it is required an object that implements the ‘write’ method.

as it is done now, the function hides a dependency on the Echo class. you are building the object inside the function, instead of delegating this responsibility to a different function.

Also, same function builds ‘rows’ object with a default value, a thing that you have said in previous example that should be done using parameters with default values.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions