How much work is it reasonable for an object constructor to do? Should it simply initialize fields and not actually perform any operations on data, or is it okay to have it
Why not just pass the parser to the constructor? This would allow you to change the implementation without changing the model:
public interface IParser
{
Dictionary ParseDocument(string document);
}
public class HtmlParser : IParser
{
// Properties, etc...
public Dictionary ParseDocument(string document){
//Do what you need to, return the collection of properties
return someDictionaryOfHtmlObjects;
}
}
public class HtmlScrapper
{
// Properties, etc...
public HtmlScrapper(IParser parser, string HtmlDocument){
//Set your properties
}
public void ParseDocument(){
this.myDictionaryOfHtmlObjects =
parser.ParseDocument(this.htmlDocument);
}
}
This should give you some flexibility in changing/improving how your application performs without needing to rewrite this class.