603 karma · joined Sep 13, 2017 (9y ago) · 435 submissions
comment 9y ago · link · parent
There is one thing that would make me switch, and that's apples IME methods for Chinese characters, which are a lot more sophisticated than the Linux offerings.
comment 9y ago · link · parent
One trick I often use is to have the window take half (or less) of the screen and spoof my browser to be Chrome on Android Kit Kat. I just wish there was a change to have a different browser spoofed per tab, or maybe a "whitelist" of websites that are designed well enough that I won't pretend I'm on a phone.
comment 9y ago · link · parent
It's not limited to Africa though. I'm from New Zealand, and I've had Europeans ask if I visit Japan a lot, because I'm so close (I'm about as close to Japan as Germany is). I've had Americans ask if I was ok when they heard news that tropical cyclones were hitting Queensland (I'm as far from Queensland as a Jamaican is from Ohio). And the hemisphere thing stumps so many people. Usually they just constantly forget that the seasons are reversed, but I've had one educated, multilingual gentleman from east Asia ask me if North and South mean the same thing in the southern hemisphere, or if they have opposite meanings.
comment 9y ago · link · parent
The problem was that over time, there modules started drifting. Their domains became different ever so slightly and the owners of those modules became different teams. Now if you wanted to modify the domain object, you had to check it wouldn't break code the other teams were developing.
Isn't the real issue here that the architecture didn't keep pace with reality? It sounds like the dev who made the package had the right ideal. The real issue was subsequent devs introducing their domain specific stuff into a common package, instead of extending it or composing it with their own domain specific code.
comment 9y ago · link · parent
You've articulated here what I've actually been trying to communicate. I have no problem if a method does nothing but get/set a variable. I just think they should be named with domain semantics.
comment 9y ago · link · parent
comment 9y ago · link · parent
I'll concede defeat. That is a pretty good example. At the end of the day, "customer details" class is actually a big bag of fields that needs some access control and validation.
comment 9y ago · link · parent
If you want to reduce coupling, why not write a real method? Get/Set couples you to your class fields. If you change your class fields, your getters and setters all suddenly become useless.
Maybe I just hate the middle ground (:
comment 9y ago · link · parent
My argument is that having getters and setters exposes your implementation. If you have "getFoo" and "setFoo" it exposes that your class contains a value called Foo. My argument is that you should either give your methods better names, or get rid of the pretense of encapsulation altogether and just make them public. Get/Set is just an awkward middle ground.
Even if we keep this immutable, your implementation is different in that it uses twice as much memory.
How can my implementation be different? No one else has written one (:
But maybe not. If you had getters and setters, you could seamlessly try the other implementation without changing all of the client code.
And if you had actual methods with names that didn't break encapsulation, you could do the same and divorce all your calling code from the burden of knowing about the internal structure. Again, the middling approach is the worst of both worlds to me.
comment 9y ago · link · parent
class Satellite {
Coordinates coordinates;
double celcius;
/*** constructors, etc ***/
public double Celcius() { ... }
public double Kelvins() { ... }
public void Move(...) { /* modifies state */ }
}
Note how none of the methods make any mention of low level operations like setting/getting internal fields.You could make the argument that I do have a getter there, Celcius. But at the risk of pedantry I'd argue it isn't so. The name doesn't imply that it's retrieving the value of a field - ie the internal representation could easily change to Kelvin or Fahrenheit - where as "getCelcius" definitely tells me there's a field there called Celcius.
Hmm, after writing that I wonder what the definition of a setter actually is. I have no problem with a method that just returns a field, as long as it doesn't go out of its way to tell me that's exactly what it's doing. Maybe the distinction I am making is too subtle.
comment 9y ago · link · parent
> but "setters are always bad and i don't understand why anyone would ever use them" seems like a needlessly hard-line sentiment, IMO.
I have a strong opinion because I read some compelling arguments, thought about a lot, stopped using setters, and the quality of my code improved. I don't see a need to moderate my opinions on programming, especially when that's what I really think. Again, happy to be shown a great counter example and admit I was wrong.
comment 9y ago · link · parent
I'm open to the idea that setters do have a use case, but I'm not seeing one here.
comment 9y ago · link · parent
I guess in my mind FP and OO are orthogonal. If I write an immutable object and I send it messages that are referentially transparent, am I not doing both? Would it help FP people if they thought of such objects as "a record of partially applied functions"? So I hope both. I'd love if there was a statically typed, high level pure OO language without all the cruft of Scala or C#. Maybe I have to wait for the next programming fashion cycle for that to happen.
> Thanks for posting your feeling on OO. In some ways I've always felt very restricted writing OO (even in Python), but learning Smalltalk is making me see it from an entirely different perspective.
I often wonder if I need to coin a better term for "OO" for what I am talking about. Alan Kays whole schtick was that objects contained both data and procedures, but by combining them they became something new, and more than just the sum of their parts. That's the powerful idea to me. But language changes, and OO in 2017 just means "Java".
comment 9y ago · link · parent
If you feel like it, write out how you'd implement the class and why. I posted a fairly strong opinion, but I'm happy to have my mind changed.
comment 9y ago · link · parent
class Temperature {
public final double celcius, kelvins;
Temperature(int celcius, int kelvins) {
this.celcius = celcius;
this.kelvins = kelvins;
}
public static Temperature fromCelcius(int c) {
return new Celcius(c, c - 273.15);
}
}
What's wrong with that approach, and how would you do it?comment 9y ago · link · parent
https://news.ycombinator.com/item?id=15606777
In the structs & records world (C, F#, Rust, etc) they never seem to have this issue. Either the struct is completely transparent and you can read and write fields at will, or it's completely opaque and the functions that operate on it have better names/semantics than "setField".
comment 9y ago · link · parent
To clarify, I would not consider something like this a setter:
class Monster {
int health;
void Damage(int d) {
this.health -= d;
}
}
True, it is a method that just sets a variable. But it makes no mention of that variable. It's defined in terms of its actual purpose (inflicting damage on a monster), not its implementation (modifying an internal field called 'health').There is definitely a time and place for plain data objects. But if you find yourself actually needing validation and preprocessing in your get/set, then you probably have a 'real' object hiding their. Stop being lazy and give it proper methods.
comment 9y ago · link · parent
If you're writing a plain data class, why on earth would you write getters and setters? Just make your fields public and be done with it.
I will be forever perplexed by the idea of getters and setters (and this extends to C#s syntax sugar). I have no idea what problem they solve. If you're at the level of plain data, then just make a class with public fields and no methods. If you're trying to write a 'higher level' object - then don't refer to the names of fields in your method names. The getter/setter/property approach is just the worst of both worlds. They make explicit reference to an objects internal fields, while at the same time obfuscating what happens when you actually access them.
comment 9y ago · link · parent
I don't know if it would work for forth - too low level - but for something like Factor I could see it being really useful.
comment 9y ago · link · parent
comment 9y ago · link · parent
What Joe Armstrong (who I admire) complains about is actually what I love about OO languages. And for me that's the true essence of what OO is, and how it differs from non-OO. People keep trying to frame OO in terms of mutability (completely orthogonal) or C++/Java coding practices (C++ doesn't define OO because it has objects, anymore than it defines FP because it has lambdas).
The real difference, the real paradigm shift is in data + functions vs objects. And I maintain that objects are more powerful and better idea than data + functions. The banana can't be peeled without the gorillas opposable thumbs.
comment 9y ago · link · parent
I have a Taiwanese book for school children that includes the governments romanisation, hanzi, and some kind of extended bopomofo. While the native speaker I was learning with could read hokkien-with-characters, he couldn't do it quickly, and often had to puzzle over a certain character. In cases where they had both characters and romanisation I was able to help him on the characters he was stuck on by (badly) pronouncing the romanisation. Still, I haven't met any Taiwanese hokkien speakers at all interested in romanisation. Which is a shame - it covers all the sounds, and the language does seem to be slowly dying (the fact people don't write it probably has a lot to do with it).