-
January 31st, 2013, 01:00 AM
#1
Design issue (loose vs strong coupling)
I have a function, but not a method, that is used to generate skinned meshes from it.
The object that is calling it will grasp a copy of this skinnedmesh from the out parameter,
which is not likely to be desired in today's software engineering practice.
But It is not very logical to encapsulate that function into that class since I want that generated skinned mesh
to be transient. Therefore, I need to pass more parameters to it, which increases the coupling.
Anyways, on a conceptual level, how can I improve this design?
Thanks
Jack
-
February 1st, 2013, 03:06 AM
#2
Re: Design issue (loose vs strong coupling)
For example
Code:
void GenerateSkinnedMesh(Device *device, SkinnedMesh *skinnedMesh)
{
// do something
skinnedMesh = factory.generateSkinnedMesh(...);
}
class AllocateHierarchy
{
CreateMeshContainer(...);
};
void AllocateHierarchy::CreateMeshContainer(...)
{
SkinnedMesh skinnedMesh;
GenerateSkinnedMesh(device, &skinnedMesh);
}
-
February 1st, 2013, 06:25 PM
#3
Re: Design issue (loose vs strong coupling)
I don't see why you would complicate the design in that manner. Why not just expose GenerateSkinnedMesh(Device*, SkinnedMesh*)? Free the memory as soon as you don't require the mesh anymore, if you desire transient existence of the object.
Best Regards,
BioPhysEngr
http://blog.biophysengr.net
--
All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.
-
February 2nd, 2013, 10:48 PM
#4
Re: Design issue (loose vs strong coupling)
Sorry, BioPhysEngr, I have some comprehension problem understanding the term "expose". Could you please raise an example?
Thanks
Jack
-
February 3rd, 2013, 12:26 AM
#5
Re: Design issue (loose vs strong coupling)
I meant to say, why not just allow that method (which returns a pointer to a SkinnedMesh as an out parameter) to be directly called? You seem to want to avoid out parameters, but there is not a compelling reason to avoid them (other than perhaps they are not fashionable - which I am not sure is even true). I think it is best to use a more simple and logical design, without complicating it with another layer of encapsulation.
Best Regards,
BioPhysEngr
http://blog.biophysengr.net
--
All advice is offered in good faith only. You are ultimately responsible for effects of your programs and the integrity of the machines they run on.
-
February 3rd, 2013, 11:05 PM
#6
Re: Design issue (loose vs strong coupling)
Hi BioPhysEngr,
One mo question for you, so now I have a certain thingy known as the skinning method, this object is specific to certain mesh. So it should be encapsulated into a class. But as GenerateSkinnedMesh is a function, it isn't capable to encapsulate anything. Don't you think I should wrap this function inside a class? I think and re-think, and I gradually believe this "function" should belong to a class.
Thanks
Jack
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|