Drawing: The Right place to keep bounds
Drawing: The Right place to keep bounds
- Subject: Drawing: The Right place to keep bounds
- From: Paul Bruneau <email@hidden>
- Date: Wed, 25 Nov 2009 10:27:23 -0500
I'm really trying to do things correctly with my app but I'm at a
place where I can't figure out what correct is, and all my best
examples do it wrong (I think).
I am working on the drawing parts of my app. In my last app I most
definitely did things Wrong but they work fine and there's just one
user and it was my first Cocoa app so I didn't beat myself up too much.
It's document-based, non-core-data, and aimed at 10.5.
For reference, I am using Sketch, and Cocoa Design Patterns by Buck
and Yacktman. I also am referring to my memory of several helpful
posts to this list by Buck over the past couple years that I have been
watching for them.
I think I recognize, and I am pretty sure I have read that Sketch does
things Wrong. I see that the shape objects keep their own bounds (and
frame?) information. It seems clear to me that this is Wrong. What
does Sketch do if it ever can have two views of the same objects?
I am also pretty sure that Cocoa Design Patterns does it wrong because
it admits such:
The model in this example is deliberately kept simple to preserve
the focus on the Controller
subsystem. In most applications, properties like rectangles and
colors are user interface concerns that
don’t belong in the Model subsystem. However, in this case,
MYShapeDraw is a drawing program.
This seems like a common problem that I have had with various Cocoa
information over the years. Everything is kept simple for the sake of
the example, and I am left clueless about the correct way to do it (or
I am too dumb to see it). In the quote above, I have learned that the
rectangles don't belong in the Model subsystem. OK that's a good
start! Now, where do they belong?
I have a window controller, which is the file's owner of a nib that
contains the window. In the window is my custom view. My custom view
contains the skeletal beginning of a category for the drawing code of
the model objects that are displayed in it (as explained by Buck,
around page 257). This part I feel I understand pretty well and it
works.
But where to put the rectangle and other data that each object needs
in order to be kept track of (for clicking on, etc) and drawn?
Thank you for any insight!_______________________________________________
Cocoa-dev mailing list (email@hidden)
Please do not post admin requests or moderator comments to the list.
Contact the moderators at cocoa-dev-admins(at)lists.apple.com
Help/Unsubscribe/Update your Subscription:
This email sent to email@hidden