Swift - what should the default values of properties be in the parent class? -
not sure if worded question correctly, here's issue: have base class , subclass, , base class should never instantiated on own (in other languages abstract). know abstract classes aren't thing in swift. have computed read-only properties change return in each subclass; more or less customized constants. firstly, overridden computed properties best way handle kind of thing? secondly, if these variables need initialized, i.e. can't nil, should initialized in parent class? there way otherwise indicate parent class shouldn't initialized on own?
you should use protocol instead of base class in case. common implementation can done in protocol extensions , won't need provide default values constants - specify required get
methods in protocol.
Comments
Post a Comment