• 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
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

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
 
this llama doesn't want your drama, he just wants this tiny ad for his mama
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic