Here is the logic: The server prepares the file (like index.html, or some.pdf) that it is going to send through HTTP response. Based on the suffix I wanna set the Content-type in HTTP header.
The logic now is I have Class Filetype, with lots of specific filetype subclasses extending it. But still I need to use "switch" to identify the suffix. Something like:
Filetype f = null;
if(suffix == "pdf"){
f = Filetype_pdf(source);
} else if (suffix == "html") {
f = Filetype_text(source);
}
But I use inheritance just to avoid these "if"s. Any advice to this issue or is this the way it should be? Thanks.