• 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
  • Liutauras Vilda
  • Tim Cooke
  • Jeanne Boyarsky
  • Paul Clapham
Sheriffs:
  • Devaka Cooray
  • Ron McLeod
  • paul wheaton
Saloon Keepers:
  • Tim Moores
  • Piet Souris
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
Bartenders:
  • Al Hobbs
  • Frits Walraven
  • Scott Selikoff

performAnimalEnrichment() Code Examples

 
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello - Per the OCA Java SE 8 Programmer I Study Guide, on page 145, it states that the performAnimalEnrichment() "method can't be reused" because it is not using the Period class.  I ran both examples and I do not see the difference in the outputs when I ran the code below.  I must be missing something, would someone please explain why the first example on page 145 can't be used?

Thank you in advance for your review and/or help!

 
Marshal
Posts: 27450
88
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I don't have the book so I can't be certain what you're referring to. But in real life the first method would be better like this:



Perhaps that's what the book is trying to get at?
 
author & internet detective
Posts: 41381
853
Eclipse IDE VI Editor Java
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
The comment about reuse is for if you want to change the number of months. If you want to change 1 months to three, you don't have to change the method that takes a Period as a parameter. And that's good reuse.

This feels trivial because everything is in one class. But pretend it wasn't. If another developer/team wrote the method and gave it to you inside a jar file, it wouldn't be so easy to change the method insides.
 
Shannon Sims
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Yep, from a reusability, that makes sense.  Thank you!
 
Shannon Sims
Ranch Hand
Posts: 201
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I wasn't thinking in that manner...thought it would update the LocateDate object.
 
reply
    Bookmark Topic Watch Topic
  • New Topic