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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T05:51:20+00:00 2026-06-11T05:51:20+00:00

So, this is more like a philosophical question for someone who is trying to

  • 0

So, this is more like a philosophical question for someone who is trying to understand classes.

Most of the time, how I use classes are actually a very bad way to use them. I think of a lot of functions and after a time just indent the code and makes it a class, replacing stuff with self.variable if a variable is repeated a lot. (I know it’s bad practise)
But anyways… What I am asking is:

 class FooBar:
       def __init__(self,foo,bar):
           self._foo = foo
           self._bar = bar
           self.ans = self.__execute()

       def __execute(self):
            return something(self._foo, self._bar)

Now there are many ways to do this:

   class FooBar:
         def __init__(self,foo):
           self._foo = foo


       def execute(self,bar):
            return something(self._foo, bar)

Can you suggest which one is bad and which one is worse?

Or suggest any other ways to do this.

This is just a toy example of course. I mean, there is no need to have a class here if there is only one function.. but let’s say in __execute something() calls a whole set of other methods?

Thanks

  • 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-06-11T05:51:22+00:00Added an answer on June 11, 2026 at 5:51 am

    If each FooBar is responsible for bar then the first is correct. If bar is only needed for execute() but not FooBar‘s problem otherwise, the second is correct.

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

Sidebar

Related Questions

This is more like a conceptual question. When to use Model Binding (in ASP.NET
This is more like a math related question. I'm trying to create a cute
This is more like a good practise question. I want to offer different generic
This is more like a question of principle. I made a table with 100%
This is more like a strategy question: I need to check regularly a long
This is not a question, more like sharing with others a problem I encountered
This is more of a licencing issue than a code question. I really like
I use C# code more-or-less like this to serialize an object to XML: XmlSerializer
I know this is more like a serverfault question than a stackoverflow question, but
I think this is more like Math question rather than programming but since I'm

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.