• 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

Repetitive code in Chapter 12 of Head First Android Development, Second Edition

 
Greenhorn
Posts: 2
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
     I am in the middle of reading Chapter 12 the classes PizzaFragment,  PastaFragment, and StoresFragment (pages 486, 487, and 488) look almost identical.  The only difference is the String Array Resource (R.array.pizzas, R.array.pasta, and R.array.stores).  
     Could a more general class be used where a is String array is passed into the constructor?  Is that something that I a missing in the Android architecture that would prevent this? or was it just simpler to create three classes, when the objective of the section was to describe pagers?

Thanks,
 
Author
Posts: 143
15
Android Python Ruby
  • Likes 1
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hello Ted,

Good question The code is designed to be understandable, not to be efficient, so in a real application you would most certainly look for efficiencies and to remove duplication. But for the purposes of teaching, we will often leave duplications in place, if it leaves the code easier to understand.

D+D
reply
    Bookmark Topic Watch Topic
  • New Topic