instruction stringlengths 34 36.1k |
|---|
I have to design a database, but I don't yet know which underlying technology it will use (not just my decision). Could be SQL, could be NoSQL, could be something else.
I do have quite a few requirements and I have enough knowledge of the business domain to create a data model.
Obviously, not the physical model. I woul... |
If you're a very old programmer like me you may have written stuff like this early on:
DIM A, B, C
LET A = 2
LET B = 2
GOSUB ADD
PRINT C
END
ADD:
LET C = A + B
RETURN
(Actually, if you're an assembly programmer, you may be stuck writing stuff like this anyway, but let's not digress.)
Of course the modern approach woul... |
I'm struggling to find good ways to split up classes without exposing private data. Most articles I read about SRP seem to ignore how the new classes that take on the separated responsibilities access the data that once used to be private to the original class.
Take, for example, a Gripper class representing a roboti... |
I have a customer-facing enterprise app. (like AWS). Customers specify config on the app and relevant infrastructure is spun up along with my software on it. My CloudOps team, like the AWSCloudOps team, would have access to an internal version of the app which would have a lot more nuts and bolts that are not exposed t... |
Let's say a sample case where we want to create an article with some tags. Following are my pseudocode, and the questions are at the bottom.
Sample Case
Request:
@Data
public class CreateArticleRequest {
@NotEmpty
String content;
@NotEmpty
List<Integer> tagIds;
}
Controller:
@RestfulController
public ... |
I have been exploring the microservice architecture for the batch-based system.
Here is our current setup:
Code:
We have 5 systems that are internally connected and they pass data from one system to another. Currently entire logic is sitting in Oracle as PL/SQL, Hadoop(Hive, Impala, Spark, etc) and Shell scripts.
Com... |
Let's say you have an app like Facebook, where each Post can be tagged with a Place. Now, the whole social app backend api (basically the whole client api) is built using nodejs + postgres. But the Places autocomplete is a custom API that is built in Golang for example.
Since the Places API is essentially based on a st... |
So, in C#, I understand the historical difference between the two vaguely; a Task is a newer concept and the highest level concurrency native C# offers.
AsyncResult is a bit more ambiguous. For example, the docs say BeginRead relies on the underlying stream for non blocking behavior.
I know ReadAsync creates a Task w... |
For a system, I have certain requirements
should be soft realtime.
should be able to handle lots of operations in parallel
should have ability to add, remove, alter features
should be able to increase/decrease memory, computation based on load
So I have implemented an app design based on microkernel architecture wit... |
Being mobile developer for quite some time (ios/android) I've learnt that local database is very rarely needed. Mobile application are mobile by definition, they usually serve only as clients to access some REST API and do parsing/display work. In such cases server and its database are the true and the only source of t... |
For example, if I want to write a daemon program in C# that uses anonymous pipes to communicate with programs written in another language, is this both possible and feasible?
I ask because I intend to write the code in a language that can cross-compile to several targets (Haxe). I intend to write an application which c... |
This is an initial thought I'm having on logging. Clearly, am missing something about the whole picture because I don't think someone didn't think of this before.
PHP runs on one request. That means it's contained, which means every request needs to open its own connections, etc. this is somewhat given but, when you lo... |
I am designing a system that contains organizational hierarchy management. There are four roles in the system which are the user, admin, manager and head of procurement:
I am trying to let the admin of each organization create his own hierarchy by creating new roles using tasks and privileges predefined in the syste... |
What were the motivations for java to use the @FunctionalInterface annotation, instead of creating a new FunctionalInterface modifier?
@FunctionalInterface
public interface MyFunction {
TypeB myFunction(TypeA objectA);
}
vs.
public FunctionalInterface MyFunction {
TypeB myFunction(TypeA objectA);
}
this quest... |
I have a large hash, around 6 gigabytes that I load into memory. On my current laptop that I develop from, it really does a number on my system, causing massive amounts of lag while I try to go about other things, say for example, debugging or browsing stack overflow. This would not be an issue if I could simply store ... |
So I've got "Services" in my system that handle creating, updating etc of the data.
For example state_service.create() would create a new state in the database. This state belongs to a group.
The problem is, the group needs to be created first, before the state can be added.
Now, I can always call group_service.create(... |
I just curious to know that what is the best practice or way for sharing common functionality or code among the micro-services. For example, there is one micro-service which is responsible for the operations related to user entity. Now if X micro-service needs some data related to user entity, then how can this be achi... |
I am new to using PHP Frameworks. I decided to try out Laravel. In my project, I needed to write a search function which will search through a few entities based on some keywords, then do a UNION and return the results. So the SQL will look something like this:
SELECT pages.id,pages.updated_at,pages.created_at,page_t... |
I'm used to comments in Git and Mercurial repositories:
Commit comments, which may involve multiple files over the whole repository - has a comment. Commits without comments are possible, but rare (in my experience).
Branch descriptions: These are the opposite in terms of use: Many people don't even know about them, ... |
As a long-time perpetrator of monolithic systems (oh, the shame!), I recently had my eyes opened to the concept of microservices. I've now read lots of online articles, and enjoyed the piecemeal plan of the Strangler Pattern to break a monolith into microservices. I can see how especially with the advent of technologie... |
In his book "Concurrency in C# Cookbook", Stephen Cleary writes:
If you can, try to organize your code along modern design guidelines, like Ports and Adapters (Hexagonal Architecture), which separate your business logic from side effects such as I/O. If you can get into that situation, then there's no need to expose b... |
I have once seen a universal download for an app. It was said to work on Windows, MacOS, and Linux. If the exact same app is designed to work on three different without changing any code. For example, Java can be made to run cross platform. Are there performance benefits to creating platform specific apps rather than c... |
I have done quite a bit of reading about microservices but I have so far never designed any. I am working on doing that now and I am wondering which approach is correct (see the image below).
Basically, I've read that each microservice should own its data and only expose it via an API and that totally makes sense. Howe... |
As a practical example, imagine a Gripper class which represents a robotic gripper in a simulation.
Gripper has a TryGrip method, which checks if there's a GrippableItem in the correct position (within the gripper's rectangle). If there is, the gripper takes control of the item until it is dropped:
class GripperItemLoc... |
When implementing GET on a resource is makes sense to respond with 404 if the resource cannot be found. For POST and PUT verbs it is a little more complicated.
To respond with 404 in that case I would need to do some kind of pre flight check. First do a SELECT in the database, check if there is a matching row, if not, ... |
I am planning to develop a subscription based Video on Demand android App.
I am planning to host videos on VPS with unlimited free bandwidth. It's said that nothing beats nginx for static hosting. So I've plan to serve videos through nginx with server configuration :
- 32 vCPUs @2.4 GHz
- 60 GB Ram
- 1800 GB SSD
costi... |
Is there a more syntactically beautiful/simply better way to write the following (without major abstraction)?:
if (usart_error.CRCError == true || usart_error.DMATransferError == true ||
usart_error.FramingError == true || usart_error.NoiseError == true ||
usart_error.OverrunError == true || usart_error.Pari... |
When using data and domain models, where does validation take place? Both or just
For example:
class UsersDB():
def create(self, user_data):
# Create user here
return insert_status
def confirm_user(self, token):
if token_date < today_start:
# Token expired, return False
... |
Please forgive me if I am mixing up the terminology here, I'm a bit unfamiliar with it. I wanted to find a way to support extensibility in a web application; I wanted a web application that was similar to Microsoft Azure DevOps, where in the web application out of the box is fully functional, but also extensible in a c... |
I'm designing an API for a website where users can share images and all other users can see these images. The current idea is to have a path
/user/name/images/xyz to GET a user's image and then a path images/abc to GET any public image "abc." I'm worried that there is a design flaw if I'm separating image retrieval ac... |
The team I am on is using the git implementation in Azure DevOps. We have been using almost the GitFlow model. We are using story branches instead of feature branches, and the long-lived develop and master branches.
The develop branch is deployed to the development environment, and the master branch is deployed to the ... |
I have a need to generate a next number for each file type my Logic Apps is generating. My Logic App is doing some translations between an WMS and a customer's ERP. The issue is the customer is requiring us to generate and maintain a sequence number to be placed in the files. The full list of requirements are:
Gene... |
Problem Background
Recently, I joined a government agency as a software engineer/scientist/analyst. Previously, worked in software industry - gained 3 years of software engineering experience at previous job (to add to about 7 years in computational science/scientific computing). My current job is to come up with a str... |
In the context of a multiuser database desktop application, the concurrency problem has to be considered.
Many articles focus on two models: optimistic and pessimistic locking.
In pessimistic locking you expect a concurrent access to a record and so you lock the resource to prevent others to access it while it's being ... |
I hope everyone is good. Well, I am at the end of my degree BS (Software Engineering), and in the third Phase of my Final Year Project named as 'Test Phase'.
My Project is to build an Expert System for assessing programming course performance of e-learning students. We are advised to design it as a Web Application as h... |
I am making a social media app. I have a use case in which i have to cluster similar type of data. For example, take Instagram. When a user likes a post, we get a notification that 'x likes your post'. Same in the case of follow. If 3 more users liked that post and 2 more followed the user, after some time, notificati... |
I am converting a monolith to micro services architecture using RESTful apis using C#. I have identified various micro services that will completely represent my monolithic application.
One important service is a configuration service which holds important configuration information which would be needed by the remainin... |
Though this seems less like a software engineering problem, IMHO it is actually about programming paradigms, instead of specific "how to solve this bug" questions...
Say we have article, author and tag. article---author is M:1, and article---tag is N:M. Table:
TABLE article: id, author_id, text
TABLE author: id, name
... |
My understanding of mocking vs not mocking is that mocking too much creates brittle tests that need to be changed all the time, while on the other hand less mocking better verifies that the system works as it's supposed to all the way through.
I can see the value of not mocking too much in an untyped language since, bu... |
I am to write a piece of software to a friend of my uncle's, but I don't exactly know all the elements that are needed to fulfil the user's needs, so I can't begin to formulate a design yet. Since the problem is kind of solvable (in a small, non practical scale) by spreadsheets, macros, forms and a database, I am doing... |
At my company, we are developing pretty simple React Native and sometimes mobile-only React apps. Most of them have some similar logic, such as 'sign-in by phone' flow, some payments stuff, etc., and also some similar UI-components as well.
What we wanna do is take all those modules with similar logic, which is basical... |
I have an ASP.NET MVC application and I will need to execute a task every one minute.
The task is:
-> Go to database
-> Check from Table 1 if a record has value = "something"
-> Perform a task in my web application(submit content to a website)
-> Update Record in Table 2
-> Delete item from T... |
I am facing dilemma on how to best design the following functionality. What design patterns and OOD principles should I use.
For simplicity sake following are basic requirements:
displays type can be any of the following: PC Monitor, LG TV, Samsung TV, or other manufacturer
displays can have different functionaliti... |
I'm working on designing a system for reporting/storing information on hardware devices (IoT-like), and trying to figure out how that would best be structured in Azure's Cosmos DB.
Every device will have a unique string identifier, and several groups of properties we need to record. I don't have the structure finalize... |
I have a Rails app with HighSchoolTeam and ClubTeam models. I'm currently using Single Table Inheritance (STI) with Team. That means I only have a Teams table in my database, no High_School_Teams or Club_Teams tables.
What seems appropriate to me would be for HighSchoolTeam and ClubTeam to have their own tables in the ... |
I had a question about big scale projects.
what if the team decides to change a library and therefor the codes should be changed.
for example what if the team wants to change the picasso library to glide so we should change the
Picasso.get().load().into();
100 times.how should we handle this situations?
|
I'm currently working on a project which is build as a microservice architecture.
We have one "Gateway" which aggregates the data coming from the different microservices to return one aggregated result to the frontend. The "Gateways" exposes GraphQL queries and mutations to CRUD data.
The microservices are build using ... |
When sending a request to another module and expecting a result, it seems to me there are two ways of dealing with the 'non-happy paths'.
Throw an exception
Return a result object that wraps different results (such as value and error)
I would say the first one seems better in general. It keeps the code clean and read... |
TL;DR How do you build an airtight license control system for your onprem application, which revokes access once subscription ends?
Premise
I am building this application in Python that needs to be deployed on premise of the client. This application runs constantly like a service spewing out stats. This application is... |
i have a confusion about what code should be placed in view and what in viewmodel
for example click events
here is a snippet code of google ToDo app example for showing application architecture (Link):
//this code is placed in view (TasksFragment)
override fun onOptionsItemSelected(item: MenuItem) =
when (item... |
I'm setting up a development environment for my application. As such, to run it locally, the API dependencies need to be mocked, to keep it as lightweight as possible.
The problem however is keeping the data that the mocks return up to date. i.e. as the APIs and their data matures, it may return vastly different data ... |
I would like to know if it is possible to code any function f that takes a structure S as a parameter while, in case we want to make drastic change to struct S, we can do it without touching a single hair of f ?
Ok, i'll share here what blows and finally your comments will help me to understand things better:
They need... |
Background
The high level overview of my situation is described here. I am breaking it apart into smaller, specific questions, such as this one, regarding extensive use of global variables in a procedural style.
Problem
In the large legacy Fortran codebase that me and some other new team members have inherited, the use... |
I am facing difficulties establishing constraints in the following situation. This is a hypothetical scenario for practicing DB designing.
Imagine, a rule in a School states that the Courses there will be taken in some fixed Rooms. E.g: Math Course can only be taken in Room 101, 102 and 110. Now, a Course can have man... |
For teaching purposes, I'm trying to replicate in a more faithful way from this conceptual UML (from wikipedia):
In a "so-so" real world example, in my case, families of Loans and Insurances:
So, can it be considered a valid GOF Abstract Factory?
Have I followed all the original principles? Or does it needs any kind... |
Suppose I have a domain entity representing a person. (Examples in TypeScript)
class Person {
constructor(public name: string) {}
}
Now, because other parts of the domain will need to reference the Person entity from outside the aggregate, I need to expose the Person's ID in the database.
class Person {
constr... |
Considering a feature needs changes at many places in different modules of the software: UI, business logic, backend, etc.
What is a good approach to do so?
We are using dependency injection and considering to use the ApplicationBuilder to exchange the modules at one single place, BUT this would require code duplicatio... |
In a REST API, when I want to update all the properties of an entity, what is better to use in terms of good practices? PUT or PATCH? If it is better to use PATCH, why is PUT necessary? What would be the difference between the two?
If all fields are updated, in that case both operations are idempotent, right? So, what ... |
Just now I was reading a Python question on stack overflow, about clamping a list/array of results to be within a certain range.
Once of the more simple answers suggested something like:
clamped_list = [ max(64, min(128, i)) for i in source_list ]
This sort of list/array construction loop is championed as "The Pythoni... |
Why is assembly language called "assembly"?
I was just watching the 1st video in the "Crockford on JavaScript" series.
In it, Douglas says,
". . . the first program to make programming easier was the assembler,
and using something called assembly language. We don't know why its
called assembly language. . . ".
Th... |
I have been developing an app that will require a cron task every minute.
We are handling our cron tasks with Spring Boot Scheduling. Although, I am a little worried about the following question:
One part of our product must be highly available on the mentioned task, meaning, if it fails even for 1 minute, it will hav... |
I have a class which has the purpose of providing file operations i.e. providing functionality to create the file, read, write and rewrite to the file. So, the main constituent of the class is functions.
However, there is one functionality where I am using a Timer to make the thread wait for one second. So, basically ... |
I have a 24 hour "sliding window" sequence of "start" and "stop" events in memory comming from an iOT device.
I'm only interrested in finding "stop" events followed by "start" events in order to determine that the object is offline between these two events.
If I only have a start event, the device is considered offline... |
While writing this question I found out that I'm faced with 2 problems: a testing one and a production one but I hope that resolving the situation can solve both issues.
Now the question:
I have a set of data coming from a data base. For one of the data I have different rules depending of the value. To simplify let's I... |
The problem is the following: I have to download a set of JSON files and convert them to a certain format. There are 5 output formats (Let's call them A, B, C, D, E) and all of the downloaded json files are going to be in of of two formats (call them J1, and J2).
So once I decide whether I am downloading J1 or J2 type... |
So almost every post I read about oop by purists, they keep stressing about how using static methods is anti pattern and breaks the testability of the code.
On the other hand every time I look for some example code using factories (irrespective of programming language) specially for the purpose of object construction, ... |
Code below shows setting a value of an object's property and calling a private method in a setter to update the status of the object. Is this call a good practice or setter at most should only validate incoming value and should not take part in other kinds of logic?
public class Toolbar
{
private bool isMenuButton... |
Recently we had a discussion if rough DB schema (high level tables and columns) design should be part of system design phase or not.
We have two confronting approaches in the company.
Let's assume System Design consists of designing Queues, Lambdas, integration with other microservices, etc.
Approach 1)
In system desig... |
So to create a concrete factory that extends from an abstract factory class, I usually create a 'producer' class to determine what abstract factory to use.
For example:
public abstract class AbstractFactoryProducer
{
public AbstractFactory createFactory(String foo)
{
if(foo.equals("foo"))
{
return new... |
I have data in my database in UTC time format in this format (pseudo):
[
{
"date": "Date: 2020-02-12T08:00:00+0000"
"productsSold": {
0: 122,
1: 130,
2: 90,
...
}
}
]
So in this example on the 12 of February, 122 products were sold in an onlineshop between midnight and 1 ... |
In my team, we use git branching to keep different features separate (of course). However, one co-worker insists on keeping these features in different files as well to avoid merge conflicts. For example, we may have a FormView.java on master, but in have both a FormView.java and a ValidatedFormView.java on the form-va... |
What is the best way to name two classes that describe the same object, but where one of those classes does not hold the complete information? And should I make one of the classes inherit from the other?
I want to have (for the sake of example) an API that gets all people to display a list of names, and then when a per... |
It appeared, that I have in my pet project two abstractions: asset loaders and drawing tasks. For each abstraction I have some classes representing them (currently a single class for drawing task abstraction and factory, which returns new classes, for asset loaders), a store (formerly a manager, but I found it is a bad... |
I'm trying to create project siteWeb and mobile app with clean Architecture and Microservices.
create identity service with separate database A and make another api service with other database B.
for example i have table Competence from DB(B) has relationship many to many with Table AspNetUser from DB(A).
how to link b... |
So, I have an API that authenticates with Identity Server OAuth2 and gives our user a JWT token when logging in through a front end application, this is a token that has access to everything.
The API is also external facing so that third parties could access the API using client id + secret via OAuth2, this token is a ... |
We are building some microservices that we will likely be deploying using GAE and I am fairly new to GAE. I’ve done a lot of other development in my day, but this paradigm is a little different. I’m wondering if someone can provide some advice on the most common methodology to follow for development for services depl... |
In a SyML/UML activity diagram, how do you implement an OR gate ?
There immediately came to mind to use a merge node. But does a merge node always have to come after a decision node?
Also, I have seen an action with two inputs where each input has a multiplicity definition, e.g., [0..1], but how could this be used to i... |
In my ASP.net core application with Angular 2+ client, I work with a complicated object graph. In the object graph I have some objects with references to each other. I have a simplification included as an illustration below, where MainObject represents the graph:
public class MainObject
{
public int Id { get; set... |
We have a API (written in .NET Core 3.1), published to Azure Web Services. This API talks to a database for authentication. After a succesfull authentication, the API connects to other databases, depending the user that logs in.
Now we came to the part of insights. I want to know:
The datetime the API is called
By whi... |
We're designing and developing an enterprise application using Spring Boot for REST APIs and Angular 8 as the web client. It's been an year since we started.
When I started, I read multiple articles which cleared my understanding of why REST without HATEOAS is not actually REST. I went ahead with the then available Spr... |
I would like to know which architecture is more suitable when considering data sharing between tenants: a Multi-instance (Single-tenant) or Multi-tenant architecture with a database by tenant.
Imagine this first scenario with two clients who each having an instance of the same application and therefore each have a sep... |
I would like to create a REST API with NestJs. But I want to add GraphQL as another top level layer later on. So for the start I have the basic layers controller, service and TypeORM repository. Let's assume you want to update a user's username by id. The controller route could be
PATCH /users/:id/username
Two problem... |
For teaching purposes, I am trying to create a PHP implementation of a conceptual example of Builder Pattern:
First of all, some products:
class Product1 {
private string $attribute1;
private string $attribute2;
function getAttribute1(): string {
return $this->attribute1;
}
function getAttri... |
The book "Implementing Domain Driven Design" (page 361) suggests to use special types to distinguish several kinds of IDs, e. g. using BookId(1) instead of just 1 of type Int or Long. In my Clean Architecture or Onion Architecture the outermost layer is a HTTP adapter taking an id of type Long. Then this adapter calls... |
I am very confused in what I did with this mercurial repository ... I reversed a commit and after that I was never able to have a "unique" structure in my repository again. Can someone help me?
> hg log
672[tip]: 670,671 9abd695c57ee 2020-02-14 10:01 +0100
commit before
671[localgit/master][master]:669 021... |
Since I cut my teeth on code with OO, I’m biased toward using structs as classes without methods. However, there’s probably a good reason that typedef isn’t the default behavior of struct. What is it?
|
I've been assigned to a code base responsible for millions of dollars of transactions, per quarter, and has been in use for over a decade. Sifting through the solution, I see doubles used everywhere to represent money and arithmetic is done on these variables; on the rare occasion is a decimal type used.
What is an apt... |
I have a collection of animals (interface) which contains birds and cats (both also interfaces). I want to print out all the cats to the console and I am forbidden to use instanceof (I did not make up this arbitrary restriction).
What is the correct way in OOP to solve this? getClass() is not possible because I just ha... |
I have this unit test:
[Test]
[AutoMoqData]
[TestCaseSource(typeof(PhoneNumberTestCases))]
public void PopulatesPhoneProperty(
string inputValue,
string expectedValue)
Entity source,
[NoDefaultEnum] ConcreteUserMapper sut,
{
source.Logi... |
I am struggling with naming 3 variables defining the following concept:
An action, after being performed, is not available for an amount of time and then is available again.
The concept comprises 3 variables:
- A boolean (is action available?)
- An int (action 'cooldown' duration)
- Another int (action 'cooldown' count... |
I'm writing a web server as a test project in node.js
Whats really bothering me so far is the lack of control or even awareness of memory usage. Naturally I want to cache some stuff in RAM for faster operations but how much are my objects using? There seems to be no reliable way to tell.
Best I can think up is estimat... |
I am primarily working with C#, dotnet and Visual Studio 2019 with extensions like Resharper enabled. Visual Studio with Resharper is a memory hog.
I currently have the following PC at home where I do my development work:
CPU - Ryzen 7 2700x
RAM - 2 x 16 gb 3000Mhz
Storage - 512 GB SSD - WD Blue
Motherboard - Asus Ro... |
Saw below definition on https://http2.github.io/:
What is HTTP/2?
HTTP/2 is a replacement for how HTTP is expressed “on the wire.” It is not a ground-up rewrite of the protocol; HTTP methods, status codes, and semantics are the same, and it should be possible to use the same APIs as HTTP/1.x (possibly with some small ... |
This is my first time PM experience. I have created a developer team and we want to work on an Angular-NodeJS project.
I have defined some tasks and divided the project into the different modules/components. For example each page of the website has a component. Also we have routing component, different services, etc.
A... |
I have a .net core api trying to implement it according to domain drive design principles.
In the domain layer there is a public Create method that contains all validation and business rules. If one fails it will throw an exception. So basically you can not create an invalid entity or an invalid value type. For exampl... |
I'm implementing a custom templated container as part of a learning project in C++. The container makes use of different components like serialization, memory management, iterators. I am wondering what is the best way to organise the code.
Option 1: Put everything into one header file:
I've seen this in several example... |
Context: A system tracks some sort of transactions (e.g. money flow) for it's whole user base. At the end of the month each entity capable of receiving transactions has to be sent exactly one bill containing all the transaction's of the current month.
This system is instanced, meaning that there are multiple instances ... |
In a tennis match, each game has the possible scores of Love, 15, 30, 40, or Advantage. This could be modeled as a dictionary [0: "Love", 1: "15", 2: "30", 3: "40", 4: "Advantage"] or enumerated type cases. In the situation where both players win six games however, the next game is a tiebreak where points are simply sc... |
I'm trying to find the best design approach to handle a design change in a new project I'm working on.
At the moment, the flow runs and makes some calculations based on a parameter which is used.
Now, different parameters needs to be added and a new flow would have to be run for each of the other params as well.
Just ... |
I'm making a chat server using sockets and a MySQL database, and after it's working I want to expand it to become a more complex game server.
I want to know whether my design is missing anything.
Specifically, I'm worried about database access from different threads, or whether I may be creating too many threads, and w... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.