?

User tests: Successful: Unsuccessful:

avatar malukenho
malukenho
22 Jul 2014

Make it more simple and easy to read.

avatar malukenho malukenho - open - 22 Jul 2014
avatar elkuku
elkuku - comment - 22 Jul 2014

Big :+1:

avatar wilsonge
wilsonge - comment - 22 Jul 2014

:+1:

avatar malukenho
malukenho - comment - 22 Jul 2014

@Ocramius Thanks :D

avatar Bakual
Bakual - comment - 22 Jul 2014

I don't think I like the last commit. It removes the instanceof checks. Or do I miss something?

Edit: Found what I missed. Variables are already typehinted in the function declaration.

avatar Ocramius
Ocramius - comment - 22 Jul 2014

@Bakual yes, and it is equivalent

avatar malukenho
malukenho - comment - 22 Jul 2014

If we already have typehiting, we do not need to check again. This is redundant.

avatar Bakual
Bakual - comment - 22 Jul 2014

Yep, fully agree with this change. :+1:

avatar b2z
b2z - comment - 25 Jul 2014

Can you make a PR for 3.x also? ;)

avatar Mathewlenning
Mathewlenning - comment - 26 Jul 2014

I don't like this change. ternary conditionals have little to no expressive value and just make the code harder to learn.

Instead I would suggest:
if(is_null($input)
{
$input = new JInput();
}
$this->input = $input;

Expressive code is important to reducing the learning curve.

avatar Ocramius
Ocramius - comment - 26 Jul 2014

This code is very expressive imo. Additional conditionals only distract
from what is actually relevant.
On 26 Jul 2014 16:50, "Mathew Lenning" notifications@github.com wrote:

I don't like this change. ternary conditionals have little to no
expressive value and just make the code harder to learn.

Instead I would suggest:
if(is_null($input)
{
$input = new JInput();
}
$this->input = $input;

Expressive code is important to reducing the learning curve.


Reply to this email directly or view it on GitHub
#3943 (comment).

avatar Mathewlenning
Mathewlenning - comment - 26 Jul 2014

Ocramius, how long have you been coding?

When we program we should be thinking about the person that just heard about Joomla from a friend. They haven't read a single "Joomla" book and only googled PHP yesterday.

So read this outloud and tell me is it English? $this->input = $input ?: new JInput;
Make sure you read exactly what is written not the covered association that you gained through X Years of developer experience.

I read it as "This input equals input question mark colon new JInput." Is that English?

Now read my version

"If is null input, input equals new Jinput. This input equals input." That is what expressive code is about.

avatar Ocramius
Ocramius - comment - 26 Jul 2014

I am fairly sure about my previous statement.
On 26 Jul 2014 17:32, "Mathew Lenning" notifications@github.com wrote:

Ocramius, how long have you been coding?

When we program we should be thinking about the person that just heard
about Joomla from a friend. They haven't read a single "Joomla" book and
only googled PHP yesterday.

So read this outloud and tell me is it English? $this->input = $input ?:
new JInput;
Make sure you read exactly what is written not the covered association
that you gained through X Years of developer experience.

I read it as "This input equals input question mark colleen new JInput."
Is that English?

Now read my version

"If is null input, input equals new Jinput. This input equals input." That
is what expressive code is about.


Reply to this email directly or view it on GitHub
#3943 (comment).

avatar dbhurley
dbhurley - comment - 26 Jul 2014

Agreed with @Bakual, @elkuku, and @b2z - the code, simple, clean and to the point. +1 @Ocramius

avatar Achal-Aggarwal
Achal-Aggarwal - comment - 26 Jul 2014

How about keeping those comments? For example

// If a client object is given use it otherwise instantiate a new web client object.
 $this->client = $client ?: new JWebClient;
avatar Ocramius
Ocramius - comment - 26 Jul 2014

The elvis operator has pretty much only one purpose, which is implemented
here ;-) I just don't see how any further clarification/comment could be
needed.
On 26 Jul 2014 18:51, "Achal-Aggarwal" notifications@github.com wrote:

How about keeping those comments? For example

// If a client object is given use it otherwise instantiate a new web client object.
$this->client = $client ?: new JWebClient;


Reply to this email directly or view it on GitHub
#3943 (comment).

avatar roland-d
roland-d - comment - 26 Jul 2014

@test: Looks good to me.

avatar wilsonge
wilsonge - comment - 26 Jul 2014

@test works as expected. Please merge this and close the arguments

avatar Mathewlenning
Mathewlenning - comment - 26 Jul 2014

No argument here. If you already know that it is called an elvis operator good to go right.

If not, take your mind off learning the program and google "?:" to find out what the this means.

Sincerely,
Mathew Lenning

Babel-university.com

P.S. This message was sent via iPhone, so please forgive any errors

On Jul 27, 2014, at 2:20 AM, George Wilson notifications@github.com wrote:

@test works as expected. Please merge this and close the arguments

\
Reply to this email directly or view it on GitHub.

avatar dbhurley dbhurley - change - 26 Jul 2014
Status New Closed
Closed_Date 0000-00-00 00:00:00 2014-07-26 23:34:06
avatar dbhurley dbhurley - close - 26 Jul 2014
avatar dbhurley dbhurley - reference | - 26 Jul 14
avatar dbhurley dbhurley - merge - 26 Jul 2014
avatar dbhurley dbhurley - close - 26 Jul 2014
avatar b2z
b2z - comment - 27 Jul 2014

And what about Joomla 3? ;)

avatar wilsonge
wilsonge - comment - 27 Jul 2014

Unfortunately we've had to revert this because it didn't have PHP5.2 support (Elvis operators are 5.3+). I've done the same thing in #3996 but with 5.2 support by adding the extra expression in

avatar Ocramius
Ocramius - comment - 27 Jul 2014

Argh, Joomla is still on 5.2? :-(

avatar wilsonge
wilsonge - comment - 27 Jul 2014

2.5 is 5.2 and higher (which is the branch you PR'd to). 3.x is 5.3.10 and higher

avatar Mathewlenning
Mathewlenning - comment - 27 Jul 2014

Does this help illustrate why Elvis shouldn't be used in Joomla?

Wasting cognitive energy on making distinctions between PHP versions isn't going to make anyone's life easier.

I know some of you might think I'm just being a code snob, but these little things add up quickly.

For the sake of saving a few lines, you raise the learning curve substantially.

Program for people, not machines really has value in real world software development.

Sincerely,
Mathew Lenning

Babel-university.com

P.S. This message was sent via iPhone, so please forgive any errors

On Jul 27, 2014, at 5:57 PM, George Wilson notifications@github.com wrote:

2.5 is 5.2 and higher (which is the branch you PR'd to). 3.x is 5.3.10 and higher

\
Reply to this email directly or view it on GitHub.

avatar Ocramius
Ocramius - comment - 27 Jul 2014

@Matthew I'd rather say "code for this decade". It's a completely different
argument, can't do much if joomla keeps maintaining for dead horses.

The patch should still land in 3.x

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

On 27 July 2014 11:41, Mathew Lenning notifications@github.com wrote:

Does this help illustrate why Elvis shouldn't be used in Joomla?

Wasting cognitive energy on making distinctions between PHP versions isn't
going to make anyone's life easier.

I know some of you might think I'm just being a code snob, but these
little things add up quickly.

For the sake of saving a few lines, you raise the learning curve
substantially.

Program for people, not machines really has value in real world software
development.

Sincerely,
Mathew Lenning

Babel-university.com

P.S. This message was sent via iPhone, so please forgive any errors

On Jul 27, 2014, at 5:57 PM, George Wilson notifications@github.com
wrote:

2.5 is 5.2 and higher (which is the branch you PR'd to). 3.x is 5.3.10
and higher

\
Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub
#3943 (comment).

avatar Mathewlenning
Mathewlenning - comment - 27 Jul 2014

Code for this decade and it will be obsolete five years from now.

Clean expressive code is self evident. It withstands the test of time. When do you think they'll depreciate or change the IF statement behavior?

Sincerely,
Mathew Lenning

Babel-university.com

P.S. This message was sent via iPhone, so please forgive any errors

On Jul 27, 2014, at 6:43 PM, Marco Pivetta notifications@github.com wrote:

@Matthew I'd rather say "code for this decade". It's a completely different
argument, can't do much if joomla keeps maintaining for dead horses.

The patch should still land in 3.x

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

On 27 July 2014 11:41, Mathew Lenning notifications@github.com wrote:

Does this help illustrate why Elvis shouldn't be used in Joomla?

Wasting cognitive energy on making distinctions between PHP versions isn't
going to make anyone's life easier.

I know some of you might think I'm just being a code snob, but these
little things add up quickly.

For the sake of saving a few lines, you raise the learning curve
substantially.

Program for people, not machines really has value in real world software
development.

Sincerely,
Mathew Lenning

Babel-university.com

P.S. This message was sent via iPhone, so please forgive any errors

On Jul 27, 2014, at 5:57 PM, George Wilson notifications@github.com
wrote:

2.5 is 5.2 and higher (which is the branch you PR'd to). 3.x is 5.3.10
and higher

\
Reply to this email directly or view it on GitHub.

\
Reply to this email directly or view it on GitHub
#3943 (comment).

\
Reply to this email directly or view it on GitHub.

avatar Ocramius
Ocramius - comment - 27 Jul 2014

http://www.antiifcampaign.com/ :-)

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

On 27 July 2014 12:39, Mathew Lenning notifications@github.com wrote:

Code for this decade and it will be obsolete five years from now.

Clean expressive code is self evident. It withstands the test of time.
When do you think they'll depreciate or change the IF statement behavior?

Sincerely,
Mathew Lenning

Babel-university.com

P.S. This message was sent via iPhone, so please forgive any errors

On Jul 27, 2014, at 6:43 PM, Marco Pivetta notifications@github.com
wrote:

@Matthew I'd rather say "code for this decade". It's a completely
different
argument, can't do much if joomla keeps maintaining for dead horses.

The patch should still land in 3.x

Marco Pivetta

http://twitter.com/Ocramius

http://ocramius.github.com/

On 27 July 2014 11:41, Mathew Lenning notifications@github.com wrote:

Does this help illustrate why Elvis shouldn't be used in Joomla?

Wasting cognitive energy on making distinctions between PHP versions
isn't
going to make anyone's life easier.

I know some of you might think I'm just being a code snob, but these
little things add up quickly.

For the sake of saving a few lines, you raise the learning curve
substantially.

Program for people, not machines really has value in real world
software
development.

Sincerely,
Mathew Lenning

Babel-university.com

P.S. This message was sent via iPhone, so please forgive any errors

On Jul 27, 2014, at 5:57 PM, George Wilson notifications@github.com

wrote:

2.5 is 5.2 and higher (which is the branch you PR'd to). 3.x is
5.3.10
and higher

\
Reply to this email directly or view it on GitHub.

\
Reply to this email directly or view it on GitHub
#3943 (comment).

\
Reply to this email directly or view it on GitHub.


Reply to this email directly or view it on GitHub
#3943 (comment).

avatar dbhurley
dbhurley - comment - 27 Jul 2014

Ok guys :) Too far off topic. Let's keep it to the code.

avatar Mathewlenning
Mathewlenning - comment - 27 Jul 2014

@David
Agreed. There is no point in arguing about an PR that had to be reverted anyway.

Happy Joomla!ng

Sincerely,
Mathew Lenning

Babel-university.com

P.S. This message was sent via iPhone, so please forgive any errors

On Jul 27, 2014, at 7:47 PM, David Hurley notifications@github.com wrote:

Ok guys :) Too far off topic. Let's keep it to the code.

\
Reply to this email directly or view it on GitHub.

Add a Comment

Login with GitHub to post a comment