Win a copy of Transfer Learning for Natural Language Processing (MEAP) this week in the Artificial Intelligence and Machine Learning forum!
  • Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Tim Cooke
  • Paul Clapham
  • Devaka Cooray
  • Bear Bibeault
Sheriffs:
  • Junilu Lacar
  • Knute Snortum
  • Liutauras Vilda
Saloon Keepers:
  • Ron McLeod
  • Stephan van Hulst
  • Tim Moores
  • Tim Holloway
  • Piet Souris
Bartenders:
  • salvin francis
  • Carey Brown
  • Frits Walraven

lost a interview chance after written test was submitted

 
Greenhorn
Posts: 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
I had a written test before an interview. I have finished the test then their IT manager replied that my code was not good.
just want to know do you have any improvement suggestions of my answers?
written test file






 
Marshal
Posts: 68899
275
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
Welcome to the Ranch

You would fall down for poor formatting because the code lines are too long. You would fall down for incorrect use of the main() method, and you would fall down for not using object orientation in the first class; everything is marked static.
 
Rancher
Posts: 157
14
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
You'd probably have got more feedback if you posted in a different forum.

Anyways I'll code review
---

General comment: No javadoc comments on anything. This isn't good.

General comment: Including unit tests would have been a good idea if you had time to do so.


This line of code would be cleaner if you set it up a as a Map<Product, List<Product>>


Code can go in a constructor if you make this stuff non-static.


Reduce the size of your main method to a single line run call. For example move all of this code into a private (non-static) method called "run" and then call:



Poor exception handling here. What does a NumberFormatException mean? Tell that to the user.
Why make the call to showMenu() again? The try won't break the loop.


I don't like this scanner.nextLine(). It's better to always consume the newline rather than only if they enter something wrong.


This code has no purpose


Magic number here (and other) needs to be refactored into a constant.


I'd prefer this be handled with a loop than a recursive method call.


This exception type doesn't make sense for the context it's thrown in.


Split up long lines with newlines.


Purpose of remove here is unclear and should be commented.


Non-descriptive enum value names here


Intention of this code is unclear and should be explained (maybe this is just because it's called A, B, C)


Functionality of this line is unclear.
 
Marshal
Posts: 25436
65
Eclipse IDE Firefox Browser MySQL Database
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Zachary Griggs wrote:
Functionality of this line is unclear.



Not only unclear... it's also dividing two int values and then converting it to Double. This is probably not quite what was needed: for example if you divide 1 / 2 and then convert to double, you get zero. Whereas you probably wanted to get 0.5 instead. You need to cast either the dividend or the divisor to double before the division takes place.
 
Campbell Ritchie
Marshal
Posts: 68899
275
  • Likes 1
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator

Zachary Griggs wrote:. . . a good idea if you had time to do so. . . .

Interviewers assume that the applicants will all take a lot of trouble about the submission and will all make sure to take the time to create a polished product. If the idea is to reduce fifty applications to five to interview, the reviewing process will be very fast, and ruthless. You see the iffy declaration in line 3 and the very long line 57 [or 80], and you stop reading.

[edit]Add “[or 80]”
 
I don't like that guy. The tiny ad agrees with me.
Two software engineers solve most of the world's problems in one K&R sized book
https://coderanch.com/wiki/718759/books/Building-World-Backyard-Paul-Wheaton
    Bookmark Topic Watch Topic
  • New Topic