language agnostic - Ideas for automatic refactoring of modules -
i have problem function , type definitions aggregate on time in single module (we can assume module corresponds source file). @ point source file big barely maintenable anymore. example, 1 realizes module contains lot of functions logically related handful of different topics, , 1 feels should in own modules.
the idea have tool suggests ways split such module. actual creation of new source files old ones made automatically.
i have follwoing:
- list of functions , data types, along direct dependencies on other functions , types in module.
- from this, can compute dependencies every item
we can topological sort, make dependency groups. example
(a, (b,c,d), e)
- an item more left in outer list not depend on ones further right
- inner grouped items (b,c,d) depend recursively on each other
the modules must form acyclic hierarchy, i.e. not possible module imports module b when b or 1 of modules imports imports a. follows (b, c, d)
example above must not splitted across different modules.
now somehow stuck , looking strategy make sensible suggestions based on information found far.
of course, 1 possibility split according topologically sorted list of dependency groups. however, let assume list starts thus:
(a, b, c, ....)
where c depends on b , a, b on , on nothing. here following:
- module abc defines a, b , c
- module defines a, module bc imports , defines b , c
- module c imports , b , defines c, module b imports , defines b
if map dependencies between functions dependencies between modules may end module hierarchy complex , fine grained.
somehow must take further factors account. maybe desired module size, or number of imports.
any advice, pointers existing software doing welcome.
it sounds describing efferent , afferent couplings http://en.wikipedia.org/wiki/software_package_metrics
this language agnostic question know of few tools in java such jdepend (http://clarkware.com/software/jdepend.html) compute these metrics guide future refactorings.
Comments
Post a Comment