instruction stringlengths 34 36.1k |
|---|
I have two tables products and product_tags in my database having a many-to-many relationship. But I am having a hard time coming up with a practical name. So I was wondering if there is a standard for such a stuff?
For orders and products which also have many-to-many relationship, I can name the association table like... |
In Computer Systems: a Programmer's Perspective,
In addition, the compiler may need to add padding to the end of the
structure so that each element in an array of structures will satisfy
its alignment requirement. For example, consider the following
structure declaration:
struct S2 {
int i;
int j;
char c;
};
If we pa... |
In Computer Systems: a Programmer's Perspective,
Alignment is enforced by making sure that every data type is
organized and allocated in such a way that every object within the
type satisfies its alignment restrictions. The compiler places
directives in the assembly code indicating the desired alignment for
global data... |
I have been confused about the best process for private distribution in iOS - imagine we are a company like Just Eat, where venues can sign up with us and take orders from customers via a customer app. Conversely, they can then see/process their orders via a venue app. It is the venue app I wish to be privately distrib... |
I wanted to get some feedback on the design of a chat application I recently developed. The application is written in PHP, but the language probably isn't important here.
The main components are User, Conversation, and Message:
class User {
public function getId(): int {}
public function getUsername(): string {... |
A project is structured as so:
A build server listens to changes in two repositories: a frontend and backend repo. When it picks up a change it builds, tests, and deploys the updates to a production server that exposes a publicly accessible endpoint.
On the production server, the backend is a Golang https server that s... |
TLDR:
If microservice A needs to combine data from services B & C (that are not aware of one another), should B (or C) do the data merging for service A, or it will be up to service A?
In Details
So our retail website has a microservice that is responsible for Products data:
Get products by category, or do a GET for a ... |
One of the major issues that I am facing as a Website and App developer, is that certain components / features have to be redeveloped over and over again with a new project. For instance login, signup, user account settings etc with each new UI.
Is there a recommended method or a best practice (Design Pattern) to facil... |
Let's say that I have the following class.
class Application
{
protected $dependency;
public function setDependency($type)
{
$this->dependency = ServiceLocator->getServiceFor($type);
}
public function execute()
{
$this->dependency->handle();
}
}
The $type v... |
Problem to solve
I have a method parse_doc that should dynamically determine a parsing function to parse document_id based on the value of the document_id string:
# list of files that may have different custom parser that depends arbitrarily on name:
documents = [
"my_file.py",
"my_file.sh",
"another_file.t... |
So, in general casting and dynamic_cast in particular are to be avoided.
But I don't see a proper alternative for this:
List<DerivedA*> ListA;
List<DerivedB*> ListB;
Bool Add(Base* obj)
{
if(DerivedA* AsA = dynamic_cast<DerivedA*>(obj)
{
ListA.Add(AsA);
}
else if(DerivedB* AsB = dynamic_cast<DerivedB*>(obj... |
I have a use case describing the following:
The actor can view the table of listings.
and I want to create another use case where the actor can delete a listing.
I consider viewing the table of listings a precondition in order to be able to delete any listings, so can I include the use case title as a precondition or s... |
So I am writing a project using Spring Boot. All of my logic resides in @Service classes. I have separated each service class based on entity. For example - If I have two independent entities A and B, then each has following different classes:
RestController
DTOs
Service
Repository
Entity
When I start writing code fo... |
We need to call a webservice which registers a shipment with either UPS or TNT.
You fill in some details, call the function to register and pass json for details. Pretty basic stuff.
Shipment shipment = new Shipment
{
Services = new List<int>(),
Lines = new List<Line>()
};
shipment.Addresses = new List<Carrier... |
To start off with an example: I have a read-only Repository used for getting arbitrary values. This behavior can be implemented multiple ways.
I also want to allow opt-in mutation of the repository's values through a MutableRepository, which implements Repository because it satisfies Liskov substitution principle (any ... |
I try to use dependency injection as often as I can but every time I end up with the same problem : I always have a giant main function.
If I use it without any framework and send the classes in the constructors, I have to initialize every class in the main and it can take quite a lot of lines.
If I use a framework wit... |
I've just read this article, about handling distributed transactions in the microservices world.
In the article, the author explained two possible solutions available.
I'm familiar with SAGA. But never actually tried the Two-Phase Commit pattern.
And here we go with my question:
In the Two-Phase Commit pattern, how to ... |
I'm currently trying to make a simple program with UI where a user can add, select and remove different objects inherited from an abstract common interface with a mouse.
What I plan to do is use a set<unique_ptr<Concrete_class*>> to store collections separately for each type of all the objects created and store one cur... |
I started to play with C++ recently. One of the difficulties I have quite often is when the compiler tells that there is an issue with the types: more often than not, those compiler errors look extremely cryptic to me. Here's an example:
Smooth.h:63:15: error: invalid user-defined conversion from ‘Smooth<T, S>::sum(st... |
In our company we split up software development in three non-overlapping teams: a team that writes the specification, a team that writes the code, and a third team that tests the implementation against the specification. I'm looking for a bibliography reference for a description of this division of labour? It seems to ... |
I have read this https://stackoverflow.com/questions/5818898/where-to-put-global-rules-validation-in-ddd and I have create my validator.
But now I need to create a validator that must check the order entity.
This is the problem: When I create or edit an entity "Car", I need to check 2 conditions:
I can't have the prope... |
I have been studying about OS and currently, I am on "types of the kernel". Now in the book and some websites are saying Monolithic kernel-based OS is faster, but how are they faster than Microkernel-based OS.
|
I'm trying to learn the fundamentals needed in order to be able to analyze CISC architecture executable binary instructions and break down each instruction into its components including the opcode and address.
The following diagram I found here is almost exactly what I'm looking for, but whereas I'm new to the subject,... |
I'm trying to found the best way to manage Exception for all over my application.
Actually, I've come with two solutions :
Solution 1
One Exception to govern them all.
namespace App\Utils\Exception;
class LogicException extends Exception
{
/**
* @param MessageI18N $messageI18N A message which may contain para... |
I am trying to design a database where each user can save up to ten lists of cards. Each list could theoretically have tens of thousands of items, but will likely only have hundreds.
Should I create a new table for each user? I feel like this would make the database really hard to manage.
Alternatively, if I just have ... |
I have an array of N integer values, and I need to sum elements and distribute these sums by equal parts in the range from 150 to 250, but without to mix indexes. For example {50,100,50,250,200,49, 100} will be (50+100+50), (250), (200+49), (100). This is the best solution here. But I can't write the optimal algorithm ... |
I have read in some tutorials that one of the differences between procedural programming and OOP is that OOP allows you to make member variables private, while in procedural programming you can't make member variables private.
I have also read in other tutorials that allowing making member variables private is not cons... |
I'll be using C# for my example since this is what I am using, but the problem is sort of generic.
My app code takes a collection of Foos (externally populated and edited) to do some processing, and needs to process it again every time the collection is edited (an element is added, removed or changed).
The simplest way... |
I have read that in OOP, we think of objects as "sending messages to each other", for example if we did car1.stop(), we say that "we sent the message stop() to the car1 object".
But what benefit do we get by thinking of objects as "sending messages to each other?" What I mean is, let's say that we thought of car1.stop(... |
When dealing with an API key (in this case a JSON file used to connect to the Google Analytics API), what is the appropriate way to securely store the keyfile?
"Your new public/private key pair is generated and downloaded to your machine; it serves as the only copy of this key. You are responsible for storing it secure... |
I have an API that manages projects. You can get a single project via this endpoint, where {id} is a numeric project ID:
/projects/{id}
Each project can have one or more tags. Now I want to add an endpoint that will return an array of all tags that are assigned to at least one project.
My inclination is to put this en... |
I’m curious as to why the bitwise AND of any even number with 1 is equal to 0? I’ve looked at the binary representations of an odd number and 1, and have found that the following is always true for any odd number:
00101 (5)
00001 (1)
5 & 1 != 0
00100 (4)
00001 (1)
4 & 1 = 0
The least significant bit is always 1 for a... |
I'm trying to understand and implement with good practice the Specification Pattern within my domain driven design project.
I have few questions:
For example: verifying that a customer is subscribed before update a data on a aggregate is it part of business rule and should sit in the domain layer?
Can specifications cr... |
I may not being fully understanding MVVM or how MVVMCross works, but my understanding of views is that they are components of a window rather than the window itself.
When you start up MVVMCross in C# WPF you specify the ViewModel which is ok, but this only relates to one view (from what I can gather). For my idea I wou... |
I have seen tokens like this:
var message = "Hello, {Name}";
and like this:
var message = "Hello, ${name}";
and like this:
var message = "Hello, @NAME";
and a few other styles over the years.
Is there a common or preferred token format, style or character used in creating a set of tokens?
I have tried to used con... |
This is my first question so be nice lol...
Think of it this way. Python is written in C, which is written in an older C compiler, which is written in an even older C compiler, which is written in B, which is written in (I think) BCPL. I am not sure what BCPL is written in, but it seems that there must be an original l... |
I am implementing a backend with a typescript framework called nestjs and I was reading some documentation about their usage of queues. https://docs.nestjs.com/techniques/queues I have never used queues between services and I don't understand why or when I should either. (hence my question)
So I had some thoughts regar... |
I have a feature in which the user can directly provide the entire nginx config inside the completeConfig variable in the config yaml.
Like this:
nginxConfig:
completeConfig: >
....
....
But completeConfig variable seems a little weird. Can someone suggest something better?
|
Our builds are not binary by nature of WordPress PHP/JS, merely combined and minified. But they can be re-created by any developer easily and I feel like they shouldn't be version controlled but I thought I'd ask. What's the best practice? If they were version controlled I assume we'd waste some time with conflicts fro... |
We are new to git, but this fundamental question needs to be sorted out before we can begin. It's two devs who have been working standalone for a while. Now the time has come to adopt git (at the first sight of sending each other zips and poking the same files). I work on both front&back, he works only on the back. So ... |
As the title suggests, I need to create a document viewer such that a user can log into our website and view the files tied to their account.
The reason I'm struggling with this is that the files are stored in Google Drive and contain sensitive data so must be kept private. Moreover, the users have accounts and login d... |
The Issue
When I'm fixing a bug during web development projects, I often find myself cleaning out the existing (tainted) database records, clearing out log files, etc.
I do this so that I can start from a fresh state to ensure that none of the previous buggy run's records will affect my new run.
Dropping tables, cleari... |
Our project changed the object existence checks from foo == null or foo != null to Objects.isNull(foo) or Objects.nonNull(foo). I never got an explanation why that should be better, that's why I ask.
I’ve been programming in Pascal, C, Perl, Java for a long time and have always checked for inequality with !=. This syst... |
Status quo
I created an aggregate, let's call it Foo. It has two entities within itself, let's call them Foo & Bar.
You can mutate things by calling the aggregate's public methods. E.g. $foo->doSomething(). I.e. the aggregate itself has an repository injection. Looks this way
class Foo
{
/**
* @var FooReposi... |
Given a website, our customers will pick a spot on their website and we record an xpath to that location.
Our software is DNS integrated, similar to cloudflare, and we manipulate the origin's html response based on the xpath the customer has chosen.
I am faced with a challenge where if a customer adds new or changed ht... |
We want to implement Feature Deploy Flags, so Development Application Environment will have a new Product feature Toggled on. And Release and Production Environment Webpage, it is turned off.
Its toggled through appsettings.json file.
https://launchdarkly.com/blog/what-are-feature-flags/
Our clients, do not like Featur... |
Disclaimer :
I come on this topic after it has been recommended to me on my previous closed SO topic (see closed one : https://stackoverflow.com/questions/64338968/how-to-effectively-manage-a-large-number-of-exceptions-i18n-problematic).
Also, you'll see that even after a doing some research and reading about the subje... |
I'm trying to change my module's outline since I feel I'm blocking some reuse possibilities, but I don't know how to justify it under the lens of good practices/design principles. Keep in mind this is supposed to become a template for this type of module.
My reasoning for the proposed change lies with the possible reus... |
Would it be possible to develop a program that could optimize algorithms, detect design patterns and then rewrite the code? For example:
Detect a Bubble sort and transform it into a Quick sort or a Merge sort
Replace unnecessary repetitions of instances of a class into a Singleton
Refactor similar functions into a mor... |
I'm starting to write production software (just for myself, not for a company with a pre-set mode of operations for this). I want to find a way to send a message from my users to me (the developer) whenever a critical error occurs.
For example, I write to files on the system very frequently, so I want to know if there ... |
I have to write a code where i have send some data (call it List of cases) using one of two integration tools (Jitterbit, Mulesoft), with possibility of adding more tools in future.
Integration tool being used will be determined runtime. User selects on UI and then integration runs. If user selected "Jitterbit", then i... |
I know that lots of people hate #regions in C#. IMO there is at least one legitimate use of them:
Sometimes I have a class which, in addition to its core functionality, needs to implement a commonly used interface such as IEquatable or IEnumerable. This interface requires several members which are quite separate from t... |
Which code should I prefere and why? Is there some general rule?
Code 1:
var apiLicenseInfo = GetLicenseFromApi(string userId, string deviceId);
var localLicenseInfo = MapToLocalLicense(apiLicenseInfo);
Code 2:
var apiLicenseInfo = GetLicenseFromApi(string userId, string deviceId);
var localLicenseInfo = MapToLocalLic... |
In C,
Bitwise logical operators &, |, ^ is used for selecting bits in a word.
Bitwise shifting operators >> and << can be used for implementing multiplication and division between integers.
Questions:
Are bitwise logical operators also used for implementing operations on values of higher types (e.g. integers)?
Ar... |
I work with C# and WPF and not using MVVM approach. One of the important part of applications is communication among Windows Pages and UserControls. In MVVM they do it behind the scenes and let you use some method to make it possible to send or receive data among different instances.
In code behind, Parent and child w... |
I wanted to ask what are the possibilities of maintaining reliability when exchanging messages between microservices, when one of those message is rejected. As of today, we don't want to lose messages, so we are re-queueing these rejected messages. Consequently, there is a risk that the messages will be processed in a ... |
I'm working on a Java service that runs on Google Cloud Platform and utilizes a MySQL database via Cloud SQL. The database stores simple relationships between users, accounts they belong to, and groupings of accounts. Being an "accounts" service, naturally there are many downstreams. And downstream service A may for ex... |
In a multi-tenant architecture where each tenant has its own database, what would be the best way for each of the microservices to obtain information about the tenant (such as which database to connect to)?
We are still in the modeling phase of the application. We are having difficulty to come up with the best design. ... |
I am trying to assess the viability of microservices/DDD for an application I am writing, for which a particular context/service needs to respond to an action completing in another context. Whilst previously I would handle this via integration events published to a message queue, I haven't had to deal with events which... |
Background
I am trying to migrate an SVN repository that was formerly 2 svn repositories (but within the same svn server, so sharing commit numbers), which was then combined.
So initial state (two repos):
http://svn/mergeTwoProjectsTest/project1/branches/4.0.0
http://svn/mergeTwoProjectsTest/project2/branches/4.0.0
Co... |
Let's say I'm building a simple console app which has three commands:
Create category.
Download recipe from API to category.
Display all recipes in a category.
Assuming the app will grow, I use the Command design pattern to handle console commands. I also use a factory design pattern to create the commands from the u... |
Is it an issue to have multiple almost identical interfaces?
In our company we have 9 identical interfaces for 9 document types, like: Book, Contract, Person, etc.
interface IBookInner { Book GetInnerObject();}
interface IContractInner{ Contract GetInnerObject();}
interface IPersonInner { Person GetInnerObjec... |
I am the author of a C library for parsing INI files. So far I have delegated the task of parsing values as numbers to the standard atoi() family of functions. However I think time has come that I provide my specific functions for parsing numbers, since in INI files a number can be notated in octal, hexadecimal, etc., ... |
I'm currently reading "Composing Software" by Eric Elliott, which is about functional programming in JavaScript. He states that if you compose multiple functions together, and that these functions have been fully tested in isolation - then you don't need to unit test the composed function (as that can be done using an ... |
On Android, the "Power saving" option within the location settings means that wifi and mobile networks are used to determine location. What data points from these access points does it use and how does it factor these into calculations?
|
Looking at the clean architecture layers and flow diagrams, and implemented it my self in my applications, I've always wondered which layer is supposed to contain the DB, or any 3rd Party service or SDK.
Looking at both of these images raises the question if there isn't violation in the outer layers.
I've imagined t... |
Java 9 introduced many new methods in the CompletableFuture API that support execution timeouts.
For example:
public CompletableFuture<T> orTimeout(long timeout, TimeUnit unit);
public CompletableFuture<T> completeOnTimeout(T value, long timeout, TimeUnit unit);
More can be found in the documentation.
These methods... |
I have always advocated the use of standardized api, and currently use it on my code. However i always get very strong resistance when it comes to code review, even on projects i have designed and built from scratch which there is no existing code that i will conflict with.
I use standardized API to insure that i am in... |
When teaching students Python lists (which are more like arrays, not linked-lists) I'd like to use metaphor of list being a collection of boxes put in row.
But this doesn't work well:
indexes are important to be numbers, but in my example indexes should actually be counted, and it is not obvious that "counted" and "in... |
While learning about OOP, I have noticed that a lot of the tutorials give examples of objects such as Car objects and Dog objects, but I don't know if these kind of objects are used in real life programs.
I think they may be used in a game for example, so if a game have cars and dogs in it, it would use Car objects an... |
We are building a set of web APIs. The web APIs are called by clients & can call each other.
State is required by these APIs for the users session (e.g. shopping basket type stuff). The state can be large (over 8k) so doesn't look appropriate for the client.
At the moment the state is being managed directly by the ap... |
When defining McCabe's essential complexity, the idea of a structured programming control structure is present. I don't understand why an if-then-else, a while loop or a for loop can be reduced to a single statement such that it's cyclomatic complexity is of one.
|
Let's say you have a scenario where you want to build a simple web stack (html/css/js) prototype to share with someone.
I am a little unclear on whether or not I want/need to use a small web-server to do so or whether it is appropriate to recommend opening the root html file (lets say index.html) locally in your browse... |
The examples of default settings:
Default port for server applications
Default resources directory for Java Applications
Default Webpack config file ("webpack.config.js")
My particular case
I have a utility for web application projects building, based on gulp and webpack.
When a user did not specify some settings in... |
I am planning to build an adapter between a PC and devices which have the same function but which have different interfaces. The adapter will probably be based on a Raspberry Pi and will have a touch display. The PC app will know nothing about which device is actually connected and the device will be selected via the t... |
I want to know if the way that I handle form validations is a good way.
What I actually do is a very detailed client side validation to validate each field and with custom error message for the UI according to the error. So for each field the user can see the associated error message.
But in the server, I do the valida... |
I'm a undergraduate, and studying 'Software Design And Analysis' for my current semester.
As part of the course, I was handed over a case study from which I had to make out the visual form of the resulting Use Case Diagram, with the necessary Use Cases and `Actors.
The case study is about Purchasing Flight Ticket Syste... |
Assume that we have a car in the real world, this car would be composed of atoms, and we can do operations on this car (for example: we can move the car or change its color, etc.).
And assume that we have a car object in the computer world (in RAM), this car object obviously is not a real car but rather a representatio... |
As a team we are preparing a REST API for handling chargers' operations.
Let's say we have a part of the code that is responsible for starting charging and for stopping charging.
We want to provide users (on mobile app) a way to start or stop the charger through our API.
Which of these is the most RESTful approach?
/{c... |
I have a web app that is capable of connecting to multiple databases that are identical in structure but contain different data; each of our clients who uses the app gets their own copy of the database to avoid commingling of different clients' data. We determine which database to connect to by looking up the client's ... |
I need to run software compiled for ARM on my x86 machine. Usually, to do that, you use an emulator like QEMU.
I'd like to know why we can't just process the binary for one ISA and compile it to a binary for another? Would doing so have the advantage that even if your codegen is sub-optimal, we could perhaps use existi... |
C11 standard says
6.3.2.1 Lvalues, arrays, and function designators
A function designator is an expression that has function type.
Except when it is the operand of the sizeof operator, 65) or the
unary & operator, a function designator with type ‘‘function
returning type’’ is converted to an expressio... |
The Apache 2 open-source license allows patents, does this mean it could be possible that an apache 2 open-source project would have to be removed if a company demonstrates it has a patent based on or using the project?
|
This is a question about software architecture, not databases.
I currently have 2 completely separate web applications, call them A and B for simplicity. They are on their own machines, with their own databases and web servers. My job is to integrate these 2 applications together (how I'm doing that from the front/back... |
How do you tell if a group of items is stacked horizontally or vertically given only the items x and y positions?
Vertical Group:
item 1
item 2
item 3
Horizontal Group:
• item 1 • item 2 • item 3
The items in the vertical stack can be moved left or right but each item is further down from the last.
The items in a hor... |
I did some googling, and I was directed to Software Engineering to ask architecture questions. If you know of a different forum that could help me, please direct me to it
I recently started learning about microservices, and would like to build an experimental app (the backend) just for practice. I’ll explain the app re... |
Are there any prescribed patterns or systems for allowing a user to create custom domain logic? Consider the following scenario
An application exists that allows users to run complex calculations on the applications datasets(these calculations would be the domain logic). The owners of the application are a team of mech... |
Imagine you're in a Python setup, with all of the projects you're working on. Now, as a base line, you have a Python module that is the backbone (backbone.py) to everything when it comes to getting data from a datasource. There is also a FastAPI implementation of this this backbone (backbone-api.py), offering a handy w... |
I have a monolithic application which can be divided into multiple steps and different steps have variable scaling requirement, however the input of the next step is the output of the current step. Currently, we are not able to handle the no of requests to our server and we need to have more servers/load balancer/etc. ... |
I just started thinking about building a microservices architecture for learning purposes.
I understood that microservices are split, and they should be independent, even when storing data, but what is the real application of it?
Most data isn't independent, and is relational in some way, even when using non-relational... |
I believe this is still on topic.
This question comes from a mixture of curiosity and exasperation. A colleague refuses to use native debugging; whether in a stand-alone debugging tool or in an integrated IDE. I wouldn't care, except the colleague constantly complains he doesn't understand what the code is doing in the... |
The program is written in JavaScript. To give you a rough idea what I am thinking of:
function State() {
return {
color: 'green',
size: 100,
// ... there are other properties here
}
}
function init() {
const state = State()
const otherObj = OtherObj()
// ...something like an event fires `foo`... |
In my MVC web application the controller calls a service layer which takes any relevant request parameters and builds the model for the view e.g.
Controller
var model = _modelService.Build(id);
return View("ViewName", model);
If there are multiple reasons why the model service will fail to build a valid model, how do ... |
We're currently building a Django app that's a doctor-patient-agent manager that allows patients to book a consultation, and doctors give them their prescription and information. What's important is that we're handling sensitive data, and we're planning on open sourcing some of the data (which we will be anonymized of ... |
The Scrum Guide isn't very explicit about the scope of the Definition of Done.
Is it supposed to be:
defined in general for the project?
defined per sprint or per increment?
defined per story?
defined per backlog item?
I'm confused because after reading the Scrum Guide, I'm now reading the book "Head First Agile".
"H... |
I have a function which has discrete time step ,discrete length from origin . These two give height of the function. For example at time 1.2sec , and length 5.5cm from origin height is 10cm. The step size of time is 0.4sec and length step size is 0.5cm. How to store this, I cannot use 2D array with time and length as i... |
I am writing numerical calculation software using .NET C#, which needs to be blazingly fast. There is a lot of fractional math. So using decimal type is pretty much out of the question, given its poor speed relative to using double. But of course double has its problems testing for equality, with floating point roundin... |
First, I am not sure where to ask this. Please point me the correct stack exchange if it does not belong here.
Note: I do not know how to correctly name "mobile data" in english. But I refer to 3G/4G/etc.
To send or receive a MMS (Multimedia Messaging Service), I need to activate mobile data on my phone, even if I am c... |
I tried to combine two rules.
Don't fall to primitive obsession (e.g. EMailAddress should be a value object in domain objects and not a string).
Don't use value objects in commands and events.1, 2, 3
If commands and events should not contain value objects (for obvious and often discussed reason) they contain somethin... |
I have a number of libraries that I have developed for various projects, e.g. a web server, some computation tools, some logging tools, etc.
These reside in different parts of my drive.
When I have a project that uses a few of these, I (rudimentarily) just copy the source files from the library's folder to the project'... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.