Y
HN Search
Hacker News Search
new
|
comments
|
top
|
jobs
robalni
searching PlanetScale…
1.
▲
2.
▲
3.
▲
4.
▲
5.
▲
6.
▲
15 ms
·
121.
▲
by
robalni
4y ago
If you don't want to require users to run javascript you should be able to make the server generate the timestamp.
122.
▲
Munsell Color System
(en.wikipedia.org)
5 points
by
robalni
4y ago
|
0 comments
123.
▲
Chromatic Adaptation
(brucelindbloom.com)
1 points
by
robalni
4y ago
|
0 comments
124.
▲
by
robalni
4y ago
> They will not be implementing unimplemented function signatures. In my mind, in my comments, they are library users. I clarified in the question that I'm only asking about situations where everyone has access to all of the code. S
125.
▲
by
robalni
4y ago
> I would say private is a way to tell the user to not touch the variable, or to use an accessor function that has validation to prevent entering invalid state. That's what I meant, that it's a way to tell the programmer that y
126.
▲
by
robalni
4y ago
> A private property is a property that a class user should have no reason to want to directly write to. What the user of a class has reason to do depends on what they need to get done. Maybe there is a function that already does what th
127.
▲
by
robalni
4y ago
> > Ouch, that's a pretty careless reason to start with > I think it's fine. This is probably the reason that I used to have for using private until I started thinking about it. I mean I understand if no-one would claim t
128.
▲
by
robalni
4y ago
Ok, let's assume we only care about states that's always invalid, like negative health. So then my question is the same as for Jtsummers: is private a way to tell the programmer to look at all member functions to see if there is a
129.
▲
by
robalni
4y ago
> But you forget (someone came by with cookies) to actually shrink the backing array and also to change "top". Someone could come by with cookies while I'm writing a private function too. This is more of a reason for havin
130.
▲
by
robalni
4y ago
> What matters is that users of this class cannot, in a separate module/class, directly access those three fields. Yes that's what private does, it makes sure that you can't access something from any place in the code. The
131.
▲
by
robalni
4y ago
> any references to it are bound to break Do you mean that if someone changes a class member, they would not change in all places that use that class member? Why not? > someone that relies on your class may not have access to the code
132.
▲
by
robalni
4y ago
I guess, the problem of deciding whether to use private or not.
133.
▲
by
robalni
4y ago
> there is no relevant difference between a member of my team utilizing that class (from within the same module) and other people using it (as a library I have published). The difference between a team member and a library user is that t
134.
▲
by
robalni
4y ago
1. So it's not to make it easier to change things? Otherwise what's the difference, in difficulty to change things, between using a member in 20 places outside of the class and 20 places inside the class? It's the same amount
135.
▲
by
robalni
4y ago
> The only variables and functions that should be public are those that cannot put an object into an invalid state. That's an interesting one. So a reason to use private is to tell programmers that calling this function or changing
136.
▲
by
robalni
4y ago
> To hide implementation details from class users. Yes, that's what private does. My question was more why you should do that. > the interface can stay the same even though you could completely re-do the guts. So is the reason to
137.
▲
by
robalni
4y ago
> Ouch, that's a pretty careless reason to start with I think it's fine. This is probably the reason that I used to have for using private until I started thinking about it. > there should never be a reason for consumers to
138.
▲
by
robalni
4y ago
> Dependencies kill teams Do you mean that when you have structured the organization so that each class is worked on by at most one team, you want to reduce the number of dependencies between classes in order to reduce the number of depe
139.
▲
by
robalni
4y ago
1. So the reason here to use private is as a way to tell programmers to not use a thing in too many places because then it will be hard to change in all those places if you need to change the private member? 2. First, remember that I am onl
140.
▲
by
robalni
4y ago
That's what it's called when you do things like that but what's the reason? From the linked page I read: "Encapsulation is used to hide the values or state of a structured data object inside a class, preventing direct ac
141.
▲
Ask HN: Why do you make class members private?
22 points
by
robalni
4y ago
|
112 comments
142.
▲
by
robalni
4y ago
> why can’t they stipulate requirements for using their services? They can and they do, but there is too much of this behavior that companies require too much access and control of people's computers. My computer is my private thing
143.
▲
by
robalni
4y ago
There are so many things that can be called a "clever trick" that it makes no sense to say that you should not use clever tricks. Like, one thing that can be called a clever trick is to align the code vertically to make it easier
144.
▲
by
robalni
4y ago
This first seems like a pointless thing to do because you could just make it public in class A. But then when I think about it more I realize that it might actually be pretty useful if you have a huge codebase and it would take 30 minutes t
145.
▲
by
robalni
4y ago
This is a trick that makes the experience of writing C and C++ code much better: Skip the header files and include the .c or .cpp files into one translation unit instead. * No more code duplication every time you change the type or name of
146.
▲
by
robalni
4y ago
That's what I meant in my first post that we need to get rid of. There is too much of this behavior that companies try to get into people's computers and control what they can do with their own computer.
147.
▲
by
robalni
4y ago
One old and tested solution is that you play with your friends or people you trust. This has worked perfectly for board games and other pre-internet games for many years. Otherwise if you want to play at a bigger scale, I don't know ho
148.
▲
by
robalni
4y ago
I'm not interested in any right to disrupt a service; it's just something that can happen because of other rights: to run arbitrary code on your own computer, and trying to remove that right is not going to work. We need a better
149.
▲
by
robalni
4y ago
It becomes the developer's problem because they put themselves in a position where their money and future depends on what random people do in a game. Nobody should expect it to go well when you connect random people on the internet and
150.
▲
by
robalni
4y ago
They can choose the server rules but I choose what code runs on my computer.
More ›