Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Volmarias: seconded. I've used Processing to ease beginners into working with Java, and students typically respond very well to it. It makes it possible to first teach statements and expressions, then functional abstraction and only afterwards begin discussing OOP. Once they have written a number of games and programs in Processing making the transition to Java is generally pretty painless.

Adbot
ADBOT LOVES YOU

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Pollyanna posted:

That's partly why the guy brings up a "simple interactive graphical environment" as an alternative to learning about OOP. It's a lot more obvious and provides the abstraction/metaphors that humans need to really understand it.

I'd love to try something like that, actually.

Try Greenfoot or BlueJ.

Pollyanna
Mar 5, 2005

Milk's on them.


Processing is pretty cool so far, thanks for the tip.

Wheany posted:

Try Greenfoot or BlueJ.

I tried BlueJ, but for some reason it bugs out when I use it. I'll see if Greenfoot is better.

Internet Janitor posted:

Volmarias: seconded. I've used Processing to ease beginners into working with Java, and students typically respond very well to it. It makes it possible to first teach statements and expressions, then functional abstraction and only afterwards begin discussing OOP. Once they have written a number of games and programs in Processing making the transition to Java is generally pretty painless.

Do you have a course guide or example class or something? It'd be really nice to follow something like that.

Wheany
Mar 17, 2006

Spinyahahahahahahahahahahahaha!

Doctor Rope

Pollyanna posted:

I tried BlueJ, but for some reason it bugs out when I use it. I'll see if Greenfoot is better.

Seeing Greenfoot was the thing that made me realize that there is no reason the first Java lesson has to be "public static void main"

Internet Janitor
May 17, 2008

"That isn't the appropriate trash receptacle."
Pollyanna: I do have my course materials organized with brief step-by-step writeups online. If you were going to dive in you would first want to go through a few of the Processing tutorials to familiarize yourself with the basics I would've covered in the first day.

Doctor w-rw-rw-
Jun 24, 2008

Pollyanna posted:

That's partly why the guy brings up a "simple interactive graphical environment" as an alternative to learning about OOP. It's a lot more obvious and provides the abstraction/metaphors that humans need to really understand it.

I'd love to try something like that, actually.

aaaaand another full circle, this time to Smalltalk.

IT BEGINS
Jan 15, 2009

I don't know how to make analogies
php:
<?
if (pg_num_rows($pg_res) == 1) {
    $fromcity = pg_result($pg_res, 0, "city");
    $fromstate = pg_result($pg_res, 0, "state");
    $fromcompany = pg_result($pg_res, 0, "name");
    $fromaddress = pg_result($pg_res, 0, "address");
    $fromaddress2 = pg_result($pg_res, 0, "address2");
    $fromphone = pg_result($pg_res, 0, "phone");
}
?>
Please look up the function pg_result. Notice how it's not in the php.net documentation. Want to know why? It was deprecated 10 years ago.

I don't know what's worse: the fact that we are calling the old version of pg_fetch_result() 6 times instead of doing something sane; the fact that we are using functions that have been deprecated for 10 years; the fact that this function still works.

Zorro KingOfEngland
May 7, 2008

Java code:
private static final int DAYS_IN_A_MONTH = 30;
You know there's gonna be some great code when you open a file to see this staring at you.

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"

Zorro KingOfEngland posted:

Java code:
private static final int DAYS_IN_A_MONTH = 30;
You know there's gonna be some great code when you open a file to see this staring at you.

Clearly a forward-thinker who envisions the world as it should be. (Each month with 30 days with a 5-6 day party week in the middle during in the summer. Northern hemisphere summer.)

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
Pretty sure local summer with the dates being out of sync for half the year would be how it'd be implemented in the real world.

One Eye Open
Sep 19, 2006
Am I awake?

Zorro KingOfEngland posted:

Java code:
private static final int DAYS_IN_A_MONTH = 30;
You know there's gonna be some great code when you open a file to see this staring at you.

Maybe it was software for a Lunation calendar such as was used by the Sumerians, and was just rounding up.

Dr Monkeysee
Oct 11, 2002

just a fox like a hundred thousand others
Nap Ghost

Doctor w-rw-rw- posted:

aaaaand another full circle, this time to Smalltalk.

It makes sense that a GUI framework is the most natural OOP teaching example since arguably OOP was invented specifically to solve the GUI architecture problem.

My first job in industry was in Smalltalk and the language rocked pretty hard.

qntm
Jun 17, 2009

quote:

A `Timer` is a horizontal strip on the screen with a stripe
racing across it. A `NumericHalo` is a spreading ripple on the screen
that fades. A `Sound` is a thing on the screen that makes a sound when
a `Timer`’s stripe hits it. A `Trash` is a thing that deletes `Sound`s
when you drop them on it. They all inherit from `Visible`, which
represents things that can be drawn on the screen and perhaps respond
to mouse clicks or drop events, but they do different things in those
three cases. In addition, the `Trash` and `Sound`s are subclasses of
`ImageDisplay`, because the way they handle being drawn is simply to
display a static image, so that code is factored into a superclass.

In what asinine universe is this considered more intuitive than "Car extends Vehicle"?

Suspicious Dish
Sep 24, 2011

2020 is the year of linux on the desktop, bro
Fun Shoe

qntm posted:

In what asinine universe is this considered more intuitive than "Car extends Vehicle"?

In the universe where Car extends Vehicle doesn't explain anything about code reuse, delegation, or polymorphism?

Flobbster
Feb 17, 2005

"Cadet Kirk, after the way you cheated on the Kobayashi Maru test I oughta punch you in tha face!"
Yeah, GUI framework is a good OO example but the one presented in that post is pretty poo poo.

Back when I was still in academia, I was fond of the adventure game approach. You had a game engine/service, commands (if a text adventure) rooms, items, a player, monsters, and different subtypes of all these...

You could spend an entire class period asking students to contribute to a class design about how all these pieces related to each other and fit together. A lot of good opportunities to talk about reuse, coupling, and cohesion. And it was a lot more fun for them to implement and come up with a story of their own, too.

Macichne Leainig
Jul 26, 2012

by VG
Contrary to popular belief:

code:
Assert.IsTrue(true);
This is not a valuable unit test. I don't think this guy gets the point of unit tests.

(There were just under 6 dozen of these in the last check-in. :negative:)

LOOK I AM A TURTLE
May 22, 2003

"I'm actually a tortoise."
Grimey Drawer

Protocol7 posted:

Contrary to popular belief:

code:
Assert.IsTrue(true);
This is not a valuable unit test. I don't think this guy gets the point of unit tests.

(There were just under 6 dozen of these in the last check-in. :negative:)

Possible explanations:
1. "I was going to fill it in later."
2. "I couldn't figure out what to assert on."
3. "It's better than nothing."

PleasingFungus
Oct 10, 2012
idiot asshole bitch who should fuck off

qntm posted:

In what asinine universe is this considered more intuitive than "Car extends Vehicle"?

Yeah, that example honestly suggests 'interface' to me more than it suggests 'inheritance.'

e: hey, are you http://c1qfxugcgy0.tumblr.com/ ? Just noticed that your name seemed familiar, and you don't have PMs.


Protocol7 posted:

Contrary to popular belief:

code:
Assert.IsTrue(true);
This is not a valuable unit test. I don't think this guy gets the point of unit tests.

(There were just under 6 dozen of these in the last check-in. :negative:)

Sounds like they got stuck in during the initial creation of the unit tests (automatically?), and never taken out?

Then again, there are people who actually write "if (foo == true)", so... who knows.

(a == true and b == false are the two snippets of code that annoy me most in all the world. I hate them and I hate the people that wrote them.)

Macichne Leainig
Jul 26, 2012

by VG

LOOK I AM A TURTLE posted:

Possible explanations:
1. "I was going to fill it in later."
2. "I couldn't figure out what to assert on."
3. "It's better than nothing."

Considering the comments on the check in were (abridged) "Added unit tests for data mapping on deserialization" I'm hoping so, because those kinds of tests are kind of important.

ikanreed
Sep 25, 2009

I honestly I have no idea who cannibal[SIC] is and I do not know why I should know.

syq dude, just syq!
Those are certainly not as bad as the entirely real a.ToString()!="false".

ManoliIsFat
Oct 4, 2002

LOOK I AM A TURTLE posted:

3. "It's better than nothing."

That's true. That Assert failing may be indicative of larger problems, like up being down, day being night, 2nd coming of Jesus kinda stuff.

qntm
Jun 17, 2009

PleasingFungus posted:

e: hey, are you http://c1qfxugcgy0.tumblr.com/ ? Just noticed that your name seemed familiar, and you don't have PMs.

No, although this person appears to follow me on Twitter.

JawnV6
Jul 4, 2004

So hot ...

ManoliIsFat posted:

That's true. That Assert failing may be indicative of larger problems, like up being down, day being night, 2nd coming of Jesus kinda stuff.

Well in 10 days we'll be cursing the bank software authors that pushed these halfassed assumptions into production.

raminasi
Jan 25, 2005

a last drink with no ice

PleasingFungus posted:

Then again, there are people who actually write "if (foo == true)", so... who knows.

You have to do this (I think?) for Nullable<bool> in C# and every time I see one I do a double-take.

Plorkyeran
Mar 22, 2007

To Escape The Shackles Of The Old Forums, We Must Reject The Tribal Negativity He Endorsed
I've written the equivalent of Assert.IsTrue(true) because the actual test was just that the preceding code ran without throwing any exceptions and the test framework lacked Assert.DoesNotThrow and the runner only listed tests in the UI which actually asserted something.

ManoliIsFat
Oct 4, 2002

JawnV6 posted:

Well in 10 days we'll be cursing the bank software authors that pushed these halfassed assumptions into production.
Hahaha.

GrumpyDoctor posted:

You have to do this (I think?) for Nullable<bool> in C# and every time I see one I do a double-take.
Oh man, why haven't I ever tried that? For how many times I've typed "if(x.HasValue && x.Value)"

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

Protocol7 posted:

Contrary to popular belief:

code:
Assert.IsTrue(true);
This is not a valuable unit test. I don't think this guy gets the point of unit tests.

(There were just under 6 dozen of these in the last check-in. :negative:)

It's a good test if you're testing Assert.isTrue :colbert:

FlapYoJacks
Feb 12, 2009

Volmarias posted:

It's a good test if you're testing Assert.isTrue.

Perhaps Assert.isTrue may be false?!?!?

Scaevolus
Apr 16, 2007

ManoliIsFat posted:

Hahaha.
Oh man, why haven't I ever tried that? For how many times I've typed "if(x.HasValue && x.Value)"

"if (x ?? false)" more obviously indicates that you're dealing with a nullable type.

ManoliIsFat
Oct 4, 2002

Scaevolus posted:

"if (x ?? false)" more obviously indicates that you're dealing with a nullable type.
Way classier, thanks for that.

Volmarias
Dec 31, 2002

EMAIL... THE INTERNET... SEARCH ENGINES...

ratbert90 posted:

Perhaps Assert.isTrue may be false?!?!?

Thus the importance of writing automated tests. If someone should change the nature of truth, you shall be the first to know.

Dr Monkeysee
Oct 11, 2002

just a fox like a hundred thousand others
Nap Ghost

ManoliIsFat posted:

Way classier, thanks for that.

I disagree. That looks more confusing to me because I'm used to the null coalescing operator being used to generate a value I care about not just to check a condition.

I admit (x == true) isn't much better since it forces you to double-check the type of x to make sure the author wasn't a redundant moron.

ManoliIsFat
Oct 4, 2002

Monkeyseesaw posted:

I disagree. That looks more confusing to me because I'm used to the null coalescing operator being used to generate a value I care about not just to check a condition.

I admit (x == true) isn't much better since it forces you to double-check the type of x to make sure the author wasn't a redundant moron.
I don't know. I admit it is unique, may be a little "clever" but I think it clearly indicates you're dealing with this very specific and slightly odd situation of nullable<> bools. I feel you, usually coalesce is "give me a default value if there is none" or "if you don't find it here, check there", but I still like it.

IMlemon
Dec 29, 2008

PleasingFungus posted:

(a == true and b == false are the two snippets of code that annoy me most in all the world. I hate them and I hate the people that wrote them.)

Don't forget this classic

code:
return bool ? true : false

One Eye Open
Sep 19, 2006
Am I awake?

PleasingFungus posted:

Then again, there are people who actually write "if (foo == true)", so... who knows.

(a == true and b == false are the two snippets of code that annoy me most in all the world. I hate them and I hate the people that wrote them.)

"if (somebool == true)" aids readability and is a reminder of the types as you skim the code, however "if( (x > 3) == true)" implies you are being paid by the character. In either case, it's a stylistic choice as the compiler will produce the same output either way.

TheresaJayne
Jul 1, 2011
I recently had to update our unit tests that had become out of date about 2 years ago.

I came across these tests.

assertTrue(expectedValue == result);


:freakout:

Why not just use assertEquals(expectedValue,result);

shrughes
Oct 11, 2008

(call/cc call/cc)
Sometimes I catch myself writing foo == true for some boolean foo, and often it's a sign that the variable really wants to be an enum.

(gently caress you, anthropomorphized variable, you have to be a bool.)

bucketmouse
Aug 16, 2004

we con-trol the ho-ri-zon-tal
we con-trol the verrr-ti-cal

IMlemon posted:

Don't forget this classic

code:

return bool ? true : false

code:

if(a && b)
{
       if(b)
            hnnnggggggggg();
}


e: oh oh this thing too

code:


for(i=0;i<BIG_NUMBER;i++)
{
x = expensive_func();
total += i*x;
}

bucketmouse fucked around with this message at 11:28 on Oct 8, 2013

New Yorp New Yorp
Jul 18, 2003

Only in Kenya.
Pillbug
Consulting horror: Yesterday, I spent 5 hours on a train to Boston to do a demo for some Microsoft folks (and present the same material at a Microsoft-sponsored event today). I get off the train, head over to MS, and discover that my laptop no longer boots. :waycool:

I'm just happy that my demo VMs are in Azure, not on my laptop. Total disaster averted; I can borrow someone else's laptop or present from my Surface.

Adbot
ADBOT LOVES YOU

MononcQc
May 29, 2007

Ithaqua posted:

Consulting horror: Yesterday, I spent 5 hours on a train to Boston to do a demo for some Microsoft folks (and present the same material at a Microsoft-sponsored event today). I get off the train, head over to MS, and discover that my laptop no longer boots. :waycool:

I'm just happy that my demo VMs are in Azure, not on my laptop. Total disaster averted; I can borrow someone else's laptop or present from my Surface.

I'm paranoid when I go present poo poo at a conference. I keep:

  • Copy of the presentation in original format (ppt or keynote) on my laptop
  • A copy of each on a USB drive in case my laptop dies
  • A copy of each as a PDF both on the laptop or the USB drive in case software goes bad or the backup computer I get lent doesn't have the software needed
  • Copies of the presentation and everything on my VPS as a final backup
  • Adapters I need because I won't trust the organizers to have the setup I need

And things I present have to:

  • work locally in case the network dies or has bad quality
  • be readable in black and white in case I'm forced to print them out.
  • Alternatively some projectors are super lovely and will display reds as black or dark brown and I try to make sure this isn't messed up
  • I have terminal profiles that are dark-on-light backgrounds because they tend to be more readable, and presets with huge text sizes that are readable from far away
  • code must work on other OSes, possibly over my VPS in case my laptop gets bricked
  • Have a contingency plan in case power goes out entirely -- I've had to give a presentation during hurricane Irene where we had no power and before generators were going (or knowing how long they'd be going), we had to keep going. It's always in the back of my mind now.

When I gave week-long classes teaching Erlang, I'd also just make my own fully workable virtualbox machines, and I'd carry them with virtual box installers around so that people who inevitably came unprepared didn't need to take an hour to get up and running.

It's going well most of the time now.

MononcQc fucked around with this message at 13:25 on Oct 8, 2013

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply