Saturday, June 1, 2013

Object design where hard-coded values are used to instantiate objects?

Object design where hard-coded values are used to instantiate objects?

I'm going to start creating a bookmark merging program and as I've planned out the design I've ran into a design problem that I've seen before yet I've never come up with a good solution. So lets say I have a Browser class:
Browser:
  String bookmarkFilePath
  String type
  Bool bookmarkFileExists()
When my program runs I will want to have hard-coded values of common browsers and the locations of their Bookmarks file:
Object with hard-coded values:
  "~/Library/Application Support/Google/Default/Bookmarks", "Chrome"
  "~/Library/Safari/Bookmarks.plist", "Safari"
Is there a design pattern or object type that could effectively take an object with hard-coded values (Browser name / bookmarks file path) and uses it to instantiate (and possibly manage) other (Browser) objects?
Also, flexibility is important since there are edge cases such as Firefox's file path to the bookmarks file is always different and some searching needs to be done.

No comments:

Post a Comment