[CSHARP-1112] Simplify IByteBuffer interface Created: 20/Nov/14 Updated: 06/Apr/15 Resolved: 09/Mar/15 |
|
| Status: | Closed |
| Project: | C# Driver |
| Component/s: | BSON |
| Affects Version/s: | None |
| Fix Version/s: | 2.0 |
| Type: | Improvement | Priority: | Major - P3 |
| Reporter: | Robert Stam | Assignee: | Robert Stam |
| Resolution: | Done | Votes: | 0 |
| Labels: | None | ||
| Remaining Estimate: | Not Specified | ||
| Time Spent: | Not Specified | ||
| Original Estimate: | Not Specified | ||
| Description |
|
The IByteBuffer interface represents a logical byte buffer that might be backed by various means (contiguous, segmented, using buffers from a pool or not, etc...). But the IByteBuffer interface probably has too many methods. Many of the methods could be moved out to extension methods on the interface (so they only need to be implemented once). A new streamlined interface that deals only with the buffer abstraction could look like this:
This reduces the responsibility of this interface to a single responsibility, namely to represent a (possibly) segmented variable length byte array. |
| Comments |
| Comment by Robert Stam [ 06/Apr/15 ] | ||||||||||||||||
|
In the end the IByteBuffer interface ended up having a few more members that the super streamlined version suggested in the description.
The reason was efficiency. While several of these additional methods could have been implemented in terms of AccessBackingBytes, they can in fact be more efficiently implemented inside the classes that implement the IByteBuffer interface. | ||||||||||||||||
| Comment by Githook User [ 09/Mar/15 ] | ||||||||||||||||
|
Author: {u'username': u'rstam', u'name': u'rstam', u'email': u'robert@robertstam.org'}Message: |