Show newer

The goal is to give my computer science students just enough spaghetti that they realize they are in trouble, but not so much that they become hopelessly entangled. Unfortunately, things often don't happen in that order.

RT @Nick__Bentley@twitter.com
Publishers are treating games like a commodity and it’s going badly: nickbentley.games/commodity-bo

Solution: double dispatch. I replaced:

A result = otherObject.foo();
if (result instanceof B) {
B b = (B)result;
d.doSomething(b);
} else {
C c = (C)result;
d.doSomething(c);
}

with :

otherObject.foo().doSomething(d);

where B and C have different definitions of doSomething.

As desired, otherObject still can't call doSomething, even on Bs and Cs it creates, because it doesn't have access to d.

Show thread

RT @TheOnion@twitter.com
Thousands Gather For Stuffing Of Giant Rockefeller Center Turkey trib.al/PJUtIfM

"Whoever did this licked so many frogs." -@ShutUpShow@twitter.com on the box art for Inis

Another puzzle:

Interface A is implemented by classes B and C. I call a method that returns an A and want to do different things depending on whether I actually get back a B or a C. Is there a cleaner way than this?

A result = otherObject.foo();
if (result instanceof B) {
B b = (B)result;
doSomething(b);
} else {
C c = (C)result;
doSomething(c);
}

I can't change doSomething(b) into b.doSomething() because (for security reasons) I don't want otherObject to be able to doSomething.

instanceof feels dirty.

Ideas?

On its very first move, my primitive Scrabble AI played "LO".

Censoring taboo language with the wrong number of asterisks is a f******ing brilliant idea.

RT @sadanduseless@twitter.com
World's Greatest Gallery of Round Animals (Not Photoshopped!) sadanduseless.com/cute-round-a

RT @kthorning@twitter.com
@djolder@twitter.com I just found out that food pantries and homeless shelters love those cloth tote bags. Their clients prefer them to the plastic bags they usually have to use, the straps of which dig into your hands. I gave them ALL my tote bags and they were so glad to get them.

After our first session, we question the decision to launch @ingress@twitter.com at the beginning of winter.

RT @amadcartoonist@twitter.com
I mean, credit to Doctor Doom, FOOLS is a gender neutral way to address an entire room.

The title case in the "Thames Murders" box from Sherlock Holmes Consulting Detective was a nice, juicy one.

RT @cassiejokes@twitter.com
Cat: I caught this for you *drops dead mouse*

Me, lying: omg thank you I love it

Cat: eat it

Me: but-

Cat: look me in the eyes and eat it

Overheard: "We should get some kind of ice cream novelty treat out of spite."

At grocery store: "Let's get the healthy kind. That way neither one of us likes it."

That's the third time we've tried to go out to dinner and arrived to find the place had gone out of business.

Want a calmer, advertising-free social media experience? joinmastodon.org/ Now with over 1.7 million users. I'm @peterdrake.

Show older
Qoto Mastodon

QOTO: Question Others to Teach Ourselves
An inclusive, Academic Freedom, instance
All cultures welcome.
Hate speech and harassment strictly forbidden.