Jump to content

  • Log In with Google      Sign In   
  • Create Account

Banner advertising on our site currently available from just $5!


1. Learn about the promo. 2. Sign up for GDNet+. 3. Set up your advert!


Cohesion and coupling


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
3 replies to this topic

#1 lucky6969b   Members   -  Reputation: 678

Like
1Likes
Like

Posted 05 August 2014 - 04:46 AM

In my project, I code that in a way that high coupling and low cohesion is not an option. For example, the Create Object method has to know about the Object map and geometry in which they are later used for navigation mesh building process. It seems unavoidable. All the stuff in Create are unrelated. Is it a bad practice? Or it is just unavoidable like I said.
bool Create(std::string name, LPDIRECT3DDEVICE9 pDevice, SkinnedMesh *pMesh, SkinnedMesh* geom, ObjectMap obj, float fAnimSpeed = 1.0f);
Thanks Jack

Sponsor:

#2 Álvaro   Crossbones+   -  Reputation: 15525

Like
2Likes
Like

Posted 05 August 2014 - 07:09 AM

It looks pretty bad. Perhaps you can post the definition of that function, so we can see what you are doing with each argument.

#3 rip-off   Moderators   -  Reputation: 9544

Like
2Likes
Like

Posted 05 August 2014 - 07:10 AM

Can navigation mesh building / updating be de-coupled from object creation?



#4 SeanMiddleditch   Crossbones+   -  Reputation: 10055

Like
5Likes
Like

Posted 05 August 2014 - 11:09 AM

This is a typical problem that is solved fairly well with component-based design. There's no reason for graphics to know about meshes used for collision or AI, or vice versa for AI to need to know about graphics or animation data. Create each of these separately and then make your game object contain both components.

With the right content loading system and data-driven design approaches you can (almost always) completely decouple your systems' code and interfaces.

The only systems that really need to know about all the different systems would be procedural generation modules. If you think of your game as a series of layers, however, this coupling isn't a problem. Your graphics, AI, and collision systems are lower-level services than game-specific procedural generation systems, so letting procedural generation depend on those other systems is fine. Just do your best to minimize the public surface area of each system so that higher-level systems need to know as few implementation details of the lower-level systems as possible.




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS