instruction stringlengths 34 36.1k |
|---|
Upon generating an entity-relationship diagram of my database I observed several occurrence like this:
This diagram (in IDEF1X notation) shows the following:
Our team's DB convention is that each primary table (i.e., not an association-type table) has its own unique primary key called db_id.
iam_projects.db_id is a f... |
I am looking for a way to handle errors in a Node.js application without getting lots of log entries for the same error event, one from each each affected layer.
This might actually apply to any language, but I still don't understand how to do it correctly. The questions are always who handles the errors, does it make ... |
Sorry if this is broad. But I'm confused on how to scale a file system.
I'm currently working on the server side of a webapp with Node(Express)js, its file system module, and mongoDB.
I'm storing images locally right now but don't understand where these would be stored in production. Are there dedicated cloud file se... |
I am midway through my software development project in Node.js and have encountered a fork in the road. I need to create a "database" or a JSON file, that will automatically delete an entry after it has been in for X amount of seconds. An entry is simply just a random string.
Should I use JSON and write an asynchronous... |
I am a theoretical computer scientist. I have heard the following:
Practitioners do not like randomized algorithms because they are notoriously difficult to debug. So deterministic algorithms are much more preferred.
How true is this statement? If you have can provide examples or counter-examples that would be great... |
I am building a scrabble game, and I have already a dictionary working.
When the user will place letters on grid, I need to check that all the words are valid. Which algorithm can I use or how can I go through each cell of that grid to validate which are words in an efficient way ?
I tried googling but most of search r... |
I have been looking for a good, general design pattern to implement simple mathematical structures where functions have the following properties:
know which parameters they contain, parameters are "fixed"
can be called with variable values as arguments
are defined in terms of other functions, which have the same prope... |
I am designing an E-R Diagram for a simple system where there are some users and contests. A user can create a contest or invite other users to the contest who can decide to accept or not.
I am wondering if it is possible to model this in an E-R using a recursive diagram since a user can invite an other user mixed toge... |
I'm not sure if this is the right way to build React components.
I have a component with several buttons that call different functions in the component. In some of the functions I need to display some extra GUI (inputs, etc.). In vanilla JS I could just do this by creating the elements (document.createElement….) and a... |
When developing a somewhat larger application, with 3-4 screens or so, what is the most common way to organise the code?
I've read that organize-by-feature trumps organize-by-type, so I was considering a structure like so:
xyz/Feature1/
+ feature.pro
+ api/f1/header1.h
+ src/f1.cpp
...
xyz/Feature2/
+ feature... |
I'm working on a Kafka consumer in C# (using the Confluent C# lib).. and practically all of the documentation/examples online leverage console apps to do the consuming.
So, this is fine for logic validation and general playing about but clearly not suitable for a production workload. Is there a recommended deployment m... |
I have a JSON object of arbitrary complexity, representing several entities (not my design choice). I want to partially persist it, only for the changed entities. What would be the best way to mark the parts of it that I will update? (Think "dirty bit"). The JSON will be passed around several microservices (again, not ... |
I'm trying to build a C# application that sends notifications from the server to its users (a mobile app).
Since each user can have its notifications collection changed by any thread, I have to lock those collections whenever somebody tries to read/add/delete a notification.
The problem I think that I might face if the... |
I'm working on a relatively thin front-end web application that talks to an API. Depending on where this front-end application is served from (CI server, staging server, production server, etc.) I want it to be configured to talk to a different API server.
We're not really a web shop, so we're all inexperienced with th... |
We have a scenario in which all the important and transactional fields of our business entities are highly structured and relational. The data size of these important fields is also very small. However, there is a raw JSON associated with each entity that is very rarely updated (only in exceptional cases). However, mos... |
I'm using ReactJS (React Hooks, specifically) to build an application. Part of that application involves account creation, sign-in, and authentication. I only recently finished the sign-in feature, and I noticed that while all my components have access to the JWS/JWT, only my SignIn component has a state for whether yo... |
I organize my Git projects based on the article A successful Git branching model. The problem is that I don't know how to handle the following case:
develop: working on a major app redesign (taking ~6 months)
master: current production version
However, because we access paid customizations (from enterprise customers)... |
I have an API that charges for an order. It accepts the orderId and the amount as inputs. Then it makes a '/charge' call to the downstream, which returns a 202. Immediately after this call, it calls a '/verify' endpoint to make sure that the previous charge was successful.
Now it may happen that the charge was declined... |
It seems as though in software engineering, we care more about these "on and off switch" usages of binary numbers more than the actual values of them numbers... For example, say I have the number:
1011
The "value" of this number is decimal 11.
Likewise:
1001 0110 - Value is decimal 150
However, with bit manipulation te... |
I want to understand the difference between AWS Elasticsearch service vs on-premise version. Does AWS provides a fully managed service for Elasticsearch (like DynamoDB, SQS etc) Do we have to manage at the node level and ensure that Elasticsearch has proper configuration for production kind of environment?
Appreciate y... |
I have an API that return list of Employee. This API will have an offset and limit for pagination purpose.
On the frontend, I use Single-Page Framework (Vue/Angular/React..). This SPA have a Employee List Page that can create new Employee using AJAX.
And now the question, :
Should I return only OK message when server... |
Every time I'm working on an SPA with an API backend I always find myself wondering the best way to do this. The current example I'm running into is as follows:
When a User has their account created for them (by an admin user), they are sent a welcome email. I want the ability to re-send this welcome email, but only if... |
Suppose I have the following methods:
def read(file: str) -> List[str]:
temp = []
with open(file) as f_obj:
for line in f_obj:
temp.append(line)
return temp
def append_items_to_list(folders : List[str], file: str):
with open(file) as f_obj:
for line in f_obj:
fo... |
When we are inserting into a self-balancing tree, can we also assume it is sorting itself using those same operations? Or rather is there a traversal method that gets us the elements as a sorted list?
|
I'm looking for a way to manage constant strings in a Rust project. The hope is to manage my strings from a single file and avoid having the same string literals all over the place in the project.
Would the "Rust" way of doing this be to create something like constants.rs which would include my strings, something like.... |
Suppose you have a list of about 50 items that are already sorted and you add three items either to the end of the list or somewhere unsorted into the middle. Now you want to re-sort the list with the fewest possible comparisons. Which sorting algorithm or data structure would you use?
Context
I'm writing an online ... |
I'm fairly new to programming. At school I am currently learning to program with Java. I want to build an application where i can store my collection of books, records, boardgames and such. Started making an class diagram to get me started and when that was finished started programming. I have an Artikel class which is... |
I am developing a Micro Service which is going to be called/used internally. I'm trying to improve error handling, but got confused with two below approaches.
Having multiple exception classes for every layer (Business, Rest Client, Mapper etc)
Creating one general exception class with specific error codes (Business, ... |
While there are prescribed methodologies for the middle layer when it comes to transaction management like Saga pattern etc. I want to know what's the advice on handling such on a mobile application that's talking to payment related API's.
The use case is an app that's placing an order for some food, the card is alread... |
Let's imagine that I have an employee resource.
{
"id": 1,
"name": "John",
"role": "Office manager"
}
And I want an endpoint that promotes them. As part of that I want some side effects to happen, such as an email goes to HR.
How should I do this in a "restful" manner? Would the following be acceptable? And t... |
I am building a personal blog system. The system is more like a platform, means that not only the admin, but all registered users can post their blogs.
We've decided that using markdown as the blog's written language, thus we provides a markdown editor in the front end, and the editor will update in real time when the ... |
I'm trying out commanded framework for Elixir that implements event sourcing and CQRS (it have abstract structure of command, command middleware, router, aggregate, process manager, projection and event handler). I'm listening for changes in realtime database. Problem is that when RTDB or my service get offline, on rec... |
Over several years, a company developed a multi-disciplinary (firmware, software, hardware) product. No SRS (Software Requirements Specification) was ever written. A prospective customer now wants a SRS.
Any ideas how to approach writing one? Read the code? Write a user manual and convert it into requirements?
|
This is a general question but with a specific use case. There is only a single and completely unaffordable profiler for the Xamarin framework. So this makes me wonder if there are some programming methods to work around this?
Maybe something similar to debugging programs without a debugger - relying on console/file lo... |
I have worked with examples like a Player object which knows how to change its own state.
Another example, is an Invoice object which knew how to calculate its invoice charges using an algorithm.
Does this violate the single responsibility principle ?
If yes, then is creating an InvoiceCalculator be the right approach... |
I'm writing an IDE that will support many languages. I'd like to have a separate "version" of the IDE for each language, to avoid having a confusing number of seemingly unrelated features. I'd also like not to have to make the same change on multiple codebases if the change applies to all languages.
Is there any way t... |
I am trying to understand whether resources in a RESTFUL API should directly represent the underlying database or not. In particular, a problem that I have is that I usually use highly normalized databases. The result is that if my API always hyperlinks to the children of a parent resource then the network will be unma... |
In my work I frequently come across systems of interdependent equations. I have contrived a toy example as follows. The terminal values w, x, y and z are given:
e(y) = A+B
A(y) = x*log(y)+y^z
B(y) = alpha*y
alpha(y) = x*y+w
We could then consider the function e(y) as the root of an arithmetic tree with the following he... |
I've such microservice architecture as below. I want execution service to get some information from storage and assignment services. I want to use MVC App like an API Gateway and handle all microservice communication. However, that creates an overhead especially for big files since it first has to go to API gateway ove... |
Say you have 10-50 engineers working on a codebase. Everyone has different preferences for these types of things:
Folder Structure
Naming Conventions (CSS Class names, function names, variable names, etc.)
Testing Conventions
Expression location (where variables are defined within a file, etc.)
Encapsulation (should t... |
So, I came upon the code similar to the example below. One thing that bothered me about it was the fact that it's dependent on a Result object being created in the Application Service then passed down into the Domain Entities. This struck me as odd, as it's exposing parts of the domain. It's also receiving a parameter ... |
I've been reading a lot of material lately about DDD (business entity objects) and other common patterns in n-tiered(layered) architecture. One thing I have issue with is, most articles, blogs, examples, etc. seem to talk to only one aspect of a system. Some may talk about creating a BLL for containing business logic. ... |
I'm attempting to use the PIMPL idiom. This is my public header file in include/foo.h:
class FooPrivate;
class Foo {
public:
Foo();
~Foo();
private:
FooPrivate* p_impl;
};
The private class is defined in: src/foo_private.h and used throughout src/*.cpp:
class FooPrivate {
public:
...
... |
I am working on a project with a fixed deadline (there are financial penalties if we are late or drop any features).
We are late.
My project manager keeps asking if we can add people so we can get back on track.
According to Brook's Law and the Mythical Man Month,
Adding human resources to a late software project mak... |
I'm looking for valid measurements for the decision whether to implement a web application as SPA (Single Page Application) or MPA (Multi Page Application).
Which questions should be answered to get the right decision?
|
I work for a publishing company and we are making interactive software that accompanies our books. The problem is that many clients complain that the antivirus keeps deleting parts of the software, especially the .exe files.
Which is the best way to avoid this? By digitally signing the software? (I don't know if that's... |
I'm developing an application that manages many different components, including various objects in a Kubernetes cluster.
There's a nice Java library to manage K8S objects, I use it to examine objects and manipulate them, but for most of the objects, I need some kind of a "wrapper-object" to store certain internal data ... |
Say I am building a use case diagram, and there is a use case that asks for some user input (a phone number).
The requirements ask that the phone number be valid (there is an API that tests for this, in this hypothetical).
Must "validate phone number" appear in the diagram? Can it? Should it?
My impression is that it ... |
I want to take data from my goroutines and add them back to the main thread/goroutine. Problem is that I need the goroutines to stay open because data can come through the connection at any time in the program.
I can think of two ways to do it possibly...
Use channels somehow. I am not quite sure how to do it this wa... |
I am rewriting a lexer class that has several "parameters" like whitespaceSplit.
So it goes this way:
lexer = new Lexer();
lexer.whitespaceSplit = true;
lexer.otherParameter = ...;
lexer.parse(file);
The trouble is that a user of my library could change the parameters such as whitespaceSplit in the middle of the parsi... |
Here are some of the characteristics of my problem:
I must generate unique 64 bit timestamps across processes on a single machine. I am very much limited to those 64 bits. This seems to rule out using GUIDs as part of the solutioning.
Uniqueness is critical, monotonicity (across processes) is not as important.
It is c... |
In untyped languages (Python, Javascript specifically) find myself making a lot of bugs / wasting a lot of time because I forget what's in the objects I'm passing around. For example, I forget things like "is this property a string or an array of strings" (...the time I've spent debugging because I thought I was indexi... |
In the context of many devices being secured with their own symmetric key (think: thousands of IoT devices), is it reasonable to hold these secret keys in a MySQL database?
The goal is to verify the authenticity of devices; I'd like to hear from people with experience in security what their thoughts are.
|
I researched a lot about game loops but most of the explanations I found credible also stay at a high level. I still don't understand the functionality of the components in a game loop. Let's consider:
while gameIsRunning:
processInput/handleInput/...()
update()
render()
What is the difference between proc... |
My team and I are looking for a git workflow for demoing experimental changes/features in our web application before they are released. Our audience includes our project manager and designer -- people who we do not expect to run an instance of our app -- so we need to host the webserver as well.
In our first attempt, w... |
There is an initialization function in my app that does multiple inits. What is a good way to keep a track of inits done so that if init n fails all inits done before it must be cleaned up/de-init before exiting. Is there a good way this is usually handled?
|
Which is considered a generally accepted practice?
class Image {
public void decode();
};
//main
Image image;
image.decode();
vs
class ImageDecoder {
public Image run(Image image);
};
//main
Image image;
ImageDecoder decoder;
Image decoded = decoder.run(image);
In other words, are these "worker classes" that accept o... |
I am a java developer. Since one of our developers are leaving I was handed over a project he was maintaining. He says it is a node + angular js project. But as per my understanding, backend should be written in node js (just as we do java api development) and front end should be written in angular as a separate applic... |
I have read this below answer for SPA cons. In fact, I have faced some problems outlined.
https://stackoverflow.com/questions/21862054/single-page-application-advantages-and-disadvantages#answer-37443637
That is why I want to check i still taking the current path.
My question is more related to user authurization to an... |
Overview
If an application is being developed following a clean architecture / DDD approach, my understanding is that the application core or domain layer should contain classes and interfaces that directly model the business logic and represent concepts and events that the end user of the application understands and h... |
I am a software developer facing the following problem. Normally, I develop software and put client specific settings in a separate place (config file, database etc.). A new version of the software can therefore be installed by the client without losing those settings.
In my current project, the base is an external sta... |
I'm using VueJS and have data coming as json via web API. The API is strongly typed, but in my Vue component, I don't have a good way of knowing what the types being passed are.
Given the following:
export default {
data() {
return {
thisListOfThings:null,
thatListOfThings: null
... |
I read that Facebook's continuous integration environments are cut off from the internet for security and reliability reasons.
What would these reasons be? Is this a common practice?
|
What are some conventions for naming a variable in cases where the name of the variable ought to be identical to the name of the function? I'm using VB.Net.
I often have this problem when writing functions that either perform some mathematical operation, or generate an object. The return variable is declared inside the... |
A wrapper class for storing primitive parameters which are initialized with values. Is it better to use public static or private static with bunch of getters and setters, for these constants?
public class Wrapper {
// This
private static int PARAMETER = 100;
/**
* EDIT:
* public int getParameter();
* p... |
I was recently considering the difference between using raw SQL and using a query builder like knex.js for writing dynamic queries so that I get any level of granularity for filtering database tables.
Is it bad practice to allow for any level of granularity for user input in a REST API as long as I consider the implica... |
For my computer science uni project I'm required to build a web application with an integrated code editor. I believe I can just integrate open source editors like Ace Editor.
However, I feel blocked at this stage because I'm unsure what the next step should be. Say that the user enters some Python code that should be... |
I built a base/skeleton user-based web app. It just has sign up, log in, log out, forgot password, verify email address, etc. Now I can easily build user-based apps by developing on top of the base app. For example, I could build a social network or a message board.
But when I upgrade the base app how should the "child... |
I have been using singletons in the past.
However, reading articles like Singletons are Pathological Liars have led me to explore alternatives to singletons.
There are a few posts discussion alternatives such as:
So Singletons are bad, then what?
I am not able to get a concrete example on how to convert though.
Here i... |
I have a tree data structure where each node describes how to use its child nodes, and this tree is stored in a standard data format - XML for now. However, there are a large number of different kinds of nodes, and I shouldn't have to update the core code that reads in the XML and converts it to software objects every ... |
Is this a good code pattern in ASP.NET Core Razor Pages, for private methods to return IActionResult to the calling handler?
// Public handler
public IActionResult OnGet()
{
var result = SetupPage();
if (result != null)
return result;
// do some work
return Page();
}
// Private methods
priv... |
I want to build a small extension for major browsers that modifies the HTML and CSS of certain pages. On a desktop browser, this can be accomplished easily. On mobile browsers, however, content-modifying extensions are mostly not allowed. (In fact, extensions of any kind are mostly not allowed.) How might I achieve thi... |
I am looking at designing a Graph class, that should work for both lists and matrix.
For ex: something like,
class Graph {
public:
virtual ~Graph() = 0;
virtual bool AddEdge(int src, int dest)=0;
virtual int Size() = 0;
};
Now, I can have two derived classes(G_Matrix, G_AdjList), each of which implements... |
The DRY principle sometimes forces the programmers to write complex, hard-to-maintain functions/classes. Code like this has a tendency to become more complex and harder to maintain over time. Violating the KISS principle.
For example, when multiple functions needs to do something similar. The usual DRY solution is to w... |
I was reading about the history of Microsoft and Webforms. How people strayed away from Webforms because it mixes business logic with display/presentation logic. So when reading Angular 8, and seeing they are mixing web html with Business validation logic, doesn't this break SOLID principles and separation of concerns... |
If we decided to create a (TCP) socket-server (for example) on port 12336
imagine it like a:
socket.bind(12336)
and then to create a (TCP) client-socket for it, like a:
socket.connect("12.34.56.78", 12336)
Client-socket binds on port: (for example) 65123
Server-socket binds on port: 12336
Why we need to open port for... |
We work in a traveling company.
We sell tickets for domestic flights, international flights, trains, and buses.
Currently, each of these products has its own team members and they use different libraries/tools to develop their product on their own.
One team may use RabbitMQ as their message broker between its microse... |
I'm writing some tools to be used on the top a specific framework, in C#.
Most of my code should use the naming convention CompanyName.TechnologyName[.Feature][.Design], but I wonder if in some cases I should use the framework's namespace.
For example, there are some extension methods I'm implementing that make sense t... |
First of all, I am not a junior programmer. I'm just looking for best-practice.
How do you use entities and DTOs into your Spring Data JPA projects?
Assume there is our layers:
Repositories (as interface extended from JpaRepository)
Services (as Spring @Service-annotated beans)
Other code
And I have no problem in my... |
I'm creating a library, and I want there to be an abstract class called Optimizer. The user should be able to choose from a set of predefined Optimizers and if desired, use fluent methods to change certain fields.
Every Optimizer has a "learning rate", so I've defined learningRate as a field within that class as well ... |
I'm reading this article explaining the node_modules structure of pnpm.
https://pnpm.js.org/en/symlinked-node-modules-structure
It states next to the bolded text avoid circular symlinks that dependencies of packages are placed in the same folder in which the dependent packages are.
I get the next sentence it doesn't ma... |
I'm building an application which lets users view a large amount of data about a single single entity (lets say it displays a users health profile for the day) via a single webpage. The data comes from an external API in a single JSON response, which is requested when a user views a profile page.
I have no control over... |
If one wants to comply with the clean architecture principle 100%, they must not annotate the entities in the entities layer with database-specific annotations (like Hibernate, Neo4j, etc.). So, two options remain:
Creating a corresponding entity in the outer layer for each entity of the entities layer and putting ann... |
When declaring a member
class MyClass {
AnyClass<WithLong<Generic,Declaration>> myProp =
new AnyClass<WithLong<Generic,Declaration>>();
}
is quite redundant.
We may find the following, more concise, less noisy:
AnyClass<WithLong<Generic,Declaration>> value = new default();
// or
AnyClass<WithLong<Gener... |
As we know , initial state is the initial state of the system before the activity begins and the final state is the final state of the system when the activity ends. But what exactly is the initial and final state in activity diagram? I mean , for example , there supposed to be a text on the these elements to illustrat... |
Currently, we have multiple commands which share two same properties (BookName and ShopId). While handling those commands those properties must be validated with the help of some service. Let's say that those validating process is just a two lines of code.
Like this:
// Get book by name
var book = await _booksReposito... |
Let's say I have class Car (just for illustration)
class Car {
...
boolean isRed();
...
}
where to place methods which acts with objects of same class, in my example Car, but not just on that single instance of Car, rather on more - let's say 2 instances of same class (look following example).
boolean haveCar... |
OOP makes state reads and writes implicit. For instance, in Python:
class Foo:
def bar(self):
# This method may read and/or write any number of self.attributes.
# There is no way to know or limit what self state this method
# accesses and/or modifies.
Compared to:
def bar(qux, baz, flux):
... |
After learning about the data warehouse concepts whole day, I couldn't found a source that can actually say when you should not do data warehousing. In most tutorials I read, it says that DW is for getting data from various sources and have it in one place(simplifying).
But my problem is that I have a single database ... |
Since Apple introduced Catalyst ealier this year during WWDC '19 it becomes possible to have a single codebase for an app that runs on iPads and Macs.
Already for a long time it was possible to create iOS applications that run on both iPhones and iPads using the same app distribution. Obviously for such an app to look ... |
Our project's policy is to write unit tests for single classes only. All dependencies are mocked. Recently we've noticed that this approach makes us vulnerable in such cases:
Originally class A looks like this:
class A(val b: B) {
fun doSomething() {
b.doSomethingElse()
b.doSomethingElse2()
}
}
An... |
The theory is that access modifiers improve code safety because they support encapsulation of internal state. When doing OOP, every language I've used implements some kind of access restriction. I like some access models better than others.
I am on a team of Java developers. Our projects spend time in code reviews cons... |
I'm working on a winforms project that involves 3d models, Opengl graphics, hierarchical project files and uses an MVP approach. Currently i have things setup such that when the user manipulates objects the view is updated using events triggered by the object. For each object that is added to the hierarchy in e.g. a l... |
I'm having a architecture challenge. Simplified scenario:
We have a CRM-system (for now called This-Is-Our-CRM) that contains person data. We created a rest API so our data could be accessed outside of our own system.
Now our clients wants to be able to use the data available in This-Is-Our-CRM in multiple other applic... |
Suppose I have the following series of commits when using Git Flow
We have said that no new features will be included in the next release and have created a release branch (D). QA has started testing and has found a bug, which we have fixed (E).
QA conclude their testing, so we call the release done and merge back to ... |
I'm considering using the ELK stack for logging within our company. To comply with our data retention policy, we would like to anonymize data after one year so it cannot be traced back to an individual.
To automate the storage and anonymization: the following seems to me as the approach possible by ELK + ELK Extension... |
I have 2 "user" classes which are essentially the same except one is immutable without setters and one is mutable with setters. I have a separate factory for creating each object.
ImmutableUserDto - ImmutableUserDtoFactory
MutableUserDto -
MutableUserDtoFactory
Both factories take in an array of data and pass it to ... |
I am currently working on a problem that has a central controller that is handling inputs and outputs between various modules and maintaining a number of entity classes as these change. When working with getters and setters I can either provide raw values or I can provide one of the entity classes, and I'm curious how ... |
In every app, we are always getting requests that simply take data from a file and import them into the system or export from system to file/ftp etc. This is mostly used internally by the administrators. Basically they need a screen to enter some info, click a button and the import/export will be carried out.
The syste... |
I'm about to implement Error codes for my company API, so, based on rfc7807 I will include a type which is an error type which is basically an error category, and inside those categories we have a bunch of error codes, so, I'm stuck thinking/searching what's the best approach to follow, I mean, if i handle these error ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.