• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Jeanne Boyarsky
  • Ron McLeod
  • Paul Clapham
  • Liutauras Vilda
Sheriffs:
  • paul wheaton
  • Rob Spoor
  • Devaka Cooray
Saloon Keepers:
  • Stephan van Hulst
  • Tim Holloway
  • Carey Brown
  • Frits Walraven
  • Tim Moores
Bartenders:
  • Mikalai Zaikin

Implementing Implementation Patterns

 
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi Kent,

I hope you know IntellJ's inspection feature. Do you think it is possible to create inspections that check for the violation of your implementation patterns?

Thanks
Walter
 
author
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Dear Walter,

I am not familiar with IntelliJ's inspections. Assuming they are triggered by a kind of AST matcher, some of the patterns (or their absence) should be detectable.

Regards,

Kent Beck
Three Rivers Institute
 
Greenhorn
Posts: 6
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Walter,
actually there are already some inspections that handle patterns of the book. I.e. narrow scope or naming, final parameter/variable, convert field to local and many more intentions. Just take a look at the intention list in the settings and compare them with the implementation patterns.

Others are just sound OO-knowledge and available through the numerous refactorings IDEA offers.
(i.e. extract Interface, Superclass, Encapsulate Fields, Replace Inheritance with Delegation, Move (instance) Method, Find Method duplicates)

It is quite difficult for an IDE to recognize smells that are in the eye of the beholder. It can't know which responsibilities you want to group together, which ones you want to extract and how they relate from the business point of view.

Michael
 
Kent Beck
author
Posts: 45
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Michael,

I think there is more to it than that. For example, I look for multiple messages to the same object in a given method as a hint that the receiving object could use more responsibility. I don't do any fancy business analysis, I just pattern match. I think an automated tool could detect this pattern, but it would have to be fairly sophisticated:
for (X each : Y.Z()) {
Y.W();
}
for example, probably belongs in Y.

Regards,

Kent Beck
Three Rivers Institute
 
Walter Bernstein
Ranch Hand
Posts: 57
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Originally posted by Kent Beck:
Michael,

I think there is more to it than that. For example, I look for multiple messages to the same object in a given method as a hint that the receiving object could use more responsibility. I don't do any fancy business analysis, I just pattern match. I think an automated tool could detect this pattern, but it would have to be fairly sophisticated:
for (X each : Y.Z()) {
Y.W();
}
for example, probably belongs in Y.

Regards,

Kent Beck
Three Rivers Institute



"Feature Envy" is already detected. I will check your book to see which inspections are still missing.
 
Don't MAKE me come back there with this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com
reply
    Bookmark Topic Watch Topic
  • New Topic