instruction stringlengths 34 36.1k |
|---|
I'm currently developing a bot for Discord that sends news over webhooks to multiple servers and I've decided to separate that news onto it's own microservice because the bot runs multiple instances of itself so that means this would run multiple times as well (while I could theoretically just tell it to launch on a sp... |
I have a Material class :
public class Material
{
public string Name { get; private set; }
public double Density { get; private set; }
public double SpecificHeat { get; private set; }
public double Conductivity { get; private set; }
public Material(string name, double d, double c, double l)
{
N... |
I'm working on an application that contains a central class, called Engine, made of different sub-modules (classes), where each module is responsible for a specific functionality. Those modules are private in the engine class, and the engine class itself exposes their work through some public methods. For example:
clas... |
I have a Kafka topic providing events of the following type: id(hash):[ADD|REMOVE].
These events may be generated at a high rate and are idempotent, i.e. getting 123:ADD one time and ten times in a row produces the same result: state of 123 is ADDED
Processing of each event may take a while (not hours, but seconds).
P... |
I have one microservice (in GO) that needs to read a whole table every hour, filter out some data and send it to another application.
So as an example, imagine I have the following model:
type User struct {
ID uuid.UUID
Name string
Surname string
Birthdate time.Time
}
And I need to read all the users of the ta... |
A simplified version of my code looks like this:
def process( object ):
try:
if suitedForA( object ):
try:
methodA( object )
except:
methodB( object )
else:
# we would get a bad result from methodA()
methodB( object )
... |
I have a transmitter class which contains raw data which represents physical values (double and int). These values should be taken by a receiver class to display them with logs (string) sorted according to the physical values.
Maybe I think too much but I don't know in which class I should process the data.
If I create... |
My website deals with states, which contain regions. So there will be a page called /states that lists states, and if you click on one, you get /state/{id}.
Note 1: This is not a REST endpoint, but an actual web page where you view the state info with a nice UI.
Note 2: I'm not concerned about the id's in the url. The ... |
I am trying to wrap my head around the concepts of Clean Architecture, and specifically about the responsibility of the Infrastructure layer. Its purpose is often described as "to provide functionality to access external systems", which is a bit vague when you try to think deeply about it.
Consider this example. Let's ... |
I read a talk entitled "Deep C (and C++)" by Olve Maudal and Jon Jagger. I paste the relevant code and quote below, but here is the link to the slides.
On slide 349, the presenters show this C++ code snippet which deliberately contains issues:
#include "B.hpp"
class A {
public:
A(int sz) { sz_ = sz; v = new B[sz_]... |
When modeling classes I always have stumbled on the problem that the class has a field with the same name. Look at this example:
class Name {
string meaning;
string language;
string name; //the actual name
}
As you can see, the class Name has a field name, which is the actual name. Is this good practice?... |
I have an angular based SPA, and backend resource server is written in springboot. I have integrated keycloak to provide OIDC support. Currently the app talks to auth server for login, (supplies credentials) and gets a token, which is uses further to access resource server APIs. But I don't want end users to be aware o... |
This sounds like a newbie's question, but please bear with me. I have 10+ years of commercial software development experience, and I still don't know how to do this properly.
I'm working on a pet project that's taking me months to think through all the subtleties. The actual code will be a small amount, maybe 10K LOC, ... |
See: Type inference with duck typing - does this work? Why is it not used?
And: General approach for proving decidability/undecidability
Hello, I wanted to ask a theoretical question about type system conversion. The proposition is to suggest or complete static typing for gradually typed languages (or dialects / transp... |
I was going through the source code of an existing project and totally confused about one implementation. The project is created in .Net 6 and it's a frontend MVC project. It's part of a microservice project and data is coming through an API.
Now the thing is, there is a generic class written for API access and it has ... |
CONTEXT
My project is about implementing the "conventional method for house-energy-efficiency assessment" in France (120 pages). I want to provide a strict yet easy to use API to this method. At first, the audience will be engineers that are not programmers but have basic knowledge in C# to consume such an API inside t... |
Here I'm working in Python, but it's more of a language agnostic question, unless specific language features makes it clear that an option is better than the other.
I get my raw data from a REST API, and need to do many operations with it.
tc_builds_by_agent = [
{
'agent_id': agent_id["id"],
... |
When in the refactoring step of a TDD process, if we "factor out" some common functionality from two (or more) code modules, how do we avoid that "factored out" code not being properly covered by unit tests?
Here is a toy example to illustrate what I mean. Since it is a toy example, the factored-out code is very small... |
I am going through this nice write up on thoughtworks about inheritance vs composition. I understood the authors explanation of the dual purpose of inheritance. But, I am confused on the specific details about "dimensions".
When you have a situation where either composition or inheritance will
work, consider splitting... |
Suppose there is a flow of functions in C++
step1();
step2();
step3();
step4();
step5();
and they interact by adding and modifying data on a data class D (only data, no functions). For example, step1() creates d in D, step2() modifies d, and step5() uses d.
The problem with this design is that at a given step function... |
I'm designing a web application for image analysis using AI. My API for CRUD operations is written in Django. Now I want to add the AI functionality which loads the model once on the startup, receives images, and returns the results. In the future, it would also allow for annotating data and fine-tuning the models.
Fir... |
For example, A system can accept a description of a symbol as "black-heart" or "heart-black". As far as this system is concerned, both description are valid.
Is there a computer science terminology or math concept for the existence of multiple, equivalent codes/representations of a concept/object?
|
I know that as a general rule, you shouldn't construct SQL queries dynamically because of the possibility of SQL injection.
However, it could come in quite handy to break this rule and define for example my SELECT statements like so and use it for all my tables:
public static string SelectAll<T>() => $"SELECT * FROM {t... |
I've been searching the internet and I can't find a good question to this so I believe I have a fundamental misunderstanding on what they are.
Is the only difference that in gitflow there is a release branch for your "not released yet" changes and in trunk based there isn't one?
Because for either method, you are going... |
From what I understand from this answer, it is not possible to use a typeddict and typechecking in a function. So for example, if one has a function:
def some_func(some_int: int, some_dict:Custom_typed_dict) -> str:
"""
Takes a value from dict and adds it to some_int and converts
the result into a string.
... |
I work for a supplier of software solutions, and when we want to deliver our solutions to the network of a customer, we are forced to use a myriad of tools: VPN connection over GlobalProtect, VPN connection over PulseSecure or another FortiClient, ...
Edit: it's the idea that we deliver support to our customers, while ... |
I have a UI for a tool with a fair amount of user interaction.
Imagine a sports tournament predictor where you select which team will finish 1st in the group, 2nd in the group etc., with the winners of each group progressing to the quarter finals and so on. The user's task is to predict who finishes where. The user can... |
Not 100% a coding question, more around developer productivity.
I work in Data Science, meaning a lot of my day is spent reading some data, manipulating it, making some charts, training some models, evaluating them, etc...
I'm proud to say the code we are using is very optimized (files are saved in parquet, all manipul... |
There has been a change in the project I am working on.
Until today, there was only one type of user in the system.
From the moment you logged in, you had all the information about the user.
The new change we need to make is to support several types of users.
Some types of users have information about them, and some do... |
I'm interested in understanding, conceptually (e.g., similar to how many of the concepts in networking are explained in textbooks like Tanenbaum's Computer Networks, or Kurose's Computer Networking), how a virtual private server (VPS) processes an incoming packet with data conceptually and it is mapped to my virtual in... |
I recently took on a long ago python project which has some weird code style that I can't pinpoint. e.g.
# this is a params and value package?
opts={
infile="xxx",
outfile="xxx"
}
def parses():
with open(opts['infile'], 'r') as f:
#do something here and get a parased_object
opts['infile2']=parased... |
I have three services, each of which has its own databases
User information table located in service one database.
The membership table located in the database of Service Two, which specifies which company the user belongs to.
The table of financial information that is located in the database of
Service Three.
The ch... |
I have an embedded system running on a little-endian Cortex-M3. This system is able to accept packets from the network and reply to them. Now, I would like the system to start generating files. These files will then be downloaded and inspected with tools running on regular x86 desktop computers (i.e. also little endian... |
In the simplest case, I have some code where the user may want to do one thing (a), another thing, (b), or both (a+b).
The options are reasonably complex and have their own functions, but I would like an elegant way of executing one, the other, or multiple.
I want to consider the types of the choices supplied, as I thi... |
I want to run a complex algorithm consisting of many subtasks in parallel on a number of processors. These subtasks depend on one another, so that this algorithm is characterized by a DAG (Directed Acyclic Graph) of subtasks. An arrow from A to B in the DAG means that subtask A must be completed before subtask B starts... |
We're dealing with a lot of "data analysis", basically different sorts of data mangling, aggregations and calculations using Pandas. Usually, the data is time series data.
All underlying data is stored in a SQL database.
As of now, we usually wrap all data access logic into a single "DBWrapper" class that implements me... |
I am currently seeking a solution to run sanity tests on my GitLab repos architecture. There are more than 20 repos in a GitLab group.
My idea is to create a "Health Check Repo" (HCR) that would do several health checks on all these repos. For example:
verify that for all the branches whose names respect "branch_v[num... |
I'm finding myself in a situation where I need to define common behaviour and implement it depending on the environment (minecraft server or javafx runtime). The simple graph below describes my idea.
Maybe a few more notes to get the big picture.
A user starts the gui module and makes some changes to the default setti... |
Question Background
Consider a scenario in which I have two structs. Both consist of three fields for doubles. The only difference is the names used to refer to these fields. The first struct is for non-descript Tuples and the components are to be named x, y, and z. The second struct is for RGB values and the component... |
We are doing a mobile app development and currently, we have Dev - UAT - Staging - Main branches.
We branch from the Main branch as feature/fA for feature development.
We do our development in that branch and when it is done, we create a merge request to the Dev branch. We go on with the tests and create a new merge re... |
I want to build a web application with a Single Page Application as the front end and an API as the back end. The front-end SPA will read and write data to the API.
The SPA and the API will be hosted on two different domains:
SPA: https://my-spa.com
API: https://my-api.com
The API needs to be private so only authenti... |
I have scheduling requirements where I place all my schedules in SQL db and then use the azure function every minute to read that database. When the schedule is met, I then perform a durable function for that schedule.
This causes a lot of Azure Functions to be invoked, and CPU usage also increases as this is continuou... |
I have an index file that uses three main JS classes each defining one method. The JS application is about listing a folder datasets, deleting a dataset from that folder, or uploading a dataset from the same folder. As i defined a class containing one method for each of these functionalities that i use in the Index.js ... |
Recently we have this client who asks for a API Gateway solution, in this case it’s Kong. Currently, they have 10 services (200 APIs) that are running on really legacy stuff (built with C++ and Fortran). It’s a pain for third party to integrate, hence they ask for API Gateway as a front to handle authentication, rate l... |
Python is one of the few languages to support a string data type of code points (Unicode Scalar Values). I'm also wanting to creating a language that has this same characteristic, but I need to understand how Python optimizes such representation.
There is a PEP about this: https://peps.python.org/pep-0393/ But I don't ... |
I am new to Azure Function App. I am using a consumption plan.
Does it make a difference how many functions are in a Function App?
What about if there are functions, such as the service bus triggered function, which is no longer called? Should these be deleted?
For example, I have MyFunctionApp
It has an IoT Hub Trigge... |
I'm sorry, no good title.
I'm working on a C project right now and am writing tests. I usually do a 'struct method' style of programming. So I have opaque structs (no implementation revealed outside of the .c file) and methods that act on pointers to them. But this applies to OOP as well.
Typically, when I am unit tes... |
In a Microsoft Learn article on MVVM there is an, what I assume, UML diagram that didn't make sense to me. (https://learn.microsoft.com/en-us/archive/msdn-magazine/2009/february/patterns-wpf-apps-with-the-model-view-viewmodel-design-pattern)
I do not understand what is meant with the double arrow means. I couldn't fin... |
If streams in programming is about reading data in chunks, how then is it possible to process the data in the scenarios where the data cannot be processed bit by bit, but the processing logic needs the full data?
I can imagine in some cases it might be possible to process data bit by bit, but it is not hard to imagine ... |
Context:
I am working on an application which loads a cache on startup - periodically refreshed. However it turns out that this cache is something which is very general and can be used by other applications as well. Currently as a work around other applications are using rest commands on this application to fetch data ... |
I am trying to create a spell casting system for an auto chess game.
I find myself not knowing which direction to go in my design. I started out with a Spell as a scriptable object that contains a list of spell effects (damage, heal, etc). Each effect can spawn a game object (usually some sort of particle effect) to in... |
I wanted to know the best practice(s) for ensuring scalability while passing arguments.
Say, in version 1.0 of an application, the foo function looks like this
void foo(int i)
Now, in version 1.1, the function has to be changed to
void foo(int i, bool enablethis=true)
Version 1.2 forces me to change the function to
v... |
I'm working on a project that requires the use of verifiable credentials, and I'm looking to build a wallet that can store and manage these credentials according to the W3C standard. However, I'm trying to avoid using a blockchain for this purpose. Are there any alternative technologies or approaches that I could use t... |
What are the most efficient and low-latency approaches for sharing data between threads in a C++ system, and why? My primary concern is minimizing latency and maximizing performance, as I have two threads that are each pinned to their own core: a thread that builds an orderbook snapshot and a thread that reads the snap... |
I was developing a new API, and some doubts appears about context of payload data. Example:
{
"transaction_id": 123,
"transaction_date": "2022-12-25",
"user_id": 999,
"user_some_data: ...
}
VS
{
"transaction": {
"id": 123,
"date": "2022-12-25"
},
"user": {
"id": 999,
"some_data: ...
}
... |
I'm making a class diagram for my school project, an Inventory Management System. So far, I've made the use-case and activity diagrams, however, I'm struggling with the class diagram and mostly because of this one thing (stated in the title). Here's my diagram so far:
See how I use the same string "products" in Manufa... |
I'm working on an npm package, and I'm kind of new to this. I published version 0.1.0, but when I did, I saw that there was a bug that broke the entire package. I do not think that it is right to make a patch (v0.1.1) because that will leave v0.1.0 useless. (Or maybe I'm wrong?)
My question is: What's the best professi... |
I've got a file in my includes folder, which is the folder I expose, that isn't used externally and isn't supposed to be used too. When I noticed that and tried to remove it - I noticed that it's included in another file in the includes folder - the interface. So, removing this file won't solve anything because it'll b... |
I have a task that is to convert cable schedules into an Excel spreadsheet. I have tried a few different OCR (Optical Character Recognition) things such as websites, code in R (tesseract), javascript, data from picture in excel and looked into C.
So far none of these have worked. I believe the main 3 errors are that I ... |
I am working on a mobile application, and I want to plan a separation between the model layer that represents a user (that comes from the server) and the "applicative" user that has the same fields but additional parameters. The goal is to make sure that a change in the model layer will not harm the applicative user.
O... |
I have seen Martin Fowler using the term "collaborators" as some sort of synonym of "dependencies". Unfortunately, Martin Fowler does not seem to define the term anywhere, so it is unclear whether he means this term to have a slightly different meaning from "dependencies".
Others use the term too, for example someone h... |
Arrays are stored in a linear fashion, with memory cells of fixed size for each element. To have fixed sized memory cells Arrays should be homogenious. So in Arrays we get an Nth element by skipping certain amount of bits (defined by element type) N times.
But what about lists? Or heterogenious arrays like we have in J... |
Note: This question is not about this particular instance of this grid with these exact words, but about any combination of words.
I am programming a puzzle game where you have to arrange a grid of words correctly. The image below shows a final grid.
The grid is represented by a two-dimensional string array and could l... |
I am looking to create a multi-page web app. I had begun the construction of this web app in angularJS when I realized this was no longer being supported. I am early enough in development that it isn't catastrophically bad to change my implementation language from angularJS (.js) to angular (.ts). Given the lack of sup... |
Having been trying to improve my unit tests, I'm trying to adhere to the principle of avoiding call verification. This is because it aligns with other principles I believe to be true:
We Should test the behaviour, not the implementation details of code (i.e. don't try to prove the code is written like the code is writ... |
Background
I have been attempting to create a line editor in C, eventually becoming a visual editor, and as a means of both allowing the editor to be useful but also learn more about C development, I would like to implement regex in the project, however, using a library I know (like C's regex library) would not satisfy... |
I like typescript, and I want to add it to some projects in the company.
Thing is, it is rather powerful, probably too powerful for it's own good at times.
From experience, it doesn't take long until someone who knows the type system just enough to be dangerous to define types and interfaces that are as complicated as ... |
I had a discussion with a colleague and we don't seem to be able to agree. Can someone help me understand his arguments?
Initial situation:
We have an adapter in our application which queries other internal services and constructs out of those request an object for our service. Currently every time we want to use this ... |
I am interested in robotics programming. HW control often involves calculating the derivative or integration of the signal. It seems quite inevitable to avoid local states for such calculation. (Since it must store past n signals).
The advantage of referential transparency seems attractive for the safe and reliable ope... |
I'm trying to develop a CRUD feature for an ASP.NET app that lets me manage customer information. Each customer can be subscribed to one or more services, and each service can have one or more terms.
I'm struggling with the same types of questions for both the frontend and the backend.
I'm trying to decide whether to m... |
I'm learning cqrs right now.
Problem
My concern is event ordering.
Assumption 1: user service is creating user and three events in order.
Each event was sent after each step was finished in write model.
Event A: user ABC created
Event B: changed email for user ABC to abc@mail
Event C: change email for user ABC to abc2... |
I have an distributed application that sends P2P messages parallel (for fault tolerance) across different channels.
This mandates an filter to avoid multiple receivement of the same message. Therfor I added an GUID as an unique ID on each message, before sending it across those channels.
While it works fine, I have som... |
So I'm building a client for a third API and I want to be able to Get() and GetMany() for each type this controller can provide.
So I've built this adapter, that provides generically typed methods for these.
public interface IClientAdapter<T>
{
public Task<T?> Get(string predicates = "");
public Task<List<T>?> ... |
I'm not sure if this is the correct area to ask this question, quite honestly, I'm not sure how to phrase the question because I don't know if what I'm thinking is possible.
I'm trying to figure out a better way to trigger third party API calls from an on Premise SQL Server database. Currently, there is a Python scrip... |
I am working on a compiler in TypeScript, and currently am focused on how to pass around the "lexical scope" to the relevant objects. Essentially every time there is a conceptual major branch in the code, there is a new lexical scope created and assigned to that AST node, pointing to its parent for parent variables.
mo... |
We've recently taken up DDD approach to design. Some of our developers are using the Aggregate pattern (https://martinfowler.com/bliki/DDD_Aggregate.html) but to me this sounds very similar to the well-known Model approach (from MVC).
Aggregate is a pattern in Domain-Driven Design. A DDD aggregate is a
cluster of doma... |
I'm using a REST API to retrieve data from my back end at my front end. I'd like to figure out which way of receiving data from the back end is the better one (= clean, robust, and best practiced).
There are the following two ways of retrieving data from the back end (the example code assumes the retrieval of some rese... |
Recently I had many problems opening old projects, which had all dependencies in package.json defined with ^ x.y.z. When I pull the code and run npm install the dependencies are installed but I will for sure have some problem with some package that is related to versions.
My question is if having a package.json like th... |
I'm experimenting with some projects at the moment and I am stuck trying to decide on the correct approach to this question.
Given a simple architecture like this consisting of
Domain - (Person and IPersonService)
public class Person
{
public string Name { get; set; }
public string PhoneNumber { get; set; }
pu... |
This problem is quite "a classic", but I can't find a good solution to it.
I am using CreateFile to open a file. Sometimes I would want it to be read-only, sometimes write-only and sometimes I would want the same file to support both read and write. Of course I would like to follow RAII principles.
I am trying to accom... |
In one of the project I am working on, I am facing a problem in terms of creating an object with a dependency that sits at a deeper level in the class composition. Following diagram shows the class composition.
The problem I am facing is as follows:
The IFrameGrid object contains 'IBracings' object at a deeper level ... |
Multi threading could cause a racing condition if two threads are accessing the same memory slot, but why is that? From a HW point of view, if the two cores are designed the same, internal pipelines are the same, the logic gates/transistors pass electrons the same way and the speed of those electrons is a constant valu... |
Im not dealing with a x minute task that can use an message queue and some workers to be done. Lets say that i have an cctv camera that capture 24/7, but can be stopped or started again via Web API for example. In this example i can't just use normal task queue (like Bull in js or Celery in python) as each worker will ... |
I'm working on a microservices application that is implemented from the ground up with MediatR em CQRS. We have a list of domain events that will be published via MediatR [simple pub-sub library that implements a mediator to commands and events] as soon as a Command (CQRS) commits the database.
Let's imagine a new user... |
My question is regarding how would the developer know when you add interfaces/protocols to their code and inject them as dependency.
Consider an example of BudgetService.
protocol BudgetServiceProtocol {
func save(name: String, amount: Double) throws
}
class BudgetService: BudgetServiceProtocol {
private ... |
I am working on a program to automatically design heater units based on varying client specifications.
The process for creating each heater is quite involved and requires multiple optional steps depending on the type of the heater and it's options.
I am trying to figure out what the best way of creating heater objects ... |
We have an ongoing argument in our team. Please help. Here is the problem:
In our SPA web app, let's say we have a resource which can be edited by only those users who belong to the team of the user who created that resource.
Now, we are sending this resource to the multiple places in the frontend. At some of those pla... |
I was asked to write a use case diagram based on a description/scenario
and I got a little confused when designing this use case because I doubted a little whether it's a functional or non-functional requirement (because I'm specifying how, not what)
In my case, the user shall be able to add transactions manually or a... |
I've got this class:
[UsedImplicitly]
public class ClassicalKeplerian
{
public ClassicalKeplerian(Angle argumentOfPeriapsis, Angle inclination, UnitFraction eccentricity, Angle rightAscensionAscendingNode, Length semiMajorAxis, ReferenceFrame referenceFrame, Angle? trueAnomaly = null, DateTime? epoch = null)
{
... |
In a project I am doing, I have to perform a lot of repetitive checks at the beginning of each API end point. As the amount of duplicate code started to grow, I thought of using a decorator to wrap all of my api endpoint view functions, and to perform the checks there. This approach actually turned out to be useful for... |
Problem statement:
The information system of a university must manage information relating to its employees, departments,
institutes, courses provided, and research projects.
Information relating to employees includes the normal personal data (name, surname, date of birth,
...).
Employees are divided into researchers, ... |
Let's say I need a queue for my project and the language I use does not have a built-in queue structure. So I decided to implement one myself.
So I create an object with elements positions as the object's keys. I also keep track of where the head and the tail of my queue are. I increment and decriment those values when... |
I am new to Kafka, trying to do a project. Wanted to do it as it would be in real life example, but I am kinda confused. While searching thru the internet I found that if I want to have 3 brokers and 3 zookeepers, to provide replication factor = 2 and quorum, I need 6 EC2 instances. I am looking thru youtube to find so... |
Assuming I wanted to implement the Database per Service pattern or one of its related patterns like Private-Tables-, Schema- or Database-server-per-service (https://microservices.io/patterns/data/database-per-service.html) for microservices: How do I go about this if I want to run the databases in Kubernetes and not wi... |
We would like to differentiate (by HTTP status codes) between correct request but the requested resource is missing or deleted and resource not found because of invalid request (URI).
For example:
/api/non-existent-api-because-mispelled-path which returns 404 because the URI doesn't exist.
And
/api/my-awesome-api/{id} ... |
I have a service which is used to register tasks. These tasks are asynchronous and executed in background using a state management engine.
The state management engine is running inside the service and it is executing 4 concurrent tasks at a time. I have an algorithm to auto-scale the service based on the number of task... |
Goal: I am learning about SOLID principles and trying to refactor Gilded Rose code, in order to make it fresh and clean.
What I have done: I have created an AbstractItem class as follows, which "wraps" Item class:
public abstract class AbstractItem {
protected static final int MIN_QUALITY = 0;
protected static ... |
The article "Products over Projects" by Sriram Narayan makes the case for treating projects as products.
I can see many benefits to this and would be my preferable methodology, but the examples of 'projects' referenced in this article seem to be 'almost' products already in that they are delivering shared components th... |
I'm working on a HR application that has employee management and access control.
We decided to go with these bounded contexts:
Employee management: manage employees information, like name, contract, birthdate etc
Access control: manage whether an employee can get into the facility, in which case we upload his or her f... |
There are few reliable absolutes in this world. One I have relied on is the idea that checking if a file exists before doing something with it just creates an unwanted race condition. Meaning between the check and the attempt at usage, the OS was free to do whatever it liked with the file. So I had no right to expect a... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.