I have a method signature like this.
public void calculateFinalInvoice(int a, int b, int c, int d, int e, int f, int g, int h, int i, InvoiceDO invoiceDO ) {
// TO DO
}
I am passing somany parameters. So is it better to pass all these parameters performance wise. Or 1) maintain a class for all this parameters 2) maintain HashMap for all these parameters 3) maintain an ArrayList for this.
Can you please suggest which one is better to achieve performance.
What version of Java are you using? What are you doing with those parameters. You might be better off moving the DAO to the front of the argument list and then using varargs
to pass however many int
s you want:
calculateFinalInvoice(InvoiceDO invoiceDO, int args...) {
}
Do not worry about micro managing efficiency on things like this. Code for clarity and after done coding, worry about efficiency if needed. In this case, you might want to rethink your design and create some more structure to your code. For example, you might want to use arrays :
public void calcualteFinalInvoices(int [] invoices, InvoiceDO action){
//...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With