DEV Community

Cover image for What Does It Mean To Inject Code?
Milecia
Milecia

Posted on • Edited on

What Does It Mean To Inject Code?

In the tech industry, there's no way you won't hear about code injection. You'll be expected to inject code without being told exactly what to do or how to do it and that's ok because we're going to talk a little about what code inject is.

All code injection means is that you pass in code to other code similar to how you pass in a parameter to a function. Think about dynamic web pages for example. Depending on some user permissions you set, different people will see different layouts. That's because you'll have different code that runs based on those user permissions.

The good thing about code injection is that you can re-use chunks of code incredibly easily with some simple logic. You might have some validation code that needs to execute every time a user logs in. Code injection will help you keep the validation separate from all the other things you'll need to run.

Another thing code injection helps with is automation. If you have a trial version you want people to use, this can help you regulate which users still have access to the trial.

Now it's not all sunshine. Code injection can make debugging take an obscene amount of time. That's because it's harder to tell where the error started since a lot of the executed code is anonymous.

Code injection can also be a security risk if you're not careful. Hackers look for holes that they can poke their code into and you don't want to leave anything open for them. Just make sure you use good security practices.

Of course there's a more technical explanation although hopefully this gives you a high level idea of how code injection works. You've probably already been doing this for a while whether you knew it or not. Coding jargon always made me feel like I was a bad developer until I started to see I knew how to do the right things. Don't let the jargon get you down.


Hey! You should follow me on Twitter because reasons: https://twitter.com/FlippedCoding

Top comments (0)