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 3300760
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T20:41:26+00:00 2026-05-17T20:41:26+00:00

Let’s say I’m implementing my own version of Scrabble. I currently have a Board

  • 0

Let’s say I’m implementing my own version of Scrabble.
I currently have a Board class that contains lots of Squares. A Square in turn is composed of a IBonus and a Piece. The bonus implementations are actually the usual bonus for Scrabble, but it is possible that I might try to add some new and twisted bonus to spice the game — flexibility here is paramount!

alt text

After thinking for a while I came to the conclusion that for IBonus implementations to work, they’ll need to know the whole Board and also its current position(on the Board, so it knows where it is and it can check for the piece that’s in the same square as the bonus is). This strikes me as bad as basically it needs to know a whole lot of information.

So, my naive implementation would be to pass the Board as argument to IBonus.calculate() method, IBonus.calculate(Board board, Point position), that is.

Also, it seems to create a circular reference. Or am I wrong?
alt text

I don’t particulary like this approach, so I am looking for other possible approaches. I know I can make calculate accept an interface instead of a concrete class, i.e., calculate(IBoard board) but I IMO that isn’t all that better than the first case.

I fear being too focused on my current implementation to be able to think of whole different designs that could fit at least as well as solutions to this problem.
Maybe I could re-architect the whole game and have the bonuses in other place, so it would facilitate this calculation? Maybe I am too focused on having them on the Board? I certainly hope there are other approaches to this problem out there!

Thanks

  • 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-17T20:41:26+00:00Added an answer on May 17, 2026 at 8:41 pm

    I assume Board has the visible state of the game, and there would be other objects such as Rack (one per Player,) and a DrawPile.

    “Double Score if word contains a real (non-blank) Z” – would require you pass in the Word, or the Board and the position of the word.

    “Double Score if the word is the longest on the board” requires the entire Board.

    “Double Score if the first letter of the word matches a randomly selected letter from the DrawPile” requires the DrawPile of course.

    So to me it just depends on the rules you implement. I’d be comfortable with passing Board to the IBonus score() implementation.

    edit – more thoughts.

    So a board has 17×17 squares, or whatever. I’d assign an IBonus implementation to each square of the board (there would be an implementation called PlainEmptySquare that was inert.) You’d only need to instantiate each implementation of IBonus once – it could be referenced many times. I’d probably take the low road and instantiate each one explicitly, passing in the arguments needed. If one type needs the Board, pass it in. If another needs the DrawPile, pass it in. In your implementation, you’d have perhaps 12 lines of ugliness. /shrug

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

Sidebar

Related Questions

Let me explain best with an example. Say you have node class that can
Let's say you have a class called Customer, which contains the following fields: UserName
Let's say you have a class, with certain properties, and that you tried your
Let's say that I have a SQLite database that I create in a separate
Let's say on a page I have alot of this repeated: <div class=entry> <h4>Magic:</h4>
Let's say I have multiple requirements for a password. The first is that the
Let's say that I have a date in R and it's formatted as follows.
Let's say I have the following classes : public class MyProductCode { private String
Let's say you have a method that expects a numerical value as an argument.
Let's say I have a bunch of links that share a click event: <a

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.