|
Steve French posted:So are files containing code, both as written by humans and compiled code. That's data-driven development!
|
# ? Sep 11, 2017 01:34 |
|
|
# ? Jun 5, 2024 23:54 |
|
Steve French posted:So are files containing code, both as written by humans and compiled code. No lie, some of my first personal projects used Python modules as configuration; I'd just import them and access the data I needed that way. In my defense, the fact that this basically meant that configuration files could do `rm -rf /` and similar did eventually occur to me.
|
# ? Sep 11, 2017 01:45 |
|
I don't have a problem with that. You configure Django in settings.py
|
# ? Sep 11, 2017 02:14 |
|
Pollyanna posted:You could just do this in that case: There may also have been a case for returning dummy test data instead of null while the source of the incoming stuff was still indev, but you're right that it still wouldn't need the else block except out of paranoia. TooMuchAbstraction posted:No lie, some of my first personal projects used Python modules as configuration; I'd just import them and access the data I needed that way. I currently use a .php file with just a config class full of const values. This file can be found by my autoloader by that class name like any other class I write. No parsing, no passing. code:
Then again, maybe this really is a horror (simplified a bit, I even have a mapping of abbreviations to class names!): code:
code:
I write mostly static functions in classes (they're actually faster than bare statics), but this should work for any sort of class stuff. So with that header you can just call Config::perfectbuttratio anywhere. Ranzear fucked around with this message at 05:02 on Sep 11, 2017 |
# ? Sep 11, 2017 04:58 |
|
I usually just put the constants right in the code, scoped to where they're needed. Extremely rarely do I need to pull them out as configuration to my program: 90% of the time such config values are basically unused.
|
# ? Sep 11, 2017 05:13 |
|
These are mostly per-server configuration values kept outside of version control and locked down. MariaDB password, cross-server secret, live vs dev values, etc. Stuff that can't be put right into the db like the regular configurables.
Ranzear fucked around with this message at 05:23 on Sep 11, 2017 |
# ? Sep 11, 2017 05:18 |
|
Modern versions of Spring can use Java classes for configuration, primarily for beans.
|
# ? Sep 11, 2017 05:25 |
|
It's more important in some development environments than others. For us, we mainly change configuration values when something needs to be updated in production, or in general to vary behavior between local development, staging, and production environments (which downstream service endpoint are we using? which database? what's our metrics namespace?) Another big factor is language: setting configuration in code for our scala services is a poor option because it's much nicer to be able to update configurations at runtime, and use the same build/deployment artifact in all environments, rather than compile and package all of that hard coded into our JARs and docker images. Easier to get away with that in Python or PHP
|
# ? Sep 11, 2017 05:25 |
|
Forgot to mention my first experience with YAML was someone using it for the config file for a minecraft mod. It took me way too long to figure out how insistent it was about four spaces and never tabs. Never again. Then I sent a nastygram to the dude who used JSON instead but you had to add most keys you wanted to change manually because only a few were pre-populated. I take it back for the former, but still not the latter.
|
# ? Sep 11, 2017 06:17 |
|
iirc the only reason the C spec includes undefined behaviour is so that the compiler can format your hard drive if you use tabs instead of spaces for indentation
|
# ? Sep 11, 2017 06:20 |
|
Ranzear posted:
You should be careful loading modules from paths relative to your working directory, rather than relative to the script's location. (Or absolute paths, of course.) You might get code you don't expect loaded. If you've made a command-line tool, for instance, and there just so happens to be a file with the right name in the folder you run it in, that will get loaded instead of the code you expect. If this is an untrusted folder, and your application is trusted, this might pose a security problem. It might not be relevant in your use-case, but it is something to consider. In the latest release, Perl spent a great deal of effort removing "." from its default search path for this exact reason: https://news.cpanel.com/cpanel-tsr-2016-0001-full-disclosure/
|
# ? Sep 11, 2017 16:09 |
|
The reason why code-as-config was dodgy in my case is that the use case was a videogame. I was a little perturbed by the idea of distributing a game where the game data (which players might want to modify and share with each other) was actually code that could e.g. do `rm -rf /`. Of course game mods often include code content these days, but a) if that's not necessary, e.g. for simple asset mods, then it shouldn't be done, and b) I would hope that game mod systems properly sandbox the code they're running.
|
# ? Sep 11, 2017 16:17 |
|
Hey, if you have a property called "validate", which has a function associated with it, what do you expect that function to do? If you guessed "take the data and return true or false depending on whether the data is valid or not", you're absolutely wrong! What it actually does is munge the data into a particular format we want, e.g. clamping between values or between a range of dates. This most definitely did not confuse me for a good two hours, no siree.
|
# ? Sep 11, 2017 18:50 |
|
I think every project I've ever worked on that has had "validate" functions has at some point had at least one which actually did format conversion.
|
# ? Sep 11, 2017 19:00 |
|
JawnV6 posted:Adjust the value of "human" as appropriate I'm a human and I can read it, therefore it's human-readable.
|
# ? Sep 11, 2017 19:00 |
|
In order to avoid style wars, I check all my source code in as esprima AST .json files. This way, each person can choose their favorite style when they reserialize the AST back to JavaScript.
|
# ? Sep 11, 2017 19:42 |
|
Plorkyeran posted:I think every project I've ever worked on that has had "validate" functions has at some point had at least one which actually did format conversion. All of them do that, though. To the point where the documentation explicitly says that validation just sets the values, and all the utility functions are in the `parse` module.
|
# ? Sep 11, 2017 19:57 |
|
Suspicious Dish posted:In order to avoid style wars, I check all my source code in as esprima AST .json files. This way, each person can choose their favorite style when they reserialize the AST back to JavaScript. For a long time thats the basic reasoning I used for indenting with tabs, aligning with spaces...each person could set their favorite indent width. Problem is no one could be hosed to adjust their editors setting for width of tabs.
|
# ? Sep 11, 2017 20:40 |
|
Pollyanna posted:Hey, if you have a property called "validate", which has a function associated with it, what do you expect that function to do? It returns a valid date I don't see the problem
|
# ? Sep 11, 2017 21:20 |
|
Yeah are you sure the function isn't named "validdate"
|
# ? Sep 11, 2017 21:25 |
|
Validate, as in "make valid"
|
# ? Sep 11, 2017 21:28 |
|
Nippashish posted:Validate, as in "make valid" That feels like it should be "validize" or something.
|
# ? Sep 11, 2017 21:30 |
|
Normalize
|
# ? Sep 11, 2017 21:38 |
|
Thermopyle posted:Problem is no one could be hosed to adjust their editors setting for width of tabs. So we let them become lazy because they just whine to their mommies that someone uses a different editor. Guess what happened? Now we have Unicode spaces appearing at the front and back of lines leading to runtime errors (because you know why, snakes are nice but not that language).
|
# ? Sep 12, 2017 01:18 |
|
Why don't you just pick a style and run a formatter when saving your code?
|
# ? Sep 12, 2017 01:44 |
|
Then you lose your sense of superiority.
|
# ? Sep 12, 2017 03:13 |
|
vertical tabs for indentation, ascii bell character for alignment
|
# ? Sep 12, 2017 03:43 |
|
Munkeymon posted:It returns a valid date I don't see the problem JawnV6 posted:Yeah are you sure the function isn't named "validdate" Nippashish posted:Validate, as in "make valid" They're actually objects that can represent any particular piece of data, and that object has a validate property that supposedly holds a function that determines if it's valid or not, but apparently that's not actually the case. If it was validDate it'd be funny as poo poo tho.
|
# ? Sep 12, 2017 04:04 |
|
I worked with a contractor that didn’t escape strings. When the device was booting, it would print some garbage that included a bell character. My terminal would dutifully ding every clean boot. By the time I sorted it out I was trained to the bell, if init was messed up it wouldn’t ding, so I left it in like a Pavlovian dog.
|
# ? Sep 12, 2017 04:05 |
|
JawnV6 posted:I worked with a contractor that didn’t escape strings. When the device was booting, it would print some garbage that included a bell character. My terminal would dutifully ding every clean boot. What's worse, using a bell character, even by accident, or the fact that it still works?
|
# ? Sep 12, 2017 04:59 |
|
Thermopyle posted:For a long time thats the basic reasoning I used for indenting with tabs, aligning with spaces...each person could set their favorite indent width. Prettier along with standard solves this problem, especially if you've setup githooks to format upon add/commit. Stuff like gofmt is awesome, gently caress these stupid formatting flamewars.
|
# ? Sep 12, 2017 10:50 |
|
Pollyanna posted:Hey, if you have a property called "validate", which has a function associated with it, what do you expect that function to do? stamp the parking ticket so the customer doesn't need to pay when they leave!
|
# ? Sep 12, 2017 13:30 |
|
Odette posted:Stuff like gofmt is awesome, gently caress these stupid formatting flamewars. I think there's a larger horror here: Any system that requires perfect alignment to operate is flawed. A greater issue isn't "spaces versus tabs", it's "why the gently caress isn't this damned thing working at all?!" when one is trying to handle things like Python and YAML. With tabs it's immediately obvious when something is incorrect: Simply changing your tabs to 8 or 20 or 2 or 17 wide in your screen, and the alignment errors are made clear almost instantly, and this all editors handle. With spaces, your eyes glaze over and you're stuck looking at the code one way, gently caress you gentle code reviewer, you will only see what we want you to see, good luck getting out of the mindset of the programmer that made the mistake in the first place. Yes, the words chosen might be dramatic, but this is the reality. Just yesterday I was handed a YAML config that someone else copy/paste but wasn't working. There were basically two of these within a 500 line config: code:
In the end, after fixing the five YAML formatting errors they made, and the two completely-missing parameters they somehow deleted, there's still significant issues with the values themselves, so I'm giving up and completely dumping their config. I can't really post the example; they have the complete list, but they're not mapped to the subsystems correctly, nor are the values correct (mebi versus mega ffs).
|
# ? Sep 12, 2017 14:03 |
|
You know, I just thought of why I don't like YAML at all. It's got its own rules that I've got to remember for no reason other than config files and its not even that widely used to begin with. At least with JSON/XML/code configuration I already know the rules. Yeah, those options all have other problems but apparently those problems haven't been bad enough for me to grow the disdain for them as config file formats that I have for YAML. (also, I just knew my comment about tabs/spaces would get some replies)
|
# ? Sep 12, 2017 14:10 |
|
At least JSON doesn't introduce security concerns (like unserialization) / DoS (like XML) I'm not touching JSONP
|
# ? Sep 12, 2017 14:45 |
|
I'm going insane seeing poo poo like this:C++ code:
|
# ? Sep 12, 2017 14:48 |
|
Two projects I was introduced to today have code quality so bad they have to compile with optimisations disabled just to get predictable behaviour. No problem, it's just code for a hard real-time system on a bottom-end microcontroller where space and time are both critical
|
# ? Sep 12, 2017 15:48 |
|
Spatial posted:Two projects I was introduced to today have code quality so bad they have to compile with optimisations disabled just to get predictable behaviour. Government?
|
# ? Sep 12, 2017 15:52 |
|
Jeb Bush 2012 posted:vertical tabs for indentation, ascii bell character for alignment One of my TAs in a freshman course told us on day one or two that his favorite thing to do to unlocked screens in the CS building was add vbell to their PS1, rather than do the replace desktop with a screenshot of the desktop prank.
|
# ? Sep 12, 2017 16:15 |
|
|
# ? Jun 5, 2024 23:54 |
|
Munkeymon posted:One of my TAs in a freshman course told us on day one or two that his favorite thing to do to unlocked screens in the CS building was add vbell to their PS1, rather than do the replace desktop with a screenshot of the desktop prank. I used to have a lot of fun with this script: https://github.com/eckankar/prank-script All reversible; some more easily than others.
|
# ? Sep 12, 2017 16:54 |