Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1078217
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T21:41:24+00:00 2026-05-16T21:41:24+00:00

I prefer coding standards to be logical. This is my argument for why the

  • 0

I prefer coding standards to be logical. This is my argument for why the following set of standards are not.

I need to know one of two things: (1) why I’m wrong, or (2) how to convince my team to change them.

camelCase: Functions, class names, methods, and variables must be camelCase.

  • Makes it hard to differentiate between variables and classes
  • Goes against PHP’s lowercase/underscored variables/functions and UpperCamelCase classes

Example:

$customerServiceBillingInstance = new customerServiceBillingInstance(); // theirs
$customer_service_billing_instance = new CustomerServiceBillingInstance();

Functions/methods must always return a value (and returned values must always be stored).

This appears on hundreds of our php pages:

$equipmentList = new equipmentList();
$success = $equipmentList->loadFromDatabase(true, '');
$success = $equipmentList->setCustomerList();
$success = $equipmentList->setServerList();
$success = $equipmentList->setObjectList();
$success = $equipmentList->setOwnerList();
$success = $equipmentList->setAccessList();

The return value is rarely used but always stored. It encourages the use of copy-and-paste.

No static methods

Lines like the following appear thousands of times in the codebase:

$equipmentList = new equipmentList();
$success = $equipmentList->loadFromDatabase();

I would prefer:

$equipmentList = equipmentList::load();

What reason is there to not use static methods or properties? Aren’t static methods responsible for non-instance-specific logic? Like initializing or populating a new instance?

Your code is not OOP unless everything returns an object

There’s a piece of code that performs a query, checks it several ways for errors, and then processes the resulting array. It is repeated (copied+pasted) several times, so I put it in the base class. Then I was told returning an array is not OOP.

How do you defend these practices? I really do need to know. I feel like I’m taking crazy pills.

If you can’t defend them, how do you convince the adamant author they need to be changed?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T21:41:24+00:00Added an answer on May 16, 2026 at 9:41 pm

    I would suggest trying to list down the goals of your coding standards, and weigh them down depending on which goals is the most important and which goals are less important.

    PS: I don’t speak PHP, so some of these arguments may contain blatantly incorrect PHP code.

    camelCase: Functions, class names, methods, and variables must be camelCase.

    Workplace’s Apparent Reason: “consistency” at the cost of “information density in name”.

    Argument:

    1) Since ‘new’ keyword should always be followed by a class, then you can easily spot illegal instantiation, e.g.:

    $value = new functionName();
    $value = new local_variable();
    $value = new GLOBAL_VARIABLE();
    

    would raise an alarm, because ‘new’ should be followed by a TitleCase name.

    $value = new MyClass(); // correct
    

    Relying on Case makes it easy to spot these errors.

    3) Only functions can be called, you can never call variables. By relying on Case Rule, then we can easily spot fishy function calls like:

    $value = $inst->ClassName();
    $value = $inst->instance_variable();
    $value = $GLOBAL_VARIABLE(); 
    

    3) Assigning to a function name and global variables is a huge deal, since they often lead to behavior that is difficult to follow. That’s why any statement that looks like:

    $GLOBAL = $value;
    $someFunction = $anotherFunction;
    

    should be heavily scrutinized. Using Case Rule, it is easy to spot these potential problem lines.

    While the exact Case Rule may vary, it is a good idea to have different Case Rule for each different type of names.

    Functions/methods must always return a value (and returned values must always be stored).

    Workplace’s Apparent Reason: apparently another rule born out of blind consistency. The advantage is that every line of code that isn’t a flow control (e.g. looping, conditionals) is an assignment.

    Argument:

    1) Mandatory assignment makes unnecessary long lines, which harms readability since it increases the amount of irrelevant information on screen.

    2) Code is slightly slower as every function call will involve two unnecessary operation: value return and assignment.

    Better Convention:

    Learn from functional programming paradigm. Make a distinction between “subroutine” and “functions”. A subroutine does all of its works by side-effect and does not return a value, and therefore its return value never need to be stored anywhere (subroutine should not return error code; use exception if it is really necessary). A function must not have any side-effect, and therefore its return value must be used immediately (either for further calculations or stored somewhere). By having side-effect free function policy, it is a waste of processor cycle to call a function and ignoring its return value; and the line can therefore be removed.

    So, there is three type of correct calls:

    mySubroutine(arg);            // subroutine, no need to check return value
    $v = myFunction(arg);         // return value is stored
    if (myFunction(arg)) { ... }  // return value used immediately
    

    you should never have, for example:

    $v = mySubroutine(arg);  // subroutine should never have a return value!
    myFunction(arg);         // there is no point calling side-effect free function and ignoring its return value
    

    and they should raise warning. You can even create a naming rule to differentiate between subroutine and functions to make it even easier to spot these errors.

    Specifically disallow having a “functiroutine” monster that have both a side-effect and return value.

    No static methods

    Workplace Apparent Reason: probably someone read somewhere that static is evil, and followed blindly without really doing any critical evaluation of its advantages and disadvantages

    Better Convention:

    Static methods should be stateless (no modifying global state). Static methods should be a function, not subroutine since it is easier to test a side-effect-free function than to test the side-effects of a subroutine. Static method should be small (~4 lines max) and should be self-contained (i.e. should not call too many other static methods too deeply). Most static methods should live in the Utility class; notable exceptions to this is Class Factories. Exceptions to this convention is allowed, but should be heavily scrutinized beforehand.

    Your code is not OOP unless everything returns an object

    Workplace Apparent Reason: flawed understanding of what is OOP.

    Argument:

    Fundamental datatypes is conceptually also an object even if a language’s fundamental datatype doesn’t inherit from their Object class.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have tried all of this: Changing coding system: (prefer-coding-system 'iso-latin-1-unix) Ensuring no translation:
This is probably a common pattern in coding, though I am not knowledgeable enough
In the (otherwise) excellent book C++ Coding Standards , Item 44, titled Prefer writing
What think to be consider when you prefer coding a solution in form of
// I prefer to perform forward declaration on myclass, as I do not //
Which coding style do you prefer: object o = new object(); //string s1 =
I dread coding this but has anyone coded this before or are you using
here C programming Guidelines and coding standards says we have to avoid magic numbers
I'm currently coding a project in python where I need a sort of cache
From Herb Sutter and Andrei Alexandrescu's 'C++ Coding Standards', Item 16: Avoid Macros under

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.