Hi folks,
this question is an extension to a previous question i asked (and was answered). I'm refactoring my code an playing around with / experimenting with various refactored solutions.
One of the solutions i came up with (but wasn't happy with .. remember, i'm just experimenting with some personal coding styles) wsa the following code :-
if (data is ITagElement)
{
if (((ITagElement) data).TagList.IsNullOrEmpty())
{
((ITagElement) data).TagList = new List<Tag>();
}
((ITagElement) data).TagList.Add(new Tag
{
K = xmlReader.GetAttribute("k"),
V = xmlReader.GetAttribute("v")
});
}
Notice how i'm casting the parent object data
to the interface type it impliments a number of times? Code works, but i feel like this is code smell -> that it's not very efficient. I feel like this could be cast improved upon - thoughts from any guru's out there?