instruction stringlengths 34 36.1k |
|---|
In a project that aspires from the onset to be maintainable across a revolving team of developers, what difference would it make to use literate programming against thorough commenting guidelines?
The latter would imply: classes with explicit purposes of what they do, why they are there, with examples, non-cryptic erro... |
When payment is made, it either succeeds or fails for whatever reason. In this case, though not important, the payment is made on a third party payment website, like Paypal, and a callback url is supplied for success or failure.
My question is should that success or error page expire, that is start returning a 404 afte... |
I am wondering how to take these Hieroglyphs and make them into Unicode. I read through the Tesseract docs on how to create training data, but it seems largely tailored toward "traditional" writing, that goes in one direction and has only one character per vertical-space-per-line. Whereas in Egyptian hieroglyphs, it is... |
I've looked up a lot proofs for the halting problem (that are basic enough that I can understand what they are trying say ^^) but for all of them I don't get their last step right before they pull the conclusion out of a magic hat.
Assume we have a function H(x) -> bool that can determine if a program x halts or not. W... |
We have multiple producers that publish messages to the same SQS queue. We have a single consumer that processes the messages. The producers do not care about the response. It is more like a broadcast message.
We are evaluating several options of how the producers are going to publish to the queue.
Evaluated solution p... |
Does anyone know of a methodology that can be used on a project file tree to identify dead files, dead code, unused libraries, etc. I have been thinking about this for some time as I seem to inherit code that was develop from another code base and find that my maintenance reveals unneeded libs, unused files and last of... |
I'm trying to get into the habit of making sure that each master commit to a repository I work on does not break any existent tests. In my current flawed workflow, there are some intermediate commits on master that do not pass all tests, and I'm trying to adopt a solution to this.
From About Continuous Integration
Bui... |
I'm maintaining an intranet using ASP Classic. Some of pages looks like one or more HTML tables used for administration tasks.
Those tables are obtained by SQL requests. Server side, they are kind of "raw". They are next decorated client-side with icons and buttons to perform those tasks or getting information from AJA... |
Many articles on the internet focus on methods to keep secrets outside public-access (like mobile apps, website frontend etc). But let's take the example of a really big organisation. It has secrets outside public-access, as recommended, but it is within any developer's reach because they have access to the backend cod... |
I'm working on a project with 5 different modules. Should I make separate use case diagrams and class diagrams for each module or should I make all-in-one use case diagram and all-in-one class diagram? Your help will be highly appreciated.
|
I have looked at several examples for implementations of Momento on the web. I wonder if it is correct to retrieve the status of Originator, since this is much more accurate, up-to-date and reliable?
Is it correct to use a getState() method that allows me to gain a better understanding of the current status, in real-ti... |
Context
When designing the API of a React component, you may decide to receive props in a more semantical way. Here's a simple example
<Modal headerTitle="foo" />
vs
<Modal>
<Header>Foo</Header>
</Modal
A more complex example would be this one, where we have a table and we need to set responsiveness:
const hideOn ... |
I want to start developing an. open-source javascript library. I can see other open-source libraries are well structured. They have src, dist, test kind of folders, etc.
Which is making me very confused. My end goal is i want to develop a well structured and well documented JS library, but initially i need some hierarc... |
In my node.js app I have a async function that fetches remote documents and caches them on the disk. Upon a retrieval request for a document first checks the disk, if found loads it from the disk otherwise initiates a network request.
async function getDoc(id){
if (await diskCache.found(id)){
return await d... |
I am confused by the two principles of SOLID, liskovs substitution principle and interface segregation principle. It seem as though they conflict each other's definitions.
How can a class that implements interfaces also guarenttee that it also fits the liksov subsitution?
For example, in this code, if a client to make ... |
I'm writing a C++ application. This is a memory management question, I have a background in scripting languages and am new to C++.
I have a little class representing a GUI view, call it View, and within that view there's a text field and a button. When the user clicks the button, the text field is interpreted as a shel... |
Whenever I am asked to give a quote for a project that involves a remote REST API, I become very cautious.
Most of the REST API's I worked with had a documentation, but it usually turned out to be very basic (I may not need prose texts, but I don't have a crystal ball either), with the real complexity hidden somewhere ... |
I have a situation where my business logic depends on data coming from an external service. I initially though this would be a prime candidate for a domain service, but now I'm starting to wonder if that's even needed. With years of working mostly with relational database for fetching data, I think my brain may be stuc... |
We want to adopt ISO 25000 quality model, which explicitly states it does not deal with functional requirements (i.e. its Functional suitability is truly about assessing how the functions fit in the context etc.).
According to this and other sources, quality is a non-functional attribute, basically a sum of quality att... |
I was reading an old answer which was recently updated, and noticed that the author doesn't quote the simplicity of data migration as a benefit of MongoDB. I always thought that the major benefit of a NoSQL solution such as MongoDB is that it makes migrations extremely simple compared to the usual relational databases.... |
I've written a little library that uses the builtin ast library to convert between functions, docstrings, argparse .add_argument, classes, and [soon] more.
Stubs look something like this, with ir referring to 'intermediate representation'; i.e., a common internal data-structure that everything parses to and emits from:... |
Let's say you are engineering a chat room software.
let client = new Client();
let room = rooms.FindRoom();
room.addClient(client);
This room (parent) now has a client (child).
client.on('message', (event) => {
// With the above code, room must be found
let room = rooms.FindClientsRoom(client);
if(room){
... |
I and a colleague had a rather strange discussion with our boss related to the architecture of the applications we are currently developing. The C4 (second level) diagram of the existing architecture is the following:
Highlights:
shared database between the external app and the internal one
the internal one is develo... |
Here's an example: In the documentation for java.util.HashSet, there's a list of "Methods inherited from interface java.util.Set", including equals, which is an abstract method in java.util.Set. In contrast, other abstract methods in java.util.Set have their own documentation in java.util.HashSet, such as iterator. Why... |
Let's imagine a simple domain model:
// aggregate root
class TaskList(
id: Long,
name: String
)
// aggregate root
class Task(
id: Long,
taskListId: Long,
name: String,
dueDate: OffsetDateTime,
subtasks: List<Subtask>,
isDone: Boolean
)
// value object
class SubTask(
name: String,
isDone: Boolean
)... |
Our company is against the Generic Repository and Unit of Work in C#, which makes sense. Since Entity Framework Core already completes those functions.
However, I'm reading articles that a Repository is not even needed. We have a Repository C# project to isolate files from other Application services (including Parsing ... |
Where should I store data of user that is not yet registered?
Data that I want to store:
Search history (to show appropriate products on a store page)
Theme preference (dark / light theme)
Cookies? In database by IP of the user? Something else?
I tried for my use cases of using "database by IP of the user" but found ... |
I was trying to understand how to embed v8 engine in a C++ application and was trying to understand the following hello world problem as a result.
I found the code to be unreadable at first glance. e.g.
v8::HandleScope handle_scope(isolate);
Here, handle_scope is not referenced anywhere at all. But if I remove this li... |
I don't know how to phrase this better, but I remember reading an article about type theory, that categorized the values being received by a function and the values being sent back from the functions.
The example was something like:
T2 function(arg T1)
In this example T1 would be a received type, and T2 would be a sen... |
I have role based access control to my applications. I have team leader application where team leader with valid role can view their teams performance metrics. Now my top management wants to get a view of the team leader aka they want to mimic a particular team leader to see what they can see.
I am planning to add a ta... |
According to Wikipedia, we talk about stages of development;
prealpha
alpha
beta
release candidate
stable
But, beta also have 2 sub-stages;
perpetual beta
open/closed beta
Now if we were to version a software with these and semver. It would look somewhat like this:
prealpha: 0.x.x
alpha: x.0.0-alpha.x
beta: x.0.0-... |
I have a Flutter and Angular application that previously used Firebase, but for various reasons I'm working on switching it over to my own RESTful API with ExpressJS. One topic I'm a little confused on is how I can manage my JWT and their renewal. Currently essentially my auth related endpoints for my API look like the... |
I have a few objects that should communicate between each other. I also want to have my code unit tested.
I am questioning how I should handle their communication:
Should I make one instantiate the other one?
Should I pass one in the constructor of the other one?
Should I make them communicate via events/a observable ... |
This comes with a debate with my colleague that I'm using null as an object initial state.
type Value = Node | null
const [value, setValue] = React.useState<Value>(null)
function test(v: Value) {
if (value === null) // Do something
else // Do something
}
I'm curious if null is a mistake in this case. What alterna... |
This come with a debate with my colleague that I'm using nullable object type.
type Value = Node | null
const [v0, setV0] = React.useState<Value>(null)
const [v1, setV1] = React.useState<Value>(null)
const snapshot = (nodes: Node[]) => {
const root = Parser.parse(nodes)
if (v0 === null) {
setV0(r... |
The Substring method of C#'s string class (which is also available in every other .Net language) does not seem to alter state and will always return the same value, given the same arguments.
So is it a "pure" method?
I'm asking, because in Microsoft's reference source code of the System.String class, many other public ... |
We have a complicated query in Entity Framework which filters on the grandchild and selects parent attribute. Our current architecture goes from Data Entity --> Domain --> Dto
Would this kind of query be a Repository Method, Domain Service, or Application Method?
select distinct c.customerName
from dbo.customer custome... |
I would like to have IDs of different sizes from the alphabet 0-9. So I have 5-length IDs as in 10000 or 13531, etc.. I have 10, 15, 20, up to 39 digit strings (the size of a UUID). I would like to guarantee that I select a random one from the set of possible values and that it has never been used before. This isn't th... |
I am developing a REST api endpoint that accepts a list of item IDs and will return some details for each item.
Let's make the following assumptions
Performance wise in the DB there is no significant difference whether the endpoint accepts 10/100/1000 etc IDs.
The details that will be returned for each ID are a JSON w... |
I'm working at a project which integrates several Applications mostly SaaS Applications. The SaaS solutions have all the possibilities to hook into the internal event system with webhooks. The webhooks give us the ability to send a message to a single system but we have to create multiple webhooks to send a single even... |
What we want to do is very simple
We have a check-in kiosk website (C# ASP.NET MVC), and we are trying to set up 30 kiosk stations at each building (each building is about 200 ft away from each other).
Every time a person checks in at a building, we want to collect the time and the location of the check-in. (e.g. Perso... |
I have a web application where users must authenticate with a 3rd-party OAuth 2.0 service in order to do what they need to do in the app. On initial registration/login, they will connect with the service and my backend will get their access tokens and refresh tokens and keep those fresh for the duration of their user e... |
I am working on a weird ID system where I generate all the IDs in advance and need to atomically pop() one from the database, so no ID is read twice at the same time (and so used more than once). This is simple and straightforward when you have 1 request per minute, but hardly at 1 per second or faster than that.
I am ... |
public interface ILogin
{
Task Login();
}
public class LoginStrategyA : ILogin
{
Site site;
public LoginStrategyA(Site site) => this.site = site;
public Task Login()
{
}
}
public class Site : ILogin
{
ILogin loginStrategy;
public Site(ILogin loginStrategy) => thi... |
MVC+ xml web service using MS MVC.
The project is made with MS ASP.net front end and business logic, and the logic contains does coded with some complicated logics to interact with the front end layer , then it calls a xml web service to handle some other business logic, and at the end it interact with the SQL server... |
Let's assume that we have a set of valid results, ex. Fruits: "Apple, Banana, Kiwi, Pear, ...".
(In reality, it’s not fruits but complex objects)
Now we need to pick the best result according to some simple prioritization. For example, let's say this prioritization is simply an arbitrary order of preference determined... |
I am trying to design an application that will be a REST API following MVC. For now ,I have 2 main features: Projects and Tickets associated to Projects.
I would like to apply SOLID principles, and I want to have a rough idea on how to design it, before I start coding.
My idea so far has been like this to create the Co... |
I had to move houses recently and I found that it is tedious to check every potential place's broadband coverage. For that reason I want to build a website where you can check which broadband options are available at a specific address.
I have downloaded JSON documents describing broadband internet options for a place ... |
I'm developing a backend service that is supposed to process items in a pipeline-fashion. Each stage is essentially a Function<IN, OUT>. So the current stage's input is the previous stage's output. Moreover, each stage needs to write it's result to the Record object and each stage can get the previous results (not only... |
Usecase:
TeamA: Adds 5000 IDs to a blacklist per day and notifies other teams by publishing an SNS message per ID added that all other Teams listen to.
TeamB: Gets 4K TPS to its API, and if a given ID is within that blacklist, it must reject it that request.
Notes:
When TeamA updates their blacklist, TeamB and all o... |
For reference, I am reading from "Game Engine Architecture 2nd Edition" by Jason Gregory.
Although I understand the theory behind Stack Allocators, I am having trouble implementing it fully. The book goes over Stack-Based Allocators and here is what I have so far in terms of code.
Memory.h file:
#pragma once
#include <... |
Recently, I've been writing a wav writer in C. For this question of mine, Let's consider two wav files that we'll be combining the samples; both are s16le mono wav files to be simple.
The first idea that struck in my mind for combining the samples of this wav files was just adding them together.
To illustrate it, here'... |
I've got a project where I have several implementations which are stateless and should provide the same results for the same input (but use different internal APIs) and need therefore be tested to deliver equal results for equal inputs no matter which implementation is used.
Imagine something like
class TripleByMultipl... |
This has really nothing to do with MVC but I came across the issue and also found a related question in that context. Unfortunately the related question fell short of describing where the LSP violation occurs in its original example and thus did not produce a satisfactory answer.
Suppose we have an MVC (or any other) f... |
In one of my projects I saw wrapping the expected results as a static variable in non static class. The reason for doing so is to make the code more readable, so that the massive expected result model wont clutter the code. From my point of view this is a code smell because
The expected result is not a good candidate ... |
I'm not sure that I'm even asking the right question so I hope you guys can point me in the right direction here.
I have a full stack web app which has listings (think eBay, Gumtree, Craigslist) and I want to implement functionality which allows for featured or premium listings.
The best way I thought to implement this... |
I am not clear on the usage of diagrams in the requirements engineering and design stages of the project. I assume the design stage follows the requirements engineering stage in the life cycle. I further assume SRS is the output of requirements engineering.
I have noticed people use various diagrams in SRS, for example... |
Currently my code makes a series of updates to some resource via a REST API but I also have some "rollback" logic that basically updates the resource to its original state before my updates if some kind of error happened. So in psuedo-code, the logic looks like:
public void doUpdate(Resource r) {
// do a GET to get ... |
I have a multiple files (one per CountryCode) which all get ~5000 entries added to it per day.
Each entry in the file looks like (256chars max):
{countryCode_customerId:{"ownerId": "PDXService","notificationId": "0123456789-abcdef","requestDate": "1970-01-01T00:00:00Z","retentionDate": "2020-08-13T14:02:35Z"}}
My API ... |
I have a dictionary in the form of Dictionary<int, List<int>>
The problem is that I need to group the keys together into buckets defined by the value (List<int>). It is easier to explain with an example.
Consider the dictionary:
{
1: [5,4]
2: [4]
3: [10]
}
Out of this, I need the dictionary:
{
5: [1]
... |
I have a rest api and a reactjs front end, in some cases, the api will send an error to the front end and I need to display that error. My app will support multiple languages, so the error must be translated, but what confuses me is how should I send that error so it can display the correct translation?
How should I do... |
I'm developing an Ionic 4 based (Angular) web application. It has a lot of logic on it and needs to store session specific data (such as a JWT, selected language, among other preferences and temporary settings).
But recently I've been working a lot on its security. The last piece I'm trying to sort out is removing ever... |
I'm new to JUnit/Mockito and to unit testing in general. I'm asking this question in order to get feedback and learn best practices/patterns/strategies.
I wrote a class but when came time to unit test I ran into issues because the class has a dependency on an external AWS DynamoDB. I re-wrote the class and implemented ... |
Let's say my software lets you place a square on the map and say "This is a good place to find Pokemon". I need this data to go to my gym leader's map, and to my friend's copy of Pokemon Go (through their API). If my gym leader moves the square to the east, his copy of the software needs to tell my copy about the new m... |
Every now and then I see someone delaying an action by a certain number of milliseconds to ensure it is working.
Something like:
doSomethingInHtml();
timer.schedule(100); // delay for 100 milliseconds to ensure stuff was rendered
doSomethingElse();
But, while it may work now, that 100 can either be too much, therefore... |
A common issue I run into when building CRUD applications is how to retrieve many-to-many relationships from the database and put them into an object model.
Say, for example, I have the following data structure:
customers:
- name: bob
items:
- chair
- hat
- name: steve
items:
- hat
... |
I'm currently building my first ever microservice using NodeJS, but I stumbled upon a problem.
TL;DR
~ How to ensure data consistency between 2 microservices while both having write permissions
Setup
I currently have 2 independent microservices: session & recovery
Session: Handles authentication (sign up, sign in, sig... |
A employer is looking for C programmers, and I'm told they say that ...
Good C design isn't the same as good C++ design
... and so they're looking for candidates experienced with C and not only C++.
How is the design of a large C system (hundreds of thousands or millions of lines of code) very different from that of ... |
I was looking at the angular documentation and noticed this code:
export class QuestionBase<T> {
value: T;
key: string;
label: string;
required: boolean;
order: number;
controlType: string;
type: string;
options: {key: string, value: string}[];
constructor(options: {
value?: T,
key?: stri... |
Suppose we have a layered architecture like onion architecture or clean architecture with three modules representing each layer:
domain.py
usecase.py
databaseadapter.py
The domain layer contains the business logic, so i have functions, which transforms data:
in usecase.py we have:
domain.call_business_logic()
domain.c... |
I have a PHP closure defined as function () use ($contents) { return $contents; }. It's like a value object except it's a closure. Is there a name for this?
|
I have a system in development and part of the system is how permissions are handled, business logic rules for this are very complex so after lots of trials, we couldn't fit them directly in the database and I came up with the following model (the structure is very simplified of course):
Table [OperationType]
Id | N... |
Recently I have started working on a project in which we are using Cassandra. It's a quite a new project, so we haven't decided how to initialize the schema.
We are using Docker and Kubernetes. I've read many articles stating a good solution is to load required scripts to Docker container to entrypoint.d (if there is o... |
In chapter 4 of the Zone JS primer the following is mentioned:
So far, we have discussed how zones are created, forked and how they maintain their state across asynchronous operations. Zones are nested at runtime in the same way that execution stack frames are nested (but usually with lower depth.) There is one zone w... |
I am trying to setup a multi-region (global) AWS system, where each region (which has multiple availability zones) has its own VPC. In theory these VPCs all use different portions of the private IP address space so they can communicate with each other internally. But the question is, does every VPC need to be connected... |
I know that the inode points to the actual disk blocks in the case of the normal file system. But what does it point to in the case of .... say .... the terminal device file. Does it point to the terminal device driver?
|
When it comes to name things like if, else, or return, many developers and a lot of documentation calls it control flow or control flow statements.
https://docs.oracle.com/javase/tutorial/java/nutsandbolts/flow.html
On the other hand, some developers and some documentation calls it flow control and flow control state... |
I have been reading the AWS documentation for a solid 2 weeks, and configuring a terraform system to deploy a multi-region network. I have it mostly wired up, but I am not sure I have accounted for all the pieces in the system. I would like to ask if the system or "recipe" I am about to outline is wired up correctly fr... |
Say you were to develop a REST API that provides access to a set of complex, long-running, operations.
The typical paradigm for an API like this (as I understand it) usually involves (the client) making a request to the server, asking it to perform a given long-running operation. The server will respond with a 202 Acce... |
I have been debating with my colleagues about the following and we still did not reach consensus.
The architecture is as follows:
medium size monolith application for intranet usage
a small application that features a SPA and a Web API which allows some folks to fill in some tests (Internet)
both applications use th... |
I have a data synchronisation concurrent algorithm. It does the following: get data and files from server, send data and files to server, save them to database / filesystem. Imagine the system like this:
You have 1000 functions. Each one does some atomic operation. For instance, fetch latest objects of type X and inse... |
In our organization we're looking to adopt a service oriented architecture where new requirements (that are natural bounded contexts) are being built as separate services that integrate into the main monolith as APIs & sometimes frontends as well (iframes today, we'll use some form of webcomponents later on).
Today our... |
I'm thinking of creating a system which would help me transfer the output of my bash terminal to an app in a remote device(like my Android smartphone).
I was thinking of tackling this problem as just a read and write problem on two ends of a Socket with the Server running in my machine and Client in my phone. But the p... |
I want to write a Node CLI that leaves a server/daemon running in the background, so subsequent calls to the CLI are much faster, as it can just print the latest info from the daemon (which is already primed with info as it's been watching the filesystem).
My purpose is not type-checking, but the CLI architecture I wan... |
I have a website where new requirement came up where user can download a zip file of 500MB from the server. I am expecting max 10 concurrent users(CU) will be performing this activity . Webservers contains the files on same server.
Current stats : Currently server 60 request per sescond with 99 percentile served with ... |
What are the drawbacks of sharing immutable state between actors in a non-clustered system?
It's clear as to why a mutable shared state works against a lot of the guarantees that the actor model provides, but what if that state is immutable? In our case, we have a large dataset which needs to be readily available in me... |
nalzok posted an interesting question over a year ago: "Why not use SQL instead of GraphQL?".
Respondents seem to suggest three main problems:
One should not directly expose one's database to external users.
SQL is too powerful to allow external users to have direct access.
This exposes the internal structure of one's... |
I have a web application with an express/node backend using typeorm and PostgreSQL. The home page in my app is a query with lots of inner joins that shows the user a complex report. This query takes about 30 seconds to run which is a bad experience.
I could easily add caching with a ttl value, but that has 2 problems. ... |
When it comes to using an LR parser generated by a tool, such as Bison, a disadvantage that often comes up as counterarguments is that the resulting parser will be unreadable and complicated to debug, which is true.
However, I don't really understand this argument since we just use one or two functions in the generated... |
I have a website that is based around some external APIs related to a certain theme. It combines data of responses from multiple APIs before returning to the frontend.
With that said, my server side does not have a database. Instead, it requests data from the external APIs, and returns things to the frontend, without p... |
I believe extensive automated unit tests should be part of the build. However the testing pyramid suggests that there should be a much smaller number of system tests.
Should an automatic build include a large number of system tests?
When you have automated system tests that are long running and flaky due to network and... |
I'm developing real-time chat functionality as part of an application. As per my initial structure I had 3 Domain Objects as part of this new context:
Thread (aggregate root)
ThreadMessage (entity, part of the Thread aggregate as a collection; has a ParticipantId to know it's sender)
ThreadParticipant (entity, part of... |
I noticed a pattern in my code, where im repeating a solid amount of code.
Let's say my application has 2 layers. UI and Services.
I have a FileService class, that has a CopyTo method. Now there are 2 things that can commonly go wrong. First the file already exists in the destination, second the file is already in use ... |
I am currently researching existing authentication/authorization solution that are used for REST APIs. More specifically I'm interested in backend-to-backend interactions but client-to-backend is relevant too.
I looked at few existing solutions and how existing services manage this. It looks like in many cases using JW... |
We have an API platform which allows user to create and manage a certain type resource.
Client is expected to provide a callback url where our server will send notification to when the resource is updated.
So far all our notification types don't require any response from client. However, we plan to have a new type of n... |
Sorry if my question sounds general, I'm new to GUI and frontend/backend ideas and all that (mostly I just do scripts for math hw and such) but I make it more specific here. I have a program that runs through various processes (A -> B -> C -> etc), where each process depends on different user inputs. So here's what I t... |
I have the following situation:
class User
{
public Thing curThing;
}
//each thing can only belong to one user at a time
//And vice versa
class Thing
{
public User curUser;
}
The curThing and curUser references need to match for a given pair. In some places in the code I... |
I hear this term from time to time but haven't found any well defined precise technical definitions posted online. They all seem to use the notion as if the term scoped has been defined elsewhere.
I roughly understand it as logging which includes context identifiers that map to the stacktrace where the log records pair... |
It is often useful to document when (i.e. in which versions) a feature was added, marked as deprecated, etc. For example:
Function FooBar(x, y, z)
Foos x with y and bars them with z.
(Parameter z was added in version 1.2)
I'm wondering when and how those notices are best added, and I can think of two alternatives:
W... |
I'm trying to write unit tests for business logic classes I have control on, but which operates over some services that are not designed with the testability in mind. Currently I’ve extracted the problematic services as constructor injected ones, but I still need to mock them during the arrange part of the tests. The a... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.