-
Notifications
You must be signed in to change notification settings - Fork 8
Conversation
Requesting review from all - feel free to drop in comments on this over the next week (this is optional). Otherwise we will go over it at the meeting next weekend :) |
Realized #159 needs to be dealt with - going to do some research on this to rethink our current namespaces. |
Namespaces - thoughts
Our current namespaces are as follows:
In my mind (not considering our current directory structure), we have 6 main areas where code has different purposes:
interface, mock, and hardwareSince interface, mock, and hardware go hand in hand, and correspond directly with some already-known Here's what it'd look like:
app and componentSince we are in control of the content in app and components (as in not built to correspond with another library), the namespacing choices are more freeform. I like how we already group things into "suites" of code like dsp, imu, uart etc. which helps indicate what each class's purpose is. For app and component code, I lean towards continuing as we have been. This means the following namespaces:
An example:
We could add another namespace "comm" or "cmd" to encapsulate the rx/tx helpers in app, and the future protocol buffer components. If some new class doesn't relate to the other classes in component, we can give it its own new namespace. I'd only see naming conflicts happening with the classes that are more closely-tied to libraries e.g. the UartDriver and UdpDriver, if e.g. we needed another generic UartDriver based on a library that isn't HAL. However I think that's unlikely, and we can always create sub-namespaces e.g. uart::hal and uart::$other_library. Also, we should also consider a master namespace for all our code which we don't intend to be a public API e.g. "utra_robot". We don't need this now though so maybe think about it further down the road. testTest would continue to have anonymous namespaces. Thoughts? |
Good point, I like this.
Since the mock is associated with the abstract interface
Yeah a master namespace is a good idea. We are developing 2 things at the same time: (1) libraries, interfaces, and infrastructure which are (ideally) components that can be reused across various embedded systems projects; and (2) application code for our robot. Perhaps all of our code could be in the namespace Looking at our current namespace list, I see the following 3 namespaces which seem like they could probably be refactored:
(The lowercase part is consistent with what we already have and I don't see any problem with it) Also, I shared this book in the group chat a while ago (code examples here) and one thing that caught my eye looking at it again just now is the |
What I was meaning here, is that The example I was concerned about in particular was say if the LwIP Sockets API was used for one component, and the FreeRTOS Sockets API for another. In our current way, we'd have a To ensure no collision in the above situation, I'd have two files like
That's where namespaces would come in to tidy these up:
Which would eliminate collisions between libraries happening. Of course we're probably never going to have to use a different API for UART other than HAL, but I still think namespacing We could do something like with |
Agreed that these should be refactored, but disagree on how they are refactored for the reasons I mentioned. The way I'd refactor them would be:
|
Agreed, I like splitting the application code that way.
I like the idea of a util file and namespace, that'd help avoid duplicating code. Also interesting to note the comms and protocol namespace setup here: https://github.com/arobenko/embxx/blob/master/embxx/comms/protocol/MsgDataLayer.h#L36. |
Whew, sorry for the slew of text, not meaning to bikeshed too much on this. We can maybe discuss some of these points today's meeting and the next meeting too. |
} | ||
``` | ||
|
||
5. (**C only**) Function names should be preceded by the name of the module they are associated with followed by an underscore. Example: `Dynamixel_getVoltage` is a function from the Dynamixel module that gets the voltage of an actuator. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
another proposition from @Shah-Rajab - include a specifier for the type in the variable/function name, this makes it easy when reading/grepping large codebases
note on namespaces: we will try to automate generation of a |
88424d9
to
05b6bba
Compare
05b6bba
to
3d3ae5f
Compare
^ updated after review meeting today - see latest commits. Ready to pull in once approved |
Will merge this around 8pm this evening if no objections |
This takes from the style guide in our wiki [0], and adds a few things (mostly based on reading the Google C++ style guide). The added parts are marked with PROPOSED throughout this draft.
It turns out this draft of the guide is still quite lengthy, feel free to shorten it where possible or suggest taking out sections which might be too verbose. On the other hand, if there's anything missing, feel free to add it.
Also updated the template with a proposed change of a space between the different groups of includes (see the "Include ordering" section in this doc).
Some sections in Google's style guide that may be applicable to us and worth a read, but I didn't think need to be covered in our guide: [1]
These are the parts that are essentially ripped out of the style guide, I'm thinking we could have these in a tutorial doc in the wiki, on asynchronous programming and I/O.: [2]
Closes: #158