Tic Tac Toe Design Plan

I was wondering if I can get your thoughts and advice on what would be the best / most profitable design template for the Tic Tac Toe multiplayer game?

I looked at the following design patterns: Factory, Abstract Factory, Singleton, Prototype, and Builder.

In your experience, which will be the best to use, and why?

Right now, my Tic Tac Toe game is a streaming client-server game that can be played over the Internet through sockets. However, I am going to reorganize the game in some way to use the design template.

I was thinking of setting up a client-server architecture that can be used to play many different types of games, such as tic tac toe, connect 5, etc.

Which direction should I go? I want to go in a direction that will really give me some experience in developing templates ...

Thanks!

+3
source share
5 answers

Caution: I hate it when people use “design templates” as a GOAL. Create good code, and if what you do looks like DP, use DP to help you improve the code. But don’t start saying: “I want to write my program using the“ Impact Crane ”template. This put the cart in front of the horse. DP should appear from your design. They should not control the design.

Endcaveat

. DP - "", . : " , ?"

, . , , , factory . factory, , , .

+16

. , , .

, - singleton factory . Singleton , , factory , .

+2

, , , , , , , , . , () " ", " ", " " ..

+2

, , factory / factory. , , , , factory.

, "". , ( ), , . , , , .

factory hello world . / . , , - , , .

+2

- -. tic-tac-toe , . , - .

You want to reorganize your code fairly fairly, but don’t do it because you want more design templates in it. Do this because you want to clear your code, make it more general, and possibly extend it to other games.

To get a good answer to the design pattern, provide a specific example:

Q. How do I restrict network_handler to a single instance? - A. Use Singleton

Otherwise, you may find a reason to include almost every design pattern.

+2
source

Source: https://habr.com/ru/post/1721904/


All Articles