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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 12, 20262026-05-12T01:11:26+00:00 2026-05-12T01:11:26+00:00

I have question regarding the use of function parameters. In the past I have

  • 0

I have question regarding the use of function parameters.

In the past I have always written my code such that all information needed by a function is passed in as a parameter. I.e. global parameters are not used.

However through looking over other peoples code, functions without parameters seem to be the norm. I should note that these are for private functions of a class and that the values that would have been passed in as paramaters are in fact private member variables for that class.

This leads to neater looking code and im starting to lean towards this for private functions but would like other peoples views.

E.g.

Start();  
Process();  
Stop();  

is neater and more readable than:

ParamD = Start(paramA, ParamB, ParamC);  
Process(ParamA, ParamD);  
Stop(ParamC);  

It does break encapsulation from a method point of view but not from a class point of view.

  • 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-12T01:11:27+00:00Added an answer on May 12, 2026 at 1:11 am

    In an object-oriented language it is common to pass in dependencies (classes that this class will communicate with) and configuration values in the constructor and only the values to actually be operated on in the function call.

    This can actually be more readable. Consider code where you have a service that generates and publishes an invoice. There can be a variety of ways to do the publication – via a web-service that sends it to some sort of centralized server, or via an email sent to someone in the warehouse, or maybe just by sending it to the default printer. However, it is usually simpler for the method calling Publish() to not know the specifics of how the publication is happening – it just needs to know that the publication went off without a hitch. This allows you to think of less things at a time and concentrate on the problem better. Then you are simply making use of an interface to a service (in C#):

    // Notice the consuming class needs only know what it does, not how it does it
    public interface IInvoicePublisher {
      pubic void Publish(Invoice anInvoice);
    }
    

    This could be implemented in a variety of ways, for example:

    public class DefaultPrinterInvoicePublisher
      DefaultPrinterInvoicePublisher _printer;
      public DefaultPrinterInvoicePublisher(DefaultPrinterFacade printer) {
        _printer = printer
      }
      public void Publish(Invoice anInvoice) {
        printableObject = //Generate crystal report, or something else that can be printed
        _printer.Print(printableObject);
      }
    

    The code that uses it would then take an IInvoicePublisher as a constructor parameter too so that functionality is available to be used throughout.

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

Sidebar

Related Questions

I have a question regarding an update function I created... CREATE OR REPLACE FUNCTION
I have question regarding the CreateWindowEx function. I have 2 windows, a main one
I have a question regarding the two additional columns (timeCreated, timeLastUpdated) for each record
I have a question regarding handling errors in a J2EE application. Our current application
I'm writing a small webapp in Grails and I have the following question regarding
Following on from my recent question regarding parsing XML files in Java I have
I have a question about best practices regarding how one should approach storing complex
I have a simple question and wish to hear others' experiences regarding which is
There have been several questions over the past few days about the proper use
I'm using the hoverIntent Jquery plugin and I have a question regarding callback functions.

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.