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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T20:49:20+00:00 2026-05-15T20:49:20+00:00

I am working with a type that passes state through instance variables. So you’ll

  • 0

I am working with a type that passes state through instance variables. So you’ll see methods like so:

public MyType MyMethod()
{
  DoThisMethod();
  DoThatMethod();
  AndDoThis();

  return _bleh;
}

Is this a recognised approach?

It’s a little disconcerting working with this code because if you don’t understand the code fully, the instance variable might be transformed without your knowledge by another method. If instead state was passed via method parameters, then you could be very confident of the value of the parameter passsed in.

  • 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-15T20:49:21+00:00Added an answer on May 15, 2026 at 8:49 pm

    If the order of those method calls is important I would call this “Bad Programming” – as you’ve said any method that requires an earlier call should be using method parameters that are indicative of this.

    I’m pretty sure Code Complete gives some great examples of this approach.

    Basically something like the following, where each method requires the previous invocation’s result.

    public MyType MyMethod() 
    { 
        thisResult = DoThisMethod(); 
        thatResult = DoThatMethod(thisResult); 
        _bleh = AndDoThis(thatResult ); 
    
        return _bleh; 
    } 
    

    Secondly, I like to keep methods “orthogonal” as much as possible (that is they depend only on the state that you provide them among other things). For a great summary on Orthogonal Code see this article.

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

Sidebar

Related Questions

I am working on an app that uses a custom file type, I've figured
I'm working on a web project that takes the results from a survey type
Actually I'm working with BufferedImages, that provide me pixel values in int type. Do
If I'm working with, say, a BookID of type int in my code that
I'm working on legacy code that looks very similar to this: public class BaseParser
I'd like do implement a generic function with the generic constraint that the Type
I'm trying to get a helloworld type program working with REST CI/jquery. I've included
I am working with a decimal type in my application and have to submit
I'm working on something of a wizard-type application to allow users to build simple
I'm working on a predict the results type system where users are asked 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.