The stupid question is the question not asked | |
PerlMonks |
Hmm...by SpanishInquisition (Pilgrim) |
on Sep 21, 2004 at 16:58 UTC ( [id://392713]=note: print w/replies, xml ) | Need Help?? |
Deeply chained ifs are ugly in ANY coding style. One point may OOP advocates miss is that inheritance and polymorphism are often just drawing out a simple if or for loop or whatever and obscuring it exists. Often, this makes it worse and designs can be 5x longer in LOC and actually less readable (ever heard the phrase "Java is readable -- like a phonebook?").
What we have is a simple coding error that could have been tamed in other styles as well, such as adding a function to check for tags of certain types. In fact, the thought to make that a function would have been more readily obvious in a functional paradigm, at least I think so (i.e. short functions that build on other functions so everything works like magic). Liberal use of objects can be a good thing, but using polymorphism or inheritance to defeat an if statement is suicide. Beer is good in small amounts. Objects are good in small amounts. Know your limitations. <quote> This section has presented numerous rules for staying out of trouble with inheritance. The underlying message of all these rules is that inheritance tends to work against the primary technical imperative you have as a programmer, which is to manage complexity. For the sake of controlling complexity, you should maintain a heavy bias against inheritance. </quote> 100% Agreed! Thank you people for backing me up! I'd print this out and put it on my cube wall, though everyone here at Innotech would stone me for those beliefs. I'm already a black sheep though... (baaa!)
In Section
Meditations
|
|