Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I work in a PHP development shop and several new developers have joined the team. One of the new members insists on declaring class properties at the bottom of the class declaration rather than the at the top, as one would normally expect.

In all my 5 years of working in web development, I have never seen this done. Is it a common coding style?

share|improve this question

closed as not constructive by Bill the Lizard, gnat, Walter, Jarrod Roberson, ChrisF Jun 9 '12 at 11:37

As it currently stands, this question is not a good fit for our Q&A format. We expect answers to be supported by facts, references, or expertise, but this question will likely solicit debate, arguments, polling, or extended discussion. If you feel that this question can be improved and possibly reopened, visit the help center for guidance.If this question can be reworded to fit the rules in the help center, please edit the question.

3  
No you are not. Even if it was the inverse and your shop did what he does he should be conforming to the coding standards in place. Actually though, I have no idea where he could have possibly picked up that practice unless he is a non-pro programmer. –  Rig Jun 6 '12 at 14:18
    
Ask him if he prefers top-down or bottom-up development. Once he answers with the former, proceed to rip him. –  Jelkster Jun 6 '12 at 14:36
    
Although I can't know for sure, I'm guessing the down vote and close vote was because of the tone of your last paragraph, which I've edited to be a bit more constructive. I can understand your frustration, but we prefer posts to be written in a professional tone. –  Yannis Rizos Jun 6 '12 at 14:36
2  
I follow that coding style in Java, and I think of it this way: what is the most important thing about a class? Its public constants and public methods. These are the first things that should be apparent to the reader. As I go down in the source code, I'm digging deeper, and at the lowest level, I have the private fields. –  wrock Jun 6 '12 at 15:52
    
Be thankful they're all in one place. –  JeffO Jun 6 '12 at 16:53
show 2 more comments

3 Answers

up vote 2 down vote accepted

Some dev environments get around these kinds of issues by using static analysis tools - StyleCop for .NET and Checkstyle for Java. If there are any for php, I'd suggest getting one.

Likewise, it doesn't so much matter what style you, or your company, uses - just that it stays consistent. If you can't find a static analysis tool for php, then just document known style issues (don't discuss it, just document what exists in current, stable source files that people haven't had style problems with) and call that the style guide.

This is an issue that can explode into all kinds of bikeshedding. It's important to not let it become an issue where people feel like they can provide input.

Toss that up onto your project wiki/shared folder/whatever and send out an e-mail to the team.

If you're not a lead/senior/someone with the authority to do this then give the doc to your lead and ask that they do it.

Enforce it, and change it as appropriate, in code reviews.

share|improve this answer
add comment

Overview

Weird. I just discover I worked several years, putting properties at the bottom of the class declaration. And, later, several years, putting properties at the top of the class declaration, and, I almost didn't notice the change ...

Answer

Both, cases are good, but, int this specific case, your developer should stick to this company standard.

share|improve this answer
add comment

I think that the simplest way is to follow a coding standard like PEAR or Zend Framework and many others. so if the company have its own standards then the user must apply them.

share|improve this answer
add comment

Not the answer you're looking for? Browse other questions tagged or ask your own question.