Click here to Skip to main content
15,887,434 members
Please Sign up or sign in to vote.
3.40/5 (4 votes)
See more:
I was recently asked for a sample of my code.. by a prospective employer...

What constitutes a good block of Sample Code to give a prospective employer, other than something that works ;P ?

Should it be tert... <1M?

Should it be inventive, say a solution for solving unknown problems? :laugh:

Does it need to be elegant, commented, stand alone, etc...

1. Proper naming conventions <- dependant on where one works.
2. Exceptions handled <- Good code shouldn't throw exceptions.. or Am i wrong in that assumption
3. Single responsibility principle held <- who says one scope of responsibility is better/more appropriate than another?
4. Bad data handled <- See point two above

My biggest issue is this: All of the code i've worked on is intelecual property of someone else.. as such I need to come up with a code sample... I am without ideas...
Posted
Updated 7-Mar-10 6:53am
v5

For me, a good block of code would constitute (other than something that works as expected!):

1. Proper naming conventions
2. Commented where and if necessary
3. Exceptions handled
4. Single responsibility principle held
5. Bad data handled

UPDATE:
:)
Atleast you have to tell your counters to employer, isin't?
After all, one cannot just assume that everyone is equally good and would take your counters into consideration themselves? You need to put something up!

You yourself said "Good code shouldn't throw exception".. well right enough.. thats what he is asking for... show him the GOOD CODE! :thumbsup:

UPDATE 2:
Why so? Why are you out of ideas? You worked on code that had intellectual property rights by someone, its ok - employer must not be asking to "show" that code. Either come up with some small example of yours or better ask the employer to tell something on which you can write a small piece of code and show him how good you can write! done! :thumbsup:

UPDATE 3:
No doubt it's a point that can be discussed long as it's quite relative and depends on person to person. Though what points i wrote can satisfy and should be sufficient to convince the prospective employer then!:thumbsup:
 
Share this answer
 
v6
The employer is probably interested in all and none of the things you talked.

Everything you said is not "absolute value" but realtive to the context.
"Good code doesn't throw exception" ... Not necessarily: base code can throw... "Single responsibility principle": there are canonical cases where it cannot be applied ...

What the employer is interested is probably a context into which evaluate your "congruence". That merely means consistence of style, consistence of formats, consistence of names, consistence of comments etc.

Independently on what the code does, good "styled" code reveal better logic minds than randomly placed "try and paste" code.
 
Share this answer
 
1. Proper = consistent and sensible
2. Good code should deal with exceptions. Also, exceptions are in many environments the standard mechanism for signaling errors - though not everywhere. I'm not sure where you got that generalism from.
3. Experience
4. See point two above. You don't need to use exceptions - but you need to handle it.

-----------------

As for your biggest issue: you never wrote a little tool for yourself? Tried out something for yourself? Well then - write something. Anythign oyu wished you had for your job, anything that annoys you about computers.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900