Skip to main content
typo
Source Link
Steven A. Lowe
  • 33.8k
  • 2
  • 86
  • 151

caveat: any design suggestions are based on what i thought you wrote, and a bag of unfounded assumptions. Code something that works, and refactor it until a 'good' model emerges - you'll end up doing that regardless of where you start, toso pick something that makes sense on paper or in your mind, and start with that.

caveats aside, it sounds like you have the following classes:

  • Ad
  • Website
  • Event
  • Scanner

The Scanner scans a list of web sites, looking for ads and events. The extraction regex/logic is specific to a particular web site (thus eliminating your switch statement), but if extraction is always a regex then you can pull that from a database table to instantiate web site objects as needed (or just pull the regex from a db or in-memory table).

in other words, soft-code the web site regexes if possible, so you don't have to have a subclass for each web site

don't worry about efficiency until it works and you're happy with the underlying model, then use a profiler to see where the implementation needs to be tweaked, if at all

i suspect that a 'good' model will also naturally be efficient

good luck!

caveat: any design suggestions are based on what i thought you wrote, and a bag of unfounded assumptions. Code something that works, and refactor it until a 'good' model emerges - you'll end up doing that regardless of where you start, to pick something that makes sense on paper or in your mind, and start with that.

caveats aside, it sounds like you have the following classes:

  • Ad
  • Website
  • Event
  • Scanner

The Scanner scans a list of web sites, looking for ads and events. The extraction regex/logic is specific to a particular web site (thus eliminating your switch statement), but if extraction is always a regex then you can pull that from a database table to instantiate web site objects as needed (or just pull the regex from a db or in-memory table).

in other words, soft-code the web site regexes if possible, so you don't have to have a subclass for each web site

don't worry about efficiency until it works and you're happy with the underlying model, then use a profiler to see where the implementation needs to be tweaked, if at all

i suspect that a 'good' model will also naturally be efficient

good luck!

caveat: any design suggestions are based on what i thought you wrote, and a bag of unfounded assumptions. Code something that works, and refactor it until a 'good' model emerges - you'll end up doing that regardless of where you start, so pick something that makes sense on paper or in your mind, and start with that.

caveats aside, it sounds like you have the following classes:

  • Ad
  • Website
  • Event
  • Scanner

The Scanner scans a list of web sites, looking for ads and events. The extraction regex/logic is specific to a particular web site (thus eliminating your switch statement), but if extraction is always a regex then you can pull that from a database table to instantiate web site objects as needed (or just pull the regex from a db or in-memory table).

in other words, soft-code the web site regexes if possible, so you don't have to have a subclass for each web site

don't worry about efficiency until it works and you're happy with the underlying model, then use a profiler to see where the implementation needs to be tweaked, if at all

i suspect that a 'good' model will also naturally be efficient

good luck!

Source Link
Steven A. Lowe
  • 33.8k
  • 2
  • 86
  • 151

caveat: any design suggestions are based on what i thought you wrote, and a bag of unfounded assumptions. Code something that works, and refactor it until a 'good' model emerges - you'll end up doing that regardless of where you start, to pick something that makes sense on paper or in your mind, and start with that.

caveats aside, it sounds like you have the following classes:

  • Ad
  • Website
  • Event
  • Scanner

The Scanner scans a list of web sites, looking for ads and events. The extraction regex/logic is specific to a particular web site (thus eliminating your switch statement), but if extraction is always a regex then you can pull that from a database table to instantiate web site objects as needed (or just pull the regex from a db or in-memory table).

in other words, soft-code the web site regexes if possible, so you don't have to have a subclass for each web site

don't worry about efficiency until it works and you're happy with the underlying model, then use a profiler to see where the implementation needs to be tweaked, if at all

i suspect that a 'good' model will also naturally be efficient

good luck!