Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

the DIP example seems wrong to me #31

Copy link
Copy link
@valentind24

Description

@valentind24
Issue body actions

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

      Morty Proxy This is a proxified and sanitized view of the page, visit original site.