I would avoid having code could potentially create two separate objects. It can make the code slightly less clear than if you require a person to be explicit and have to know which object they are working with. I believe that the first case is less clear than the second case but that is just me.
I have also found that inexperienced programmers tend to repeat patterns religiously. If you hand this first type of code off to them they will write code that constantly evaluates the type of object it is rather than break it into two separate, but clearly defined routines for working with the object.
my $object = Product::create( $data_ref ); if ($object->isa('Product::Real')) { &call_real_product_api( $object ); } else { &call_potential_product_api( $object ); }
if (Product::isa_Real_Object( $data_ref )) { &call_real_product_code( $data_ref ); } else { &call_potential_product_code( $data_ref ); }
In reply to Re: Reblessing yourself
by Herkum
in thread Reblessing yourself
by Ovid
| For: | Use: | ||
| & | & | ||
| < | < | ||
| > | > | ||
| [ | [ | ||
| ] | ] |