? Success

User tests: Successful: Unsuccessful:

avatar malukenho
malukenho
27 Jan 2016

Turn the meaning of the hardcoded number explicit

avatar malukenho malukenho - open - 27 Jan 2016
avatar malukenho malukenho - change - 27 Jan 2016
Status New Pending
avatar joomla-cms-bot joomla-cms-bot - change - 27 Jan 2016
Labels Added: ?
avatar brianteeman
brianteeman - comment - 27 Jan 2016

What is the benefit of this change?

avatar malukenho
malukenho - comment - 27 Jan 2016

@brianteeman turn explicit the meaning of this number on code. I guess it's much more easy to read in that way.

avatar brianteeman
brianteeman - comment - 27 Jan 2016

Seems harder to read to me

avatar malukenho
malukenho - comment - 27 Jan 2016

@brianteeman do you think that the number itself is "self-explanatory"?

avatar brianteeman
brianteeman - comment - 27 Jan 2016

Speaking purely personally - yes

avatar malukenho
malukenho - comment - 27 Jan 2016

@brianteeman then should I close this one?

avatar brianteeman
brianteeman - comment - 27 Jan 2016

Maybe others agree with you

avatar joomdonation
joomdonation - comment - 27 Jan 2016

I think it is easier to read. It is hard to know that 1048576 is 1MB

avatar mbabker
mbabker - comment - 27 Jan 2016

I don't think you need to define it as a constant to give it meaning. It's just as easy to put a comment above the line saying "convert to megabytes, 1048576 bytes = 1MB" (or something like that).

avatar brianteeman
brianteeman - comment - 27 Jan 2016

You youngsters - i see that number and automatically know its 1mb ;)

On 27 January 2016 at 12:34, Michael Babker notifications@github.com
wrote:

I don't think you need to define it as a constant to give it meaning. It's
just as easy to put a comment above the line saying "convert to megabytes,
1048576 bytes = 1MB" (or something like that).


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

Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
http://brian.teeman.net/

avatar malukenho
malukenho - comment - 27 Jan 2016

@mbabker constants make it easy to change, as change in one line. also, I want to avoid put unnecessary comments if I can explain it just in code, and this number appear twice on this code, so I feel bad to comment it 2 times.

avatar brianteeman
brianteeman - comment - 27 Jan 2016

But its never going to change

On 27 January 2016 at 12:37, Jefersson Nathan notifications@github.com
wrote:

@mbabker https://github.com/mbabker constants make it easy to change,
as change in one line. also, I want to avoid put unnecessary comments if I
can explain it just in code, and this number appear twice on this code, so
I feel bad to comment it 2 times.


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

Brian Teeman
Co-founder Joomla! and OpenSourceMatters Inc.
http://brian.teeman.net/

avatar malukenho
malukenho - comment - 27 Jan 2016
avatar mbabker
mbabker - comment - 27 Jan 2016

Defining it as a class constant adds the constant as a part of the public API and assumes that value is in some way expected to be used outside JProfiler. And by the time you've added the full doc block for the constant you've added more lines to the file (see JVersion::PRODUCT as an example) than just simple one line comments in two places. As for things changing, doubtful; changing units would be a B/C break (the redesigned profiler in the Framework doesn't even do conversions but just stores all values in bytes and lets the user convert if they choose).

avatar malukenho
malukenho - comment - 27 Jan 2016

@mbabker ONE_MEGABYTE will never change, if you want to change the value you should create another constant as TWO_MEGABYTE, and for BC break, it'll happens anyway if the value is changed. I see no problem with dock block as it'll not duplicate things (comments). I see no point to make it less clear.

avatar mbabker
mbabker - comment - 27 Jan 2016

It's crystal clear regardless of whether it's a class property, constant,
or a comment. There is no need to make properties and constants out of
arbitrary values that are used in one or two places. If there were
numerous references to the value across the CMS, it'd be a different
argument. But your proposal is seriously equating to "we use this integer
twice in this class, define it as a constant to give it some sort of extra
meaning".

On Wednesday, January 27, 2016, Jefersson Nathan notifications@github.com
wrote:

@mbabker https://github.com/mbabker ONE_MEGABYTE will never change, if
you want to change the value you should create another constant as
TWO_MEGABYTE, and for BC break, it'll happens anyway if the value is
changed. I see no problem with dock block as it'll not duplicate things
(comments). I see no point to make it less clear.


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

avatar malukenho
malukenho - comment - 27 Jan 2016

Thanks @mbabker and @brianteeman for the fast answers. I'm closing it right now :smile:

avatar malukenho malukenho - change - 27 Jan 2016
Status Pending Closed
Closed_Date 0000-00-00 00:00:00 2016-01-27 14:17:11
Closed_By malukenho
avatar malukenho malukenho - close - 27 Jan 2016
avatar malukenho malukenho - close - 27 Jan 2016
avatar malukenho malukenho - head_ref_deleted - 27 Jan 2016

Add a Comment

Login with GitHub to post a comment