When should one use final arguments?

Hi all,
When should one use final arguments?
I have searched the forum for this, but couldnt find a precise answer. I am specifically looking for cases where they are:-
1. the only way to acheive something
OR
2. the stylistic way to acheive something.
Thanks,
Binil

My $0.02 - I don't think (practically) you ever need
final method parameters (it's not like they prevent
subclassing or anything). However, I think (stylistically)
you should make method parameters final wherever you
can - it makes the code a more explicit (the contract
between the invoker and the invokee is clearer).
I seem to recall something about JVMs being able to
optimize methods with final parameters better too, but that might just be moonshine or more people would
(probably) be going on about it.

Similar Messages

  • When should one use interfaces?

    Actually, I don't get interfaces at all. From what I understand, all an interface does is make sure that a class which implements the interface has certain methods. If someone could explain interfaces, it would be appreciated,
    I am thinking of making a small game, and I was wondering if it would be good to use intefaces with my sprites, for example enemies and the player character sprites would implement Damageable, while a weapon, or some element which causes damage would not be Damageable. Is there a better way to set this up?
    Thanks

    whenever I click the button, voila! the
    actionPerformed method is called. How does that all
    work?It works because code, working behind the scenes, is written to assume objects of the interface type.
    The ActionListener interface specifies actionPerformed. You supply an object implementing the ActionListener interface which means it implements all methods the interface specifies. You then give that object to a JButton object. Later, when the button is pressed, the JButton object calls actionPerformed of the ActionListener object you gave to it.

  • When should one use Dynamic Triggers ?

    I have a requirement where I want to send an email to HR whenever the supervisor of an employee changes.
    I am on 11.5.10.2 and the options which I know are :
    a) Business Events ( Not Possible as on 11i there are form handlers and not api on people/assignment form)
    b) Database trigger ( I do not want to use custom trigger on database)
    c) Alerts( I am currently using but its difficult to identify change in supervisor value only)
    d) Dynamic Trigger ?
    Thanks
    Ashish

    Hi Ashish,
    Why do not you try with form personalization.
    1) using execute procedure call a procedure .
    2) then from the procedure you can call the below standard procedure to send email.
    l_mail_conn := UTL_SMTP.open_connection (l_mailhost, 25);
    UTL_SMTP.helo (l_mail_conn, l_mailhost);
    UTL_SMTP.mail (l_mail_conn, from_name);
    UTL_SMTP.rcpt (l_mail_conn, to_name);
    UTL_SMTP.open_data (l_mail_conn);
    UTL_SMTP.write_data (l_mail_conn
         , 'Date: '
         || TO_CHAR (SYSDATE, 'DD-MON-YYYY HH24:MI:SS')
         || CHR (13)
    UTL_SMTP.write_data (l_mail_conn, 'From: ' || from_name || CHR (13));
    UTL_SMTP.write_data (l_mail_conn, 'Subject: ' || subject || CHR (13));
    UTL_SMTP.write_data (l_mail_conn, 'To: ' || to_name || CHR (13));
    UTL_SMTP.write_data (l_mail_conn, Message );
    UTL_SMTP.close_data (l_mail_conn);
    UTL_SMTP.quit (l_mail_conn);
    3) Make sure that you enable the below setups .
    The UTL_MAIL package is new enhancement in Oracle 10g. you have to run
    {ORACLE_HOME}/rdbms/admin/utlmail.sql
    {ORACLE_HOME}/rdbms/admin/prvtmail.plb
    to install it and also run
    ALTER SYSTEM SET smtp_out_server = 'ip_address:port' SCOPE=BOTH;
    I hope it may help you ..
    Thanks
    Asif

  • What is the difference between saving to "Documents" and "Macintosh HD" and when should you use each one?*

    What is the difference between saving to "Documents" and "Macintosh HD" and when should you use each one?

    When you save to the folder with the little house icon, the file is placed at
    /Users/your_user_name/
    You would really have to go out of my way to save at:
    (the shortcut for the Boot Drive, regardless of its name).
    I am not sure how you decided that Time Machine is not saving your files. The default is for Time Machine to do incremental Backups of everything on all attached drives, except for certain temporary information in Cache files. If you have four Users, Time Machine will back them all up.
    Looking at the raw Time Machine backups will tell you very little, because it does lots of its work with Hard Links, and because it does incremental backups, so only files that changed since the last Backup are saved at thet cycle. The way to determine whether Time Machine is saving things is to display the window you care about in the Finder, then invoke the "Star wars"/ "Back, back, back in time" Interface.

  • J1INCHLN when should I use error control mode checkbox

    Hi Experts,
    I am using t-code J1INCHLN for creating remittance Challan.
    But in ECC6, EHP 5 there is new functionality added & no documentation available for same.
    There is one field with tick option called Error Control Mode.so when should i use this functionality.
    Can anyone help on this?
    Thanks and Regards,
    Sameer

    HI
    Please refer the note no :  1567443
    Manual Control in J1INCHLN to change currency key/doc type
    "After this, if you will run J1INCHLN, you will get a checkbox at the end
    with 'Error Control Mode' which will be selected by default. If you want
    to change document type, currency or rate during processing, you should
    uncheck it else it will take you to the last screen."
    I hope note is allready available in your system hence you are getting above cheeck box.
    If you want to change the document type and currency or rate during posting then you need use the check box.
    Regards
    Madhu M

  • When should you use dmg vs copy or duplicate

    When should you use dmg vs copy or duplicate

    Your answers are very helpful. They encourage me to ask the more complete and complicated question: we have a web site that was developed using iWeb several years ago. iWeb support was dropped by Apple some years ago and we moved the site to GoDaddy, but still using the iWeb software. Now we have only 1 computer which can continue to edit, add to and support our web site. Our aim is to copy as much of our material as we can so that when this computer finally dies we can salvage as much of our material as we can to resurrect our site once more. GoDaddy says they cannot help us.
    Here is my wife's web site:
    www.adajillschneider.com
    Thanks for all your time and help.
    Ron Schneider

  • When should a subclass have its own fields and when should it use its super

    When should a subclass have its own fields and when should it use its superclass' fields?
    Hi, thank you for reading this post!
    Let me use a specific example to ask my question.
    public class BankAccount {
         private double accountBalance;
         public double getBalance() {
              return this.accountBalance;
    public class SavingsAccount extends BankAccount {
         private double accountBalance;
         public double getBalance() {
              return this.accountBalance;
    }In the bank account example, both BankAccount and SavingsAccount will have a method getBalance(). Therefore, they
    both require a account balance field. My question is since getBalance() for both classes will perform the exact same
    operation, when should I omit declaring the getBalance() method and the accountBalance field in the subclass, and
    when should I include them?
    My own thought is when we never have to instantiate a superclass object (e.g. an abstract class), then we place
    common fields in the abstract superclass and have subclasses access these fields via protected getter/setters to
    access the superclass' fields. This is the principle of reuse.
    But when you do need to instantiate a superclass and the superclass does need to maintain its own fields, then
    I would need to duplicate the accountBalance field and getBalance() method in the subclass.
    Is my thinking correct or incorrect?
    Thank you in advance for your help!
    Eric
    Edited by: er**** on 22-Aug-2011 20:19

    er**** wrote:
    If SavingsAccount inherit BankAccount.getBalance()...getBalance() would return BankAccount's accountBalance. This is NOT the correct result we want.Actually, I think it's precisely what you want.
    We want getBalance() to return BankAccount's accountBalance when we use a BankAccount object, and SavingsAccount's accountBalance when we use a SavingsAccount object.I seriously doubt that. I think you're confusing a BankAccount with a Customer, who can have more than one account.
    In every system I've ever seen, a SavingsAccount IS-A BankAccount - that is to say, it's a genuine subtype. Now, it may well contain other fields ('interest'?) that a normal account wouldn't, but 'balance' ain't one of them.
    Winston

  • Should one use MPIO and/or CSV in a Windows 2012 R2 guest cluster?

    Should one use MPIO and/or CSV in a Windows 2012 R2 guest cluster using VMware ESXi 5.5 presented Fiber LUN RDMs.
    If MPIO were implemented is there a preference for HW manufacturer DISM vs. MS DISM in a guest cluster?
    What partition size/offset is recommended for the MSR partition (currently set to 1000 MB) - unfortunately seeing storage validation error with failing block write at block 2048 (which in return may be related to VMware ESXi 5.5. disk partition layout)
    The current setup works without using MPIO (question is would it help overcome the current failing persistent SCSI-3 reservation warning.)
    What were the benefit of using CSV if any in a guest cluster? The Luns in scope would eventually hold SQL data and log files.
     Thanks for your input already.
    Sassan Karai

    Hi,
    Regardless of what type of the shared storage is failover cluster have to use the shared storage, the shared storage can redirect the failed node data to others node, accordingly
    the failover cluster can get the high availability.
    From you descripted error there must you choose the VMware® unsupported storage with failover cluster, please refer the following VMware® official KB then reconfirm your topology
    design is supported.
    Third party KB:
    VMware vSphere support for Microsoft clustering solutions on VMware products
    http://kb.vmware.com/selfservice/microsites/search.do?language=en_US&cmd=displayKC&externalId=1037959
    The related KB:
    Failover Clustering Hardware Requirements and Storage Options
    http://technet.microsoft.com/zh-cn/library/jj612869.aspx
    More information:
    Validate Storage Spaces Persistent Reservation Test Results with Warning
    http://blogs.msdn.com/b/clustering/archive/2013/05/24/10421247.aspx
    Understanding Cluster Validation Tests: Storage
    http://technet.microsoft.com/en-us/library/cc771259.aspx#PersistentReservation
    Shared storage for Windows Failover Cluster with MPIO
    http://blogs.technet.com/b/storageserver/archive/2011/05/31/shared-storage-for-windows-failover-cluster-with-mpio.aspx
    Hope this helps.
    We
    are trying to better understand customer views on social support experience, so your participation in this
    interview project would be greatly appreciated if you have time.
    Thanks for helping make community forums a great place.

  • When should I use static variable and when should not? Java essential

    When should I use static variable and when should not? Java essential

    Static => same value for all instances of the class.
    Non-static => each instance can have its own value.
    Which you need in which circumstances is completely up to you.

  • Why or When should we use Execute Immediate in PLSQL??

    Hi Frnds,
    Long Ago i have received a interview question that ...
    How can U create a table in the PLSQL object(Function or procedure)?
    But the thing y should we use execute immediate?
    In which scenario we should we should use????????????
    Why or When should we use Execute Immediate in PLSQL????

    OR
    http://stackoverflow.com/questions/18375990/oracle-what-does-execute-immediate-means
    For DML you'd use it when running statements that you don't have available at compile time, e.g. if the column list is based on a selection from the user.
    In your case it's being used because DDL cannot be run as static SQL from within PL/SQL. Only certain query, DML and TCL commands are valid. Anything else has to be treated as dynamic.
    I'd say it's rare to need to use DDL from a PL/SQL block. TRUNCATE might be reasonable; if you find anything creating or dropping objects on the fly then that might be more of a concern as it can suggest a suboptimal data model.
    EXECUTE IMMEDIATE itself does not automatically commit; but if you execute DDL then that will behave the same as if you ran it outside PL/SQL, so it will commit in your case, yes.
    Incidentally, I'm not sure why your code is using an intermediate variable to hold the statement; that's useful if you want to display what it's going to run maybe, but you don't seem to be doing that. What you have could be done as:
    EXECUTE IMMEDIATE 'TRUNCATE TABLE BD_BIDS_EXT_DET';
    Thank you

  • When Should I use the Inner Classes ?

    When Should I use the Inner Classes ?
    What is the advantage(s) and the disadvantage(s) ?

    When I use innerclasses?
    1) Allmost allways when I need simple owner child behavior.
    2) When I need a behaviour, that is quite small, and used only once, I make it anonymous inner class. For example specialised streams and threads.
    3) Enumerations

  • What are the mapfiles for and when should I use them?

    Hi,
    what are the map files for and why/when should I use them?
    /usr/lib/ld/map.noexstk
    usr/lib/ld/map.noexbss
    /usr/lib/ld/map.noexdata
    /usr/lib/ld/map.pagealign

    Hi, I'm sure you've read the comments, but for the benefit of those who haven't: /usr/lib/ld/map.noexstk # Linker mapfile to create a non-executable stack definition within an # executable. /usr/lib/ld/map.noexbss # Link-editor mapfile to create a non-executable bss segment definition # within an executable. /usr/lib/ld/map.noexdata # Link-editor mapfile to create a non-executable data segment definition # within an executable. These stop the various segments from being executable. Which could reduce the risk surface for exploiting security holes in an application. /usr/lib/ld/map.pagealign # Linker mapfile to create page-aligned data within an executable. Aligning the start of the data segment can reduce the number of TLB entries needed to map the data. So the smallest TLB page size is 8KB, then we have 64KB, then 4MB etc. If the data starts on a 4MB boundary then it can be mapped with 4MB pages, if not then it has to be mapped with 8KB pages until a 64KB boundary, then 64KB pages until we get to a 4MB boundary. You sometimes get a bit of performance from this, but you may also get performance stability from it. If the mapping is random sometimes it works well, sometimes it works less well. Regards, Darryl.

  • HT4571 When should I use data roaming?

    When should I use data roaming?

    When you are outside your carrier's network, you may be able to access the Internet using another wireless carrier, that's dataroaming.
    More info; http://support.apple.com/kb/HT1976

  • When should I use the power adapter?

    I just installed a wireless router. Should I use the power adapter when I'm not going to use the Macbook for several hours? Does the Macbook drain the battery when it is shut down or sleeping?

    When should I use the power adapter?
    Whenever you are near a power outlet. Not 100% of the time, of course (you have to flex the battery sometimes) but as often as possible.
    Should I use the power adapter when I'm not going to use the Macbook for several hours?
    If you are near an outlet, yes.
    Does the Macbook drain the battery when it is shut down or sleeping?
    When sleeping, it drains a negligible amount.
    Further reading:
    http://support.apple.com/kb/HT1446
    http://support.apple.com/kb/HT1490

  • When should I use validate(), reValidate, and inValidate()?

    When should I use validate(), reValidate, and inValidate()? Also, I would like some detailed differences on them.
    Virum

    Anyone?

Maybe you are looking for