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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T16:17:55+00:00 2026-05-31T16:17:55+00:00

I am implementing a basic board game in Java and that I am having

  • 0

I am implementing a basic board game in Java and that I am having difficulty deciding the pros and cons of in solving. I am already successfully making use of the Command Pattern to enable undo functionality in the game, and originally intended to implement game saving/loading by serializing the entire set of game model objects.

However I realised that as the game is a board game with no random elements involved and always initialising with the same state, I could implement save/load functionality by simply serializing the object containing the command stack and the commands themselves up to that point, and then re-execute all of the commands in order to bring the game up to the saved position.

My current design does not allow me to do this, as my Commands hold references to the object instances that form my board’s tiles and pieces, which I believe is best OO practice. That would mean I would also have to serialise those model objects, which would defeat the purpose of just serialising the commands and executing them. My question is whether having the commands just hold the integer locations of the boards tiles would be considered bad practice.

Relevant portion of my Command class code:

private GameController controller;
private Tile sourceTile;
private Tile[] route;

public MoveCommand(GameController controller, Tile sourceTile, Tile... route) {
    this.controller = controller;
    this.sourceTile = sourceTile;
    this.route = route;
}

@Override
public void execute() {
    controller.executeMove(sourceTile, route);
}

I intend to change the Tile references into references to a new serializable class called TileLocation or something to that effect, which will hold an X and Y integer so that the board can find the tiles.

  • 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-31T16:17:57+00:00Added an answer on May 31, 2026 at 4:17 pm

    Nothing wrong with storing your game state and moves as integers. But I would not recommend to use java serialization for long term storage. (it will be almost impossible to update game
    classes and reread saved states). Use some kind of XML or JSON databinding ( Jackson, GSON , whetever you like) for long term persistence.

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

Sidebar

Related Questions

I'm trying to grasp higher-order-polymophism in scala by implementing a very basic interface that
I have a basic form with controls that are databound to an object implementing
I am implementing a really basic server-client model in Java, by using UDP sockets
I'm implementing a simple game for an assignment that would ideally run both on
Implementing the basic algorithm using last array as a pivot in Java, is it
I'm having a small issue with implementing custom basic authentication for a asmx in
I am writing a game for gameboy advance and I am implementing basic AI
I am implementing a basic chat server on Java. Actually I finished basic things
I'm looking for some ideas on implementing a basic message factory that reads a
I am currently implementing a basic raytracer in c++. Works pretty well so far,

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.