Default method parameter values

I really, really think that they should incorporate default method parameter values in the next major release.
It is time-consuming, obstructing and confusing to have methods with 1...n parameters.
I.e.
public void doStuff(int id)
    doStuff(id,"",false,Collections.EMPTY_LIST, new Date());
public void doStuff(int id, String name)
doStuff(id,name,false,Collections.EMPTY_LIST, new Date());
public void doStuff(int id, String name, boolean sort)
doStuff(id,name,sort,Collections.EMPTY_LIST, new Date());
public void doStuff(int id, String name, boolean sort, List values)
doStuff(id,name,sort,values, new Date());
public void doStuff(int id, String name, boolean sort, List values, Date date)
doStuff(id,name,sort,values, date);
}Not to mention the amount of JavaDoc-tags it requires.
Wouldn't it just be simpler, more understandable and easier to have it as:
public void doStuff(int id, String name : "", boolean sort : false, List values : Collections.EMPTY_LIST, Date date : new Date())
    //Do the stuff here
}Suggestions?

I agree that getting default method parameter values implemented will be a good thing.
If you really have a large number of methods (>5) that usally just add a parameter with a default value, you could introduce a "Parameter Object" that contains the defaults for the parameters. The drawback is of course an extra indirection to get to the parameter.
class MyParameterClass() {
  String name = "";
  boolean sort = false;
  List values = Collections.EMPTY_LIST;
  Date date = new Date();
myMethod(String arga, String argb) {
   return myMethod(arga, argb, new MyParameterClass());
myMethod(String arga, String argb, MyParameterClass params) {
}arga and argb are there to illustrate you might have parameters you don't have defaults for. (Yes, you could include them in the constructor of MyParameterClass instead.)

Similar Messages

  • How to clear a default condition / parameter value in a Discoverer Viewer ?

    Hi there,
    Appreciate if anyone can help with what I am trying to do below in Discoverer10g:-
    1. In Desktop we created a workbook with a parameter and we set the default value of the parameter as '%%'. This is so that all values are selected for that parameter unless the user over-writes it by picking values from the LOV.
    2. When we run the workbook in Desktop, and pick a value out of a LOV, the system automatically remove the '%%' and substituted with the values picked from the LOV. This is working well.
    3. However, when we published the workbook to our Disco Viewer users, on the parameter screen, when a user picks values out of the LOV, the system DOES NOT remove the '%%' automatically, and appends the picked values to the list. Of course this makes the report select all values for that parameter.
    4. To resolve the problem, the Viewer user has to manually remove the default '%%' before picking values out of the LOV. Often they forget to do that and trust the value reported on the worksheet.
    5. We believe some sort of a "REPLACE '%' with BLANK" function on clicking the "Move" button will remove the '%%' values when we pick values from LOV in the parameter screen. But we do not know how to do this.
    If anyone has successfully done the above and share his experience, that will be much appreciated.
    Thank you.

    Hi there,
    Thanks for your feedback.
    Our workbooks mostly have muitii-item parameters where the users can pick more than one value.
    I have created a test workbook in Desktop with a mutil-value parameter. After picking up multiple values from the LOV, the '%%' default automatically get sover-written.
    I shared this same workbook to a Viewer user.
    In Viewer, after picking multiple values from the left window and clicking the [Move] button, the '%%' value stays. Wonder if anything can be done to remove the '%%' in Viewer after the user has picked a value and the [Move] button is clicked.
    Further help / comments appreciated.
    Thanks again for your help.
    Regards

  • Default firewall configuration values

    Hi,
    I've trying to modify my ipfw rules and i got the idea of use a script. After use it i cannot conect to internet and i reverted those new rules but there is one rule that start with my mac and i need to " sufo ipfw flush" to flush it and connect again
    it is "add 65534 deny log logamount 1000 ip from any to any in"
    I searched the firewall.conf file  on /etc/ folder and re-write
    "65535 0 0 allow ip from any to any" instead the other one
    The problem is that im not sure is this is the preconfigured value, if anyone know what are those values and can write here I'll be grateful with you (:

    I agree that getting default method parameter values implemented will be a good thing.
    If you really have a large number of methods (>5) that usally just add a parameter with a default value, you could introduce a "Parameter Object" that contains the defaults for the parameters. The drawback is of course an extra indirection to get to the parameter.
    class MyParameterClass() {
      String name = "";
      boolean sort = false;
      List values = Collections.EMPTY_LIST;
      Date date = new Date();
    myMethod(String arga, String argb) {
       return myMethod(arga, argb, new MyParameterClass());
    myMethod(String arga, String argb, MyParameterClass params) {
    }arga and argb are there to illustrate you might have parameters you don't have defaults for. (Yes, you could include them in the constructor of MyParameterClass instead.)

  • Default Data Parameter

    Post Author: despec
    CA Forum: General
    I have read that in previous CR version (before XI), you could default a date parameter to the current date.  Is there any way in CR XI to achieve this or our we SOL until we upgrade to CR 2008 (which I hear does allow date parameter defaults)?David

    Hi,
    It depends which version of Discoverer you are using. Search the Discoverer forum (http://forums.oracle.com/forums/search.jspa?objID=f56&q=SYSDATE+parameter) or check these links (Default parameter value to sysdate Default a parameter value to sysdate for possible solutions.
    Rod West

  • How to use different default parameter value for different report subscriptions

    In ssrs is it possible to define different default parameter values for different subscriptions? In the following example I have a report which has two subscriptions with different start date and end date values:
    Report name – Testsubscription.rdl
    Subscription-1
    Input parameter (default values):
    start_date = first day of current Month
    end_date = till date
    Subscription-2
    Input parameter (default values):
    start_date = first day of current Quarter
    end_date = till date
    I know an alternative way of doing this would be to copy the rdl file with a different name but I am curious whether this can be done within a single report definition file. I am using SQL Server 2008 R2 Standard Edition.
    Thanks!
    spp

    Hi sppdba,
    As per my understanding, there is a report with two parameter: start_date and end_date, you want to configure subscription for the report, and set different default values for start date and end date. And you want to know if it is possible to achieve you
    goal by using a single report definition file.
    Since you are using SQL Server 2008 R2 Standard Edition, we need to achieve your goal by configuring two subscriptions for the report. For detail information, please refer to the following steps:
      1. In design surface, right click start_date and open Parameter Properties dialog box.
      2. In General pane, type Name and Prompt, set Data Type to Date/Time.
      3. Click Available Values in left pane, select Specify Values.
      4. Click Add button, in Label text box, type “First day of Current Month”, click (fx) button in Value section, then type the expression like below:
    =DateSerial(Year(Now()), Month(Now()), 1)
      5. Click Add button, in Label text box, type “First day of Current Quarter”, click (fx) button in Value section, then type the expression like below, then click OK.
    =DateSerial(Year(Now()), (3*DatePart("q",Now()))-2, 1)
      6. Right click end_date and open Parameter Properties dialog box.
      7. In Available Values pane, select Specify Values.
      8. Click Add button, in Label text box, type “Today”, click (fx) button in Value section, then type the expression =Today(), then click OK.
    Now that the parameters are created, we need to configure subscription for the report. For detail information, please follow these steps:
      1. Open Report Manager, and locate the report for which you want to create a new subscription.
      2. Hover over the report, and click the drop-down arrow.
      3. In the drop-down menu, click Manage. This opens the General properties page for the report.
      4. Select the Subscriptions tab, and then click New Subscription.
      5. Select the delivery extension and data source for the subscription.
      6. Select a method of delivery, then choose report delivery options.
      7. Specify conditions that cause the subscription to process and delivery to occur.
      8. Set start_date to First day of Current Month, end_date to Today, then click OK.
      9. Create a new subscription as step4 to 7, set start_date to First day of Current Quarter, end_date to Today, then click OK.
    The following screenshots are for your reference:
    For detail information about Creating Standard Subscriptions, please refer to the following document:
    http://msdn.microsoft.com/en-us/data/ms156307(v=sql.105)
    If you have any more questions, please feel free to ask.
    Thanks,
    Wendy Fu
    If you have any feedback on our support, please click
    here.

  • How to get the selection parameter values to Posting logic method

    How can i  read the selection parameter values at " posting logic" method, which are given in  " Select Option function module"?

    max bianchi wrote:
    Hi
    >
    > The selection-screen data are stored in ABAP memory, so it need to clear it .
    >
    > Now how set ID parameter can depend on SAP release, anyway in ECC 6 this should work:
    >
    >
    INITIALIZATION.
    >   DATA: BEGIN OF MEMKEY,
    >           REPORT  TYPE SY-REPID VALUE SY-REPID,
    >           VARIANT TYPE RSVAR-VARIANT,
    >           INT_MODE(2) TYPE N,
    >           KIND(1)     TYPE C,
    >         END OF MEMKEY.
    >
    >   SYSTEM-CALL INTERNAL MODE INTO MEMKEY-INT_MODE.
    >   FREE MEMORY ID MEMKEY.
    >
    > But in this way it'll clea whole selection-screen...do you wnat do it?
    >
    > Max
    @Max : The above hack seem to work fine unless you assign a  'DEFAULT' value to the selection fields.
    @OP   : Here is an other work around,  however, this approach needs an additional effort to create
        new PF-STATUS('MYLIST') and assign a function code of your choice to the function keys in the standard toolbar and handle them in the 'AT USER-COMMAND'   event as shown below. Let us know if you have/find any issues with this.
    PARAMETERS:
      p_test TYPE char5 DEFAULT '123'.
    AT USER-COMMAND.
      CASE syst-ucomm.
        WHEN 'MBACK'.
          SUBMIT zytest WITH p_test = '' VIA SELECTION-SCREEN.
      ENDCASE.
    START-OF-SELECTION.
      SET PF-STATUS 'MYLIST'.
    -Rajesh.

  • Crystal Reports 9 and SQL Server 2005 default parameter values

    We're using Crystal Reports 9 and upgraded from SQL Server 2000 to SQL Server 2005.
    I'm noticing a very weird problem which I wonder if anyone else has experienced (and hopefully found a resolution for). It appears that in using Crystal with SQL Server 2005 stored procedures, if we have default parameter values in the stored procedures, the default parameter values get completely ignored if you pass in a NULL value from Crystal!
    For example, if you have a stored procedure that begins like this:
    ALTER          Procedure [dbo].[StoredProcedure]
    @Param1 VarChar(200) = '',
    @Param2 VarChar(200) = ''
    AS ...
    both @Param1 and @Param2 have a default value of an empty string, and therefore should become empty strings if nothing (NULL values) gets passed in for them.
    But, like I said, what I'm finding is that with Crystal calling the stored procedure with NULL @Param1 and @Param2 values, they never become empty strings, but rather remain as NULLs.
    This was never a problem with SQL 2000.
    Very perplexing. Anyone else every experience this?
    Thank you.

    Please ignore my earlier post -- answered my own question.
    NULL parameter values do not get replaced by default values in SQL -- that is normal behavior in both SQL 2000 and SQL 2005. Just goes to show, that no many how many years programming experience you have, you can still get tripped up sometimes : (

  • Can I use calculated value as default parameter value?

    Discoverer version:
    Oracle BI Discoverer 11g (9.0.4.00.00)
    Oracle Business Intelligence Discoverer Plus 11g (11.1.1.3.0)
    Discoverer Model - 11.1.1.3.0
    Discoverer Server - 11.1.1.3.0
    End User Layer - 5.1.1.0.0.0
    End User Layer Library - 11.1.1.3.0
    Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - 64bit Production
    Java Virtual Machine: Sun Microsystems Inc. 1.6.0_29
    JVM Memory Available: 9286KB out of 43728KB
    Operating System: x86 Windows 7 6.1
    Can I have a pre-calculated value in the value selection box E.g. a date value that is calculated from a function that getting current finanical year from a item.
    That is, when 'Edition Parameter value' window pop up, a calculated value exists instead of a blank field.
    Edited by: 901005 on Dec 8, 2011 6:12 PM

    Hello
    Your friend is wrong - this functionality has never existed. Perhaps your friend is getting confused over the ability to define a fixed default value which has always been there.
    Sorry about this.
    Michael

  • How to set default bind variable value to task parameter value

    Hi,
    I 'm implementing a BPEL process with a human task, and I autogenerate the task form. I have a custom sql table that stores opinions, different processes should show different opinios, so my ADF table can only show records related to that process. A custom process number is sent to the task form as a task parameter. How do I use that value as the bind variable default and only value?
    Thanks,
    I.D.

    Hi Shay and thanks for your reply,
    What I want is what you have but without the login page. I tried to start my flow with an action and for some reason it didn't work.
    Is there anything else you can tell me?
    Thanks,
    I.D.
    P.S. I was able to get it to work using the aproach Frank Nimphius described in another post.
    Re: How do I prepopulate a bind variable from a session variable?
    Anyway just out of curiosity could you please tell me if I could have done it your way?
    Thanks a lot,
    I.D.
    Edited by: user8696770 on 5/Ago/2009 7:12

  • How to find Parameter values of a non-default listener using LSNRCTL

    Hi,
    I have a non-default listener with name like "lsnr_abcd" in non-default port.
    I am on 10.2.0.4 database version. If I want to find out parameter values (like displaymode,dynamic_registration,etc)
    for a non-default listener, which command should I use?
    I know that for default listener, we can do the following
    1) Execute lsnctl
    2) show dynamic_registration
    What should I execute if I want to get this details for a listener "lsnr_abcd"
    Thank You
    Sarayu

    After setting your current listener to non default listener like this
    lsnrctl> SET CURRENT_LISTENER lsnr_abcd
    You can execute the further commands without your listener name
    lsnrctl>set DISPLAYMODE
    Edited by: vreddy on Jul 19, 2012 6:53 AM
    Edited by: vreddy on Jul 19, 2012 6:54 AM

  • CR-XI How to prefil Default Parameter value in code

    I am setting parameter default value(s) in VB6 code.  When the report is launched the default parameter is in the list but not selected.  The user has to manually select the value instead of just accepting the default value and pressing enter key to launch the report.  I would like parameters to prefil with default values like they did in Crystal version 7 when using the OCX.
    I am using CR XI and VB6.  I am passing a default parameter by using .
    <report object>.ParameterFields(1).AddDefaultValue
    If I use <report object>.ParameterFields(1).AddCurrentValue the parameter then the report viewer knows the parameter value and the form does not display the value incase the user desires to change it.
    My Question is how can I display the parameter and prefill with the default value.  When I use "AddDefaultValue" like above the parameter will be in the dropdown but will be blank when the form opens.  This requires the user to use the mouse and click the dropdown to display the default value.  I would prefer the default show in the dropdown so the user just has to press the enter key to launch the report (if the user wants to accept all default values).
    If this is not possible with the current viewer class then maybe the development team can include in future updates. 
    Thanking you all in advance.

    Hi Brent,
    The document you linked is for the Enterprise Product.  As Jonathan stated, the RDC for XIR2 is supported for use in VB6, you do not have to have .NET.  This can be found in the Crystal Reports supported Platform document found here:
    [http://resources.businessobjects.com/support/communitycs/TechnicalPapers/cr_xi_r2_supported_platforms_windows_sp3.pdf|http://resources.businessobjects.com/support/communitycs/TechnicalPapers/cr_xi_r2_supported_platforms_windows_sp3.pdf]
    Crystal Report XIR2 is the last version that has the RDC.

  • Default method - how to pass value to method container?

    Hello,
    I am dealing with a hyperlink in 'Objects and Attachements' section of the workitem.When i click on the link, the default method of the business object gets called automatically.
    My question is: How to pass values to the default method (i.e. method container) as i don't invoke the method in my workflow explicitly?  The method gets called when we click on the hyperlink.
    Regards,
    Monica.

    Hello Monica,
    a default method doesn't require parameters (and cannot make use of them), as they are designed to be called from various situation, such as the view from a workflow container, the display button within a workitem or the attachment list. So this is part of the system design.
    To make an object dependent of workitem values I usually follow two different design patterns:
    <b>1) Using a flowitem/workitem instance with a special default method</b>
    - Create a subobject from type WORKITEM (if I'm going to use values from the current workflow instance) or subobject from type WORKINGWI (if I'm going to use values from the current dialog workitem).
    - Do not make a general substitution for this new object type
    - If using a ZWORKITEM, create an instance of this object type before the dialog step and then pass this object to the dialog workitem
    - If using ZWORKINGWI, assign the object instance during the data flow to the step.
    - In the properties of the object choose (any one) default method
    - Within the coding you have the reference to the workitem/flowitem as object-key-... and you can further use functions/methods to read the workitem/flowitem container and do whatever has to be done
    <b>2) Retrieving values from the current workitem on-the-fly</b>
    Within the coding of the default method call the function module SWO_QUERY_REQUESTER that returns the instance/id of the current workitem-in-work (with is also set when using the hyperlink from a workitem). If the list is empty, there's no active workitem, otherwise use functions/methods to read the workitem container.
    --> edit: Solution is not release safe, is it aint working with SAP R/3 Enterprise and higher
    Best regards,
       Florin
    Message was edited by:
            Florin Wach

  • Dynamic default parameter value

    Hi,
    I'm running Oracle BI Discoverer Plus 10g (10.1.2.45.46c)
    Is it possible to make the default parameter value dynamic ?
    In my case I want the default parametervalue to be set to the week before actual week.
    Eg if I'm running the report during this week it would be set default to '2005W43',
    running the report during next week it would be set default to '2005W44' and so on...
    Have tried to assign the default value with "TO_CHAR(SYSDATE-7,'RRRR')||'W'||TO_CHAR(SYSDATE-7,'IW')"
    Note the enduser must have the possibility to change from the default week to some other week.
    Any ideas ?
    /Sam
    Message was edited by:
    [email protected]

    Post Author: synapsevampire
    CA Forum: General
    A common solution is to use a Union All in a query to get the ...All and the dynamic values using a Command Object.
    select '...All' from tableUNION ALLselect field from table
    -k

  • Missing parameter values - mystery solved

    I've tracked down why I was getting this error to the refresh method of the ReportDocument object.
    The sequence of execution is as follows;
    load report
    get/set parameter values
    set database location
    refresh report
    export report
    The refresh step clears all the parameter values and defaults.  I can't believe that this is correct behavour but hey ho, I'll try and work around it by saving all the parameter values to local storage when I open the report and then reset them after the refresh.
    Is this correct?
    Steve

    No, that is exactly how the refresh is supposed to work actually.
    The reportdocument.refresh call removes saved data. That includes any parameters set on the report.
    99% of people who call reportdocument.refresh do not have a need to do so to be honest.
    If you are using an empty report template (ie a report that does not have saved data) then you should not need to call it at all.
    If you want to call it just to make sure, do it before you do anything else, then pass any information you need to the report object.
    Jason

  • Passing parameter value back from Child region [BTF] to Parent

    Hello,
    I am using Jdev 11.1.1.6. I have a use-case where I need to pass value back from child taskflow to parent.
    Let me elaborate the use-case:
    I have a main page which is implemented as BTF with fragment. This main page contains a child region [again a BTF with fragment].
    I am passing a parameter value from parent page to it's region using taskflow input parameter. Now value for one of the parameter changes inside child/region taskflow and I need to make this value available to main page taskflow.
    This parameter is just pageFlowScope variable, so basically not coming from any VO.
    I know that taskflow can return value via return parameter but I don't know if that is true for taskflow implemented as region in a page.
    Is it possible to communicate the pageFlowScope variable value from child region to it's parent page?
    Thanks,
    Jai

    Hi Frank,
    I tried to follow steps mentioned in your post but encountered error that "The scope of the referenced object #{viewScope.parentBeanName} is shorter than referring object childBeanName"
    Let me explain what I did:
    1. Created a bean parentBeanName in viewScope
    2. Created another bean childBeanName in pageFlowScope
    3. In ChildBean.java, created a private property parentBeanProperty for Class [ParentBean] and generated the accessors
    4. Created a input parameter in region TF as:
    <input-parameter-definition id="__28">
          <name id="__27">parentBeanParam</name>
          <value>#{pageFlowScope.childBeanName.parentBeanProperty}</value>
          <class>ParentBean</class>
          <required/>
    </input-parameter-definition> 5. Since my mainPage contains child page as region. I added parameter to mainPageDef to pass it to child TF, like this
    <parameter id="parentBeanParam" xmlns="http://xmlns.oracle.com/adfm/uimodel"
                       value="#{viewScope.parentBeanName}"/>6. Introduced a client method in childBeanName that is called from UI. There I am retrieving parentBeanParam instance from pageFlowScope and call setter method of my variable inside ParentBean.java
    7. Ran the page but encountered the error.
    Did I miss something somewhere?
    Initially I got error where #{viewScope.parentBeanName} returned NULL due to parentBeanName not instantiated. I created a variable in mainPageDef with it's default value pointing to #{viewScope.parentBeanName.variableName}, which I guess will instantiate the bean in viewScope.
    After this I got error of shorter scope. It never reached to code in Step 6 during execution cycle.
    FYI - My application is based on UIShell and essentially a one page application. Main page referred above is also a jsff based on BTF. I hope, this should not affect this implementation but I thought of at least mention it.
    Thanks,
    Jai
    Edited by: Jai Om on Dec 18, 2012 2:38 PM

Maybe you are looking for

  • I can't update my MacBook Pro Late 2011 NSURLErrorDomain error - 1012.)( - 1012)

    This is what I get whenever I try to update my OS X to 10.8.5 I have MacBook Pro 15" With OS X 10.7 I bought OS X 10.8 from day one and I was updating everything were normal until today ? what should I do ? How to fix this ?

  • Why does searching by file name ignore files that are there?

    This is NOT a question about Spotlight. I'm using the old-fashioned command-F method of searching, and I'm searching for terms within a file name, i.e "Name Contains _". When I type in the name of a known file and search for it, it doesn't show up. T

  • Publishing Event Video to HTML5 ?

    I have inserted an event video into a slide and uploaded an mp4 file.  When publishing the project and viewing it in a web broswer, the HTML5 output does not allow for any video controls, and as such the video does not play. I cannot publish the vide

  • Include a New Meta Tag in head section of OBIEE generated HTML

    Hi, Is there any xml place holder, that we can modify / add any additional HTML tags to the <HEAD> section of the HTML that OBIEE is going to generate. Requirement is to add the following tag in the <HEAD> section. <meta http-equiv="X-UA-Compatible"

  • Wireless EAP / 802.1x with MS NAP

    Hi, I'm trying to configure 802.1x on a 1131AG AP using MS NAP as a radius server. Using a switch everything works fine with EAPOL and the clients authenticate the way they should. But as soon as I start using the AP and clients try to authenticate,