开发者

iphone sdk - object model context design help

开发者 https://www.devze.com 2023-02-20 01:39 出处:网络
i need some help with designing iphone\'s core data object model context. I\'ve started making a golf scorecard application using XCode 4, and the way I want the application behave is...

i need some help with designing iphone's core data object model context. I've started making a golf scorecard application using XCode 4, and the way I want the application behave is...

-User can add players (with first/last name, initials)

-User can add courses (with name, address details, holes with par/lenght)

-Play a round so that in on top of scorecard tableview (hole view) I want to have fixed section that will not scroll, and that will show current score for each player on a round in addition to the best score ever on that same course.

-On hole view, in section header, I want to show like "Hole 11: Par 3 / 150 m" and on each row I want to show buttons to add strokes, and the best score ever on that particular hole.

-When managing players, adding/deleting, user can also browse the rounds that player has ever played.开发者_StackOverflow社区

What is the best approach to design entities? I already got some consultation and he suggested that I should have it like this:

PLAYER:  
- first_name  
- last_name  
- initials  
- ROUND:*  
-- date  
-- COURSE  
-- SCORE  

COURSE:  
- name  
- address  
- hole 1 (par/length)  
- hole 2...18  

SCORE:  
- hole 1  
- hole 2...18  

SCORECARD: (will only be temporary object, to be deleted when round is complete)  
- PLAYER*

* = multiple objects

Is this a good design? I somehow feel that I should have a permanent SCORECARD objects that will hold PLAYER objects, one COURSE object and 18 holes attributes that will get values like "3:3:5:4" (score for each player, colon being seperator).

I hope this is not too messy posting, and please, forgive my english.


I would consider extrapolating the hole attributes to be an entity. Attributes would be "par" and "length". Then, have a relationship so that a course entity has many holes. Each hole conversely belongs to a specific course.

The data modeller in XCode is really good for visually creating entities and the relationships between them. I'd recommend experimenting until you feel that you have a good model. Think also about how you will use the model in your code. For example, what sort of look ups will you do?

For more detailed study it's worth getting a good book on object modelling. I used Larman's "Applying UML and Patterns: An Introduction to Object-Oriented Analysis and Design and Iterative Development".

0

精彩评论

暂无评论...
验证码 换一张
取 消