What design pattern should I go for if I want to "sort of" convert the interface?

Started by
1 comment, last by haegarr 8 years, 11 months ago

Now I just got 2 projects to combine into one. There are 2 similar classes that behave more or less the same.

One is called Unit in the pathfinding module and one is called the Object class in the main game module

Now I just need to change the interface so I just need one of them to swing into actions.

Should I use the adapter pattern to do so? I don't know because I am not actually *converting* the interface,

just, so to speak, combine the 2 classes together without changing the source code itself?

One thing to consider is that they may not use the same data structures.

Grids Opposed to Navigation Meshes

Thanks

Jack

Advertisement

There are many options to choose from, depending on the purpose and coding style. Maybe some code snippets of your interfaces would give a hint. One thing to keep in mind to not focus too much on code reuse as a solution to code duplication. Sometimes finding the common concepts for abstracting the code is really hard.

openwar - the real-time tactical war-game platform

The OP doesn't contain exhaustive informations, so to say. In principle I would / do arguing as follows:

The navigation system is a service provider for AI (can I go there?) and the movement system (how to go there?), i.e. it is at lower level than those, and those are at a lower level than game objects (as a whole). When different navigation solutions are available and probably even need different data structures, then integrating all that into game objects would be messy. A possible solution is to use an agent attached to the game object, so that the agent utilizes the services, holds the appropriate data structures, and mediates between them and the game object.

This topic is closed to new replies.

Advertisement