CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Dec 2010
    Posts
    907

    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

  2. #2
    Join Date
    Dec 2010
    Posts
    907

    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);
            
    }

  3. #3
    Join Date
    Feb 2011
    Location
    United States
    Posts
    1,016

    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.

  4. #4
    Join Date
    Dec 2010
    Posts
    907

    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

  5. #5
    Join Date
    Feb 2011
    Location
    United States
    Posts
    1,016

    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.

  6. #6
    Join Date
    Dec 2010
    Posts
    907

    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
  •  





Click Here to Expand Forum to Full Width

Featured