Question

Hey guys, i am planning to write a lcd numeric / 7 segment display for iphone.
(a display that consists of several numbers, each consisting of 7 (dash) segments.)

  1. My question is, after mvc pattern, where does the 'number parsing' code belong? View or its controller?

    So, should the controller pass the view just a number to display, letting the -drawRect method find out which segments to lighten up?

    Or should the controller pass the view directly, which segments to lighten up, after finding that out in a method within the controller class?

    As i learned so far, the controller is responsible for all logic things. But i'm not sure if that kind of logic is also meant by that.

  2. Oh and by the way, should the controller just set properties on the view, or would it be better to call the controller as a delegate from within the view class to fetch the data?

Was it helpful?

Solution

I would say that the view should be figuring out which segments to draw. Ideally, you would be able to turn your app into an analog clock by just swapping out the view (since the numbers delivered from the controller wouldn't change.) While you don't want your view performing business logic, "visual" logic (how data should be drawn) is definitely within the purview of the view.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top