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 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

Related Questions

A lot of time I have to code from home. Normally I just remote
I'm trying to debug an application that download a lot of resources from internet.
I saw a lot of times code where return status of function was set
I feel like I spend a lot of time writing code in Python, but
I spent a lot of time figuring out the function in the code level
A lot of times I'll have a breaking test. So I'll go to the
I know this has been discussed a lot of times but is there any
Similar questions to this my have been asked a lot of times before. But
I know this question has been rised quite a lot of times, but then
Yes, I know this question has been asked a lot of times, but I

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.