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

  • SEARCH
  • Home
  • 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 6048165
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T07:25:58+00:00 2026-05-23T07:25:58+00:00

Is it considered bad practice to pair function names with classes? For example in

  • 0

Is it considered bad practice to pair function names with classes?

For example in kohana I could do the following.

function Model($a,$b){
    return new Model($a,$b);
}

Then I could drop all references to new, wouldn’t have to make a $temp variable, and no factory clutter.

$temp = new Model('book');
$book=$temp->where('title','=','name')->find();

Or

$book = Model::factory('book')->where('title','=','name');

To

$book = Model('book')->where('title','=','name');

I understand global pollution is bad and it is slightly obscure to read at first, but it has it’s benefits.

I mean it would be even more confusing if someone else defined a function that had no relation to the class, so why not use the function?

For example:

$book = new Model('book');
// looks so close to the above, it's scary
$book = Model('book');

Other Pros or Cons?

  • 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-23T07:25:59+00:00Added an answer on May 23, 2026 at 7:25 am

    I do that occasionally. It sometimes can make code a bit more readable.

    It’s called factory procedures. But it makes most sense if they are less shallow. For example if depending on parameters such a method might return different objects (alternative placeholder/stub objects):

    class User { ... }
    
    function User($id) {
        return ($id < 0) ? new PlaceholderUser() : new User($id);
    }   // or another *stub object* to support the application flow
    

    But of course you can just use that for nicer looks. It’s basically a cleaner approach than the commonplace static factory methods. But I would reserve such wrapper functions for objects which you really use a lot. It makes no sense to fill up the function scope with a wrapper call for each existing class.

    And the common criticism here is: inexperienced developers can easily get confused by the object instantiation without new. (Not sure if that’s true. But that’s often said in this context.)

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

Sidebar

Related Questions

Are static classes considered bad practice? I read an article about this a couple
Is it considered bad practice (VB.NET or any language) to code a function with
Is type checking considered bad practice even if you are checking against an interface?
I know that having diamond inheritance is considered bad practice. However, I have 2
Earlier I asked why this is considered bad: class Example { public: Example(void); ~Example(void);
It seems to me that explicitly specifying serialVersionUID for new classes is bad. Consider
Is it considered bad manners/bad practice to explicitly place object members on the heap
Is it considered bad practice to expose events in .net interfaces? I have found
Is it considered bad practice to use colons to put two statements on the
Although Hungarian notation is considered bad practice nowadays, it is still quite common to

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.