I disagree that a property should imply O(1), this is an implementation detail that might change. For example an array based collection will almost always have a count property that is O(1), but a liked-list based collection will almost always be O(N).<br><br>On Friday, 29 January 2016, Michael Wells <<a href="mailto:michael@michaelwells.com">michael@michaelwells.com</a>> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex"><div style="word-wrap:break-word"><br><div><blockquote type="cite"><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
>> > ,----[ Side Note, since you mentioned efficiency ]<br>
>> > | I originally wanted to uphold the principle that, “if it isn't O(1),<br>
>> you<br>
>> > | don't make it a property.” The implication is that on collections,<br>
>> > | “count” would be a method. That would include Array, for which<br>
>> counting<br>
>> > | the elements *is* O(1). Some people argued that:<br>
>> > |<br>
>> > | 1. The idea of writing “a.count()” instead of “a.count” to count the<br>
>> > | elements of an Array was absurd.<br>
>> > | 2. Programmers don't draw conclusions about efficiency based on whether<br>
>> > | something is a property.<br>
>> > | 3. The fact that Array would have an O(1) non-property that *could*<br>
>> have<br>
>> > | been a property (if it weren't for CollectionType conformance)<br>
>> > | undermines any communicative power that you might get from using<br>
>> this<br>
>> > | distinction to choose properties.<br>
>> > |<br>
>> > | I did not win that argument :-)<br></blockquote></blockquote></div><br><div>I strongly agree that properties imply O(1) and most programmers I’ve ever worked with make the same assumptions. Even if the documentation says otherwise, code like</div><div><br></div><div><font face="Menlo">fibonacciNumbers.count</font></div><div><br></div><div>looks as if you’re accessing a c-style field ‘count’ and that implies (at least to me) that it is a near-costless operation. Some of the biggest design mistakes I’ve ever seen use properties that trigger time-consuming operations like database or network access. </div><div><br></div><div>And I don’t think having to use <font face="Menlo">a.count()</font> is absurd. :-)</div><div><br></div><div><br></div><div><br></div><div><br></div><div><br></div></div></blockquote><br><br>-- <br> -- Howard.<br><br>