I was wondering, which way is better in terms of performance and memory usage?
Passing only the needed parameters for a specific function or its the same to pass an object with 30 properties but the function will use 3 of them?
It all depends if you are passing it by value or reference. Typical parameters (int, float, double, bool) are all passed by value. Means they are copied. If you pass object it only "sends" pointer to object (reference) to function which is 4 or 8 bytes long.
It is more efficient to pass object if you have that many parameters.
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