Author Topic: The General Chit Chat Thread 3  (Read 325802 times)

Online Krudda

  • Member
  • Posts: 4053
  • repent
    • My Anime List
Re: The General Chit Chat Thread 3
« Reply #15920 on: May 03, 2014, 10:00:25 PM »
heh, I think I have enough fonts for the time being:


Actually, NEVAAARRR. I need MOAR fonts

Online RayIII

  • Member
  • Posts: 1037
  • I'll troll closer now
Re: The General Chit Chat Thread 3
« Reply #15921 on: May 03, 2014, 10:13:45 PM »
heh, I think I have enough fonts for the time being:


Actually, NEVAAARRR. I need MOAR fonts

Lol my font folder won't load the property menue.  :'(

Edit: explorer.exe, it crashed.  :o  Hey, It can't be that many...2314. I only installed thouse I need, I swear. WTF?
« Last Edit: May 03, 2014, 10:27:12 PM by RayIII »

Offline AlexM.

  • Member
  • Posts: 106
Re: The General Chit Chat Thread 3
« Reply #15922 on: May 03, 2014, 10:24:47 PM »
@Burk
Ternaries and function results as parameters take longer to be understood by the average student programmer, especially when the writer was ignoring any sort of familiar style guidelines the students may have seen before, like you did. The most important aspect in teaching someone programming is making him understand how the programs work in a way that's most familiar to them. That is, through natural language. I have simplified your prof's example a bit without losing any of the original readability.

Code: [Select]
if (ISSET($_REQUEST["action"]))
{
      $action = ActionBuilder::getAction(strtolower($_REQUEST["action"]));     
}
else   
{
      $action = ActionBuilder::getAction("");     
}
$vue = $action->execute();

Is naturally read as If the "action" parameter was set, get the action from the ActionBuilder according to the parameter, otherwise, get an empty (default?) action. Store the result after executing the action.

Your example however, is naturally read as:

Store the result after executing the action which is gotten from the ActionBuilder to which we pass either the "action" parameter, if it's set, or the empty string.

Which one do you think is most appropriate and requires the least effort to understand?

Online RayIII

  • Member
  • Posts: 1037
  • I'll troll closer now
Re: The General Chit Chat Thread 3
« Reply #15923 on: May 03, 2014, 10:30:56 PM »
Nostalgia Critic - Sailor Moon
http://www.youtube.com/watch?v=mziTsgji7to

What 14 years old? Noooooooooooooooooo ooooooooooooooooooo ooooooooooooooooooo ooo

Online Krudda

  • Member
  • Posts: 4053
  • repent
    • My Anime List
Re: The General Chit Chat Thread 3
« Reply #15924 on: May 03, 2014, 10:32:05 PM »
So I reinstalled a fresh copy of windows on my Desktop and... something is up with the PnP monitor driver. "The device cannot start. (code 10)"
I can't even install my own drivers because it keeps telling me to go online and get the latest drivers, WTF!

I've never encountered this before, always just format > load drivers off CD > install software.
But this time... I don't get it?
It looks god awful using 640x480 resolution on a 1920x1080 monitor, especially when that "monitor" is 46"...

Time to google this error code.
In the mean time, I went back to my previous windows install.

Nostalgia Critic - Sailor Moon
http://www.youtube.com/watch?v=mziTsgji7to

What 14 years old? Noooooooooooooooooo ooooooooooooooooooo ooooooooooooooooooo ooo
Ba ha ha, first youtube video I've watched in aaaages, and I fucking loved it. (so far)
"Stupid girl transforms into slutty form with magical powers that make her look even more stoopid"

edit: Oh fuck man, I'm pissing myself here "sailor darth vader"
xDxDxDxDxD

Alright, gotta stop here. Even @240p, I've already gone through 100MB
« Last Edit: May 03, 2014, 10:41:51 PM by Krudda »

Online Tiffanys

  • Member
  • Posts: 7742
  • real female girl ojō-sama
Re: The General Chit Chat Thread 3
« Reply #15925 on: May 03, 2014, 10:40:40 PM »
Holy shit... someone just hacked into my LastPass and disabled my Grid multi-factor authentication which means they also had access to that e-mail address...
-_____-

Whoever designed Paypal's anti-copy/paste for changing passwords was a douchebag and a moron. It literally serves no purpose....

Offline Tatsujin

  • Box Fansubs
  • Member
  • Posts: 15633
    • Otakixus
Re: The General Chit Chat Thread 3
« Reply #15926 on: May 04, 2014, 12:33:24 AM »
Otaku from Japan are actually purchasing the American localized anime because it's cheap and comes with BD/DVD. So far the lowest stars on Amazon is 4.5 out of 5.


¸¸,.-~*'¨¨¨™¤¦ Otakixus ¦¤™¨¨¨'*~-.,¸¸

Online Krudda

  • Member
  • Posts: 4053
  • repent
    • My Anime List
Re: The General Chit Chat Thread 3
« Reply #15927 on: May 04, 2014, 01:06:53 AM »
Anime otaku from Japan are actually purchasing the American localized anime because it's cheap and comes with BD/DVD. So far the lowest stars on Amazon is 4.5 out of 5.
And this is precisely why Bandai closed their US market.
I also firmly believe the whole "Japan charges more because it's a niche market and nobody there want's to buy 'cheap crap' argument" is bullshit, due to this. It' clear Japan has changed. If they drop prices again (they conducted a test before) I bet the results would be MASSIVELY different to the last time they tested it.

That's my belief, and I'm sticking to it.

Offline Burkingam

  • Member
  • Posts: 8676
  • Love, Science & Dubstep
Re: The General Chit Chat Thread 3
« Reply #15928 on: May 04, 2014, 01:39:19 AM »
The most important aspect in teaching someone programming is making him understand how the programs work in a way that's most familiar to them.
I beg differ. I think programmers can be more productive if they understand a language in its own logic than if they try to translate it in common English. Furthermore, when  you create a "buffer" variable it creates the expectation that it might be used again if you have to remember that this variable has been created for the rest of the algorithm it dilutes your attention for the rest. Redundancies in the code also makes it harder to modify.
Don't just assume that you are right. Verify with the best tools available and if you are wrong, change your mind and you will become right.

Offline Tatsujin

  • Box Fansubs
  • Member
  • Posts: 15633
    • Otakixus
Re: The General Chit Chat Thread 3
« Reply #15929 on: May 04, 2014, 02:01:37 AM »
Well, their BDs do pack a lot of goods, art, better casing, extras, etc. Unlike the localized American stuff. The materials also feels way better.


¸¸,.-~*'¨¨¨™¤¦ Otakixus ¦¤™¨¨¨'*~-.,¸¸

Online Krudda

  • Member
  • Posts: 4053
  • repent
    • My Anime List
Re: The General Chit Chat Thread 3
« Reply #15930 on: May 04, 2014, 02:09:55 AM »
Dafuq lol :-\

Online Tiffanys

  • Member
  • Posts: 7742
  • real female girl ojō-sama
Re: The General Chit Chat Thread 3
« Reply #15931 on: May 04, 2014, 02:11:08 AM »
You might have the wrong language set.

Online Krudda

  • Member
  • Posts: 4053
  • repent
    • My Anime List
Re: The General Chit Chat Thread 3
« Reply #15932 on: May 04, 2014, 02:30:48 AM »
"English US"
only other option is "English UK"
I'm pretty sure, neither would leave out such a valuable word as "movie"

Besides, it's only on this program "Notepad++"
No other program thinks it's a spelling error

Offline megido-rev.M

  • Member
  • Posts: 16121
Re: The General Chit Chat Thread 3
« Reply #15933 on: May 04, 2014, 02:36:50 AM »
Holy shit... someone just hacked into my LastPass and disabled my Grid multi-factor authentication which means they also had access to that e-mail address...

Wow, that really sucks.

---

Man, I ate so much bread tonight.

Offline froody1911

  • Member
  • Posts: 7210
  • Confucius say man's last will is dead giveaway.
    • froody1911
Re: The General Chit Chat Thread 3
« Reply #15934 on: May 04, 2014, 04:00:58 AM »
My webdevelopment teacher always makes code in ways that complicates things for nothing, IMHO. For example he writes:
Quote
if (ISSET($_REQUEST["action"]))
   {
      $action = ActionBuilder::getAction(strtolower($_REQUEST["action"]));
      $vue = $action->execute();
   }
else   
   {
      $action = ActionBuilder::getAction(strtolower(""));
      $vue = $action->execute();
   }
When he could have written
Quote
$vue = ActionBuilder::getAction(
   ISSET($_REQUEST["action"])?
      strtolower($_REQUEST["action"]):
      ""
)->execute();
(the $action variable isn't used anywhere else)

The ternary operator is kind of a no-no. At least I'd never use it myself in actual code. But yeah, even without that he could have written it better.
I think readability should take priority over terseness while teaching a language. These tips and tricks and refactoring methods should be taught in parallel but separately.
« Last Edit: May 04, 2014, 04:04:07 AM by froody1911 »

MAL | Your mother was a father and your hamster smelt of elderberries | last.fm

Offline Burkingam

  • Member
  • Posts: 8676
  • Love, Science & Dubstep
Re: The General Chit Chat Thread 3
« Reply #15935 on: May 04, 2014, 04:02:58 AM »
In PHP, it's recommended to never combine two ternary operators together because they start acting wrong, but one works just fine. I don't see why I wouldn't use it. Less redundancy is better.
Don't just assume that you are right. Verify with the best tools available and if you are wrong, change your mind and you will become right.

Offline AlexM.

  • Member
  • Posts: 106
Re: The General Chit Chat Thread 3
« Reply #15936 on: May 04, 2014, 02:35:04 PM »
The most important aspect in teaching someone programming is making him understand how the programs work in a way that's most familiar to them.
I beg differ. I think programmers can be more productive if they understand a language in its own logic than if they try to translate it in common English. Furthermore, when  you create a "buffer" variable it creates the expectation that it might be used again if you have to remember that this variable has been created for the rest of the algorithm it dilutes your attention for the rest. Redundancies in the code also makes it harder to modify.

You seek productivity in the wrong places. What you did to your professor's code is more akin to code golfing rather than refactoring.

if they understand a language in its own logic

The logic behind languages that fit the imperative programming paradigm (PHP is one of them) is imperative programming itself. You have a sequence of steps that change the state of the program when they're executed. This holds true for any language that allows you to do this; a broken logic written down in PHP is still broken if transposed in another language.

Specific languages provide extra tools that let you express your intent more easily. The ternary operator is one of them, and if used wisely, can make code shorter without affecting readability.

Code: [Select]
$car_speed = IsKeyPressed() ? 100 : 0;

It's best applied when the statements are short and can be quickly read by the programmer. When you have to split the statement into multiple lines, it means it's too long. Jumping from line to line and merging them all into a single expression takes longer than staying on the same line for the reader. Productivity is decreased in this case.

Furthermore, when  you create a "buffer" variable it creates the expectation that it might be used again if you have to remember that this variable has been created for the rest of the algorithm it dilutes your attention for the rest.

This is not true. For this case, I'll mention that variables have:

1) A name. If set properly, the name itself will tell you what the variable is used for. This increases the productivity tremendously, because it lets programmers have a better grasp of the algorithm laid before their eyes. Intermediate results can be stored safely in one-shot variables if the names of the variables make the code easier to understand. An example below where an intermediate variable is a nicer choice than plugging in the formula as a parameter or wrapping it in a separate function.

Code: [Select]
$required_experience = Sqr($current_level * 0.5f);
ShowExperienceDifference($required_experience, $current_experience);

v.s.

Code: [Select]
ShowExperienceDifference(Sqr($current_level * 0.5f), $current_experience); //Is the result of Sqr the required experience or something else?

2) A scope. As a rule of thumb, a variable must be declared in the scope most fit for it, and its lifetime must end when the execution goes out of that scope. Usually, you deal with variables local to methods and functions. Methods and functions, to be easily read and understood, should be as short as possible. The average, as I've noticed, lies around ~8 to 10 lines of properly formatted code. 8 lines is not a lot of code through which to remember about a specific variable. If the variable is also aptly named, you won't even call it remembering the variable. You'll call it understanding the variable's purpose. It won't dilute your attention to the rest.

Redundancies in the code also makes it harder to modify.

With this I agree. Your professor did duplicate code without reason, which is something bad to show students too. Duplicated code requires duplicated modifications, thus kills productivity. However, you went way farther than removing duplicated code.

To give myself as an example, I managed to parse your professor's code in a single go, without having to stop once. Leaving the duplication aside, it was really just this:

Code: [Select]
check if a parameter is set; get an action; execute it;

Yours however, had me stop and double check if the formatting was what I thought it was (it especially had me stop at parsing the multiline ternary), how function results are passed directly as parameters, how deep this nesting actually goes, and what gets -> execute()'d. Basically, I immediately marked it as a possible source of bugs or misunderstood behavior.

If there's anything that really kills productivity and any flow you might be finding yourself in, it's having to completely stop to understand a tiny piece of code.

You may be biased now because you wrote your golfed code a short while back and understand it perfectly. Come back to it a year from now, and I can guarantee it will make you stop, even for a few seconds, to carefully tell its true intentions (i.e. where it might fail, what gets returned and where, and what gets executed).
« Last Edit: May 04, 2014, 02:43:35 PM by AlexM. »

Offline kurandoinu

  • Member
  • Posts: 9671
  • I am not a robot, I am a unicorn
Re: The General Chit Chat Thread 3
« Reply #15937 on: May 04, 2014, 02:40:33 PM »
Woah. A little tl;dr for the general chit chat thread

Online Krudda

  • Member
  • Posts: 4053
  • repent
    • My Anime List
Re: The General Chit Chat Thread 3
« Reply #15938 on: May 04, 2014, 02:49:16 PM »
Is there some way to make Danganronpa harder? Even on maximum difficulty, I'm breezing through it.

Offline froody1911

  • Member
  • Posts: 7210
  • Confucius say man's last will is dead giveaway.
    • froody1911
Re: The General Chit Chat Thread 3
« Reply #15939 on: May 04, 2014, 03:08:42 PM »
Yours however, had me stop and double check if the formatting was what I thought it was (it especially had me stop at parsing the multiline ternary), how function results are passed directly as parameters, how deep this nesting actually goes, and what gets -> execute()'d. Basically, I immediately marked it as a possible source of bugs or misunderstood behavior.

If there's anything that really kills productivity and any flow you might be finding yourself in, it's having to completely stop to understand a tiny piece of code.

You may be biased now because you wrote your golfed code a short while back and understand it perfectly. Come back to it a year from now, and I can guarantee it will make you stop, even for a few seconds, to carefully tell its true intentions (i.e. where it might fail, what gets returned and where, and what gets executed).

I agree with this bit completely. I've occasionally come back to a program I wrote just one week before and been completely unable to grasp the logic of it, because I wrote sections of it opaquely.

While you're coding for yourself, it's entirely up to you what style you want to write, but in any sort of research or collaborative project you need to ensure a balance between terseness and transparency. All I'm saying is, don't make it a fixed habit to write terse code.

MAL | Your mother was a father and your hamster smelt of elderberries | last.fm