Recent submissions

Comment · 8 years ago
We're getting there!
Comment · 8 years ago
Don't any of the langauges you support have options to keep all dependencies up to date? Eg. By putting wildcards in version numbers
Comment · 8 years ago
I think your method is much cleaner actually. Just updated :)!
Comment · 8 years ago
I agree! I find this especially useful when I have to set things like a UserId associated with an entity or with more complex entities where some data comes from injected services. I know you can create a service that handles creating the entity as an abstraction, but that gets repetitive and adds complexity in large projects. I might actually add this my article :)!
Comment · 8 years ago
I myself really dislike that piece of code (searching in exception strings isn't secure for many reasons, for example someone could use this to reverse-engineer information about my database). But the only alternative that comes to mind is to check if an entity exists before attempting to create it - which I don't like because it leads to repetitive code in large projects (and I might forget to write checks). Any other ideas?
Comment · 8 years ago
Yes, that is the usual way of doing it. However, the point of this post was to showcase some ways of reducing duplicate code in large projects. Doing it normally (by checking if the entity already exists) can get repetitive if you have many controllers/entities. If you know of a better way of doing this, I'd be happy to update my article :)
Comment · 8 years ago
I know, I just couldn't find a cross-db solution since I can't seem to find any standardized error codes in the exception. Do you know of a better way of doing this?
Comment · 8 years ago
Well the server was going to return an error anyways, instead of checking if the entity exists then trying to create it, you just go ahead and try to create it. This way if the entity doesn't exist then you've saved a trip to the database. Otherwise you return the same error. And given the server is a black box, how would you "interrupt execution"?
Comment · 8 years ago
Cierge also uses magic links, making the code invisible to keyloggers. You can configure it to use magic links exclusively.

Live from the official Hacker News API

A modern reader for Hacker News · SvelteKit + Skeleton