New answers tagged

3

Major Issues The class access modifier does not allow public access, so your class is not usable by third party consumers. Make it public. Your class should be generic to be usable. You should always provide unit tests when providing a class to consumers of your API. Pop is ill-defined. It does not return anything. It can throw a NullReferenceException when ...


1

Guard Arguments put does not check for e == null. Are null values allowed? If not, add an argument guard if (e == null) throw new NullPointerException();. Naming Conventions Call your class BlockingStack to conform to Java naming guidelines concerning concurrent collections. max should be called capacity. A collection's capacity is its maximum size. As ...


19

Avoid using namespace std; - it's a large namespace, and growing as new C++ standards appear. Bringing all its names into the global namespace completely obviates the benefits of namespaces, and in the worst case, can silently change the meaning of a program. Get used to using the (very short) namespace prefix std::. When we call checkParentheses(), we ...


12

using namespace std; may seem fine for small projects, but can cause problems later so it's best to avoid it. Prefer to output "\n" instead of std::endl. std::endl will also flush the output stream, which is usually unnecessary. We should check that reading user input from std::cin didn't fail. We can do this by testing std::cin.fail() after reading the ...


Top 50 recent answers are included