2 ms·
I am curious, how would you assess the readability of my code: http://github.com/EGreg/Platform http://github.com/EGreg/Platform I kind of developed that styl
by EGreg 11y ago
I am curious, how would you assess the readability of my code:
http://github.com/EGreg/Platform http://github.com/EGreg/Platform
I kind of developed that style organically as I went along, in both PHP and JS.
I tried to make the output readable as well. I've seen many frameworks output a bunch of gibberish, but with today's bandwidth it's not such a big deal to add a little bit of whitespace and make everything readable. Here's a fairly complex application, you can view the source of any page:
http://qbixstaging.com/Groups/ http://qbixstaging.com/Groups/
- akamaozu 11y agoThere's a bunch of directories where you keep the PHP and JS files in the same directory, like this one: https://github.com/EGreg/Platform/tree/master/platform/plugins/Awards/classes/Awards https://github.com/EGreg/Platform/tree/master/platform/plugi... Any special rationale behind that approach?
- Domenic_S 11y agoI can give you some feedback since I tend to write a lot of PHP. Mostly, code style is about consistency. You can have infinite arguments about whether opening braces should go on the same line as the operator/function, but at the end of the day as long as you stay consistent it doesn't really matter. Here are some consistency issues I found. Your function declarations put the opening brace on the following line, but flow controls open on the same lines. Ex: https://github.com/EGreg/Platform/blob/master/platform/plugins/Metrics/classes/Metrics.php#L115-L117 https://github.com/EGreg/Platform/blob/master/platform/plugi... In the same vein, commenting seems inconsistent - this file's docblock opens with /* */ style comments, but then you switch to // style. Ex: https://github.com/EGreg/Platform/blob/master/platform/Q.php#L24-L26 https://github.com/EGreg/Platform/blob/master/platform/Q.php... Further down, you use two styles of if(), one with braces and one without, right next to each other: https://github.com/EGreg/Platform/blob/master/platform/Q.php#L71-L77 https://github.com/EGreg/Platform/blob/master/platform/Q.php... I much prefer 2 space indents to tabs. To me, it's much more readable. I noticed your HTML output is also tabbed, which (arguably) needlessly increases the horizontal width you need to see a page of code, especially with modern deeply-nested structures. Overall the project looks well thought out, and you may have valid reasons for any/all of the above. Just throwing in my initial reactions as a project outsider. Also, dunno if you know about PSR, but here it's a good starting point that many people (potential contributors) are familiar with: http://www.php-fig.org/psr/psr-2/ http://www.php-fig.org/psr/psr-2/
- EGreg 11y agoThanks for the reference! PSR-2 looks useful. I guess I wanted to know more feedback about the design and architecture of the system, the names for things etc.