Code readability question. Which is better, A or B?

Bar discussions . Talk about everything not only php !. Guests are welcome here , forum registration is not required.

Moderators: egami, macek, gesf

Post Reply

Which do you think is easier to read? A or B?

Poll ended at Fri Sep 21, 2018 3:50 pm

A
0
No votes
B
0
No votes
 
Total votes: 0
clone45
New php-forum User
New php-forum User
Posts: 1
Joined: Sun Sep 16, 2018 3:41 pm

Sun Sep 16, 2018 3:50 pm

Hello! I'd like to get some feedback on a code readability question. I'm not going to state my personal opinion here because I don't want to sway your decision. Here are the two chunks of code. Please note that we use the Laravel framework, and one of the examples uses Laravel helper functions called data_set and data_get. (see https://laravel.com/docs/5.7/helpers#method-data-get)

Here's A)

Code: Select all

data_set($result, '_raw.'.$lnp_service::getName(), data_get($response_payload, '_raw'));
Here's B)

Code: Select all

$lnp_service_name = $lnp_service::getName();
$raw_response_payload = $response_payload['_raw'];
            
$result["_raw.$lnp_service_name"] = raw_response_payload;
Of course, without context, both might seem a little bit strange. But generally speaking, what's your opinion? Which is easier to read and understand? Please use the polling option to cast your vote.

Post Reply