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 90075
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 10, 20262026-05-10T22:49:00+00:00 2026-05-10T22:49:00+00:00

A lot of times in code on the internet or code from my co-workers

  • 0

A lot of times in code on the internet or code from my co-workers I see them creating an Object with just one method which only gets used once in the whole application. Like this:

 class iOnlyHaveOneMethod{    public function theOneMethod(){      //loads and loads of code, say 100's of lines      // but it only gets used once in the whole application    }  }   if($foo){    $bar = new iOnlyHaveOneMEthod;   $bar->theOneMethod();  } 

Is that really better then:

if($foo){  //loads and loads of code which only gets used here and nowhere else } 

?
For readability it makes sense to move the loads and loads of code away, but shouldn’t it just be in a function?

function loadsAndLoadsOfCode(){  //Loads and loads of code } if($foo){ loadsAndLoadsOfCode(); } 

Is moving the code to a new object really better then just creating a function or putting the code in there directly?
To me the function part makes more sense and seems more readible then creating an object which hardly is of any use since it just holds one method.

  • 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. 2026-05-10T22:49:00+00:00Added an answer on May 10, 2026 at 10:49 pm

    The problem is not whether it’s in a function or an object.

    The problem is that you have hundreds of lines in one blob. Whether that mass of code is in a method of an object or just a class seems more or less irrelevant to me, just being minor syntatic sugar.

    What are those hundreds of lines doing? That’s the place to look to implement object oriented best practice.

    If your other developers really think using an object instead of a function makes it significantly more ‘object oriented’ but having a several-hundred line function/method isn’t seen as a code smell, then I think organisationally you have some education to do.

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

Sidebar

Ask A Question

Stats

  • Questions 69k
  • Answers 69k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • added an answer The error is because your appdomain was recycled/restarted. When that… May 11, 2026 at 12:30 pm
  • added an answer I would go the way with the helper class. DateRange… May 11, 2026 at 12:30 pm
  • added an answer int a = 34; int b = 50; You can… May 11, 2026 at 12:30 pm

Related Questions

Okay, I develop web applications in PHP and JavaScript and a lot of times
A lot of times when reading about web developping on the internet I hear
The title pretty much sums it up, and I'm sure there's a perfectly valid
I've had a lot of good experiences learning about web development on w3schools.com .

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.