It’s just another option, don’t gotta use it. Maybe you find yourself needing something like this, and the only other choice is making it public. At least with friend classes, you know which classes are friends so you can go look for any dependencies
There’s infinite ways to organize code. In C# or Rust where this isn’t an option, you might use nested classes or traits hidden behind a module/namespace.
Good use cases are data structures with associated helper classes. For example, a collection/tree and an iterator/tree-walker for working with elements of the collection. Or for something like a smart memory allocator (an arena or slab allocator), you might use a friend-class to wrap elements returned from the allocator, representing their connection back to it (for freeing up when done or to manage the allocation structure in ie a heap or sorted tree).
It allows for more fine grained access control and to implement afterthoughts.
Think having some private function that can break things if called improperly, but also allow you to avoid significant overhead when calling it the correct way. For example you could be avoiding input validation in a public wrapper for that function. If your friendly class already does it, or cannot produce invalid inputs, there is no need for that.
You could also implement logging after the fact, because your friendly logger object to read private members.
Arguably it’s a questionable design decision tho, as you could do all of this in other ways and it basically breaks any guarantees private would usually give you.
Just a friendly reminder there are therapists that work pro bono or for discounted rates. I’m paying $60/ session without insurance and it’s an investment for my mental health, future relationships and career.
I tried buying a used thinkpad and putting Linux on it, but then it stopped charging correctly after 2 weeks. So I went back on adhd meds and got a new job and turned my life around.
Honestly I thought I was doing good for my technical knowledge by playing with Linux and it has helped but there comes a point where I hit a plateau with that and now I just end up endlessly tweaking and just wasting time on it
Social Programs are just functions of government, they don’t necessarily have any direct ties to Mode of Production. There are examples of Socialist social programs, such as Single Payer Healthcare where everyone along the Healthcare chain is a government employee and the Healthcare industry as a whole is owned and run by the Workers via the state, but most single Payer Healthcare programs heavily involve privatized companies that are paid by the state.
lemmy.ml
Hot