Developers.Refactor
Refactoring CNeighbour and CNeighbours
write data classes CHost holds an IP address and port number CTick holds a tick count CBSTR wraps a BSTR string for COM calls
edit exising classes CBuffer move unrelated stuff out of it, and eliminate code duplication CZLib rename to CCompress and add stream compression
write function libraries Text searches and encodes text Memory has functions like swap
write feature classes CUPnP has Windows talk UPnP with a NAT router CWindowsFirewall edits the settings of Windows Firewall
CConnection contains
- the socket
- CMeter bandwidth meters for send and receive
- CCompress stream compression objects for send and receive
CPeer contains
- a CConnection object that can transfer, compress, and meter data to the remote computer
- member variables common to all networks
- a pointer to a CGnutella, CGnutella2, or CDonkey object, depending on what network we're on
CPeerList contains the collection class of CPeer objects all network specific code is moved to CGnutella, CGnutella2, or CDonkey
rename CNeighbour to CPeer rename CNeighbours to CPeerList rename CHanshakes to CListen rename CShakeNeighbour to CHandshake and move all the handshake code inside it
names and inheritance before and after before: CConnection inherited by CNeighbour inherited by CG1Neighbour after: CConnection is a member of CPeer which is inherited by CGnutellaPeer
a CPeer object points to a CConnection object that can compress data through a socket it also points to a CHandshake object that can decode and keep records of handshake headers neither of these objects inherit from a class with the socket - CPeer is at the center
ooh - it could also point to a CGnutella, CGnutella2, or CDonkey object to get member variables and methods useful and specific to the appropriate network all inheritance would be replaced by encapsulation this way you could test whether a peer is connected to a network by seeing if the appropriate pointer is non-null
collapse the CNeighbours inheritance column into a single class, CPeerList and move functionality related to each network out of it
don't have plural class names that are one letter away from singular class names instead of CThing and CThings, have CThing and CThingList so that they are easier to tell apart