Consider the following example.
I need to check if a CouponModel has a unique serial key.
I have two choices:
CouponModel model = GetFromSomewhere();
if (!CouponHasUniqueKey(model))
{
}
//or
if (!CouponHasUniqueKey(model.SerialKey))
{
}
Of course in the method where I pass in the whole object I would have to access the string property instead of working directly with the string.
Which option is better and why?
I believe the performance will be the same.
I'd also prefer to give the responsibility to the object itself:
CouponModel coupon = GetFromSomewhere();
if (!coupon.HasUniqueKey()) {
// ...
}
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