Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update member variable names to avoid shadowing #102

Merged
merged 29 commits into from
Sep 20, 2024
Merged

Conversation

oruebel
Copy link
Contributor

@oruebel oruebel commented Sep 19, 2024

Fix #60
Fix #9
Fix #106

  • Container
  • Data
  • NWBFile
  • RecordingContainers
  • Channel
  • VectorData
  • ElementIdentifiers (noop)
  • HDF5RecordingData
  • HDF5IO
  • BaseIO
  • DynamicTable

To be fixed in read I/O PR #85

  • ElectrodeTable
  • ElectrodeGroup
  • SpikeEventSeries
  • ElectricalSeries
  • Device
  • TimeSeries (already fixed in Add data read #85)

@oruebel oruebel marked this pull request as ready for review September 19, 2024 20:53
@oruebel
Copy link
Contributor Author

oruebel commented Sep 19, 2024

@stephprince This is a first pass at fixing the naming conventions for member variables to avoid shadowing of names. For the main NWB data types, I propose that I fix those on the read PR #85 since I'll need to modify those members for read anyways and modifying them here as well will only lead to tons of merge conflicts.

@stephprince
Copy link
Collaborator

stephprince commented Sep 19, 2024

I propose that I fix those on the read PR #85 since I'll need to modify those members for read anyways

Sounds good.

As I'm looking through I had a question. I thought m_ was supposed to replace this-> but in some places both are being used. I wasn't sure if there is a reason to use both of them?

Copy link
Collaborator

@stephprince stephprince left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added a couple comments/questions! Mainly suggestions to use m_ instead of both this-> and m_ since I think they are redundant? If there is a reason to use both feel free to ignore those.

src/nwb/ecephys/SpikeEventSeries.hpp Outdated Show resolved Hide resolved
src/nwb/device/Device.cpp Outdated Show resolved Hide resolved
src/nwb/base/TimeSeries.cpp Outdated Show resolved Hide resolved
src/BaseIO.cpp Outdated Show resolved Hide resolved
src/Channel.hpp Outdated Show resolved Hide resolved
src/nwb/NWBFile.cpp Outdated Show resolved Hide resolved
src/nwb/hdmf/table/DynamicTable.cpp Outdated Show resolved Hide resolved
src/nwb/hdmf/table/DynamicTable.cpp Outdated Show resolved Hide resolved
src/nwb/hdmf/table/DynamicTable.cpp Outdated Show resolved Hide resolved
src/nwb/hdmf/table/DynamicTable.cpp Outdated Show resolved Hide resolved
@oruebel
Copy link
Contributor Author

oruebel commented Sep 19, 2024

Mainly suggestions to use m_ instead of both this-> and m_ since I think they are redundant? If there is a reason to use both feel free to ignore those.

In this case, yes, this->m_ and m_ access the same variable. this is a pointer to the current object of the class so it makes it clear that we are using the object and m_ makes it clear that it is a class member variable. We can just use m_ in most places. I've fixed this in ad7aea4 to replace this->m_ with just m_ throughout.

src/Channel.hpp Outdated Show resolved Hide resolved
src/Channel.hpp Outdated Show resolved Hide resolved
stephprince
stephprince previously approved these changes Sep 20, 2024
@oruebel
Copy link
Contributor Author

oruebel commented Sep 20, 2024

@stephprince can you please re-review. I moved some of the simple setter functions.

stephprince
stephprince previously approved these changes Sep 20, 2024
Copy link
Collaborator

@stephprince stephprince left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks good to me!

@oruebel
Copy link
Contributor Author

oruebel commented Sep 20, 2024

@stephprince is it expected that the validate tests are failing or is this new in this PR. Just wanted to check if this is something I need to fix here or whether this is something for a separate PR.

@oruebel
Copy link
Contributor Author

oruebel commented Sep 20, 2024

Ok, comparing the test files generated by the main branch and this branch it looks like something broke with writing the colnames for DynamicTable and/or ElectrodeTable

@oruebel
Copy link
Contributor Author

oruebel commented Sep 20, 2024

@stephprince can you re-review. All tests are passing now.

Turns out, the issue with the invalid colnames in the created NWB files was due to #106 . I had missed that ElectrodeTable defined its own ElectordeTable.colNames which was hiding the inherited member DynamicTable.colNames and because I had only renamed one of them, it was using the empty colNames from DynamicTable instead of from ElectrodeTable.

@stephprince
Copy link
Collaborator

ah ok. So from what I understand, #106 is resolved but is a behavior to keep an eye out for in the future

@oruebel
Copy link
Contributor Author

oruebel commented Sep 20, 2024

So from what I understand, #106 is resolved but is a behavior to keep an eye out for in the future

Correct. At least I hope I caught all the places where this is happening.

@oruebel oruebel merged commit 33e3481 into main Sep 20, 2024
8 checks passed
@oruebel oruebel deleted the resolve_shadowing branch September 20, 2024 17:18
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Hiden inherited member Shadowing of variables Adopt naming convention for member variables
2 participants