eliminate IErlElement.getKind()
First: using this is the same ass using the object's class and instanceof.
Second: when replacing getkind() with classes and instanceof it is immediately obvious that the code is not OOP anymore. Having an if or case/switch on instanceof conditions is much better handled by using the class hierarchy and virtual methods. It's clearer, cleaner and simpler.
Second: when replacing getkind() with classes and instanceof it is immediately obvious that the code is not OOP anymore. Having an if or case/switch on instanceof conditions is much better handled by using the class hierarchy and virtual methods. It's clearer, cleaner and simpler.
Leave a comment
on 2011-04-15 14:43 *
By Vlad Dumitrescu
Do you agree that for example
x.getKind()==Kind.CLAUSE
is exactly the same as
x instanceof IErlFunctionClause
?
And
f(x.getKind())
is the same as
f(IErlFunctionClause.class)
?
Also, do you agree that using instanceof as a discriminator function in if or switch is not OOP? It is something you'd do in C.
x.getKind()==Kind.CLAUSE
is exactly the same as
x instanceof IErlFunctionClause
?
And
f(x.getKind())
is the same as
f(IErlFunctionClause.class)
?
Also, do you agree that using instanceof as a discriminator function in if or switch is not OOP? It is something you'd do in C.
One example is the org.erlide.ui.editors.erl.outline.ErlangElementImageProvider.getImageDescriptionFromKind(Kind) function. It does a switch on getKind, and you don't want a parallell class structure for the imagedescriptors. There are many others, IErlElement.visit, IErlModule.getPreprocessorDef, etc.
on 2011-04-29 04:52 *
By Vlad Dumitrescu
I can't find any place where using getKind can't be replaced with instanceof or getClass. The latter is slightly more verbose, true.
I still believe that it's easier to introduce a bug with getKind (for example by forgetting to update one of the many places where a new value has to be added), but it might be a subjective opinion.
We don't need to do anything about this now.
I still believe that it's easier to introduce a bug with getKind (for example by forgetting to update one of the many places where a new value has to be added), but it might be a subjective opinion.
We don't need to do anything about this now.
on 2011-08-24 05:18 *
By Vlad Dumitrescu
Updating tickets (#802, #52, #64, #460, #720, #749, #769, #775, #776, #786, #851, #83, #93, #149, #157, #163, #179, #194, #195, #222, #228, #274, #281, #283, #285, #335, #339, #349, #351, #358, #364, #373, #375, #379, #383, #401, #405, #409, #411, #413, #422, #424, #425, #428, #434, #442, #443, #449, #450, #454, #471, #479, #492, #523, #535, #537, #543, #561, #564, #574, #590, #598, #599, #603, #610, #615, #619, #632, #634, #636, #639, #640, #641, #642, #643, #645, #658, #660, #662, #664, #665, #674, #677, #684, #685, #688, #689, #693, #694, #695, #696, #699, #700, #707, #709, #719, #736, #743, #744, #746, #748, #759, #760, #761, #762, #774, #778, #780, #788, #789, #796, #798, #799, #800, #803, #809, #812, #813, #816, #820, #822, #829, #836, #837, #840, #841, #842, #848, #849, #850, #853, #854, #855, #856, #857, #860, #867, #868, #871, #872, #873, #875, #41, #159, #372, #429, #489, #577, #601, #622, #667, #679, #767, #768, #772, #785, #771)
on 2011-09-27 07:11 *
By Vlad Dumitrescu
Component changed from None to code model
Component changed from None to code model
on 2012-06-01 08:22 *
By Vlad Dumitrescu
Milestone changed from backlog to deprecated because of xtext version
Milestone changed from backlog to deprecated because of xtext version
Updating tickets (#156, #747, #805, #806, #972, #194, #274, #335, #339, #375, #603, #610, #641, #642, #664, #665, #684, #743, #744, #759, #760, #762, #796, #800, #809, #820, #853, #856, #857, #884, #893, #900, #902, #916, #917, #953, #969, #990, #1002, #1003, #1004, #1011, #1012, #1044, #40, #119, #121, #129, #130, #145, #160, #244, #264, #265, #387, #392, #433, #454, #459, #463, #479, #508, #524, #529, #536, #589)
on 2013-01-09 05:21 *
By Vlad Dumitrescu
Milestone changed from deprecated because of xtext version to backlog
Milestone changed from deprecated because of xtext version to backlog
on 2013-01-22 09:39 *
By Vlad Dumitrescu
Category changed from Bug to Internal
Found in version changed from 0.11.0 to -none-
Category changed from Bug to Internal
Found in version changed from 0.11.0 to -none-
on 2013-01-23 02:46 *
By Vlad Dumitrescu
Estimate changed from None to Medium
Sum of child estimates changed from 0.0 to 3.0
Estimate changed from None to Medium
Sum of child estimates changed from 0.0 to 3.0
on 2013-05-22 08:33 *
By Vlad Dumitrescu
Status changed from New to Invalid
Status changed from New to Invalid