Welcome to Software Development on Codidact!
Will you help us build our independent community of developers helping developers? We're small and trying to grow. We welcome questions about all aspects of software development, from design to code to QA and more. Got questions? Got answers? Got code you'd like someone to review? Please join us.
Activity for Derek Elkins
Type | On... | Excerpt | Status | Date |
---|---|---|---|---|
Answer | — |
A: How to write a function that only accepts a list of `Error string` `Results` in F# on the level of types? I'm pretty sure the answer is "no", especially in some reasonable way. If `Result` was defined in some object-oriented way, i.e. as an interface with `Ok` and `Error` being implementations of that interface, or if this was O'Caml and `Result` had been defined as a polymorphic variant, then you could ... (more) |
— | 3 months ago |
Answer | — |
A: How to implement a relationship between 2 tables where the type of participation is mandatory and RESTRICT rule for both? I would need to check, but I don't think PostgreSQL or most (any?) relational databases have a good way of expressing this "at most 8" constraint. It may be possible to express it in some way but probably not in a good way. For example, you could use triggers, but those have significant issues with r... (more) |
— | 7 months ago |
Answer | — |
A: What is the point of pipx? Well, to start, it is not an alternative to `pip`. It's built on top of `pip` and exclusively deals with applications. `pip` is more of a development tool, while `pipx` is aimed at end-users (who may also be developers). The bulk of your question seems to be complaining that loose analogies aren't... (more) |
— | 9 months ago |
Answer | — |
A: How do I find disjoint sets in a dataset One way of specifying what you want is that you want the equivalence classes of the equivalence relation generated by saying that pairs (a, b) and (x, y) are equal when either a = x or b = y. The famous union-find algorithm solves exactly the problem of incrementally computing representatives for an ... (more) |
— | 10 months ago |
Answer | — |
A: When is it OK for duplication of information between message header and payload in a distributed software application? Nowadays DRY is usually with regards to code, not data. Regardless, even for data, DRY does not outlaw duplication, it just requires a single "authoritative" copy. There are certainly similar ideas for data in relation to database normalization. I don't think either are terribly applicable here. I... (more) |
— | 11 months ago |
Answer | — |
A: What's causing mypy to give an `[assignment]` error in this nested for loop? As the error message indicates, the assignment is to the variable `row`. The `for` loop will repeatedly assign to `row`. But why is there a problem? Because Python's scoping rules are bad/broken. There is no block scoping. The scope of any variable within a function is that entire function except ... (more) |
— | over 1 year ago |
Answer | — |
A: When would one not want to return an interface? From simple subtyping concerns, you want the arguments of your methods to be as abstract/imprecise as possible while still allowing you to efficiently accomplish your goals. This allows your method to be used in the broadest range possible, and it also makes it clear what exactly your method depends ... (more) |
— | over 1 year ago |
Answer | — |
A: How to inject environment configuration values when deploying an Angular application in Kubernetes or similar infrastructure? I'm not quite sure I see what the issue is. As far as I can tell, you could continue to do exactly what you're doing now, you'd just do the token replacement on the `bundle.js` when a container is provisioned. On the other hand, I can see why you might want to move away from this approach. A more ... (more) |
— | over 1 year ago |
Answer | — |
A: Why is boolean value f (false) defined as a parsing-word while t (true) is not in Factor? The answer is indicated on the page for `f`. Specifically, "[t]he `f` object is the singleton false value, the only object that is not true." In contrast, `t` is defined simply as `SINGLETON: t` where `SINGLETON:` defines a class and thus a class word which is the sole instance of that class (i.e. it... (more) |
— | over 1 year ago |
Answer | — |
A: What is the Python Global Interpreter Lock? The Python Global Interpreter Lock (GIL) is a mutex in the primary Python implementation (CPython) that is acquired whenever Python (byte)code is executing. This means within a single (OS) process only one (OS) thread can be executing Python code at any point in time. This is absolutely an impleme... (more) |
— | almost 2 years ago |
Answer | — |
A: What allows a string slice (&str) to outlive its scope? There are two things going on here. One which technically explains what's going on fully, and another potential misconception you have. For the former, `&T` implements the `Copy` trait regardless of what `T` is. So all that's happening is when `r = inner;` executes it just does a bitwise copy of t... (more) |
— | almost 2 years ago |
Answer | — |
A: Is it possible to undo a git reset? If you've committed, then the commit is in the git repo regardless. All `git reset` does is change what commit the `HEAD` references. If you find the hash corresponding to the commit you'd like `HEAD` to reference, you could just `git reset --soft `. `git log --reflog` should list all the commits... (more) |
— | almost 2 years ago |
Answer | — |
A: Measuring arithmetic overflow checking overhead in C# Benchmarking is hard and there are a lot of potential issues with your code. I agree with Olin Lathrop that you want at least a few seconds worth of run time, not just due to the potential for a low precision clock but also to deal with noise from various sources. However, there are still other pr... (more) |
— | about 2 years ago |
Answer | — |
A: What are the drawbacks of using data snapshot testing? This is more or less equivalent to a long used testing technique that I've commonly heard referred to as gold filing. The benefit of it is that it is very cheap to do, and it can catch even minor changes that you may not have covered with a typical unit test. Two pitfalls I'll focus on are: Go... (more) |
— | about 2 years ago |
Answer | — |
A: Why static code analyzers such as SonarQube indicate a high code complexity for switch statements? It depends on why you have a large `switch` statement. I'm going to assume it's because you have a large `enum`. If not, then you probably have some complicated logic, and you should endeavor to break it into a more hierarchical form. For example, if you 12 cases, you might be able to do a check to s... (more) |
— | about 2 years ago |
Answer | — |
A: When stored procedures are preferred over application layer code? (This answer became more ORM v. "direct" SQL. If you're very narrowly focused on just stored procedures, then it's not super important to me that the logic be packaged up in stored procedures. That said, if you aren't using something like an ORM to generate the queries, it's not clear to me what bene... (more) |
— | over 2 years ago |
Answer | — |
A: In the current development context (2020+), is there any reason to use database triggers? This is somewhat of a non-answer because I also think the answer is mostly "no". I'll split kinds of triggers into three categories. 1) Those that only touch the affected rows, 2) those that additionally read data from other rows/tables, and 3) those that mutate other rows/tables. The first cat... (more) |
— | over 2 years ago |
Answer | — |
A: What advantages does Agner Fog's VCL have over OpenMP? The point of VCL is to allow you to work with SIMD operations explicitly. OpenMP `simd` is more or less just a way to provide hints to the auto-vectorization the compiler is doing, so to some degree is still subject to "the compiler is unable to vectorize the code automatically in an optimal way", ex... (more) |
— | over 2 years ago |
Answer | — |
A: Kotlin FloatArray from Iterable<Float> In your situation, the most obvious thing to do is use a for loop over the `Iterable` or the `Iterable.forEach` extension method depending on your preference, and directly `put` floats into the `FloatBuffer`. This avoids any intermediate data structure. Indeed, I'd do this directly over `myList` to a... (more) |
— | over 2 years ago |
Answer | — |
A: Transferring files from a legacy project to an existing one as varbinary The approach I would take given the constraints you've stated is to make much simpler and safer changes to Project A. Namely, 1) provide an API endpoint for fetching a file, and 2) provide an API endpoint, if needed, that takes some kind of "timestamp" (real or logical) and returns a list of files (o... (more) |
— | over 2 years ago |
Answer | — |
A: Behavior of Pointer Arithmetic on the Stack This is absolutely undefined behavior. The C standard doesn't say anything about stacks or how they should behave or how local variables should be allocated on them. The word "stack" doesn't even occur in the C standard^Feel free to do a string search on [this working draft version of the 2018 C s... (more) |
— | over 2 years ago |
Answer | — |
A: Handling high frequency requests with cancellations in an ASP.NET Core application There are two issues here. A performance problem and a correctness problem. The approach you suggest seems like it will help mitigate the performance problem while doing nothing for the correctness problem. Having some way of cancelling the computation if the result is not going to be needed seems... (more) |
— | over 2 years ago |
Answer | — |
A: Dealing with GETs with long query strings in ASP.NET Core tl;dr Just use a POST. There's likely literally no reason not to in your situation. 1. REST is not a standard. 2. Being RESTful in and of itself is not a virtue. 3. I strongly suspect that your current code/API design violates the guidelines of REST more often than it follows them so there's lit... (more) |
— | over 2 years ago |
Answer | — |
A: Is it dangerous to use json.loads on untrusted data? Short answer: No, it's not dangerous. Short of bugs in the implementation or monkey-patching, there's no reason it would or should allow executing of anything other than the JSON parsing code. This Stack Overflow answer goes into detail for the actual implementation at that time. I didn't find any... (more) |
— | over 2 years ago |
Answer | — |
A: Is there any justification for having a single tempdb database to be used by all databases on a SQL Server intstances? I can't speak for the designers' motivations, but here are some possible reasons: It's simple. Having one tempdb for everything is likely simpler to implement and simpler to configure. It works. A lot of the time the shared tempdb isn't a problem. When it is, your links provide some mitigatio... (more) |
— | over 2 years ago |
Answer | — |
A: Are there any downsides related to using Maybe or Optional monads instead of nulls? This is mostly an addition to r's answer which I mostly agree with. This elaborates on the "non-idiomatic" part a bit. Modern Java code doesn't have a problem using `Optional`. Why? Because `Optional` is part of the standard library and has been since Java 8 (which is when it would have made most ... (more) |
— | over 2 years ago |
Answer | — |
A: Using http.get to get page from frontend To start, Angular is a Single-Page Application (SPA) framework. This means your whole "site" is served from a single web page. Any apparent navigation within that site is just (Angular's) JavaScript rewriting the DOM. Back in the day, when SPAs were new, you'd see URLs like `http://example.com/#pi... (more) |
— | over 2 years ago |
Answer | — |
A: Is it a good idea to have a permanent branch for a feature? Your first diagram illustrates a pattern that doesn't really make sense and most likely doesn't reflect what you're actually doing. Specifically, it illustrates a pattern where the feature branch never gets updated from the master/develop branch. I suspect in practice you merge updates from master/de... (more) |
— | over 2 years ago |
Answer | — |
A: How do I filter an array in C? First a meta note. Code golf isn't a great way to learn a language. It explicitly optimizes for something that generally isn't valuable (fewer bytes of source code) typically at the expense of aspects that are valuable (idiomatic code, readability, efficiency, effectiveness). On a less meta note, ... (more) |
— | over 2 years ago |
Answer | — |
A: updating a function within a struct You are correct in your analysis (though I would not call `newb` a "parameter" but a captured variable). What you want is for the closure (anonymous function) to take responsibility for `newb` and not just borrow it temporarily. In other words, you want move semantics and not a borrow. As menti... (more) |
— | almost 3 years ago |
Answer | — |
A: Is it wrong to demand features in open-source projects? As you have worded it, for most open source project, particularly small ones, I would say "yes", it is "wrong" to demand features. Or rather, it's extremely rude. Most of the time open source software is free (as in beer) and, again particularly for smaller projects, done entirely in the developer... (more) |
— | about 3 years ago |
Answer | — |
A: Is it necessary for a build server to remove node_modules before an AOT build? I can't really think of a compelling reason to remove `nodemodules` as a matter of course. The most compelling one, is what you alluded to. If `nodemodules` is "corrupted" in some manner, removing and refetching it will resolve that "corruption" without needing any manual intervention. Short of a ... (more) |
— | over 3 years ago |
Answer | — |
A: When should I use wait() instead of get() when using C++ threads tl;dr If you don't have a reason otherwise, you should use `get`. More precisely, if you will be done with the future, you should use `get`. You should use `wait` only if there is some separation between when you want to ensure the visible side-effects of the future have completed and when you will b... (more) |
— | over 3 years ago |
Answer | — |
A: Permutations of an array - APL I assume the built-in definition you're referring to is pmat. That illustrates how to solve your problem near the bottom. The idea is simply if σ is a permutation of length N and A is an array of length N, then A[σ] is A permuted by σ. This leads to a definition like: ```apl permute←{⍵[pmat⊃⍴⍵]} ... (more) |
— | over 3 years ago |
Answer | — |
A: What do the number entries mean in the sympy poly.diff(...) tuple syntax? Based on the source code which delegates to this implementation among others, `base.diff((x, n))` means to compute the `n`-th derivative of `base` with respect to `x`. Any arguments to `diff` which aren't tuples get tupled with 1, e.g. `base.diff(x)` is more or less equivalent to `base.diff((x, 1))`.... (more) |
— | over 3 years ago |
Answer | — |
A: Are generic enums completely abstract? Your question is a bit ambiguous. Usually when one talks about something being "completely abstract", one means the details of the representation are opaque. This is the sense of "abstract" in "abstract data type". To this end, Rust enums are not "completely abstract" as various details of their repr... (more) |
— | over 3 years ago |
Answer | — |
A: Can regex be used to check if input conforms to a very strict subset of HTML? I mostly agree with the upshot of hkotsubo's answer, but I want to both tailor the answer more specifically to your question and give some more general advice. First, the restricted subset you describe is still not a regular language. As a rule of thumb, if you have constructs, e.g. ``, which can ... (more) |
— | over 3 years ago |