Blocks.hpp - Tech debt and potential maintainability issues #375
Labels
quality improvements
This item indicates the need for or supplies changes that improve maintainability
Milestone
I've noticed a potential source of future errors in regards to maintanence by future developers. When calculating the static property
size
insend_block
,receive_block
,open_block
, andchange_block
, you seem to be calculating the size by summing the size of properties within the block's respectivehashables
in addition towork
andsignature
properties:Aside from the fact that how
size
is computed isn't entirely clear, it's computation is prone to developer error if a developer doesn't make the connection thathashables
size is taken into account. An easy fix for this would be...The only other issues I can see is that this
size
property is repeated throughout the differentblock
child classes which gives the impression that it is required. I would try to take advantage of polymorphism and pure-virtual methods (or just plain virtual if you have a reasonable default method for computing size) to remedy this and keep guidelines clear.I would shy away from using the
sizeof
operator on types rather than properties if you can help it; however, for some things like figuring out how many bytes we need for memory allocation then it's OK. This is related to my earlier argument that it doesn't make it very clear howsize
is computed (e.g.sizeof (uint64_t)
vssizeof (work)
-- the former will have developers asking, "Why issizeof (uint64_t)
important when calculatingsize
?").The text was updated successfully, but these errors were encountered: