オブジェクト指向設計では、次のうちどれが優れていますか?
次のようなメソッドでパラメーターを送信します。
obj.InsertRecord("raed","1987")
または次のようなプロパティを使用します。
obj.name= "raed"
obj.year= "1987"
obj.InsertRecord()
オブジェクト指向設計では、次のうちどれが優れていますか?
次のようなメソッドでパラメーターを送信します。
obj.InsertRecord("raed","1987")
または次のようなプロパティを使用します。
obj.name= "raed"
obj.year= "1987"
obj.InsertRecord()
If you send parameters, you'll have to alter the InsertRecord()
signature every time the obj
's class signature changes (for example if you add a description
property), given you will want to save those new properties.
Also the object itself should not be bothered with saving itself. That is not the object's responsibility. So, something like this is the most future-proof:
ObjectStorage.InsertRecord(obj);
Object oriented programming, this is preferred: obj.InsertRecord("raed", "1987");
Component Oriented programming, the latter is preferred: like this:
obj.name = "raed";
obj.year = "1987";
obj.InsertRecord();
Btw, this belongs to programmers.stackexchange