Home     |     .Net Programming    |     cSharp Home    |     Sql Server Home    |     Javascript / Client Side Development     |     Ajax Programming

Ruby on Rails Development     |     Perl Programming     |     C Programming Language     |     C++ Programming     |     IT Jobs

Python Programming Language     |     Laptop Suggestions?    |     TCL Scripting     |     Fortran Programming     |     Scheme Programming Language


 
 
Cervo Technologies
The Right Source to Outsource

MS Dynamics CRM 3.0

Fortran Programming Language

Circular module dependencies


The standard does not permit the recursive or circular use of module
use, like the following.

module A
use B
end module A

module B
use A
end module B

What is the best practice to circumvent this? A common situation is
that a pseudo-object (defined in module A) is passed to some function
(in module B), where one needs to call a function of the pseudo-object
(e.g. an accessor)
Thanks in advance
Mick

Hello,

Sounds like you're making module A do too much.

Why not let module A just define the object (constructor, accessor(s)). If methods in
module B are still required for module A to do its definition/access job, then they
shouldn't be in module B, but in A.

I think of it in terms of definition and application modules, e.g.

module A_Def
  ....
end module A_Def

module A_App
   use A_Def
   ....
end module A_App

Module A_Def defines the object, A, for a particular task and needs nothing else (well,
maybe utility modules for defining types, setting common parameters, etc, but nothing "A"
related), and module A_App uses that definition to do stuff.

cheers,

paulv

--
Paul van Delst             Ride lots.
CIMSS @ NOAA/NCEP/EMC               Eddy Merckx

Mick Maier wrote:
> The standard does not permit the recursive or
> circular use of module use.

> What is the best practice to circumvent this?

FWIW, I recommend reading Bob Martin's DIP and SRP
articles available via

  http://objectmentor.com/resources/publishedArticles.html

which are chapters in,

  http://www.amazon.com/Software-Development-Principles-Patterns-Practi...

Regards,
--
Bil Kleb
http://fun3d.larc.nasa.gov

Add to del.icio.us | Digg this | Stumble it | Powered by Megasolutions Inc