c# - designing virtual methods -


I wonder which situation you will choose first or second design:

The first design: The child method has to call the base method

  public abstract class base {public virtual zero enabled () {IsEnable = true; } Disable Public Virtual Zero () {IsEnable = false; } Public Child Elastic (Receive; Private Set;}} Public Square Child: Base {Enabling Public Override Zero () (*) * * * / base.Enable ();} Disable the public override zero () {/ * Do not forget to call the base  / P> 
  Public intangible class base {Enable Public Zero () {IsEnable = true; OnEnable ();} Disable Public Zero () {IsEnable = false; OnDisable ();} Public Child Eligible (Receive; Private Set;} Public Virtual Zero OnEnable () {} Public Virtual Zero On-Disk Basic () {}} Public Class Child: Base {Override Zero Onable () / / Work * Overwrite Zero On Disabling () * / * Work * /}}  

Thanks

< / Div>

It depends if you really want to make sure isEnable gets set Whether or not you can visualize scenarios in which the user does not want to set it, I think that you leave them to call the base method. Otherwise, do this for them.


Comments

Popular posts from this blog

oracle - The fastest way to check if some records in a database table? -

php - multilevel menu with multilevel array -

jQuery UI: Datepicker month format -