• 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
  • Tim Cooke
  • Devaka Cooray
  • Ron McLeod
  • Jeanne Boyarsky
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Junilu Lacar
Saloon Keepers:
  • Tim Moores
  • Stephan van Hulst
  • Piet Souris
  • Carey Brown
  • Tim Holloway
Bartenders:
  • Martijn Verburg
  • Frits Walraven
  • Himai Minh

program structuring

 
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I have a task to parse a webpage. the webpage is static (the address URL won't change) and it has list of goods (the name, picture, URL to the manufacturer of the goods, price, etc). right now I have main class and Goods class. the questions are:
1. where to put the piece of code that parses the webpage and store it as Goods?
2. do I need interface or abstract class? or just put it in util class with those static methods?
 
Ranch Hand
Posts: 86
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator

Hendra Kurniawan wrote:1. where to put the piece of code that parses the webpage and store it as Goods?
2. do I need interface or abstract class? or just put it in util class with those static methods?


If no other code (written by other people) needs to implement the method(s) just make it static or just protected in a util class. Otherwise an interface would be a nice touch.

Likewise for abstract classes: If you don't have other code that needs to "be" that class via subclassing then what is the point? It seems like overkill.

Simpler should be better to handle a simple case. Did your intuition tell you that already?
 
Hendra Kurniawan
Ranch Hand
Posts: 239
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I googled around and found some suggestions to use singletons instead of static classes. Is this the right move for most cases? thanks
 
I've read about this kind of thing at the checkout counter. That's where I met this tiny ad:
the value of filler advertising in 2021
https://coderanch.com/t/730886/filler-advertising
reply
    Bookmark Topic Watch Topic
  • New Topic