instruction stringlengths 34 36.1k |
|---|
I don't know if this is the right place to ask more of a "philosophical" question.
The more I code in Java, the more I have to bear with Comparable<T>. And the more I bear with this interface, the more my code gets verbose, maybe also cryptic. I'll take my last occurrence of the problem as an example:
list.get(j).compa... |
I've been using the braces on a new line convention for my java project:
public String class()
{
something;
{
However I have quite a few methods, like getters, that could be written on one line like:
public String getOrderNo(){ return this.orderNo; }
So far I have been correcting this so as everything is in the s... |
So, I have a whole system built as microservices.On a service level, I'm utilizing Hexagonal Architecture with lightweight DDD (no events, aggregators etc.)
I have a service that fetches Users via their Tokens, and then I have to fetch their Permissions accordingly.
I'm trying to figure out how to fetch data via EF, wi... |
I have used the state pattern for my web application where a user can be in one of three states: activated, required_activation and suspended. I have created 3 states classes as given below (source is in PHP) and a variable named state holds the instance of a state out of 3.
class User {
private UserState $state;
... |
Event Storming is a great method to understand the business processes.
Scenario (Use Case Specification) also describes the business process.
They both do one thing.
But when documenting, the Event Storming is somehow not be used often in my office, but scenario.
So as the question, do I need to write scenarios if I us... |
Let's say I have a class modeling some kind of object, for example a graph (in the graph theory sense).
I will have the graph structure and data inside the class, but what about other more complex behaviors? For example, I want to create a function that transforms the graph in a specific way, or that dumps the graph in... |
As title says, I'm currently working on an alaysis model for a little website similar to Reddit for academic purposes.
I have one use cases written like this (They're not in English so they may not have been translated accurately):
Name: View Section
The user opens the page related to a specific section
The system dis... |
I'm trying to implement the Command Processor pattern using MVVM for WPF. The Command Processor pattern that I'm roughly following is the one described in the book Pattern-Oriented Software Architecture (Volume 1):
The Command Processor design pattern separates the request for a
service from its execution. A command p... |
I wasn't sure whether to post this on StackOverflow or here. Let me know if you think it belongs on StackOverflow.
I have an application that will run semi-persistently, i.e. all the time. The application interacts with a financial service through a websocket connection (we are the client-side). We keep the connection ... |
I'm working on a Node project (in typescript) that features a variation of clean architecture. I have a pretty clear understanding of the different layers of an application and how they depend on each other. What is not clear to me is where definitions for interfaces and models should exist (say for a repository, a dom... |
My Software Engineering teacher just said: "Avoid using continue and break, always make it work without using these". Is there a problem with these instructions? I would say he didn't say something so coherent, but maybe I don't know something about it?
|
I'm starting a project using Azure as our serverless framework.
The project consists of two separate frontends applications that must talk to some backend services, some will be made by me and others by other teams.
I plan to implement a BFF between the frontends and the other domain services.
My question is regarding ... |
I'm using a third party CRM application which allows you to build web forms using drag and drop widgets and the ability to add javascript code to manipulate those widgets.
I need to build a form to take payments using another third party payment gateway.
The basic process is as follows:
customer selects products on th... |
So, I'm working on a specific solution that requires the creation of jobs that should run at a specific time, and complete a certain action.
We've built a GUI where the client inputs params required for that action, and the time when that job should be started. When that happens, there should be an action in the backgr... |
I'm currently reading "Code Complete" by Steve McConnell. In section 12.9 "Creating Your Own Types (Type Aliasing)", in the pre-last paragraph of "Guidelines for Creating Your Own Types" part there are such words:
For example, you can define a type INT32 and use it instead of int,
or a type LONG64 instead of long. Ori... |
I've used the wellknown Dispose Pattern in .NET several times as described in the official docs.
Now I have the following, rather simplified code:
public class FirstForeignDependency : IDisposable
{
// all the things from another library that I want to use in my code
}
public class SecondForeignDependency : IDispo... |
Unicode has the following APL characters that don't seem to be used in modern APL. What functions or operators did they represent? Are they still supported for backwards compatibility, but undocumented? I have also seen some of these in code that's no longer in use.
Quad circle ⌼
Del tilde ⍫
Quad jot ⌻
Circle jot ⌾
Qu... |
I've been trying to get a better understanding of OOP (I'm not the biggest fan of it, but I still want to understand it).
One of the core principles of OOP is encapsulation - you're supposed to subdivide your state between different classes and make it so the only way to work with that state is via the public functions... |
My understanding of a "browser" as a means of consuming software over the web:
Browsers isolate web application execution to an environment which greatly reduces end user vulnerability.
Browsers provide an approximately standard environment which developers can target with their software.
My understanding of containe... |
I am trying to design a simple Soccer game. To keep things simple, I am having a SoccerField to represent the field and a Player class to represent an individual.
A SoccerField will contain a list of players. A Player would belong to a SoccerField (Even though a player can exist by itself, during a game, a player will ... |
So I'm designing the backend of a platform that often calls other 3rd party APIs.
The issues I've noticed were latency issues (sometimes the calls were fast, others a bit slow >15s) and I'm wondering how to handle that.
I mostly get resources (and download them every single time). Is there a better practice to have bet... |
Simple question, I'm asking here as I don't exactly know how to phrase this question correctly, I'm interested in knowing how SMS providers work, e.g how do they send you that message? who does it go through? how would you send an SMS without a middle man like twilio (without using a sim card)?
|
I am currently working on a project where there is a class ContactMonitoringJob a Quartz IJob class which in brief keeps pulling from a database and checks if any new changes have been introduced like a new contact being added or disabled for example, then generates "Actions" and persists them to the database for furt... |
Assume you have a small set of suitable programming languages (e.g., Python, C++, Julia), a clearly defined task (development of software services in the context of computational sciences), and a team of stakeholders with whom you'd like to pick the "most appropriate" language.
Assume that the pros and cons of each lan... |
In Python, consider a function like the following:
def main(*args):
value1 = pure_function1(*args)
if condition(value1):
value = side_effect1(value1)
if value:
value2 = pure_function2(value)
side_effect2(value2)
else:
value3 = pure_function3(value)
... |
When writing platform independent software in C++, can I nowadays safely1 assume that a byte has a size of 8 bits? Or do I have to calculate it like this, for example:
#include <climits>
std::size_t byteSize = sizeof(char) * CHAR_BIT;
1 In the sense it is standardized or otherwise guaranteed.
|
I need to think of a way to model how one thing is more "changy" than another.
Say I need to index a news website's different news sections with some web crawler. I want to prioritise indexing those sections (e.g. live news or sports) that receive more news items than those that don't (e.g. health or culture).
A crude ... |
Scrum training usually assumes your company's been contracted to produce software for a client. For example, a business owner might hire your company to develop an application for internal business use (like accounting or submitting expense reports)
But what if that's not what your company does? Specifically, what if y... |
Objective
I have to create way to use the same users to connect to multiple application, and i am thinking about how to do it and how to share the data between the applications.
Details
Each application will have an REST API and an Angular Frontend.
For now i thought about doing a application that will handle the conne... |
I have a few different web front ends that I use ActiveX Data Objects and ADODB connections to query an Access Database on a network drive. Usually there's some JavaScript logic that helps build the queries or otherwise parses the returned data.
There's no server involved and, for a myriad of reasons, I'm going to try ... |
I currently have two applications where one is a landing page (built in react) and another is a web page that lets users explore data (Written in ASP.NET 4.7). I'm currently using resx files to handle translations for the .NET application and I'm using the intl npm package for translations for the react app. I'd like t... |
In my event-driven architecture I have a situation where once an event is raised validation needs to occur and I'm wondering how to proceed to the next step in the process if I don't know how many validators there might be.
This situation occurs because the users of the software can dynamically extend the domain model ... |
I've read that a key portion of a RESTful interface is that the client doesn't have to know what options are available before they hit the page/access the resource. The client starts with the initial URI, and gets enough information to do whatever the application allows them to do afterwards.
In the context of manipula... |
I would like to make use of a external library to parse the core domain entities. Doing this in a naive way it would look like the following:
import { z } from 'zod';
const Audience = z.object({
name: z.string(),
id: z.string(),
});
type Audience = z.infer<typeof Audience>;
const buildMakeAudience = ({ getShortI... |
Okay, so, I'm working on an AuthService for my microservices system.
I'm putting plenty of logic around single instance of User inside of it itself, just so I can avoid repeating code, breaking SRP or anemic domain models.
.. but now I've stumbled upon a certain problem, to be precise:
I have this method inside User en... |
Let's say we have a simple application that uses a popular approach as Controller -> Service -> Repository pattern under a framework.
We would like to write integration tests and start from Controller.
Any integration tests against a controller component will eventually run service component instances and my question i... |
It seems that design patterns are actually linked to some C++ or Java object models
(e.g. they might not fit to Ocaml objects, or to Common Lisp Object System). Or at least tied to a specific programming language (e.g. Common Lisp and C probably have different design patterns?) or some application (e.g. Elephant in Com... |
I have my system which receives data from another service and then I show the data to my users. I'd like to store an ID or a link to the data. Then UI will go for the data using the ID/link.
If we were to use HATEOAS, we'd go with links, so:
Poll the data from that service
Store links to the resources
When UI opens - ... |
How do compilers parse complex data types names like function pointers. The type has to be somehow put into the AST or it has to be processed during parsing. What are the pros and cons of different methods of parsing complex data types? What methods are most commonly used? These are the ways I could think of:
Do type ... |
How can I validate that the feature (user-story) I created meets the requirement of the end users / stakeholders?
|
I am trying to implement a layered architecture consisting of; Controller, Service, Repository, Entity.
Each module has at least some of the above layers.
I am often finding that modules need to share some functionality, for example when creating a BlogPost I may need information about the Account, currently I am injec... |
TL;DR: How do you manage the complex development toolchain in different (embedded) projects?
In our company we are discussing the toolchain setups in different development teams and how to work together in the future. It is important, that for each project the setup is fixed (e.g. specific versions of all tools like py... |
I'm currently reading "Code Complete" by Steve McConnell. In section 13.3 "Global data" in last paragraph "Don’t pretend you’re not using global data by putting all your data into a monster object and passing it everywhere", he said:
Putting everything into one huge
object might satisfy the letter of the law by avoidi... |
I have a library that I am distributing on maven in the new version I will be changing the exceptions some methods are throwing. Is this considered a breaking change? If this is the only change in the new version, should I increment the major version (I am using SemVer 2)?
|
I would like to display something on my desktop by tapping a button on my mobile app.
For example, there is a "show cat" button on my mobile app. When I tap that button, a new window should be opened and display a cat picture on my desktop.
The scenario is a bit similar to Zoom. The desktop application is idle (from th... |
We have 2 applications that are part of our product, one is written in native C++ and lives in its own solution, and the other is a C# application in its own solution. Both solutions are in the same repository, and we are planning to introduce a database that both of these solutions will be using.
There is a discussion... |
I've been refactoring guard statements for my project to simply use a custom Ensure class with 2 methods. Some methods require multiple null checks and I implemented a guard method that simply accepts a list. This method will call the singular guard check for each value given. However I don't seem to find any other exa... |
I'm attempting to create a project to increase and enhance my coding skills, and I've lately migrated React to Nextjs. I've noticed that NextJs' main point or strength is rendering;
Could someone please explain the difference between Static Generation and Server Side Rendering and how they can be used in an e-commerce ... |
I have a database that keeps a temperature readouts, which are being added - let's say - every minute:
+----+---------------------+-------------+-----------+
| id | timestamp | temperature | sensor_id |
+----+---------------------+-------------+-----------+
| 1 | 2021-12-14 10:10:00 | 68.2 | 1... |
I'm writing a parser for a markup language in haskell, and a finite state machine fell out of my ideal API. I have code that looks a bit like this:
Token = BoldWord String | Word String | ParagraphBreak | HorizontalRule -- etc, etc
State = Accept Token State
| LineStart
| ParagraphStart
| WordStart
... |
Edit #1
I believe that I misrepresented my intent when writing this question by focusing too much on the issues that have arisen from our misuse/misunderstanding of locks. I am making this edit to try to clear my goal up.
I am looking to gain advice on whether or not performing some sort of static analysis and building... |
I wonder how to design a good plugin architecture in C++/Qt. The main concern I have is about dependency injection vs globals when it comes to the core components. Plugins should have access to several core functionalities like registering a socket listener, modifiying the tray menu, have acces to the main window, star... |
I recently joined a new project that is written in java. The project has been worked on for a few years by different developers, so there are many different code styles across different classes, and I'd like to consolidate this project to a singular design, hopefully to provide a little bit of optimization and/or read... |
I need some help with my authentication design. Happy to share any code as needed...
Overview
I have implemented the Google Sign-in (new web implementation here) button in my client web application. The web app prompts the user to authenticate through google, revives a JWT token from google, POST to a golang web server... |
I have two Visitor classes in my code Visitor1 and Visitor2 that execute functions on the classes ElementA and ElementB (both implement the interface Visitable that defines accept(Visitor)).
I do not want to support calling visit from Visitor1 on ElementB.
I thought of two different ways:
Throw an exception when Visit... |
I'm dealing with an application that does the following:
we have a microservice running on EKS called by jobs that pull XML data off an external system. The data volume can be fairly large (700MB-1GB at times). We cannot control the volume of data, there's no pagination or way to pull a delta.
the data gets written to... |
I have a memory pool class that manages memory objects of fixed sizes, a bit like a primitive malloc() that can only return memory blocks of a few predefined sizes and unlike malloc() is guaranteed to always be O(1), which makes it suitable for time critical code.
To prevent that the pool consumes too much memory, the ... |
I have a classical one producer - multiple consumers queue, each item can be processed independently. On rare occasions (<1%) there can be multiple queue items related to the same object the consumer is processing. It is perfectly fine to have that with the only constraint being that the object (potentially referenced ... |
I will describe my problem with a very typical example, an e-commerce application.
Says we have to manage Products, and we have 2 bounded contexts Sales, and Warehouse that store the product information.
The Sales bounded context cares about price, product name, description.
The Warehouse bounded context cares about si... |
I face a problem in understanding how this situation can be traduced to an ER diagram.
So I have an entity, let's call it car, and then, there are another entities, that are a type of car. For example, coupe sedan SUV sports...
Now, I would simply put a column in car called type, if it wasn't because they have some dif... |
I have seen a common design pattern where there will be a "lookup table" in the database like this:
Color
ColorId
ColorName
1
Blue
2
Red
3
Green
with a foreign key constraint on other tables, such as:
Item
ItemId
ColorId
101
2
(Item.ColorId is constrained to Color.ColorId)
In the code, there... |
Suppose I have two threads, A and B. A is waiting for input, while B is waiting to be executed. All other CPU cores are busy with CPU-bound tasks.
What will happen to A?
|
I'm learning and trying TDD recently, and I constantly encounter a situation when I need to ditch my current test because it's too broad. I don't know how to deal with it. To be more specific, let's suppose I have a class User, which contains a method getInfo. To follow TDD, I need to write my test first:
@Test
public ... |
I dont exactly know, how to handle the problem, where one class uses shared pointers but I want to call its method from inside other class via this pointer.
class Bar {
public:
Bar() = default;
~Bar() = default;
void OnChange(std::shared_ptr<Foo> foo) { ... }
}
class Foo {
public:
Foo(std::shared_ptr<Bar... |
I use the controller to extract data from a request and Use Cases/Interactors to validate the data. But can I use the controller to extract and validate the request data?
|
I wrote a prioritized/weighted left shuffle algorithm (the code is copied from my open source C# project Fluent Random Picker).
What does that mean? You've got some values and each of them has a priority/weight (a number).
The higher the priority is, the higher are the chances of the value being far on the left after t... |
I want to specify in a BMPN model that a workflow starts whenever a specific service outside tells me to. What standard BPMN symbol shall I use for this?
Think of it as a company wants to start a workflow only at night, so it uses an application and that app, at night, sends signals to our BPMS and we have to run the w... |
I would like to ask a question about OAuth2 with an external identity provider.
Assume a scenario with the following roles: Client A, Resource Server B, Identity Provider C. Furthermore assume that Client A is a web-application which makes the usage of a combination of client-id and client-secret useless (because secre... |
I have a service that uses a package which is basically just a wrapper around an ElasticSearch index. I had to update the index as new data is added on a yearly basis. The source of the data needs to be added to the wrapper, which means releasing a new version. This does not at all change the expected behavior of the w... |
Let's say I have a function in a class with the following signature:
int fun(int x, int y,std::function<int(int, int)> funArg)
The output depends on the operations done in funArg.
My question is, how do you ensure that the code is tested in the right way? I can of course add a unit test with some random funArg, but as... |
I have a function that performs a task which can either be performed immediately and without any blocking or it can only be performed after some delay. The caller of that function shouldn't need to care, that's why this function has a completion handler and will perform the task asynchronously if required and then call... |
I want to adhere to the best practices and obviously encrypt the data sent to me by user. And I also want to provide the full-text search feature to the user (user can only search their own data, if that is not quite obvious).
Example usecase:
There's a messaging app which is privacy oriented (for the simplicity of the... |
(This question is inspired by the SO blog entry Fulfilling the promise of CI/CD and this old question of mine: Why is it wrong to comment out code and then gradually remove it to keep track of what I've already done and what remains to be done?)
The usually recommended software development methodology - if I understand... |
On this book (Software Architecture, 10th Edition by Ian Sommerville, ISBN: 9781292096131), the following architectural patterns are presented (Chapter 6, 6.3, p175):
MVC
Layered
Client-server
Repository
Pipe and filter architecture
My question is: Is it possible to make an objective comparison between MVC, client-se... |
As I understand, most of the business logic is stored in the value objects as constraints, like the price cannot be less than 0.
But I have a problem where the value object depends on another value object as a constraint.
Says we have 2 value objects BasePrice and Price in the Product entity. Both the BasePrice and Pri... |
I am in two minds about sharing client / server errors codes. We are writing both ends of the system, if our API was external this would not be possible, but that requirement is very unlikely.
So an idea would be to have some shared directory between client and server and then on the server:
res.send(4xx).json({ error:... |
To date, we have implemented a multi-repo approach in which each project, or for larger projects, each tier, has its own repo. Code is written in Typescript, Javascript, C#, PowerShell and T-SQL. We currently have 75-100 applications. Some are strictly server-side, some strictly client-side, most are mixed - a cli... |
I was searching about simulation of artificial intelligence, machine learning and subjects alike and saw the news that some startups around of the world are using analog computers to simulate artificial intelligence/machine learning etc.
Their argument is that (some) analog computers were not exact, even if you ran the... |
I am using Domain-Driven Design with Railway-oriented programming as an exception handling method.
Every value object will not throw an Error, but return a Result type to indicate if it failed or succeed.
Here is my process:
Command Triggered
Loading data from the database to the domain
Process changes
Saving domain d... |
I will describe the problem in a typical example Todo Application.
The user can have many TodoList. A TodoList could have many Todo.
The use case is "Add Todo to the TodoList".
In this case, with my basic knowledge, I think the TodoList must have an add method to add the todo to itself.
Since the Todo details like cont... |
I have recently learned about the not-well-known and not-widely-used annotation @RepeatedTest that, as the name implies, repeats the very same test n-times. Baeldung provides a short guide to this feature, however; I have found nowhere to explain why this annotation exists in the first place.
I initially assumed the re... |
I am confused with wording used to describe UpCasting/DownCasting compared to wording used to describe level of modules.
Imagine two classes:
public class Human
{
}
public class Doctor : Human
{
}
If we talk about level of modules, Human class is low level module, while Doctor is high level one. Its how I understand ... |
We're currently developing a product which will have a Web version and a Mobile version. At the moment, the plan is to have identical features on both of these.
From a tech perspective, there is an opportunity to reuse a lot of the business logic code because both products are developed using a React framework which ha... |
It's clear that an entity should never be in an inconsistent state; if a change would violate an invariant, a domain object should reject the change. But what if it's left in a valid, but inappropriate-for-the-input state?
For example, consider a calendar aggregate that supports a "delay all meetings" feature – upon de... |
I have some code and in it there are functions which can be run in one of two modes (in my case server mode and local mode). For example, most functions look something like this:
def path_join(path_elements,run_type='local'):
if run_type == 'local':
path = os.path.join(*path_elements).replace("/", os.path.s... |
My customer decided to have an automatic nightly build based on develop branch.
We usually make a feature branch (and if it is necessary we provide a release compiled manually on that branch) and when work is done we make a pull request (to develop branch)
The customer complained that the nightly build does not include... |
I am trying to adpot a TDD process. I am a bit confused when it comes to testing an Api. I know for sure that the status and the response should be tested.
But I am thinking if whether or not I should be testing the application state. Let's say that I have MVC design pattern where the Api is the controller and a CarSer... |
Lets say we have an Webserver-Framework and a Database-Framework, and now i want to configure that Webserver and the Database, then it could look like the following
class Start
{
public static void main(String[] args)
{
new Start().start();
}
public void start()
{
var dbb= new Data... |
I'm struggling on designing a solid architecture for my project.
In particular, I don't know how to handle the communication between the models and the controllers.
My goals are:
Following the Separation of Concerns principle and have the models as independent as possible.
Having internationalization support for the r... |
The below ERD is taken from a professional architecture reference, however I have a concern in the relation between Customer and Invoice, I believe that relation between Customer to Order , and Order to Invoice is enough and that adding a relation between Customer and Invoice is redundancy.
More over I am not getting t... |
I’m currently working in C# and I’d like to write and extension method against a type. There is a small amount of repeated logic between classes surrounding JSON deserialization, using the JsonSerializer class from .NET, that I expect would need to be changed for each one if it were to be updated. The problem I’m runni... |
I’m doing an task based application using Vertical Slice Architecture (VSA) and domain driven design (DDD). Tasks split into commands and queries and using Mediator pattern.
Say I’m having an Order domain object but multiple commands, which do some work and based on that, has to create one or more orders in the system.... |
I have an ASP.net web API. I would like to call another API that has an authentication token inside my API.
The code flow is as follows:
My API is called → Get authentication token from 3rd party API → Call the desired methods from 3rd party API.
The thing I can't decide is if my API is called 100 times, I will make 10... |
I have to create a overview documentation for a simple PLC (programmable logic controller aka industrial automation controller) program (happens to be written in Step 7 but not really important).
The structure of the program is simple. The functions i.e. "activities" are run one after another. Each activity reads a sp... |
I would like to deepen the topic of multiple inheritance using Python and I usually find examples that are too simple. I love art and I imagined the following problem and I want to understand if multiple inheritance would be a good design solution for it.
Let's suppose we have STL files (meshes) of 3D scanned faces of ... |
I'm currently working on a design for a system that can service market data to external clients over the internet. The current solution involves consuming market data from a feed (Feed Handler), this data is then processed and used to produce 3 distinct data sets as shown in the diagram below. I want to provide a web s... |
I have a bunch of scripts written in .bat files that I'm trying to implement into one big program using C#. These .bat files mostly do simple operations like copying files into network drives etc. Would it be better to implement the batfile functionality with C# or just call the .bat files using C# and System.Diagnos... |
Imagine an http request in a RESTful API that needs to request the database to perform validations before proceeding, but some of those database requests would need to execute again if the validation succeeds.
Assuming the validation is made in a separate layer, is there any design pattern that deals with this problem?... |
I was reading about these patterns and noticed that they seem to be basically the same, but in different contexts? If that's the case, why isn't Front Controller just considered as a Mediator pattern but applied in the context of web applications?
|
I'm writing an SDK for the European Space Agency's DISCOs API.
This has around 10 endpoints with different sets of query parameters, each of which returns a different payload type with different link parameters which will also need to be resolved. I explicitly don't want my user to have to construct query strings thems... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.