Ranter
Join devRant
Do all the things like
++ or -- rants, post your own rants, comment on others' rants and build your customized dev avatar
Sign Up
Pipeless API
From the creators of devRant, Pipeless lets you power real-time personalized recommendations and activity feeds using a simple API
Learn More
Comments
-
No no no no no no no, stop it! friends are essentially a bad idea in programming!
Edit:
I'm not saying that whole idea is 100% bad but missuses are too much common. Breaking encapsulation is not always well motivated (most often by lazyness).
In my opinion if you use friends you are bad designer. -
Grumpy28828y@MaLiN2223 I think I've used friends once only, in 26 years. It was something to do with overloaded operators, IIRC. It's just a weird feature.
C#'s extension methods is a parallel case. It was introduced to make LINQ possible, but some people misuse it like crack, and create obfuscation for no good reason. -
@Grumpy exactly.
Extensions methos are also good for extending string class however they forbid to use private parts of classes (if i remember correctly) hence no encapsulations are broken unlike when using friends. -
elazar10308y@MaLiN2223 friends are there to *avoid* breaking encapsulatiin by adding more public api
-
@elazar it is called 'work around' and if you see that you need something you should change the project. Code smells more and more with behavior you described.
-
elazar10308y@MaLiN2223 Sometimes, but not necessarily. It is fine-grained permissions, like "protected". It should be questioned wherever it appears, but there are good answers.
Related Rants
-
xjose97x19Just saw a variable in C named like this: long time_ago; //in a galaxy far away I laughed no stop.
-
Unskipp24So this happened last night... Gf: my favorite bra is not fitting me anymore Me: get a new one ? Gf: but it ...
-
sam966911Hats off to this lady .... I would have just flipped the machine
The problem with C++ is that all of your friends can see your private parts.
That's not a problem, it's a feature!
undefined
c++