Is_computer_on_fire() (2000)
everything2.com
everything2.com
Aw, man. The perennial question of that site. What was it supposed to be, really? Roughly, it was just about anything that you could express with basic HTML and pure text. No images, no videos. It was,
* An online encyclopedia before Wikipedia
* A meme central before 4chan
* A social network before Facebook
* A blogging platform before blogs
and several other things. About the only thing it wasn't was a news aggregator, because that was already covered by Slashdot by the same crowd. Its fashions changed with the ebb and flow of users and admins.It was a sister site of Slashdot (at a time, Slashdot would link to everything2 articles in order to define terms), and also associated to sites like the defunct JavaJunkies and the somehow still living Perlmonks, which shared the Everything engine as a codebase. The idea was to monetise the engine like Wordpress and Drupal later did, but this never happened, and Blockstackers Intergalactic folded soon after that.
Somehow, Everything2 is still up.
It was closely related to Slashdot, but when Slashdot was sold, E2 remained independent.
Some of the profits of the Slashdot sale went to Blockstackers as an investment to develop E2. Unfortunately, the dot-com crash (and, to be fair, not enough effort spent marketing the software) meant there was little market for the underlying CMS.
Had a massive community at one stage, and an active IRL scene. Some of the meetups were crazy fun. Site is still going and the code is maintained to this day.
See page 23-84 of:
http://manuals.info.apple.com/MANUALS/1000/MA1509/en_US/Newt...
Beos' app model discouraged the use of fork() - but you could if you wanted to - and instead had a pthreads-like kernel level support for threads with some very nice C classes that handle message-passing and the like; interthread communication was baked in in too so you could have strong IPC without pipes. BeOS also came with a hybrid spinlock-semaphore mutex called the 'benaphore'.
There were some very excellent C++ wrappers for all of these too, the BLooper class was a by-default message handling loop (for example).
Finally, the threading model was pretty cool, it was a logarithmic stochastic time allocator with a range of "hard priorities" that would give you RT control (but could also freeze your machine if you had an infinite loop). Unfortunately the kernel had a tendency to thrash threads between CPUs in a multi-cpu setup. I think this was fixed in Haiku.
https://github.com/haiku/haiku/blob/master/src/system/libroo...
What about applying the same logic to a function returning a number between X and Y?
if (random_number_between(1, 10) > 5) {
do_something();
}
Is this correct? I would personally name such functions get_random_number_between instead but that violates this principle.However, I agree with ariel. In a functional-style program, or indeed in most programs, the important thing about a function is what it returns, not what it does. Calling a function 'getRandomNumber' describes the action of the function, not the return value, which is just 'randomNumber'. As your example shows, the logic in English flows much more naturally with the latter.
It's much better to talk about the box.size, rather than the box.getSize, for example. To me, the presence of 'get' in a function name is almost always a bad idea.
Similarly, I normally use the word 'as' rather than the word 'to' when naming conversion functions, e.g. list.asArray, rather than list.toArray
In an immutable world where you're making a copy (perhaps even through a lens), then I often use 'with', e.g. myNewObject = myObject.withX(12.0).
I guess on many occasions, the get/set could also be avoided by thinking about the usage a little deeper. Take HTTP frameworks for example:
getHeader()
setHeader(key, val string)
could also be defined as: requestHeader()
responseHeader(key, val string)
I must admit I'm someone who, despite best efforts to give meaningful and consistent function names, often ends up with something less standardised by the time projects start to grow, deadlines loom and fatigue sets in (I'd imagine this is probably true for most people - if we're completely honest). But it's always good to get (if you pardon my pun) reminders and advice about sane naming conventions.That said, I think your ideas here are good. 'Get' and 'Set' really don't convey that much information, whilst your code above makes it clearer what is going on.
In those instances, it's only clear from the usage rather than the name how that function behaves, so I think I'd rather see getX and setX over X() and X(int x) and be absolutely clear about the role of that function.
To expand on this, the two hard things in computer science are:
1) Naming Things
2) Cache Invalidation
3) Off-By-One ErrorsEDIT: for your random number function I'd simply use get_random_number(x, y) too.
(Common sense from experience > style guides.)