SA-MP Forums

Go Back   SA-MP Forums > Other > Everything and Nothing

Thread Tools Display Modes
Old 24/03/2017, 08:36 PM   #31
Big Clucker
Spydro's Avatar
Join Date: Oct 2015
Location: United Kingdom
Posts: 133
Reputation: 15
Default Re: Why do people do this?

Originally Posted by Y_Less View Post
He lives.
Spydro is offline   Reply With Quote
Old 24/03/2017, 09:25 PM   #32
Toroi's Avatar
Join Date: Feb 2017
Location: Venezuela
Posts: 744
Reputation: 137
Default Re: Why do people do this?

Originally Posted by Y_Less View Post
So to your original question - why do it for single variables? Consistency. I admit that for just one variable it can look a little odd, but I don't mind a little oddity at one variable for the huge benefits on multiple variables. When writing code, sometimes I don't know if I will need one or more variables declaring; if I declare a single variable in one style then add a second, I have to go back and edit the style of the first instead of just appending. If I don't know how many variables I need, and had different styles depending on the number, then that would also actually slow me down - type "new" then stop and think, do I need to press enter now or not? Instead, type new, hit enter without even thinking, automatically indent to the right place, add the first variable, and by then I might know if I need a second or not, but it doesn't matter either way. Plus, as I said, consistency - if all the variables are on a new line, they all look the same and it becomes easier to parse code quickly; variables are (usually) a very short line followed by an indented block of text - that is a nice general pattern that is easy to spot from a distance without having to read too closely. Putting a single variable on one line, while surrounded by other code, just becomes another long line of text in a load of long lines of text. Yes, syntax highlighting helps, but so does this for the same reasons - pattern matching is faster than reading.
That's a valid reason. However, as you stated they do still look odd, even if they follow the same pattern than multiple lines/declarations.

This is from your file (which at this point i don't know who wrote it)

PHP Code:
begin __ps_data[e_PLAYER_SET_HACK_DATA][0];
// Is this a single value element (group or ID).
if (_:addr == begin)
It looks weird, completely out of place and disturbing in my opinion.

This is the same file few lines below
PHP Code:
sFake[MAX_PLAYERS] = {(INVALID_PLAYER_ID << 8) | 0x0F0000F0};
ret = (__ps_data[e_PLAYER_SET_HACK_DATA] = sFake),
    foreach (new 
playerid Player)
Although there is a 'new line single declaration', it is followed by a multiple line-declaration pattern which makes it look good, or not too bad. That does backup what you explained above.

However, in the first example it does look not only not good but bad, because it is the only declaration inside that function, there's no pattern to follow there or a near structure of which you can compare them, so it just does look bad.
Toroi is offline   Reply With Quote
Old 06/04/2017, 01:04 PM   #33
Huge Clucker
Runn3R's Avatar
Join Date: Dec 2013
Location: Croatia, Split
Posts: 377
Reputation: 35
Default Re: Why do people do this?

I was a person like you before but when i saw y_less's and emmets code i decided to switch to that hence it looks more cleaner and easier to read.
SA-MP 0.3.8 release date == Half Life 3 release date
Runn3R is offline   Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
for all you people who -rep pepper Everything and Nothing 13 05/02/2013 02:53 AM
Why some people lost all their things when login and some people not? CTCCoco Help Archive 1 07/07/2011 11:05 AM
SA-MP people plz help me! KILLER190 Client Support 5 29/10/2010 10:35 PM
People Scaming People's Severs coutanche7 General 19 28/12/2008 05:06 PM

All times are GMT. The time now is 07:00 AM.

Powered by vBulletin® Version 3.8.6
Copyright ©2000 - 2017, Jelsoft Enterprises Ltd.