[Monodevelop-devel] Text Editor API GetCharAt
Lluis Sanchez Gual
slluis.devel at gmail.com
Mon Jun 23 09:44:23 UTC 2014
>
> Hi
>
> I'm currently reviewing the text editor API. We've a method called:
>
> public char GetCharAt (int
> <
> span class="n" style="box-sizing: border-box; color: rgb(51, 51, 51);">offset)
>
> And atm I think about replacing it with :
>
> public char this[int offset]
>
> Maybe even add a setter to that - then the editor may feel a bit more like a string from a certain PoV.
> The question is: Is that a good or bad choice - how are you feeling about it ?
Bad. It makes the api harder to discover (no code completion) and harder to understand. Indexers should only be used for classes which are collections (and a text editor is not a collection, it just happens to contain a collection of chars, among many other things).
>
> The text editor has 3 layers: Text, Document and Editor - each layer adds something on top of the text. The GetCharAt is a functionality from the Text. On this level there is just text. I think the indexer makes sense there. But how about the upper layers? At Document level the editor becomes a collection of lines as well.
>
> I would love to hear some opinions. (About the speed: In this is a very lightweight operation - in our current Implementation it's done in O(1) in the worst case I can imagine that it becomes an O(log N) one).
>
> Regards
> Mike
>
>
> _______________________________________________
> Monodevelop-devel-list mailing list
> Monodevelop-devel-list at lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/monodevelop-devel-list
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.ximian.com/pipermail/monodevelop-devel-list/attachments/20140623/3d363a8e/attachment.html>
More information about the Monodevelop-devel-list
mailing list