3 ms·
Most senior software engineers with over a decade of experience never implement bool isNumber(const char *) for positive/negative integers and decimals. It is
by NumberSix 10y ago
Most senior software engineers with over a decade of experience never implement bool isNumber(const char *) for positive/negative integers and decimals. It is rare to need this and, if you do, either use a library or find it on Stack Overflow, in a book, or some other source. Implementing it is unnecessarily reinventing the wheel. One thing senior software engineers learn or should learn is not to reinvent the wheel.
This is one of the problems with these types of questions, including the CS 101 type questions that often make up purported coding tests during hiring. In most cases, they do not test what practicing software engineers actually do.
- hcho 10y agoThe point of the question is to see if a candidate can glue a loop,an if statement and a bit of arithmetic together, on the spot. Failing to come up with an answer to such a question is generally symptomatic of lack of problem solving skills.
- raverbashing 10y agoI disagree. If you can't code IsNumber at least for plain integers you shouldn't be touching code. Then work up to negative/decimal Yes, for a lot of problems you should go for stack overflow or a book. But this is a simple problem. SO won't have the solutions to all of your problems
- NumberSix 10y agoAs another commenter noted, for negative/decimal it is not so simple. That is why a highly experienced software engineer would look for an existing, fully debugged implementation rather than spend substantial time making sure all the corner cases are handled. In the context of an interview, it is highly likely a highly experienced software engineer will miss some of the corner cases. The exception would mostly be someone who has specifically studied and drilled on implementing isNumber(char * string) or specifically works in implementing these kind of functions which is rare. As I said there are libraries with these today.
- NotSammyHagar 10y agoYou are missing the point. The goal is to show you can do simple coding and design. The particular example is not necessarily something you'd do explicitly. It's like writing fizzbuzz.