Posts

Showing posts from March, 2022

Configuring Your Angular Application to Use an External Configuration File

Image
Normally, developers use the environment.ts  and environment.prod.ts  files (and maybe even other permutations) to configure their Angular applications for different environments. With a deployment system such as Octopus , symbols can be placed in these files to replace values with environment-specific ones. But what if you want to build an Angular application for use by someone outside of such an environment? I ran into this problem recently when working on an application I have up on GitHub. I wanted to be able to provide a release that someone could easily configure without having to do a find/replace inside a JavaScript file. As long as the application is not offline, you can add a configuration file which gets distributed with your application and have the app read from it during initialization. First, create a new configuration file. In my case, I added config.json  under my src  folder: In this file, I currently just have a single configuration option: th...

The Most Destructive Keystrokes In Software Development Are The Ones Used For Copy/Paste

Image
Okay, so maybe the title of this post is a little over-dramatic. But the fact remains: copy/paste "coding" leads to problems, and is probably my least favorite bad coding practice (or the bane of my development experience! ). I think we've all been there: we don't know how to code something, so we do a quick search, either via search engine or in our existing codebase, to find an example, and then we copy and paste that example into the code we're currently working with. And sometimes, that's where it ends -- we've found our solution, and we move on with the rest of our coding. But often, just pasting that code in and moving along can have some unintended repercussions. Here's what can happen. A Lack of Understanding Sure, you've got code that works -- but do you know how  it works? Developers spend more time maintaining  code than initially developing it, and if you don't know how or why something works, it can make maintaining the code -- or ...