Finding value types: Bundling Up and Static Analysis

48 views
Skip to first unread message

Daniel Wellman

unread,
Jul 6, 2016, 9:27:36 PM7/6/16
to Growing Object-Oriented Software
Hello,

I've discovered an object that has grown to be a bit large and I'd like to reduce its size.  It's largely a data object that exposes several fields via Java getter methods -- that is, the client code largely uses it as a read-only source of data to decide to do things.  I'm looking to either hide those fields and add behavior on that object or bundle up related fields into bigger objects.  Probably both, actually.

I'm currently looking for fields that are accessed together to see about bundling those up into objects.  I know I could do this in a manual brute-force approach, but I wondered if there was some sort of way to have the computer suggest a few places to start.  That is, given a target object, I wish a computer program would say "Hey, these two fields are often accessed together over here in Foo, Bar, and Baz, and these three are often accessed together over there in Blargh Bah and Bahumbug."  

I was thinking I could use source code repository analysis to help me figure out when two files are frequently changed together -- so I could find out what other classes frequently change with the target object.  That would give me a starting point to figure out which source files might be interesting to look at - but not which fields to check.

Does anyone know of any useful static analysis tools for Java source code that could do something like that?  Or of any other techniques for finding these candidate objects to bundle up?

Thanks for your advice!

Cheers
Dan

solomon....@gmail.com

unread,
Jul 7, 2016, 7:27:42 AM7/7/16
to growing-object-o...@googlegroups.com
Hey,

There is a ruby gem named Reek, that detects code smells like you are describing. Maybe there is a linter or static analyzer that does something similar in Java. Sadly I don't know one off hand. 

I hope that helps a bit.

Steve

Sent from my iPhone
--

---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Steve Smith

unread,
Jul 7, 2016, 9:38:55 AM7/7/16
to growing-object-o...@googlegroups.com
For .NET I would use NDepend and/or Roslyn analyzers like https://github.com/code-cracker/code-cracker

For Java I think your best bet is probably SonarQube: http://www.sonarqube.org/



--

---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
To unsubscribe from this group and stop receiving emails from it, send an email to growing-object-oriente...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages