Developers.Refactor.Buffer
Buffer Design
Names
From Central Class to Simple Type
While the design of CBuffer is technically correct according to Hungarian Notation, names like m_pBuffer and m_nBuffer look very similar and don't provide obvious clues as to what they are. Here are some alternate names for the class, member variables, and member functions:
buffer b;
b.p is the pointer to memory b.n is the number of bytes written there b.size is the size of the allocated block
b.end() points to where you can start writing b.available() is the amount of space there
b.prepare(5) tells it we're going to write in 5 bytes ourselves b.wrote(3) tells it we actually only wrote in 3 bytes
current design - strong central CBuffer refactored design - small simple buffer so you can use it everywhere, without the whole program becoming a part of this class