r/learncpp • • Aug 07 '20

I implemented some Data Structures in C++

Not sure if this is the place for posting code, if it is not, I apologize.

I implemented some data structures in C++. I am somewhat new to C++ and started this project originally to get used to std::unique_ptr via a LinkedList implementation and then decided to add a few more data structures.

Note that I have yet to fix the postorder Traversal for the binary search tree.

I think that a lot of the iterators I wrote may be bad practice, which is why I would really appreciate some feedback / suggestions for this project.

https://github.com/PetrifiedPanda/DataStructures

7 Upvotes

13 comments sorted by

View all comments

Show parent comment

2

u/[deleted] Aug 18 '20

Also if you feel like adding unit test is just some nagging advice that you know you should really do then you really don't get them.

The secret to TDD is all in the name: Test Driven Design. It means you write tests first which then drives your design. These tests are really a proof of planning and forethought, which is always what I want to see if I am to use your API.

Retroactively adding tests is like retroactively planning something, which is why they are not very effective.

1

u/PetrifiedPanda Aug 18 '20

This actually made me reconsider some of my decisions in the project. I noticed that when I think about using a BST, I never really want to iterate through the whole tree, so I am now thinking about seriously rethinking, if not removing the Iterators for the Binary-Search Tree. (This might come from laziness though, because then I wouldn't need to fix them)