N
Navaneeth.K.N
Hi All,
I have to design a "Product" class. This class will contain a product
details. I have a "ProductFactory" which contain some static methods which
returns "Product" instance. I have a "IsNew" boolean property in "Product"
class which indicates the instance is a new one. This flag will be "True"
when some one creates new instance of "Product" (Product p = new Product()).
if factory is used to get a product instance, this flag will be false,
something like Product p = ProductFactory.FromId().
I have to implement save functionality for this product. How do I go about
it ? If the product is new, I need to create a new entry in the DB, if it's
an old one, I need to update the DB. Which will be the appropriate location
for putting Save method ? Is it in the "Product" class itself or will it be
better to create another class like "ProductService" and put a Save method
there which accepts "Product" instance.
Any help for this would be appreciated.
Thanks
I have to design a "Product" class. This class will contain a product
details. I have a "ProductFactory" which contain some static methods which
returns "Product" instance. I have a "IsNew" boolean property in "Product"
class which indicates the instance is a new one. This flag will be "True"
when some one creates new instance of "Product" (Product p = new Product()).
if factory is used to get a product instance, this flag will be false,
something like Product p = ProductFactory.FromId().
I have to implement save functionality for this product. How do I go about
it ? If the product is new, I need to create a new entry in the DB, if it's
an old one, I need to update the DB. Which will be the appropriate location
for putting Save method ? Is it in the "Product" class itself or will it be
better to create another class like "ProductService" and put a Save method
there which accepts "Product" instance.
Any help for this would be appreciated.
Thanks