Skip to content

Giving the library the final polish #35

@BrainStone

Description

@BrainStone

I think you might have noticed by now that I really like your library.

And at this point I'd like to give something back to you.
Now I have some decent experience designing libraries and software in general and I have a few suggestions (that I'm all willing to implement myself):

  • Use inheritance for the specializations:
    This is a fun one! Now I like that you separated the package code into its own class. That's good design. However there is one (fairly) big flaw with how you're doing it right now: The classes don't have anything to do with eachother.
    So my suggestion is to make use of inheritance. You have the abstract Packet class (maybe it should be renamed?) that has the pure virtual functions readAvailable (how many bytes are available to read or maybe a plain boolean function is enough), readByte (reads the next available byte), writeBytes (writes the bytes) and printDebug (which prints the debug message (may be just virtual with a default implementation that does nothing)).
    This allows the library to be extended easily to any other hardware platform and the base class can be made without any external dependencies so it can be used for the Linux/Windows variant of the library.
  • Make the CRC library compile time constant.
    That means making sure that the library doesn't need any RAM and that everything is written in the ROM (constexpr magic at play here ;) ). Now with a preprocessor flag I could toggle between a ROM lookup, RAM lookup or live calculation.
    And lastly let's abandon using class instances for this. My suggestion would be to use only static members in a class. If you really want the size and polynomial to be configurable that can be achieved with templates.

Now if you aprove of these suggestions I'll get on to implementing them.

Metadata

Metadata

Assignees

Labels

enhancementNew feature or request

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions