Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 838275
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T05:16:42+00:00 2026-05-15T05:16:42+00:00

I’m currently teaching myself objective C. I’ve gone through the tutorials, but I find

  • 0

I’m currently teaching myself objective C. I’ve gone through the tutorials, but I find I learn best when slogging through a project of my own, so I’ve embarked on making a backgammon app.

Now that I’m partway in, I’m realizing there’s some overall architecture things I just don’t understand.

I’ve established a “player” class, a “piece” class, and a “board” class. A piece theoretically belongs to both a player and the board. For instance, a player has a color, and every turn makes a move; so the player owns his pieces. At the same time, when moving a piece, it has to check whether it’s a valid move, whether there are pieces on the board, etc.

From my reading it seems like it’s frowned upon to reach across classes. For instance, when a player makes a move, where should the function live that moves the piece? Should it exist on board? This would be my instinct, as the board should decide whether a move is valid or not; but the piece needs to initialize that query, as its the one being moved, no?

Any info to help a noob would be super appreciated. Thanks guys!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-15T05:16:43+00:00Added an answer on May 15, 2026 at 5:16 am

    I think you’re probably over engineering your class hierarchy. A good rule of thumb is to start with a handful of classes whose functionality do not overlap, and then refactor your overall design, on demand, as you expand on your program.

    A class to model each player may not be necessary at all. I would start by just having a board class manage the “state” of the backgammon game — namely whose turn it is, if the dice have been rolled, the dice roll if necessary, the state of all 24 points + bar + “off” for each player, the state of the doubling cube, the current match length and the current score for each player. (I wrote my MSc thesis on backgammon, including a command line shell program to play games, so I understand the domain here fairly well.)

    @Mark Bessey I would certainly not have a design where the piece (checker) knows how to move itself.

    @Felixyz Determining a legal move is actually a little more difficult in backgammon than it is in chess. This is especially true if you want to generate the complete list of legal moves on any given turn.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Seemingly simple, but I cannot find anything relevant on the web. What is the
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I want to count how many characters a certain string has in PHP, but
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I want use html5's new tag to play a wav file (currently only supported
I have a French site that I want to parse, but am running into
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I am currently running into a problem where an element is coming back from
I want to construct a data frame in an Rcpp function, but when I

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.