13
\$\begingroup\$

When answering questions, the asker of the question from time to time either explicitly or implicitly adds some constraints to the question.

Common constraints are:

  • We are bound to Java version x.
  • We are not allowed to use any high level language feature.

I think those constraints are fine as they can be explained with good arguments, whether you and I agree or not is not relevant, it matters that the relevant people agree on them, like a manager or a teacher.

I have just come across an interesting case though: Karatsuba C++ implementation

Here the OP is implicitly using C++ more like C than like C++, and even further down in the his comment he explains that he likes it more this way.

So I think that the question boils down to: Should we follow OP's preferences (disguised as requirements) if there are no other stakeholders in play?

Where stakeholders are defined as a manager or as a teacher.

I have the feeling that with this particular question, we should suggest that he uses the C++ features if he is coding in C++, whether he likes it or not, it is best practice, even though the OP on the other hand said that he did not want to use those features, without giving a good reason.

\$\endgroup\$
  • 1
    \$\begingroup\$ My opinion on this is that we should respect constraints, but that does not mean we shouldn't point out what is possible without those constraints. Sometimes constraints can be removed if there is a compelling enough argument. \$\endgroup\$ – RubberDuck Oct 8 '14 at 16:35
11
\$\begingroup\$

One of our Help Center rules, and indeed, one of our core values, is

Do I want the code to be good code?

To that end, any answer that makes the code "better" is fair game. It's just that this OP has declared some preconceived ideas of what is "better", so you would have to work extra hard to convince them to abandon the self-imposed constraints. Then it would be up to the community to judge whether your counterproposal makes good sense. (Don't be surprised if the OP chooses not to accept your answer, though.)

I've even written answers in which I've proposed switching to a different RDBMS for technical reasons. If you genuinely feel that the code would benefit greatly, state your case in your answer.

\$\endgroup\$
8
\$\begingroup\$

The review is not necessarily just for the OP.

People read these questions/comments to improve their code. So to limit your review just for the OP is doing a disservice to subsequent viewers (this is a learning site).

So in my personal opinion I disregard constraints and tell people the best way to do things. I may expand on this and add a best way to do it given the constraints as well if that is appropriate.

Here the OP is implicitly using C++ more like C than like C++, and even further down in the his comment he explains that he likes it more this way.

That probably just means he is more experienced with one tool set as compared to the other and thus understandably has a preference for using features that he understands better. But this just means he really does need it explained how to do it properly (and to limit it for subsequent reviewers would be to lead them in the wrong direction just because the OP has a bias).

In this case mixing two completely distinct languages is a recipe for disaster and should explicitly be called out as a problem. In my opinion he can go either way. It should be all C or all C++ mixing the languages just makes the chances for a problem higher. In this casn the use of C-Strings and new/delete will make maintenance a real issue as things may seem to work for a long time after a real problem occurs.

\$\endgroup\$

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .