Marlysson / Algoritmos-Redes

Implementação dos algoritmos de Hamming e CRC na camadas de correção/detecção de erros
2 stars 0 forks source link

Opinion - How method change_bit(position) works.. #3

Open Marlysson opened 8 years ago

Marlysson commented 8 years ago

Verificate whether the method change_bit(position) just operate over a instance of Frame just change bit

frame = Frame("001")
frame.change_bit(2)
>>> frame
Frame("011")

Or make your operation and return a new instance of Frame ( immutable objects )

frame = Frame("001")
changed = frame.change_bit(2)
>>> changed
Frame("011")
mazulo commented 8 years ago

If the Frame's representation works through a string, maybe it's a good idea return a new instance. That's the default operation in immutable objects anyway.