-
Notifications
You must be signed in to change notification settings - Fork 21
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
Private methods, constructors or classes are against EO principles #89
Comments
@llorllale/z please, pay attention to this issue |
@fabriciofx can you balance this against the rule of three? |
@llorllale I don't have anything against code duplication. I've against methods, constructors and classes private . Look that Rule of Three is basicaly against create new abstractions to avoid duplication, but when you create a private method, constructor or class you already created the abstraction, but put them hidden to others. |
In most cases I don't think we (conciously) have. For example, can you extract any meaningful abstraction from |
@llorllale I think the |
@fabriciofx please elaborate on how this Buffer type would look. |
@fabriciofx is still of concern and if yes, can you list what are the problematic method, constructor or class? IMHO private methods, constructors and inner classes can make sense as they are part of the encapsulated object. It can make sense to make them public IF you find a good reason to do so, not beforehand. See this articles about the danger of thinking in term of reuse as a first principle and the danger of having the wrong abstractions: https://www.sandimetz.com/blog/2016/1/20/the-wrong-abstraction |
@victornoel well, due to respect, including to Sandi Metz, I disagree. But I agree to close this issue, if you want. |
@fabriciofx before closing it, maybe we can look at the problematic class, methods, constructors and see if it makes sense to do something, but I would like to be clear about the job to be done before putting that in scope |
@victornoel I think what Sandi Metz said about abstraction is about an abstraction which is used to build class around you project, like interfaces do. If it's the point, I agree with her. But my point is: when you make a private class or method they already a kind of abstraction too. So, if you're creating a new abstraction, why not put it in a public class and use it in your class or method? The advantage is you can allow for others users reuse (or not) this class too. Bu you can think: "ah, but this class or method doesn't make any sense outside this other class". How we can sure about that? We don't know! Just let's do it public and let the user decide if it wants use or not. |
@fabriciofx still, until you don't put a rough list of what you think should be changed, I don't know if I can put this in scope, we can argue about theory for a long time, but looking at real use case we will know what to do :) |
Private methods, constructors or classes are against EO principles. Please, check this comment and @yegor256 opinion about them. So, let's change the code to create package or public classes and only public methods.
The text was updated successfully, but these errors were encountered: