Take the 2-minute tour ×
Programmers Stack Exchange is a question and answer site for professional programmers interested in conceptual questions about software development. It's 100% free, no registration required.

I've been working with TDD, most patterns, mostly OO code and still not found a way of knowing if a particular piece of code confirms to modularity , without the need reviewing the code.

On a recent project which had split up everything into jars specifying a "module" which still wasn't modular code.

So is there any way of actually knowing or measuring if code is modular or not?

Modularity is away of minimizing the ripple effect when doing changes to a system. I've been doing a post mortem on a large system and one of the biggest issues have been the inability of containing changes to a minimum.

There are several reasons for this, one where the code is actually not modularized despite following best practices. As a result the belief have been that the system is actually resilient for changes but in practice it isn't.

A distinct pattern have emerged and shows why the system fails being modularized and that might be a a way of actually provide metrics for how modularized you code is.

share|improve this question

closed as unclear what you're asking by Kilian Foth, AProgrammer, MichaelT, gnat, Caleb Jan 14 at 18:00

Please clarify your specific problem or add additional details to highlight exactly what you need. As it's currently written, it’s hard to tell exactly what you're asking. See the How to Ask page for help clarifying this question.If this question can be reworded to fit the rules in the help center, please edit the question.

6  
Your question would become much clearer when you would present us the definition of modularity or "module" you have in mind. I "smell" a very good question behind a bad wording. –  Doc Brown Jan 14 at 9:51
1  
If you're not going to look at the source, why do you care? Does the exposed API do what you want? Are the dependencies reasonable (and documented)? Does it perform? Those are the important questions if you aren't looking inside. –  itsbruce Jan 14 at 12:22
    
@itsbruce because in large projects it's hard to do follow up on everything. –  user2806884 Jan 14 at 14:49
4  
You need to answer Doc Brown's point before anything more can be said. –  itsbruce Jan 14 at 15:21
1  
Having read your update, I'm pretty sure that modularity is the wrong word. –  itsbruce Jan 15 at 14:38

2 Answers 2

I believe that if your separated piece of code depends only on interfaces or abstract classes - all the classes take interfaces in constructors as well as the methods/properties return interfaces - you can move it to a separated library and being easy on calling it a module.

That's actually what a module is - you can always replace it with another library/jar/dll that provides the same interface and different implementation. So if you didn't couple your application tight you should be able to extract modules easily.

share|improve this answer
    
Yes, this was also my belief but I know for a fact it's not. Interfaces and abstract classes are a technical constructs. –  user2806884 Jan 14 at 11:05
    
@user2806884 Interfaces are not technical construct. They are logical construct of design. –  Euphoric Jan 14 at 11:40
    
@Euphoric Yes and no. You can always model interface with an abstract class. If it is all you are using abstract classes for then it is only a negligible detail. Of course interfaces are better, imho. –  SOReader Jan 14 at 12:12
    
@Euphoric interfaces are a technical construct. Been doing a post-mortem on a multi million dollar project and one of the failing facts were the view of interfaces. –  user2806884 Jan 14 at 18:35

If you look at diagram of concrete class and know that all the dependencies (eg. arrows in UML diagram) point outwards and all those arrows point toward either to interfaces in case of association or different class in case of inheritance. Then you can be quite sure the class is modular. But this of course only takes into account modularity the code was designed for.

But measuring how much the whole codebase is modular is impossible. If it was possible, It would be used all over the place as useful metric.

share|improve this answer
    
Is it proven impossible or you assume it's impossible? –  user2806884 Jan 14 at 10:59
    
@user2806884 It cannot be proven, because there is no mathematical definition of modularity. Thats why it also cannot be proven possible. –  Euphoric Jan 14 at 11:40

Not the answer you're looking for? Browse other questions tagged or ask your own question.