The question in general is:
Is it a right design to add functionality to primitive objects, so that the object can "take care of himself"
Recent example:
I have a singleton logMngr. The logMngr saves records of different types to different Azure Tables. records are received, queued as BaseRecord, and then saved to Db with different thread using threading.Timer. We have 2 ideas:
1.The BaseRecord has an abstract method"saveToDb", and each record knows how to save himself to Db(the table name, the keys...) save to Db needs to use DAL singleton to do that. Maybe it is not a good idea for primitive type to have such a complex functionality, But the code is very "object oriented"
2. use:
if (record is xRecord){logMngr.SavexRecordToDb}
, and then it is not an open - close code. We do not expect to have more record kinds.
Any insights? Maybe a better idea than both?
Thank you, Tal