From 4669f1b04bfab6b3c8441597f34a5f62544d476a Mon Sep 17 00:00:00 2001
From: Beman
The best approach to endianness for a particular use case depends on interactions between -the approach characteristics and -the application needs.
+The best approach to endianness for a particular application depends on the interaction between +the application's needs and the characteristics of each of the three (conversion +functions, buffer types, or arithmetic types) approaches.
-Recommendation: If you are uncertain, new to endianness, concerned -about security, concerned about reliability, or don't want to invest time making -engineering trade-offs, use the endian arithmetic types. They are safer, easier -to use, and your code will be easier to maintain.
+Recommendation: If you are new to endianness, uncertain, or don't want to invest +the time to +study +engineering trade-offs, use endian arithmetic types. They are safe, easy +to use, and easy to maintain. Use the + +anticipating need design pattern locally around performance hot spots like lengthy loops, +if needed.
Applications often traffic in endian data as records or packets containing +multiple endian data elements. For simplicity, we will just call them records.
+ +If desired endianness differs from native endianness, a conversion has to be +performed. When should that conversion occur? Three design patterns have +evolved.
+ +This pattern defers conversion to the point in the code where the data +element is actually used.
+ +This pattern is appropriate when which endian element is actually used varies +greatly according to record content or other circumstances
+ +This pattern performs conversion to native endianness in anticipation of use, +such as immediately after reading records. If needed, conversion to the output +endianness is performed after all possible needs have passed, such as just +before writing records.
+ +One implementation of this pattern is to create a proxy record with +endianness converted to native in a read function, and expose only that proxy to +the rest of the implementation. If a write function, if needed, handles the +conversion from native to the desired output endianness.
+ +This pattern is appropriate when all endian elements in a record are +typically used regardless of record content or other circumstances
+ +This pattern in general defers conversion but does +anticipatory conversion for specific local needs.
+ +This pattern is particularly appropriate when coupled with the endian buffer +or arithmetic types.
+Last revised: -17 December, 2014
+31 December, 2014© Copyright Beman Dawes, 2011, 2013
Distributed under the Boost Software License, Version 1.0. See www.boost.org/ LICENSE_1_0.txt