ios - Massive Parent-Child and delegate pattern -
i'm facing complex design problem. due hard designed graphic can't use apple navigation pattern uinavigationcontroller
or other ones. app diagram
black arrow: protocols direction blue arrow: parent-child pattern direction
i created flow because want maintain code inside single viewcontroller
clear , isolated: thought them modules can used somewhere in other apps. rootviewcontroller
mainvcs
position manager. decides current view-controller must showed , configures based on status (modified delegate methods). single mainvc
doesn't know rootvc
exists , call root using protocols. single childviewcontroller
doesn't know mainvc
exists , call main using protocols , on.
code clear , easy understand, purpose, when have apply modify skeleton (rootvc
) childviewcontrollern
, child of umpteenth childviewcontroller
, child of umpteenth mainviewcontroller
, have propagate protocol until rootviewcontroller
.
my first question is: pattern correct? think it?
my second question is: there limit point haven't use delegate pattern kvo
?
adding read university lecture composite pattern
says:
a composite object knows contained components, is, children. should components maintain reference parent component? depends on application, having these references supports chain of responsibility pattern
so, according chain, can maintain reference of parent have declare custom interface kind of reference. however, doing decrease number of protocols, second question still unanswered
opinion:
when go beyond single level of parent/child relationships, tend stop using delegates , move nsnotification
. frequently, go directly nsnotification
reduce dependencies. prefer kvo because explicit, whereas kvo harder debug project progresses.
(example: looks simple variable assignment on background thread results in hard-to-diagnose crash if listener deallocated on main thread between moment of assignment , kvo delivery.)
Comments
Post a Comment