instruction stringlengths 34 36.1k |
|---|
AFAIK, Option type will have runtime overhead, while nullable types won't, because Option time is an enum (consuming memory).
Why not just mark optional references as optional, then the compiler can follow code execution and find whenever it can't more be null?
Edit: I see I was misunderstood. I understand and agree wi... |
If I have a Ban User process that should definitely modify the Accounts data store and if I have Create Account that should also should modify the Accounts data store.
|
I made a pretty simple CRUD API to store customers and some related information in a database.
My customer has 20 properties like Name, Telephone etc. that are all stored in an anemic domain model.
My application has a core assembly where my domain logic is located. There I have a business model, looking pretty much li... |
While in general terms I realize this is a sub-version number that's bumped based on patches that don't bump the major version, is there a more exact definition for this?
Must the number match the number of patches applied for example?
Or is this a general term that each project uses slightly differently?
|
I'm not sure this question matches this forum's purpose, but I didn't think it should belong to the stackoverflow one either, so here it goes:
I created a model binder that makes one mapping so "clean" by putting it in the model binder itself, but now I wanted to do it again in another action method and I was just wond... |
In looking for a simple heuristic to see when inheritance can be abused, I came up with the following hypothesis:
If subclass B overrides method foo, but does not call base.foo(), it seems like inheritance in that method is broken, as it only uses the same method signature, but not necessarily the same behavior.
Is ... |
In our microservice architecture, this is how requests flow.
Service Layer: Requests hit this layer from public LB. Also, response composition is performed here.
API Gateway: The core job of API gateway is to make parallel calls to respective microservices.
Please note Usually response composition is done at API Gate... |
In a typical server software design, business logic will generally invoke "services" (such as a database or web service).
When I design such a system, I tend to think of each service as a singleton which is created when the system starts up and handles multiple concurrent requests throughout the lifetime, usually not s... |
We have a weird use-case that I need to support in my application and needed some opinions on how to design it.
At a basic level the application allows users to work on a "list" of "tweets" she cares about
To work on any list the user "locks" the list and then can do actions like reordering the tweets, add some small ... |
I am in the middle of a project building an internal admin web site using Asp.Net MVC Core 3.1
Some of the features I need in the app could benefit from Blazor Client side. (Single Page App features?)
My question is would it be logical to try to somehow bring Blazor Client into the existing project or would it make se... |
I am wondering why all LinkedIn profile URLs are of this type linkedin.com/in/username. Why not just linkedin.com/username? Is there a design reasoning here that I'm missing? (Ex: linkedin.com/in/williamhgates)
|
My application I have two types of customers: individuals and business customers. My users sometimes need to be able to see the full details of one customer, but at other times they only need to see a brief summary with a few fields (e.g. in a list of search results). I currently have three classes: IndividualCustome... |
I want to have a control flow decide whether an object can pass through a point in a flow or not. From my understanding of control and object flows, this would not work in the way I have done it, since an object and control flow are being joined together into something undefined. What would the correct way to do this l... |
To Put My Question In Better Context...
I am about done writing my first real-world Node application, which would be classified as a REST API. For myself, it was a bit challenging to wrap my head around Node's Async event processing. I still don't think I fully grasp it, as you will see by the specifics of this post. T... |
I have an API I wrote that I want to test at the API level.
Given that I'm testing from an external point of view, how can I manage data sets for each tests?
The simplest solution I could come up with is to create a test suite where each test depend on the state the previous one set.
For example to test that a comment ... |
I'm trying to test an API (see API testing).
Some operations depend on time.
Here are some examples:
A post may only be edited within the first 5 minutes
You may not try to login more than 10 times in 1 minute
After X weeks of inactivity a post is archived and set as read-only
If I'm testing from an external point of... |
I am starting to look into how to implement SHA256 in JavaScript, and found this for example. It requires UTF-8 encoding it sounds like. Another one I saw required/supported only ASCII encoding and otherwise returned undefined.
This makes me wonder, how does the algorithm change based on the encoding? Where can I find ... |
I am trying to understand how MVVM works. Here are two examples (in Andrdoid) on how I understand it should work, please tell me if I understood correctly.
I currently want to make a list of radiobutton "Sex" with currently two possible values (Male, female).
I expect it to change to "Gender" and three possible values ... |
When creating a new .NET Core Web API the controllers will be put in the Controllers directory. I want to create request models for incoming requests (for validation purposes) and response models which might differ from the database models. So a basic folder structure could be
API
├── Controllers
│ ├── UsersControlle... |
Following the hexagonal architecture and package design you will have somewhere an entry point reaching to your core functionality. Often this is done by using a facade.
To hide the core logic from outside i usually pass DTOs into that facades. For example imagine an File Import module which has the following facade me... |
Is it OK to have a function that returns true/nothing instead of true/false?
My examples use JavaScript, but I'm wondering about the general case, not attached to one specific language.
The subjects of my interest:
Is it OK from the practical side?
Is it OK from the logical side?
I mean, some languages provide too mu... |
I've been struggling for a while of what would be the "recommended" approach for a microservice itself.
There are quite of top architecture designs that are the holy sacred for a lot of craftsman devs, such as CQRS, Hexagonal, DDD, etc...
But from my point of view, depending of how "big" is the microservice, because y... |
I have an ASP.NET Core Entity Framework Core application and I want to implement my own custom logger. I don't want to use ready solutions like NLog or Serilog.
I added a new class library project ("Logger") to my application and added classes that do the logging. Mostly they call the service provider to get the db con... |
Good day everyone.
I am planning to build a terminal, which will support common commands like ls, cd, cat, etc. But I am confused on how I should structure my codebase so that if in future, I decide to support more advanced commands, it shouldn't have to be a total re-write. I checked out the official linux source code... |
Let's say there's a domain that's similar to Reddit.
Aggregate roots are
Board // you can ignore this
- boardId
Post
- postId
- userId
User
- userId
- username
where each aggregate emits
Post
- PostCreated
User
- UserCreated
- UsernameUpdated
for the query side, the query will try to fetch a page of p... |
Building games and simulation frameworks, it seems I am regularly hounded by this conundrum:
Let's say you have a 2D grid, and you have an crate in that grid. I can put the coordinates on the crate, or somewhere else.
# Option A:
grid = Grid()
crate = Crate()
grid.add(x,y,crate)
# Option B:
grid = Grid()
crate = Crate... |
I was wondering if its a requirement to consider BDD the use of Cucumber framework or other framework of test abstraction.
Because I was playing around with @SpringbootTest and TestContainers(both compatibles with Cucumber) but I "discovered" the @DisplayName() on each test method/class and I thought that can "replace"... |
I am writing an application where a single variable may be affected by different filters applied to the data that's read from the DB. Each different variation has to be stored (as each one serves different purposes) in different variables, however, I'm not sure about the best naming convention for this cases as it will... |
Hey so I have been looking into ORM since my last question and I am wondering.
Instead of worrying alot right now about whether I will use mysql, postgre, or sqlite, would it be better to use ORM along with flask and SQLAlchemy and thus be able to change the databases more easily? Or did I get ORM wrong when reading a... |
I'm just reviewing some of my code and thought I'd throw this out there for comment.
I have a factory class that builds and returns a class for RSA Crypto tasks. It implements IDisposable. All the uses of the created RSA instances are created with RSA.Create() and are wrapped in using() statements.
One of the construct... |
Currently, in my PowerShell scripts I am using [ValidateSet()] in my functions in order to limit the options for user input. Now I discovered the Enum as an alternative. I have read a couple of blogs about Enums vs ValidateSet, i.e. community.idera.com.
The advantages of ValidateSet() are supposed to be:
Backwards com... |
We have a problem of load time in our REST API, which is the result of having Fat DTO (nested DTO s) & the N+1 problem (which is off my question), means that we are loading too much data in one request, and a big chunk of this loaded data is not going to be used by the client (this is a classic problem in REST API).
e... |
I'm working on a Gradle project that has several modules. The project is implemented in Kotlin. One of these modules is the main entry point to the project, which is the main module. Another module provides a number of utilities to the main module.
My problem is that these utilities module requires some command line a... |
I joined a company and the project I'm working on have an event handler that extends the FirstChanceException functionality to log the exceptions. The logs are stored in a file and not registered to the console.
All the controllers actions have try catch blocks and they ignore the exception in the catch (because it's b... |
I want to choose between several options, and if the criteria I'm using for selection happen to be equal, I want one at random (reasonably so, so it's equal-chance each time, rather than arbitrary). This is easily done with nested ifs, but it gets pretty ugly and ends up duplicating code.
A simplified example case, in ... |
So I suppose this question isn't as much as a 'How to' but a 'which way' kind of question.
So I have a .net core api backend that makes calls to a dB
I also have a xamarin forms project that connects to the API and gets and posts all info.
However when it comes to authenticating and authorising. I am relying on jwt. ... |
I'm building a .NET Core class library wrapper for a REST API that, ideally, could be used in both console applications and ASP.NET Core web applications. So far, I've based development on supporting dependency injection for the latter by creating a typed client for each group of REST API methods, i.e. one client for e... |
I have been thinking about this here and there for several years but haven't gotten around to having the time to actually implement it. I am getting closer to being able to implement a graphics renderer like Pixi.js or Three.js, but would like to know first what the ideal data structure is (in the case of 2D and 3D eng... |
We have several Rails applications using the same ActiveRecord, Book. For simplicity let us assume we have only these two:
BookWarehouseApp (that deals how new book are added, or other inventory processes)
BookLibraryApp (that deals with how book are being borrowed and returned)
BookWarehouseApp has read and write ac... |
I am currently building a web application where users can place stocks trades. So far I use plain HTML, JS, CSS (forms, AJAX calls, etc.) for the frontend and Django/Python at the backend.
I am now wondering how I can build a compiled application interface in order to increase both speed and security when placing trade... |
I am a JavaScript developer mainly, so I am familiar with object-oriented code and dealing with things you can see easily and interact with, like the GUI, even HTTP requests, etc. Plus you can put breakpoints around and inspect the object properties and such, or log it to the terminal, etc.
However, I would like to sta... |
I am working on a project to detect cancer and I am using deep learning (Convolutional neural network). In the user interface, the user has only to input an image number then click test
when the user input the image number " the number of the image in the dataset " it will tell if this is a scan image of a person who h... |
My Git repository contains dot files required by my tooling:
.dockerignore
.gitignore
.pre-commit-config.yaml
I'm using Azure Pipelines for CI/CD, which is typically defined in azure-pipelines.yml, but this is customizable.
I've noticed that other CI/CD tools use dot files:
.github/workflows/
.gitlab-ci.yml
.travis.... |
I've been trying to develop a website with some success for the past few months. One question that I always have lurking at the back of my mind is whether to develop a very in-depth, powerful admin panel in favor of me just editing the code.
In a more simpler words, let's say I'm the developer for nbcnews.com. On NBC's... |
I am writing a web service for research and learning purposes and try to find an approach to separate user data from other users to ensure a request can never deliver or reveal data from another user.
I give you an example in a slightly different field. Imagine an HTML form whose inputs will be written into a database.... |
Pretty often I have a need to migrate the location where some data is stored - to a new column, a new table, or even a new data store. And usually this needs to be done with no down-time. I can see two approaches. Either:
Change all live writers to write new data to both locations
Do a one-time migration of data from ... |
My base class must provide an interface to get a value that is dependent solely on the type of the derived class. I can think of two ways of implementing this:
Solution A, virtual functions:
class Base
{
public:
virtual ~Base() = default;
virtual int get_plain_value() const = 0;
};
class A final: public Base
... |
For the following use case I tried to use (self-)reference loop.
Use case
A round based game what changes difficulty level after each round.
The set of difficulty levels is fixed size.
After each round the game should go to the next level.
When it reaches the last level in the set, then it will continue with the first... |
When running Apache Spark one submits jobs to a Cluster Manager. The cluster manager is delegated with the task of accepting / declining requests for resources. The cluster manager could either be YARN, Mesos, Spark Standalone or Kubernetes.
What are the benefits of using Kubernetes as the cluster manager?
|
Apologies if the title doesn't reflect the problem entirely; I'm not sure how to name the title so please edit if you feel it's necessary.
I have an application that employs the Producer-Consumer pattern.
In my main thread (Controller class), I create 3 blocking queues and assign them to 3 consumers (each running in ... |
Ive done two HTML parsers.
Done with Regular Expressions [that accounted for nesting]. It was quick, but error prone.
Done by evaluating Character by Character through switches. Here was the basic structure:
Evaluate html character by character, beginning to end.
Characters are fed through through various switches... |
I've been using a somewhat odd yet effective pattern for a current use case. The one issue is that I'm getting an undefined method notice on a method that is unique to the subclass. The method of course works fine but the notice leads me to believe that either my architecture is shotty or something else is going on.
I ... |
I am building an Angular web application that retrieves part of its data from a Azure SQL Database table via APIs developed in Azure Functions (with Azure API Management at the API Gateway). The data in the table (80k records) do not change for at least 24 hours. The web app needs to display this data in a grid (table ... |
I am creating a API to create Personnels of X city. Assume that there is a generalised service for creating personnel of any city and I want to call this service for X city personnels from my API.
While implementing my API, I am planning to do following:
Validate the input parameters and business logic validation whi... |
Domain-Driven Design suggests to seperate applications into Bounded Contexts. Each context has its own set of specific, unambiguous words, which collectively make up the Ubiquitous Language.
In the process of finding the Contexts and the Language for a project, a team will probably generate several pictures of Contexts... |
Consider you have two repos A, B.
Let say repo A has some infrastructure code - not needed to be updated always-
but it has the code for the service we want to deploy as infra.
On the other hand, repo B include all business logic to be run inside of the wrapper service mentioned in repo A.
So dependency is that A rep... |
I'm creating a web application using Node.js and Pug, and have recently been looking at adding external OAuth authentication to this site, using Express and Passport.js.
I've found a lot of examples to do this online such as:
https://developerhandbook.com/passport.js/how-to-add-passportjs-google-oauth-strategy/
https... |
Say I have a Group object which maintains a list of its Members:
private $members;
Now the class Member has a range of subclasses such as OrdinaryMember and GroupLeader. Every group has precisely one leader. The GroupLeader can provide a list of pending applicants to this group:
$groupLeader->getApplicantList();
Howe... |
I am trying to create a social network app. When I started I had proper domain models for Feeds, Activities, Author etc. with all the behaviour encapsulated within the Objects. I had the luxury of ef-core for easy change tracking and infrastructure abstraction.
But then I started using GetStream.io to get feeds for my ... |
Would it be (mostly) correct to say that the following are the parallels to the Haskell Monad operations in the imperative world?
Monad's >> ~ C/C++/JavaScript/etc. , operator
do expressions ~ C/C++/JavaScript/etc. ; operator (kinda)
MonadFail's fail ~ C/C++/JavaScript/etc. throw
To demonstrate the point, some exam... |
I recently encountered a microservice architecture with 50+ services communicating with messaging using publish/subscribe on a topic. I have previously worked with event based systems where each service creates and dispatches its own event, so I was suprised when I realized this(theese) system(s) were actually sharing ... |
My Goal
I'm currently in the process of trying to get my company to adopt Continuous Deployment of the web product I work on. As far as I know, we're the first product in the company to attempt this. I'd like to know any pain points people have run into when moving to CD or tips people can give me who currently work at... |
Let's say we have business logic to perform in an MVC framework after a user submits a form:
class BusinessLogic:
def sendDataTo3rdPartyApi(self):
# do stuff
def validateResponse(self):
# do stuff
def persistData(self):
# do stuff
def calculateFees(self):
# do stuff
... |
I am currently trying to implement a Generic solution for common processes, and this solution will require supporting different payloads for each specific usage.
I am not aware of a way to define a flexible payload, my approach will be that I will use all the fields needed by each process in one common Data Model, and ... |
I would like to implement a microservice which can support both REST and SOAP, and will use the protocol based on the client preference (or what the client is already using).
I have been thinking of a way to do that, I thought of header which will be set by the client to specify the protocol to be used, I am not sure ... |
I'm told that software is everywhere and therefore used in other domains. My question is if you're a software engineer working on software for lawyers or software for biologist when do you actually get the time to learn about the other domain you're impacting?
How can you make software for lawyers if you're not familia... |
Our company did not properly design Address Record Code Module. Developers are updating Address SQL table with Multiple Service Methods, and are not updating AddressHistory Sql table. They're asking me to unify/resolve the issue :) . What are some methods to resolve this?
I came up with these 3 alternatives. Just curio... |
I'm working on a spring boot REST service.
It's divided into three layers: REST controllers, services, persistence/DAO.
We have multiple services and persistence repositories. We have the following situation:
Service-1 needs to access the persistence layer under Service-2. One of our colleagues added a direct dependenc... |
I'm trying to find the time complexity for the following code.
N= number of elements in array
D= a constant: D>1
V= a constant: V>1000
counter=1; //the maximum value of the counter is N/D.
for(i=0; i<N; i++)
{
[OP1] O1_Operation; // O(1) operation. [Total: N times]
[OP2] if(i%D!=0) continue; // O... |
How to dependency inject repositories that inherit an abstract class (that inherits another abstract class) which implements the interface?
I will give you a simplified version of my current architecture.
Architecture (simplified):
public interface IConcreteRepository<TEntity, TId> where TEntity : class
{
// a lot... |
I am trying to build an API server. For the register operation I send an email to the given email address and wait for user to activate his account by using the code in the email that i sent.
I use an external Email API for sending the email.
So of course I don't want this to happen in my development environment becaus... |
Say, I have two classes:
class FTPClient:
def __init__(self, host, port):
self._client = FTPDriver(host, port)
...
class FTPSClient(FTPClient):
def __init__(self, host, port, username, password):
self._client = FTPSDriver(host, port, user=username, password=password)
Objects of type FTPClien... |
I am working on a DSL for text processing. The core is searching for regular expressions with some operators around them. These searches are embedded into a more procedural program, which allows for selective execution and setting of metadata. Hopefully, a little snippet gives you an idea how it could look like:
xml_mo... |
I am building the frontend of a web app in JavaScript that manages list of past events. It basically has the following requirements:
Events are displayed in a vertical list.
Events can be moved to arbitrary different positions in the list.
Any event can be "connected" to the event before or after it, by clicking an i... |
When I was study lvalue i see that
C expression can be lvalue if a subscript ([]) expression that does not evaluate to an array.
(from
https://docs.microsoft.com/en-us/cpp/c-language/l-value-and-r-value-expressions?redirectedfrom=MSDN&view=vs-2019)
But jagged array does evaluate to an array and we can use them as l... |
I'd like to design a class that holds comparison results about to objects.
Given I have a class Thing and that Thing has a bunch of properties. Now I have an engine that compares Thing instances (held in a collection) to one another. Comparisons are actually Types deriving from a Comparison base class and can be fairl... |
So recently I have been working with a large-scale app that has a large number of individual objects with specific group attributes. For example, I have a list with objects such as
{Name: "Todd", Desc: "Todd likes basketball", Team: "#23"}
This list is has about 10k of these objects in it with about 1,000 different ob... |
For studying purpose, I've tried to create a simple PHP implementation of Builder GoF (not the Joshua Bloch's one) inspired on this slide.
The main goal of this example is to encapsulate the construction of data files from diferents inputs (Directors) and outputs (Builders)
Lots of Builder example (including the wikipe... |
I needed some design suggestions for a tricky workflow we have to implement in our system:
At a basic level the application allows users to work on a "list" of "items" she cares about
To work on any list the user "locks" the list and can edit/save/unlock etc. No one else can open the same list in the UI for editing, wh... |
I have the following application:
This application receives an API call (HTTP), does some internal work that usually includes reading or writing to a database that has 5 different tables, generates an XML file and then sends it to another system via a REST interface. This has around 5K lines of codes.
I'm now studying... |
We're in the middle of architecture a SaaS web app which will operate on a subscription basis. Each user is associated with a merchant by means of a claim on their identity and the subscription exists at the merchant level.
We have a number of separate microservice API's and we'd like to prevent anyone without a valid ... |
Maybe that's simple, but it confuses me. I have such a code now:
describe VarnishLogExaminer::Entry do
let(:entry) do
file_string = File.read('./spec/assets/varnish_example.xml')
first_entry_string = file_string.split("\n").first
described_class.new(first_entry_string)
end
describe 'initialize' do
... |
First off, I totally understand that an interface cannot contain a static method because what would the method act on - that is clear. Suppose I want an interface to mandate a method that is particular to a class but acts statically (and as an interface method may be shared by many classes.)
To propose a crazy example... |
Im new to object design and Im trying to figure out which design is better.
I have a Material entity which can have multiple versions. I have two designs, one is with nested classes, and the other is flat, more like a database table.
Nested example (pseudo code):
class Material
name
path = "some/path/" + name
... |
We receive product data from vendors on a regular basis to be incorporated into our catalog. The data looks like this:
[
{
id: 123,
collection: Spring,
name: New Beginnings,
size: 8,
price: 29.99,
...
},
...
{
id: 456,
collection: SUMER,
name: The Escape,
size: 6,
price: 49.99,
...
}
]
The... |
I'm a junior engineer, but I've worked at two companies now. In both cases I've found that my colleagues and I are assigned tasks with no thought put into the design before being told to do it.
Typically I spend about 90% of my time writing down on paper how I'm going to do the task, then the code sort of writes itself... |
I have this NamePath class that accepts a string from some system path and tries to split it into two properties, Name and LastName.
Is the code example below fine? I've read that throwing exceptions in constructor is okay, but is there a better way for this case?
public class NamePath{
public string Name {get; priv... |
I am currently in the process of developing a machine learning application, where my users can upload their own data to train models. Furthermore, the users must be able to extend their uploaded data with new data (append new data to it). I am in a bit of doubt when it comes to actually store this (and whether or not i... |
I read in the book "Game Engine Architecture" by Jason Gregory that:
"It’s possible to access data items that are narrower than the width of a machine’s data bus, but it’s typically more costly than accessing items whose widths match that of the data bus. For example, when reading a 16-bit value on a 64-bit machine, a ... |
I can't wrap my head around this statement here:
One common drawback of using composition instead of inheritance is
that methods being provided by individual components may have to be
implemented in the derived type, even if they are only forwarding
methods
What does it mean?
|
I work for a small company with only three programmers (including myself).
Our workflow is:
We write the code;
We create a pull request on Github;
We ask for code review;
We merge the pull request.
Normally when I want to explain the motivation behind that code, I review my own code in my pull request and add commen... |
I'm creating a console program where the user has the option of making the output more verbose when the system processes their requests.
There will always be an output, but the verbose output would be an additional set of printing to the screen.
Making the output more verbose is a setting that they can change. It corr... |
I've been reading a log about CI (mostly Addison-Wesley books) and taking "CI" courses. I see two clear distinctions between old books on CI and new ones:
Old ones focus on "committing" or "pushing" your code often (integrating often)
New ones talk about practices for having feedback early in the process, like running... |
I'm currently on the research if my current monolith architecture
can be improved by moving to micro-services.
From what I saw, there are a lot of good things about micro-services
but there is a low of caveats and pit-falls that might complex
the whole system (transactions, data-query, data-sync and duplication, fault ... |
Here is an example with the function:
Examining this I believe that it is possible to achieve 100% path coverage.
My understanding of path coverage is that you need to design test cases such that all independent paths in the program are executed at least once.
Looking at the source code and simplified control flow gr... |
Disclaimer: I'm not very knowledgeable when it comes to SQL or RDBMS in general.
I've encountered this interesting answer about SQL as a language: https://stackoverflow.com/a/1643440/414063
This also talks about stored procedures, but stored procedures are still related to SQL (I think).
Are there viable candidates/alt... |
While reading an answer here, I saw this code:
char ** v = malloc(0);
while ((r = strtok(s, " ")) != NULL) {
char ** vv = realloc(v, (n+1)*sizeof(*vv));
The thing that bugged me was the call to malloc with an argument of zero. According to the standard, this will return either NULL or a non-NULL pointer that can b... |
I have an activity diagram below.
I want to know if that kind of loop is correct.
Is that "Waiting for the actor to stop listening to the music" a correct way to end the whole use case with that kind of ramification?
And how that ramification should be described on the use case scenario? What number/index should every... |
I'm seeking a way to generalize the way log levels are managed in my services. I have multiple services, written in multiple languages, and using multiple libraries to manage logs.
Almost all of them has its own choice for numerical and string representation of a log level, and they had different number of available le... |
I would like to ask a question about Scrum. At the end of a Sprint, when we have the Sprint Review, we present an Increment.
The guide says that this Increment has to be potentially releasable.
My question is, does this mean that every increment should involve a running prototype of the software we are building, even ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.