Discussion:
[GOOS] Finding value types: Bundling Up and Static Analysis
Daniel Wellman
2016-07-07 01:27:36 UTC
Permalink
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
--
---
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-oriented-software+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
s***@gmail.com
2016-07-07 11:27:38 UTC
Permalink
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
Post by Daniel Wellman
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
--
---
You received this message because you are subscribed to the Google Groups "Growing Object-Oriented Software" group.
For more options, visit https://groups.google.com/d/optout.
--
---
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-oriented-software+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Steve Smith
2016-07-07 13:38:52 UTC
Permalink
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/
Post by Daniel Wellman
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
--
---
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
For more options, visit https://groups.google.com/d/optout.
--
Steve Smith
http://Ardalis.com/
http://twitter.com/ardalis
--
---
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-oriented-software+***@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
Loading...