Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

the DIP example seems wrong to me #31

Open
valentind24 opened this issue Jul 19, 2023 · 0 comments
Open

the DIP example seems wrong to me #31

valentind24 opened this issue Jul 19, 2023 · 0 comments

Comments

@valentind24
Copy link

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant