instruction stringlengths 34 36.1k |
|---|
In a server application, I have a class called Controller which receive the incoming request. I also have a class called Service which do business logic and a class called Database. All classes are "public", but only one of them is really reachable from the "outside", the Controller.
I am in a dilemma, should I only te... |
Say, for instance, I have this simple function in my domain layer:
function canCreateNewUsers (principal: User): boolean {
return principal.isSuperAdmin || principal.isAdmin // || ... a bunch of conditions
}
And this function has already been unit tested in my domain tests.
Now say I have another layer, the service ... |
Related (but different) question:
How do you dive into large code bases?
I have always worked on small projects where editing a piece of code is easy: you modify the code, you recompile and in a matter of seconds you can play around with the compiled program.
Everyday one may end up doing the "edit compile try" loop ... |
I am curious about it because I talked with a friend about the strategy pattern, and we diverge about when we have to use it.
Our scenario is that I have to build a view component with 3 variants. All variants have particular colors and ways to resolve the string content, and it is supposed never to change. We don't kn... |
I'm working on an application implemented in different microservices, which uses a message broker (event bus) to consume events (simple pub/sub).
As for now, in a given microservice, we are spawning 1 thread per event subscriber, which will be running in background checking for new published events (specifically) to pr... |
Question on securing JWT token integrity, given the following scenario:
Client sends a JWT to server signed with Client's private key
Server caches public key, but uses http (and not https) to retrieve the public key to validate that JWT is signed by the client.
Attacker intercepts the http connection, changes the pub... |
With the current implementation of getaddrinfo(), I'm not given any information about a timeout of the IP address(es) returned. The library implementing that function has the information, but I haven't yet seen a function to retrieve the timeout.
What I'm wondering is how do people current implement the concept of conn... |
I have been coding in python for a little over a year, and I have learned a lot and developed quite a few applications, in the process.
I do not program for my profession, I simply program recreationally. With that said, I am not exposed to new programming techniques/data structures etc., that I would be learning if my... |
First let me phrase my understanding of GitHub flow before asking the question:
In GitHub flow, we have a main branch, and feature/topic/bugfix/whatever branches branching off that main branch. Once ready, this topic branch is then merged into the main branch. It is important to make this separation between the develop... |
I am looking for general guidance or any relevant links for a complex project.
We are a small business that sells a construction materials testing software. The client is a Windows application with over 3 million lines of code, written almost entirely in legacy C++98. Business objects are persisted in a SQL database wi... |
This question is a follow-up question to Clean Architecture use case testing.
Suppose the production code injects Use Case Interactor into the Input Boundary - that happens somewhere in the main component1. But now I want to test the Input Boundary/Output Boundary of the use case. I can only think of two ways to do th... |
I am looking to identify a benchmark to shoot for, and to come up with a decent game plan for introducing tests into our systems before deploying new code.
Just some backstory
My employer is not a tech company and our end users are inside the organization, we are just a department of 2-4 developers supporting a medium ... |
I've read the canonical article about GitFlow by Vincent Driessen, and there are 2 things I'm not sure about:
In the big diagram in the beginning of the article:
In the line of the develop branch, we see some commits that seemed to be just committed directly to the develop branch (not merged from any feature branch)... |
I've seen in many places, one of them here (and also in the guiding questions of GitVersion) that, when coming to determine whether or not to use GitFlow, one key consideration is whether or not I need to maintain several versions in production.
So if the answer is yes - GitFlow can fit you. What objective advantage do... |
In WPF when Datagrid's CanUserDeleteRows property is set to true, then conveniently I don't need to implement deletion of elements from an underlying data structure. But it does mean that deletion mechanism is not testable as deletion can only be invoked from GUI. Or maybe it is OK because the behaviour was (presumably... |
Background
I am building a web app that allows the user to integrate with multiple services like Google, Twitter, Github etc. using OAuth2.0.
Currently, I retrieve the refresh token on sign-in to service and store it in my DB. (encrypted before storing). (Access Tokens are discarded after use).
The application is hoste... |
I'm refactoring a code base to have something more easier to read and follow SRP. However I'm at the point I'm unsure what the best design is.
Currently it looks like this: A thread receives a "command" to execute. The "command" is always the same, it takes the form of an encoded message to send to a WS. The message fi... |
In a DDD-CQRS scenario, should my commands in the Application/Service layer always be just a facade to different aggregation method and other inner layers like repository calls in the infrastructure layer? Or should commands retain business logic inside it (consequently transferring that logic from domain models to the... |
So I wondered how matplotlib (or equivalents) makes graphics appear on your screen.
I found that matplotlib does not do the drawing itself; instead it is built on TKinter, which is built on TK, which is...and the rabbit hole/stack continues.
Is the software package/library/code at the bottom of this stack achieving thi... |
I have a Django application of 2 GB running and I need to receive a CSV file of more than 1 GB, read it and load the data to a PostgreSQL DB in IBM Cloud. The problem is that if I receive the file, it would have to be stored locally and I will definitely have to increase the memory of the server or handle it in a diffe... |
(Hi I’m new here - I believe this question suits here from the guide saying “ architecture, and design” - however if there is a better place, just pop me a comment. As there’s no actual code it doesn’t suit stack overflow )
I am designing a simple site and app where people can create alerts for product stock availabili... |
I need to stream changes from my MongoDB instance to Elasticsearch. I also need to perform complex transformations on changed documents. After doing some research I narrowed my options down to 2:
MongoDB native change streams
Using a Kafka connector like Debezium to capture MongoDB and stream them to Kafka, then have ... |
Here's a scenario I need help with.
Say you have a dating app (distributed, multiple instances), that has a table likes
| id | user_id | liked_id |notification_sent|
If User A likes User B
Insert into likes
If likes contains (B likes A)
Send match notification(A,B)
Set notification_sent true for... |
I have a data science codebase that contains several classes. Several of the methods in the classes rely upon various helper functions. These functions will just precede the class definitions in my module.
My question is, is it accepted practice to have these helper functions outside of a class? The benefit of this ... |
If developing event-driven application(more precisely event sourcing application) that will run solely on 1 machine are RabbitMQ Streams an overkill, or maybe a misfit?
In theory RabbitMQ Streams seem nicer than manual callback in code that are hard to track and monitor, but then on the other hand RabbitMQ Streams seem... |
As part of my master's thesis, I am currently working on a framework for building microservice-based service systems. Based on my research, I am able to define important design criteria that the system must fulfill. In order to make these design criteria usable in practice, I want to draw on proven design patterns. How... |
It seems to me that there is a conflict between clean architecture and the recommendation not to use instanceof. Consider the following code:
class ParentEntity {
}
class AEntity extends ParentEntity {
List<Integer> entityIds;
}
class SaveUseCase {
IEntityRepository entityRepository;
void save(List<Paren... |
We have an existing code base in Python which doesn't yet use any code formatting tool. Now we have settled on YAPF as a tool and also created its configuration file. To me it is not clear how to reformat the code base without causing havoc in further rebases.
At the moment we rebase everything onto master such that it... |
I am practicing design patterns and OO concepts such as inheritance in java and I'm writing an application that represents a vending machine.
I have two questions focused on ideal structure and design patterns:
What is an alternative way to decide which treat from the vending machine to manufacture based on the passed... |
I have a question regarding the architecture of microservices and event sourcing.
Imagine that I have the User service and the Franchise service.
In the Users entity on the user service I have an attribute called franchise_id that contains which franchise this user belongs to. When a franchise is created in the franchi... |
I happen to have a reason why I might want to dereference a nullptr.
Of course when I do, my program crashes, and from what I gather, this is due to the compiler playing it safe and stopping my program, rather than risking the program acting upon the dereferenced nullptr, which is undefined behaviour.
So my question is... |
I have a Node.js HTTP REST API server and a Node.js WS server. I separated them into 2 entrypoints so that they can be more easily debugged and run separated from each other, but now I need the REST API to produce results inside the WS server, to send specific data to WS clients that are connected, depending on which o... |
I have a distributed application backed by a distributed database. (Distributed here means running across multiple hosts with one or more instances on each host). Application has several toolings around it, each does a different operation such as getting some form of update, starting certain application-specific proces... |
I have a general design question. Suppose I have a List:
List<String> list = new ArrayList<>();
list.add("Str 1");
list.add("Str 2");
list.add("Str 3");
I need to process the elements of that list in a loop. There are at least 3 options that I can think of.
Passing only the list the perform the operations:
public Lis... |
Suppose we have multiple services which each of them uses its own db(SQL or NoSQL, could be physically distributed). How can handle queries which require data from two or more microservices?
PS 1
As an example suppose Users (id, first_name, last_name,...) and Orders (id, user_id, goods_id,order_date,...) are two micro-... |
In a Restful API, it is better to use GET to list a collection. However, in our scenario, we allow people query with a list of parameters (say CodeList) and then return details.
As we allow upto 500 codes in the codelist parameter, it is possible that the size limit of 2,048 characters for a GET url is not enough. What... |
In our project we are using Django and Django Rest Framework as main application to get/query the data from database and send it to the frontend. Those endpoints are very fast as they should be. However we need to implement some sort of ETL module that would get data form excel files or clients CRMs and that would take... |
An important view in our application is a big table of entities. For the purposes of this question I'll use an analogy for our entities - so let's say it's vehicles. There's half a dozen different kinds of vehicles, and they share a lot of fields, like the brand and whether it is currently available. However, there's a... |
You have the following situation:
You have an SQL database containing two tables product and product_images
You would like the user to be able to add, remove, or move around existing images
They can perform those actions from a form which downloads the current state of the product and displays each picture in order.
W... |
What would be a secure way of storing client secrets used for authentication (webservices) in Xamarin/Android apps ?
Secure Storage, which interacts with Android Keystore, seems very useful for storing sensitive data acquired at runtime, such as access tokens, but not for sensitive data that needs to be immediately acc... |
I am building an application which will provide users with custom pages served under the subdomain within my application domain.
What I want to do as next step is to allow users to create CNAME which can point their subdomain.
The issue which I see is to serve them with the valid SSL certificate for their domain.
The w... |
Sorry that this is a general question, but I believe this is a good resource to ask this sort of advice.
I would consider myself a junior developer. Most of my coding career has been working for a small company (5-10 people) where we develop a lot of GIS products. We have hundreds of products, scripts, and data sources... |
I'm developing a microservice application divided into 4 layers (API, Application, Domain and Infrastructure).
The composition root of my application is an assembly in the API layer. From what I understand all the binding and registering of dependencies in an application using a DI framework should be done in the compo... |
What are the advantages and disadvantages of including JS/CSS inside the HTML instead of separated files?
Specifically concerned about performance issues, for example, if the CSS and JS are small and simple, and they are not going to be used in any other page, is it better to include them with the HTML so there is only... |
I am studying the heap sort algorithm from the book Introduction to Algorithms by Thomas H. Corman. It differentiates between the length of the array, A.length, as
"the number of elements in the array"
, and A.heapsize, as
"represents how many elements in the heap are stored within array A"
I am trying to visualize... |
this is a followup question to the following StackExchange question -
If you had a medium size company, several developers - but zero tests written in your REST API's - where would you start?
At the time our applications were started, Microsoft provided OAuth2, but the nodejs interface wasn't exactly complete. So we bu... |
Until today I had a static C++ library with no separation between the public interface and internal headers. My other apps just linked to it, included the required headers, and used whatever they needed.
I want to change this, so I created something like
//myLib.h
class myLib
{
void doSomthing();
InterfaceA *g... |
I'm not sure how I should think regarding my database design. I have made this database schema below. And I'm trying to think about the relationship between the entities. I have read through online that many-to-many should be avoided as much as possible and it makes sense. But in my case here, can it be avoided and how... |
Our team is exploring microfrontends as part of the suite of applications we currently offer our clients. A few questions come to mind which I'd appreciate thoughts on:
I understand how a 'shell' or 'container' app can 'host' various 'remotes' which are self standing apps in themselves and, as such, be a 'suite' provid... |
I have different versions of modules and they should all work together with the same shared library which could also have different versions like displayed in the image below:
From a daily use perspective, should I
always use the latest version of the Shared Library for every Module
create a framework that allows usi... |
I have several enums that need to be defined and shared between collections.
A practical example:
There are X colors available "Light Blue", "Red", "Purple"....
people can like items of several colors
items can use several colors
I need to be able to change name of color "Red" to "Cherry Red" and all the associations... |
I have a dataset stored in ElasticSearch, only for searching purposes (the source of truth is external).
Each index has an associated schema and there are associated queries.
From time to time, the structure changes. When doing that, I update all the indexes by dropping and recreating them from the source of truth (wit... |
So I'm currently running an analysis task for my company. I won't go into too much detail but we are dealing with medical records and other confidential data. Previously this application was only used internally but now there's come a business requirement that would allow for external access by an unauthenticated user ... |
In an object oriented language like Java or PHP (other perspectives welcome as well) if I use a fluent interface like this:
my_pizza = (new Pizza).withTopping("pineapple");
another_pizza = my_pizza.withGarlic(true);
would one expect withGarlic() to clone the pizza or would one expect my_pizza to change (into a culinar... |
I have a multithreaded backend application. It is inputted x, and outputs y, and this makes up a "job". A job can take up to several seconds to complete. The application is fed input via HTTP requests, and once the job is completed it will return a response to the HTTP (so the response time can be several seconds). The... |
I'm looking for an efficient way to create appointments between teachers and students.
I want teacher to be able of make their students know their availabilities : For example, A Teacher writes on the application that he is free for an appointment on Monday from 8am to 9am. The Student wants an appointment with his tea... |
I used Google search to convert numbers from one numeral system to another.
10 to binary is 0b1010;
10 to hexadecimal is 0xA.
What's the meaning of 'b' and 'x', accordingly? I think these are abbrevations from binary and hexadecimal.
I understand the way converting works. I thought 10 to binary is 1010 and A to hexad... |
I'm building a login system using OAuth to integrate with various social networks.
The flow is very simple, first, the user is redirected to their social network to grant permission to read the necessary information, and after that my application has access to the following user information:
auth_id, auth_provider, ema... |
So I'm trying to write a interpreter with a lexer. Currently, it adds a token line by line and does some more processing later on. But when I look at sources online, they all seem to go word by word or symbol by symbol. Is there a "correct way" to make a lexer or is tokenizing each line fine?
EDIT:
I realized I didn't ... |
I have to create a reporting system based on hundreds of different tables in a database (which means a huge volume) and I'd like to know the best practices and/or your wild ideas about it.
Here are the details:
I have to generate many different reports, (around 50 report types are defined at this moment, but this numb... |
Scenario:
A very simple android app needed to be developed. It has just one screen with a list of items. Each item has a label and an icon. We fetch the item list from the server, and the server response contains labels and URLs of icons. ViewModel asks Repository for the list, the View observers the list reference in ... |
I am new to DDD and I am trying model/design the aggregates of the following domain.
The domain consists of several concepts:
Assessment Models (AM) which contain Enabling Elements (EEs) and Focus Areas (FAs). EEs also contain Generic Processes (GPs).
Assessments (As) which contain EE Sub-Assessments (EESAs), FA Sub-A... |
We're starting to record history in an about 5 y/o internet system built with ASP.NET Core and SQL Server.
Our current requirement is to save all records from a specific table, plus two fields from two other tables.
We've tried using Temporal Tables, but since in some scenarios the user can change history records - tha... |
I have a collection of opaque objects and related functions API. Such objects are typically created on the heap, but that involves a non-trivial amount of overhead. And when aggregate together, that adds layers upon layers of extra pointers and indirection.
I would like to be able to compose multiples of those opaque t... |
Have question on priority scheduling both in preemptive and nonpreemptive and wanted to make sure understand it correctly. (Higher the number highest priority)
Process Arrival Time Burst Time Priority
P1 0 5 5
P2 0 12 7
Since these processes come in ... |
A time ago I participated in an interview process where I was tasked with a simple requirement. I created the best solution I could, using some lock-free implementation.
I didn't pass the code challenge, and sadly I didn't get any feedback neither, so I never learned how the ideal solution would look like. I didn't get... |
I am developing an app in which I have to fetch data through company provided APIs. All the authentication is done on their end, so I don't have to build my own APIs.
However, There are some situations where they have some information, for eg: a new data entry notification, for us, for which they will hit an API provid... |
At the end of this discussion about coupling and cohesion https://www.youtube.com/watch?v=hd0v72pD1MI some renowned programmers agreed in the general thought that to achieve high cohesion you have to join things, and to achieve low coupling you have to split them.
This seems to be a common thought but I think is totall... |
I've been developing .NET projects for the past 3 years, and on my recent web .NET projects, I've been using Partial Views for all the screens that contain Forms for Add/Update/Delete or other information (e.g. User Info).
Here's a sample (not the exact code) of how I designed it.
For example on editing a user:
HTML - ... |
I would like to create a dynamic appointment system between teacher and student to easily allow them to make an appointment.
In this system, teachers select their 30 minutes time slot availabilities during the following 10 days. They can be available from 9am to 22pm.
Then, students can see their teacher's time slot av... |
When looking and Behavior-Driven development, "Behavior-driven development is an extension of test-driven development" (From Wikipedia). Researching around various articles, behavior-driven development is a form of TDD which is writing unit tests. At the same time, BDD focuses on business value, but not all modules pro... |
FYI: I was asked to post this on softwareengineering - this question was originally posted on stack overflow, but they are a bit funny about broad questions over there, hence I was told to post here instead...
I have searched stackoverflow for relevant questions and was surprised to find that I couldn't find any questi... |
I have an Abstract Base Class AbstractModel
class AbstractModel {
public:
struct predictionStructure{};
virtual predictionStructure predict(CompanyLib::Matrix<double> data) = 0;
std::string modelType;
public:
//constants
const uint32_t IMPORTER_VERSION = 1;
protected:
Preprocessor dataProcessor;//object ... |
I am rewriting an old asp.net 4.0 web forms website that exposes an application's data and logic to the web. I am moving this to a .net core mvc or razor page project. The website has minimal formatting logic and some take-input-and-return-data logic. I am not using his logic because he essentially wrote a procedural, ... |
As a Java developer, I just have scratched the surface of Javascript libraries like React, Angular, Vue etc. It seems that theoretically any web applications with server side rendering, like Spring-mvc with JSF, can be replaced by the aforementioned JS libraries those kinda totally decoupled views from the models and c... |
I have a website-sideproject (Application Server: Django, Database: sqlite) with "search" functionality and I've recently stumbled over this problem.
When you have a full-text-search-functionality, typically you have some kind of data-duplication going on. Typically this is by storing your original data in some kind of... |
I have a simple setup where I've decided to reduce my overall OOP design and opt for lots of small individual components that I can add and remove from a particular object.
The whole point of this was so components could be added and removed with out depending on other components - essentially they are decoupled.
But t... |
I maintain a CSS framework that is versioning with semantic versioning.
What changes to a CSS framework are considered major, minor, and patches? Specifically, what is the "API" of a CSS framework? Is it simply the CSS classes available to you and how you use and combine them, or is it something more subjective like th... |
I need some help with better kubernetes resource deployment.
Essentially, I've 2 components. C1 and C2.
My task is to not deploy C2 pods or any resources until the tasks which are running in C1 are finished.
C1 will install some dars into server machine. --> this will take almost an hour to finish
C2 is dependent on a ... |
I am using C++ , but as far as I understand most OO principles are cross language.
In most of the articles that I have read and liked about inheritance the advice are about :
not to use it for the purpose of code reuse.
inherit interface not implementations.
use "interfaces" (pure abstract class ) as base class.
pr... |
I was doing a code review today and came across a change that, while it works, "smells" to me.
Original code:
if(itemStatus.equals(ItemStatus.Preparing)){
orderStatus = OrderStatus.NotReady;
}
and the modified code looks like this:
switch (itemStatus)
{
case ItemStatus.Preparing:
case ItemStatus.Ordered:
... |
I have two interfaces: Camera and Computer. So far, each interfaces have multiple implementations in my codebase and they are loosely coupled (no implementations of Camera depends on any implementations of Computer and vice versa).
Now I am interested to create a new class called DigitalCamera. DigitalCamera optionally... |
I'm trying to get a grasp of the Clean Architecture. In the examples I found the typical solution structure consists of three projects: Core, Infrastructure, and Presentation/UI. The Core project must not have any dependencies. It contains the domain objects and business rules. The Infrastructure contains all external ... |
Apologies for the title, I'm sure there is some well-known phrase for it but I don't know it. I have a solution for a problem, but I'm not satisfied with and am seeking inputs to help me improve it.
Problem domain
I'm working with an SDK for a third party database. To use the SDK I need to instantiate a "Loader" and pa... |
Suppose I were to make two classes:
class Databank { ... }
class Dababase { ... }
Based upon the chosen terminology, could one infer how one class would behave different compared to the other?
And what are the origins of these two terms? Are there any historically significant examples of a "Databank"?
|
There is a bunch of books that state principles about good code (SOLID, DRY, Design patterns etc.) Those principles are solutions to some problems. An application of those principles could go like that:
Approach 1: I know the principles ⇒ I will write code that respect those principles.
The problem with this approach i... |
I have an Angular + Django web application in which Django functions as my backend.
In this web application, I have 12 different tables about articles, each table representing a different kind of article, which means they contain vastly different columns at times. They all have the fields creation_datetime and update_d... |
History's first webpage is still online and functional.
I was looking at its source out of interest and noticed that anchors consistently have a name attribute containing a stringified number, for example:
<p>
Everything there is online about W3 is linked directly or indirectly to this document,
including an <a nam... |
I am writing a timer-based scheduler to accomplish the task of informing a certain process of what to do and when.
The Idea:
Inform an X process of certain requests to perform at timed-intervals. So if the X process needs to perform an action every Y seconds, the scheduler should send the desired request to the X proce... |
I'm thinking about this scenario:
I can receive customer inquiries by Email.
Those inquiries can be sent from existing customers or unknown "customers" - I'll call latter "Leads".
When receiving an inquiry by Email from a Lead, a Sales Representative will need to register a new Lead in the Customer Relations Bounded C... |
I would like to use a generic interface that has been implemented.
I have two classes as such:
class App {
MainWindow<State> mainWindow;
protected:
virtual MainWindow<State> provideMainWindow() = 0;
public:
void exec(){
// Do something with MainWindow<State>
}
};
template<class StateType>
cl... |
I've been tasked with re-designing a system that is, for lack of a better term, complete spaghetti. For various reasons I feel that the system is well-suited for microservices. At a high level I feel that every service should...
Function standalone
Not have direct dependencies on other services
Have a defined API to... |
I'm converting an app to run on AWS Fargate and was going to use the Parameter Store to hold configuration values. Most of the information I've seen about it revolves around injecting Parameter Store values into the container as environment variables. Seems simple enough, but got me wondering about why you wouldn't ins... |
In the context of a web application where we handle only one command per request in a stateless fashion, do we always have to load/save aggregates as one atomic unit? Why is it recommended not to partially load/save aggregates? What are the fundamental reasons behind this rule of thumb?
Some references where I found th... |
In the code sample below. Would UserId, Email, and UserType be considered "dependencies" with respect to the ChangeEmail method? would they be considered "collaborators"? Is it a condition for a member to be of a complex type for it to be considered either?
public class User
{
public int UserId { get; private set; ... |
I was invited to review some code.
I've never done that before and barely know the project.
Thus I'm following the README step by step.
I log everything.
The README says in its "Quickstart" section:
docker-compose up -d
This line raised "..denied..access forbidden.." which lead me to invest some reasonable time into r... |
When it comes to exception handling, there are many guidelines and best practices on the web. On of them is to throw early, catch late, or even Don't Catch. So when facing an exception, the current use case would be abandoned by letting the exception bubble up, until some global exception handler catches it, logs it an... |
I'm working on a chess game and have created a base class for game entities and chess pieces, along with an enum for the state of a square, when returned in a collection of possible movements:
public enum MovementValidationResult { None = 0, Safe = 1, Attackable = 2 }
public abstract class GameEntity {
public bool ... |
We have a handful of AWS EC2s set up for testing ongoing feature developments. I'm wondering if anyone knows an easy, automated way to keep track of which git branch we're testing on each EC2. Maybe with github hooks?
For example, we might be testing with various internal departments:
a new navigation menu on test1.... |
It is said that visitor pattern is applicable to problems where objects rarely change but we add actions on those objects more frequently.
What if the objects are changing too though? For example we might have a NotificationSource class where it can have many children such as EmailNotificationSource or SmsNotificationS... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.