10 ms·
I don't agree 100% with the author on not asking them algorithmic questions. Its a process on how they go about solving it rather than just the outcome. Maybe f
by coolrhymes 13y ago
I don't agree 100% with the author on not asking them algorithmic questions. Its a process on how they go about solving it rather than just the outcome.
Maybe for the web developer position, you might not need such type of questions, but for a full stack developer the answer is unequivocally yes.
I made a mistake by hiring someone who knew django [who originally wrote plugins in WP] and the coding was just plain horrible. One such example.
`for foo in queryset:
foo.prop = 'i m bar'
foo.save()
`
Simple things like this, where a good engineer would know because of O(n) nature of the code, the so called programmer didn't.
And then there are guys who fork every possible repo, have blogs about how-tos, etc but really can't code for nuts.
- philangist 13y agoCoding noob here. Can someone explain the problem with the `for foo in queryset` implementation? Is it that for loops are inherently inefficient? What would be a better alternative?
- victorf 13y agoI don't see a problem with an O(n) algorithm to set some property on n objects.
- victorhooi 13y agoI think the issue is the call to save() (I assume this is meant to be outside the comma). Basically, it'll hit the database after each query.
- philangist 13y agoI originally thought it might be that too, but it seems to me like you'll have to hit the database n times for n queries no matter what. Unless Django has some builtin batch save functionality.
- victorhooi 13y agoHmm, there's bulk_create(), introduced in Django 1.4, to create multiple new objects in one DB call. However, I'm not aware of anything that would do the same to update properties.