instruction stringlengths 34 36.1k |
|---|
Let me start by saying that of course conventions are important, there should be a rule of thumb for some cases that is representing the best action to follow by, in order to prevent mistakes and make stuff more simple.
Now for the topic of the question/discussion.
I am working on a side project of a DNS server written... |
I've recently been developing a networking application layer (or at least attempting to) for my game I've been working on. I think I've got a decent basic idea for the system now, but there is multiple ways of implementing it (I refer to the two difference ways as class-inheritence and struct-interface) and I'm at a cr... |
In variables/classes/methods naming, sometimes "of" preposition is omitted and word order changing, for example:
"Absolute path of source file of entry point" -> "entryPointSourceFileAbsolutePath"
Now I am considering the renaming of above variable to:
absolutePathOfSourceFileOfEntryPoints
Which other approaches exist... |
I have a piece of code where I need to assign a value to a variable, but base on condition, it could take other values. It can be done in multiple ways, but need to know which would be preferred in terms of optimization.
1. Assigning the default value in the last else
if (deviceInfo.pop) {
this.forms = getPopFormMo... |
I've gone through AUTOSAR Layered Software Architecture and understood that it is something like a file structure in which it is defined to have all the hardware abstraction in one directory and called as MCAL, and so on. Am I correct? Does a proper File Structure make a project AUTOSAR Compliant?
If it is a file struc... |
Given an array of integers, we want to find how many explicit pairs can be made such that their sum is divisible by 60. The pairs are not necessarily non-unique.
For example, let's say the input into our function ReturnPairCount() was as follows:
[29, 20, 30, 100, 30, 121, 160, 31, 20]
our function would return x bec... |
I'm using a client library for an HTTP API. The client exposes objects and methods matching the domain, e.g. Api::Document.download, but the return value is just the http response from the API. As the user I have to parse the JSON response value and check the http response code for errors.
That seems like it's exposing... |
(Disclaimer : I'm asking this question here because as it is opinion-based, it have been closed from https://stackoverflow.com/questions/64050308/an-action-in-my-controller-has-too-much-responsibility)
Summarize the problem
This question has come to me because I write a function to set a current cart for a user.
Specif... |
Lets say you created an order. Since Uber is a very dynamic system, one should constantly check if there are available drivers for you.
If orders are saved as a some collection (e.g. in MySQL table and etc), then one should iterate that collection again and again and try to match client with driver, because some driver... |
OVERVIEW
We have multiple data providers who provide us information from a large set of data sources. These end data sources provide data in CSV format.
Since, the CSV formats are not consistent across different sources, we currently have a manual process in place where a human goes through each CSV file we receive and... |
Setup
Consider the following models (pseudo-code)
Place:
type: const = "Place"
id: str
name: str
lat: float
lon: float
# other fields
Event:
type: const = "Event"
id: str
name: str
start_date: timestamp
location: Place
# other fields
I am using Python for the BE and CouchDB as DB System.
When ... |
I have written the following code which takes a coord_list of points in a 2D coordinate system, a center and a radius and returns a list of all points from the list having distance at most radius from center.
def points_in_rad(coord_list, center, radius):
distances = [distance(coord, center) for coord in coord_list... |
Python is very specific language which gives developer huge flexibility.
So if I have class like this:
class Car:
def __init__(self, engine: Engine):
self._engine = engine # dependency injection
self.speed = 0
def accelerate(self, target_speed: int):
if self._engine.can_accelerate_to_s... |
I'm building a todo list app and using react-beautiful-dnd on the frontend to allow users to reorder tasks. I'm trying to work out how to persist changes to the database when a user reorders items.
With react-beautiful-dnd, when a reorder occurs, there's an onDragEnd callback which provides me with the following inform... |
I have been in two software product houses for three years in a row.
The first is a small company maintaining a fairly small management system with a monolithic legacy code base (almost twenty years). Tightly coupled code is everywhere without sufficient unit test coverage. However, the management usually does not want... |
For example, the Scrum Guide states (emphasis mine):
The Scrum framework, as outlined herein, is immutable**. While
implementing only parts of Scrum is possible, the result is not Scrum.
Scrum exists only in its entirety and functions well as a container
for other techniques, methodologies, and practices.
This appear... |
This question is not so much about how to implement a solution as I've already implemented a working solution, but more about how to improve how I implemented it. The implementation process of the requirements was haphazard. That was partly due to unclear requirements and partly due to an unclear preexisting partial so... |
The 1 logic is that due to inheritance. But, except that how does Object Oriented Systems helps in reusability?
I have read this article below. https://www.drdobbs.com/a-realistic-look-at-object-oriented-reus/184415594 But, this fails to explain exactly how "Being object oriented, reuse became possible".
That is, you c... |
There are a lot of examples over Internet that show why you should use guards.
For example:
public double getPayAmount() {
if (isDead){
return deadAmount();
}
if (isSeparated){
return separatedAmount();
}
if (isRetired){
return retiredAmount();
}
return normalPayAmount();
}
The author compare... |
It seems to me that update a property is always an 'event' and that all you can do with an event handler can be done in the property let/set routine.
And, in my limited experience, I never needed to raise an event without change a property.
So, I see them as a duplicate for a functional point of view and maybe useful f... |
Over time I become used to use the type of the returned value of a function as a piece of additional information.
For example:
A function that is supposed to return or an array if the arguments are correct and can find a result, can pass a specific enum when arguments are incorrect or the expected result cannot be foun... |
I am reading about OOD and came across Parking lot design problem.Parking lot has parking floors which has parking spots.The parking spot class looks as follow:
public enum ParkingSpotType {
HANDICAPPED, COMPACT, LARGE, MOTORBIKE, ELECTRIC
}
public abstract class ParkingSpot {
private String number;
private boole... |
I have a mobile app (iOS and android compatible) that needs to know if it's far or close to the user's laptop/ desktop (e.g. whether it's within 5 meters or not). I need to make it secure such that only the user's phone can connect to that laptop/ desktop, but other than that there's no other requirements.
Does anyone ... |
For my situation I have a device receiving string commands such as turn_on, pump, etc. Some of these commands also have arguments attached to them such as an int.
I have methods like this
void turn_on()
and some with parameters.
void pump(int milliseconds)
I'm trying to find an approach that allows something like thi... |
I am new to software testing and would like to know whether it's appropriate to draw a data flow graph that flows from initiation of variables to constructor and method.
Is there something wrong with this data flow graph?
class car {
string brand; // 1
int age; // 2
car(string brandName, int year)
{
bran... |
I'm working on my first ever software project. Being the only one working on it, I'm making the work breakdown structure and I know requirement gathering is an important phase in the development process. What I can't wrap my head around is how exactly is a software requirement different from a feature that the system n... |
Is an OS compiled every time it boots, or is it compiled once and the result used every time the OS is (re)booted?
When users change settings, is the compiled kernel modified at all?
If I am the one writing the OS, would I compile it and then users install it without need for compilation?
|
Lets say I wanted to autogenerate questions for a wikipedia page as a sort of comprehension exercise, how would i best go about that.
Using machine learning would be necessary but any other things i need to look into?
|
what i know is , in cpython when we run a code then its first compiled into byte code and the cpython interpreter( which is written in c interprets it) interprets the byte code and converts it into machine code. Does that mean the byte code is represented as c code by the interpreter and then its carried out as c code ... |
My boss say we should find a way to scale code reviews at our company. As it is right now, we have about 16 software developers spread across 4 different teams/squads, but soon the company will close a deal which will double the company size. With that, eventually we'll have dozens of developers. He recommend me checki... |
I'm a beginner at collaborative development, I started learning about merge conflicts.
And I have this question.
Is it possible for a developer to deliberately postpone merging because he doesn't want to be the one resolving a potential conflict?
If this isn’t the solution, what are the strategies that work?
|
I have a service which provides an endpoint that fetches from another service, saves, and returns an record.
Here are the details:
The caller calls the endpoint using an identifier (say a customer's student ID number)
The service checks DB for that student ID. If no record that has not expired is found, the server cal... |
I have developed a custom-made Python package, which provides 2 classes to play with: Stage and Step. They operate based on a Chain of Responsibility design pattern, and behave in a way where:
Both Stage and Step possess handle(request) method
Stage has a list of Stages or Steps underneath it
Step is the endpoint, whi... |
I'm trying to implement a safety feature that puts a timeout around a huge function call. Pretty simple, I thought, but it turned out much harder than expected; there's no built-ins for this in any of the C languages I've looked at, apparently because it's too complex under the hood. But JS engines do this all the time... |
I need a solution for decision making chain. There are number of criteria that may return true, false or be inconclusive. A non-functional code (Java) would look like this:
Boolean res = nullValuesCheck(fieldValue, node);
if (res != null) {
return res;
}
res = typeCheck(node);
if (res != null) {
return res;
}
r... |
Am new to unit testing, and I have been struggling with the right approach to test private functions. I have done my research, and am going with testing through the public interface.
My problem is the following, if I have a private function used by two public functions, I encounter test case duplicates, which I don't k... |
While investigating Wikipedia article on Qantas Flight 72 I've found "Potential trigger types" section that says (emphasis mine):
A number of potential trigger types were investigated, including software bugs, software corruption, hardware faults, electromagnetic interference and the secondary high-energy particles ge... |
I am building a three-tier architecture application that receives compressed (zlib) text records from a data store, decompresses the records into structs, and then serves the records to clients over the network, which run SQL-style queries on the records.
The issue I'm running into is I need this application to be able... |
I have a Kubernetes instance from DigitalOcean that has 2 worker nodes and 1 load balancer. Now I want to create a MySQL managed database cluster for the app that will run on that Kubernetes.
Question is: Does DigitalOcean offer enough resources for a scalable database cluster?
The plan that I'm looking at starts at $6... |
Our team is currently building out an application built with microservices. This application will handle many tenants (organizations) with a database per tenant design. Authentication is handled by Auth0. A user logins in on an SPA and all requests are sent into an API gateway where the JWT is authenticated.
Based on m... |
I have different services in a spring application that have a dependency on Jackson ObjectMapper, the unit tests rely on @InjectMocks to inject all the various dependencies to the class that is under test (including ObjectMapper).
Is this an acceptable behavior? Is there any accepted best practice about it? Should I co... |
I’m still really new to learning to program. Just learning the syntax for a few programming languages at the moment.
The courses I viewed for C# and Java touched only very briefly on getters & setters and it still didn’t make an awful lot of sense to me. So I researched them further and found that the whole subject of ... |
We are writing application service tests across our Data Service Class.
Currently writing tests liking add Product, remove Product, check for inventory after sale, etc.
They are all using the same data storage in a list, BeforeEach Method.
When they are all utilizing the same data set, I'm afraid changing one piece of ... |
I'm building a walled-garden e-commerce system where many users will add funds to the system. They can then spend these funds with merchants, who can then cash them out from their virtual account to real money in their bank account.
Due to implementaion details with our payment provider, every time a user pays in they ... |
I often use function closures for storing data (e.g. database URL), which doesn't change between function calls. Is this an (anti-)pattern? Does it have a name?
While developing apps, which recieve data, process and send data (using a variety of protocolls), I stumpled upon this recurring problem:
A functions needs 4 ... |
I have a class that is responsible for writing formatted binary objects to a file on a network drive with a 100Mbps bandwidth.
Each time an object is created (via lets call it w.addObj()) it formats it in its binary representation and written to file. This operation may take place millions of times, and calling write()... |
I need advice what is best approach to connect data between master and child table.
I have console application written in C# which scrape data from web, process data and insert them in table.
Master table with fields Id, OrdinalNumber, StringDate and child table with fields Id, OrdinalNumber, StringDate, Name, Amount, ... |
I feel this is a bad question because I probably do not understand what I am talking about. In my effort to learn about functional programming, I became stumped on understanding the idea of immutable stuff. I have been using C# as a hobby for years and I think I do not even understand OOP principles very well.
I use a ... |
We have a use case wherein we want to store incoming data and invalidate all the previously existing data pertaining to one parent entity.
ie Parent p1 --> has List< child> old_data ( already stored in the table )
now some new data comes in List new_data
PS the table only has one index is the foreign key p1.ID
EXAMPLE
... |
I'm comfortable with a lot of OpenID Connect and OAuth2 concepts in the context of HTTP-based communication between microservices. I'm currently leveraging Azure AD.
In the HTTP-based scenario I would typically use the on-behalf-of flow for communication between microservices where I need to maintain the user identity ... |
I'm making an online food ordering platform similar to something like Uber Eats. I have the menu items stored in the database which are then sent to the front end where I use a templating language to build the menu and create the initial modals (which are all hidden obviously).
Once you click an item on the menu the re... |
Imagine there is a number of filter functions that all perform filtering of items in a list based on different criteria. Say there are 5 such filter functions. All unit tested
Now imagine there is another function that takes a list of items, 5 arguments (not necessarily homogeneous), based on these arguments it decides... |
In our code base, we have several static or instance members that we would like to initialize lazily.
If the initialization cannot yield null, It's easy to implement.
Otherwise, one could use an additional boolean field that indicates whether the field is initialized, but that becomes noisy for many lazy initialized fi... |
I have a junction table, say for People and Locations
PersonLocations
PersonId | LocationId
---------------------
1 3
2 5
Now, Locations can belong to each other i.e. one location can sit inside another, which can sit inside another etc., so I have this defined by the Location table referenci... |
In UIKit framework, there are methods associated with app’s life cycle events like applicationWillEnterForeground(_:) which are called at appropriate times.
How can I make a process receive such events from an operating system? If the operating system has to be programmed to be able to notify the processes of system ev... |
My application publishes various messages (e.g., telemetry, changed-events, ...) to a RabbitMQ message-broker. The users have no access to the source-code and therefore, will need a separate documentation with all available exchanges, messages and their JSON payload.
How can i create/generate a documentation with this ... |
I need to generate videos that are several hours long from CSV files. I have a working solution, but it's unusably slow and am looking for alternative ideas.
What I'm currently doing:
using an image library to generate individual frames
use ffmpeg to concatenate all the frames into a video
Ffmpeg is surprisingly the... |
In OAuth / OpenID Connect, does the redirect url matter for server to server API calls?
I'm currently setting up Azure AD to secure our API's. The first implementation will likely only be server to server calls. All of the documentation shows that a redirect url is required. What is the purpose of this url in my sce... |
I'm currently writing some code to interact with an API that doesn't have any official libraries. The provider has given me two sets of credentials - one for testing and one for production.
I'm wondering what the best practice is for choosing which set of credentials to use.
Should I assume Testing (or Production) by d... |
I have json like below in our legacy system. In general, my json is very large. To make things simpler and easier to understand I have reduced the entries.
{
"clientSettings": [{
"clientId": 12345,
"key": "abc",
"value": false
},
{
"clientId": 12345,
... |
This is something that is puzzling me a bit.
I am seeing some people who like to implement DB-related integration tests (in the case of BLOBAs) to test the insertion with a Legacy DB in a CI pipeline, which I think bring very little value (while they require a fair amount of time for implementation) and bring a fair am... |
I have been working on a project that is being built around a microservices architecture. We are thinking on using a message broker, such as RabbitMQ, for both synchronous (via RPC) and asynchronous communication between services.
The team is constituted of Java developers, and all of the services are Spring Boot.
Supp... |
A bit of background:
I've been using Webpack with babel-loader for a while and overall the experience has been hugely positive.
Yesterday, I published an npm package of my own (to a private registry), and installed it into my "main" project that uses Webpack.
What I was surprised to find was that when I built the main ... |
In our database, we have around 150 different tables. However, there are a handful of them that are key, as in they get referenced pretty much everywhere. We also have quite a few reports that we pull across a lot of these tables and for a few of the items, we perform some calculations. We thought it best to just creat... |
I'm working on a big project with easily defined boundaries and domains.
The project includes:
Portal (news, articles, encyclopedia, users)
Forum (threads, posts, users)
Chat (messages, users)
Essentially, if I used the macroservice architecture - I would create 3 cross-communicating services (as listed above) and ju... |
I would like to create an e-commerce website that integrate other e-commerce. I can retrieve their products using APIs or feeds. The problem is that all these information are different from shop to shop and I need something to uniform and show them in my e-store. I've tried to build a Woocommerce plugin but it lacks in... |
I have a data model that is similar to the bank transactions. Simplified version looks like this:
01.01 +1000
01.02 -300
So I will have all the transactions stored in the database. Users will of course would like to know the balance rather than history of the transactions (700 in my example).
From what I can see ther... |
I am working on a UML diagram for social media website like Facebook:
The main class of this system is User, which has members as userid, email, phone, address, Friends, etc.
A user may follow a set of users. So several users may follow a given user, and a given user may follow several other users.
Does it make sense... |
The question is straight forward :
Personally identifiable information ( PII ) of an individual ( regardless of the persons citizenship) has to be on the countries server where an account is created due to compliance reason.
E.g: Your account information present on facebook, linkedin, paypal, global banks or Expedia ha... |
I am having trouble presenting my tableview cells containing a Collectionview correctly. I want to display a different animal in each section based on the firebase data. My problem is about every 4 cells the first 4 cells repeat(See images below). I have separate models for each animal and I am configuring each cell wi... |
In the new era of web components MDN (and probably the standard) suggests extending the HTMLElement class.
For a long time we've strayed away from doing that, what has changed now for this to become the suggested standard?
Is it a particularly good idea in the long-term, what happens if in the future the standard gets ... |
When compiling C programs to assembly programs and then to machine programs, does the assembler (e.g. the one used in GCC or other popular C compilers) perform the same tasks as the translator from C to assembly, i.e.
parsing
code generation
optimization?
How much is the amount of optimization done by the assembler c... |
If there is Class A and Class B and there is an association that B can be assigned to A.And the multiplicity is 1:M or M:1 from A to B.Example:
1.Room has Collection of Keys, and Key can can assigned to Room.
2.Match has a Referee, and Referee can be assigned to Collection of Matches.
I want to know, what would be corr... |
I have asked about the more nebulous 'system' and functions in general, but to explain my question let me just consider a pure function.
I think of pure functions as lemma/theorems/what have you. Given a function f and some conditions (inputs with some constraints), f applied to the conditions has some properties (e.g.... |
When using a git strategy similar to gitflow, can feature flags totally replace the Hotfix Release branch process?
When seeing bugs in production, we first make the change in the develop branch and test it. Then, we also merge fixes into the release branch or create a hotfix branch. Merges and cherrypicking are prone t... |
From Computer Systems: a Programmer's Perspective, about assembly languages:
We see that the Intel and ATT formats differ in the following ways:
The Intel code omits the size designation suffixes. We see instruction push and mov instead of pushq and movq.
The Intel code omits the ‘%’ character in front of register nam... |
i wonder what is the correct solution to ensuring consistency of a shared aggregate?
Problem statement
I try to model the registration at an event with reserved (and limited) seats (like shopping cart) that expires after n minutes when not confirmed by the applicant (like checkout). If all seats are gone, the user is a... |
I'm designing a monolith RESTful API that potentially sometime in the future may turn into microservices. I'm also trying following Uncle Bob's clean code as well. My question lies in structuring the Go code. Many times I see the following file structure for example:
|-- users
| --/ driver
| --/ entity
| --/ usescas... |
In Computer Systems: a Programmer's Perspective:
procedure calls may involve
passing data as arguments, and returning from a procedure may also
involve returning a value. With x86-64, most of these data passing to
and from procedures take place via registers. For example, we have
already seen numerous examples of func... |
I would like to have a relatively small and simple tree in C++. Each node would contain an integer. The tree should be traversable both ways.
I know it can be done with tree.hh by Kasper Peeters, but I am going to use BGL for other purposes as well. I've been learning BGL for some time, but don't have a firm grasp on t... |
Suppose we have two branches A and B which have been forked from master.
Both branches A and B make some changes and implement some unit tests. They pass all current and new tests, then are merged back into master. For simplicity, there are no merge conflicts.
Is it guaranteed that the resulting code on master will als... |
Given a repository which contains two different applications A and B (e.g. bootloader and RTOS), is it ok to copy source code from A to B in order to avoid dependencies (include's, adding A source files to the B compilation) between them, so they stay completely independent both at build-time and runtime?
Note: In addi... |
i have a case where user can filter and download multiple pdf documents merged into single file.
The client should display an error message when no document's meets the filter, and ask for confirmation when there are many documents because it might take a while to process them (let's say the confirmation should trigger... |
This is very closely linked to the question Legitimate "real work" in a constructor? but not quite the same.
I am interested in having feedback on whether this is acceptable or has any risks.
in C#, I instantiate a class:
var f = new Foo(DoSlowComplexTask());
it seems the same as doing:
var x = DoSlowComplexTask();
va... |
I have n sets that each contain some elements, for example:
{2, 3}, {6, 3}, {2, 7, 3}, {7}
Now the goal is to find the minimum number of elements that occur in all sets. For this example it would be 2 ({3, 7}). Some more examples:
{2}, {4} - minimum is 2 ({2, 4})
{4, 15, 3}, {3, 2}, {24, 4, 2}, {24}, {15, 6} - minimum ... |
I have two camera devices that are able to find a specific hardware illuminated point in an image, as well as measuring the physical distance to the surface (and some more stuff I chose to leave out, as it doesn't affect this problem right now), and the application uses the point and distance information independently ... |
If I am correct, an assembly language uses the program stack to store data.
Is it correct that the program stack is partitioned to frames, each of which is for a call to a procedure? So there is no part of the program stack, which is not associated with a procedure?
If an assembly program doesn't call any procedure, ... |
The problem I have relates to an existing system in a specific business domain. I've simplified it into a very similar 'Library/Book' relationship to articulate the problem. Answers such as 'why would you do it that way' are not helpful, as this is very similar to what I have, and need to solve for. Help that reflects ... |
Can one design an extension to any product without contacting the product developer?
For example, Does Grammarly have any contracts with Microsoft for Microsoft Word?
Here I like to create an userscript for a website and like to commercialize.
|
I am looking into the revamping my organization's application by moving from a monolithic into a microservice-architecture. My database is a multi-schema shared in one database. Each of these schemas is currently being distinguished by a different username, while the rest of the settings (url, password, dialect, etc..)... |
I'm learning to implement RESTful APIs, and the concepts of Controller and Router are common in many frameworks, along with the MVC pattern in general, so I'm encountering them everywhere.
From this question and googling around I understand that they are not the same thing, as they are responsible of very specific, and... |
Let's say we are in a company that sells coffe mugs, providing a Domain-Driven Design approach for their architecture needs.
According to common DDD practices (i.e. in literature by Vaughn Vernon and Eric Evans, nicely summarized in this Medium article), a good starting point is to identify Core Domains, Generic Domain... |
Is there a good way to search for duplicate subgraphs in an immutable directed graph, where edges and nodes may be labeled?
I was thinking I could try to name the nodes according to their position in the graph, but that isn't trivial when you have loops.
Comparing the two subgraphs arising from two different nodes shou... |
I do not know how to properly formulate this question, but I am trying to find the best algorithm to get the nearest integer number where every set of numbers (including decimals) give an integer number when doing multiplication. Example:
Assuming:
X = 232
Y = [2, 5, 1, 0.1, 0.0625]
The final number will depend on bot... |
Im starting to develop a visually-simple but infrastructural-ly robust real time multiplayer game to show off my backend skills and hopefully get a job at Blizzard or something like that.
The game is simple: a multiplayer snake game.
I'm aiming to have a game session supporting up to 8 players, all connecting to a sing... |
In COM programming, each COM object exposes a queryInterface method. You provide it a type that you want to "cast" the COM object as, and if it supports it it'll return you a reference to its implementation of the requested type.
It's sort of like a service registry, but there's a pseudo-semantic that all the interface... |
We are given a task to create an Web Service API for a mobile application. The problem is we have to use a legacy database that is not normalized and its very tedious to work with. We are accustomed of using Object-relational Mapping for implementing the Repository layer including the database so that its easier and ef... |
The ISP says that the client should not depend on things what are not needed. As a solution small focusing interfaces (contracts) can be used:
interface RegisterUser {
User register(String username);
}
class UserService implements RegisterUser,LockUser,FindUser,... {
...
}
class UserRegistrationClient {
private... |
As I boot up Eclipse for C++ with the "Darkest Dark Theme with DevStyle" installed, it spits out quotes--one per day. Yesterday's was:
A bug in the code is worth two in the documentation.
Talk about ambiguous! What does that mean?
A Google search for it (and this one too) shows it is a rather popular quote.
Possible ... |
I am looking how agile methods can be applied for setting up a chained-application (made of several services for example) developed by several teams. In particular, I think the common sources about release-cycle and environment layers (DEV, UAT, PROD) are missing a step where all applications should start to connect wi... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.