• Open Menu Close Menu
  • Apple
  • Shopping Bag
  • Apple
  • Mac
  • iPad
  • iPhone
  • Watch
  • TV
  • Music
  • Support
  • Search apple.com
  • Shopping Bag

Lists

Open Menu Close Menu
  • Terms and Conditions
  • Lists hosted on this site
  • Email the Postmaster
  • Tips for posting to public mailing lists
Re: MVC question
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

Re: MVC question


  • Subject: Re: MVC question
  • From: Ryan Bates <email@hidden>
  • Date: Sun, 8 Feb 2004 13:18:10 -0800

On Feb 7, 2004, at 1:07 PM, Koen van der Drift wrote:
Initially I thought I can pass that info with the info on the pasteboard to the model, more or less as in the Sketch example. But, does this info really belong in the model? The objects shouldn't know where they need to be drawn, the view or viewcontroller should take care of this. Any suggestions how to approach this? Maybe use a parallel array that stores the coordinates of each object?

A good rule of thumb is if a class has more than one purpose then it should be split into two classes. If the model objects you are drawing have a purpose other than to be drawn, I would create a separate "graphic" class to handle the drawing of each model class. In Sketch, the graphic objects only have one purpose - to be drawn - so it makes sense to handle the drawing there.

If you do separate the two, I would make the drawing classes similar to Sketch's. There could be an abstract graphic class which would contain the position, size, etc. I would then create a graphic subclass for each model object that needs to be drawn. The drawing class could hold an instance of the model it draws.

Let's say you are drawing a clock. You could create a Clock model class that keeps track of time. You could then create a ClockGraphic class that draws a Clock object. You could even go a step further and create an AnalogClockGraphic and a DigitalClockGraphic to draw the same Clock two different ways.

An additional question, since I am rewriting the app from scratch, would this type of app benefit from using Cocoa bindings?

I really don't know much about bindings, but it seems to be best suited for widget-type applications. Throw bindings in with a couple buttons and a table view and you can create a simple program with almost no code, but when it comes to a drawing application where most of the GUI is made up of custom objects, it might be harder to implement bindings. I could be wrong though.

Ryan Bates
_______________________________________________
cocoa-dev mailing list | email@hidden
Help/Unsubscribe/Archives: http://www.lists.apple.com/mailman/listinfo/cocoa-dev
Do not post admin requests to the list. They will be ignored.

  • Follow-Ups:
    • Re: MVC question
      • From: Koen van der Drift <email@hidden>
    • When/how to use bindings (was Re: MVC question)
      • From: mmalcolm crawford <email@hidden>
References: 
 >MVC question (From: Koen van der Drift <email@hidden>)

  • Prev by Date: Re: Drawing onto NSImageView subclass (Newbie)
  • Next by Date: Re: Document App or not?
  • Previous by thread: MVC question
  • Next by thread: When/how to use bindings (was Re: MVC question)
  • Index(es):
    • Date
    • Thread