instruction stringlengths 34 36.1k |
|---|
This might seem as a very basic and maybe a vague question but I'd really appreciate advice and experience sharing on this:
Given you have a service, which processes tasks in a queue, e.g. because they might be time-consuming, or there might be too much of them coming in, or maybe because they require fifo order, if a ... |
I am developing a. NET application. One of my DLLs manages all the security (data encryption, license management, etc).
I was wondering if someone could somehow substitute this DLL file with one of its own, in order to trick my Application.
Is there any kind of digital signature undertaken by the compiler or would I n... |
I have a business requirement that requires checking on a person's first name to ensure it does not have the character "1". The model:
public class Person
{
public string FirstName { get; set; }
}
I started writing the following function to perform the check:
public Person CleanPersonFirstName(Person person)
{... |
I had an architecture question about how to manage objects with different properties based on the services they are in. Is it okay to have an object defined in to different places with similar attributes but different scope based on the service.
As an example, a car has many parts. You might make a service that ret... |
I am busy building an interpreter for a Rebol-like language. I have previously built a Lisp interpreter where I used recursion, but now I just want to use a stack and not rely on the recursion capability of the host language.
The parsing of the code works fine, and now I have an abstract syntax tree, i.e. the model of ... |
The Browser Extensions Standard (which is based on the Chrome Extension API) includes a webRequest API with methods onBeforeSendHeaders and onHeadersReceived, allowing a browser extension to see and modify HTTP headers in requests and responses.
The HTTP headers are provided as an array of objects. Each object has a na... |
We're developing some C++ application that analyses strings using some data.
The data is large (a few gigabytes) and takes a significant amount of time to load into memory, and timing, as well as stability is crucial for the application.
We're currently discussing the option of splitting our monolithic application into... |
S-expressions are a well-known way of describing trees in high-level code.
Is there something similar for describing graphs?
The two closest things I've found are DOT and Ko. Both aren't quite what I'm looking for because:
DOT is a full-fledged language. I'm instead looking for a syntactic construct that I could use... |
Each customer has an ID. For every new customer it's incremented by 1.
My company is wanting to start selling to a new type of customer (lets call it customer B), and have their ID start at 30k on the same column.
Is this a poor design? Our system has an option to set the customer type, so there is no need for this. ... |
I have the following code:
public void moveCameraTo(Location location){
moveCameraTo(location.getLatitude(), location.getLongitude());
}
public void moveCameraTo(double latitude, double longitude){
LatLng latLng = new LatLng(latitude, longitude);
moveCameraTo(latLng);
}
public void moveCameraTo(LatLng lat... |
Suppose I have the following Character, Potion, and PotionType classes:
class Player:
def __init__(self, name: str, health: int, mana: int):
self._name = name
self._attributes: Dict[PotionType,int] = {}
self._attributes[PotionType.Health] = health
self._attributes[PotionType.Mana] =... |
I'm building a data processing system where users can submit hooks to execute on incoming data.
The hooks are untrusted and should execute in a sandbox with access only to a limited API that I expose – essentially like a DSL. Ideally, users write hooks in ES6 or Python. The code should preferably be executable from mos... |
My goal is to calculate our enterprise product team velocity in order to find process in-efficiencies and understand what could be fixed. I came across a report published by circleci that states stability, deploy time and deploy frequency to be the metrics that would help to determine engineering teams . I have a few q... |
I have 3 services Service A, B, C which put and get data to/from Service D
+============================================+
| Service A | Service B | Service C |
+============================================+
| | | | |
|--------------------------------------------|
| ... |
I'w writing a program in Rust that basically pushes data through a pipeline of steps that transforms it in different ways. The data is represented by an Entry, and I am designing a Step trait for the steps in the pipeline.
The trait should have a method that process the entry. My first design was this:
fn process(&self... |
I have two web services, one of which creates resources on disk for the other one to read and process. The resources are subject to irregular change, so I'd like to inform the consumer service when a resource is updated instead of polling and saving the file timestamps or restarting services.
Problem is, I intend to re... |
As I understand it, some parsers generate an abstract syntax tree on the fly, while others first generate a concrete syntax tree and then convert it. What are the tradeoffs between the two? Is there some way to tell what will be easier given a particular grammar?
|
I'm sorry if the phrasing of the question is a bit unclear but let me try to clarify below. (If anyone can word it better, feel free to edit)
I have a Map instance variable, groups, which is defined as follows with the given type parameters:
Map<Group, Map<Username, GroupMember>> groups
Within the same enclosing class... |
I am developing a web application for a client, connected to 4 differents sources :
E-commerce website
CRM
Emailing platform
Surveys platform
All the sources have REST Api's.
The web application has to get the data from the sources and provide a list of customers. Also the client can create/edit customers, so the web... |
I'm very confused about this. In most programming languages, there are string.ToUpperCase(), string.ToLowerCase(), sometimes Capitalize() (which capitalize the first letter of the string), even ToTitleCase() which capitalize every first letter of everyword.
But why isn't there any ToCommonSenseCase()? The one that capi... |
I'm thinking about refactoring my content indexing process to queues. Right know updates happen directly when editors change content. It is difficult to do maintance works on the search engine too because we can't easily stop write queries.
The solution I see is to index content via RabbitMQ queues and use batch proces... |
Which is the relationship between the standard libraries of C language and the standard libraries of other software platforms, e.g. Java, .NET, Python? Do the Java (.NET and Python) standard libraries use the C standard libraries for making system calls, or in other words, is the C standard library the only place in a ... |
Assume:
There is some module whose interface is IA.
There is some module B, that takes in a parameter an instance of IA, and whose behavior depends upon the type of that IA,
meaning (pseudo code, no specific language)
class B{
IA ia;
B(IA ia){
this.ia = ia;
}
doStuff(){
if(type(this.ia... |
I didn't find any helpful questions to this topic, so I am just asking a new question, correct me if I am wrong.
I am looking to build my own little smarthome stuff, e.g. a doorlock with an rfid reader, lamps that can be turned on and off over a website etc pp.
My Idea would be to use a linux Server, a pi for the start... |
I've been working on a project recently where I have an Expressjs server that supplies weather forecast data to its clients. Right now, I'm using express simply as a means of exposing some functions I have on the server. Here are some of my endpoints:
GET /web/getFullForecast
GET /web/getCurrentForecast
As you can see,... |
What do you call the time taken for a software to launch? Let's say a program or an associated file is clicked at t = t0 and the program loads open at t = t1. What is t1 - t0 called?
|
I'm trying to understand what this pseudocode does and I can't seem to understand what the comma is suppose to do here.
I know that j <- 1 is j = 1 but what about the i? And what does j <- j do in this case?
fib iter(n)
i,j ← 1
for k ← 1 to n−1
i,j ← j,i + j
return j
|
I have an api end point which receives some parameters and process them returns a csv file. But the processing time may take more than 15 seconds. My server has build in timeout and some client systems may have also timeout set.
How can I overcome this timeout issue with out changing any system settings?
I have gone th... |
I heard a case where two teams are planning each others' sprints (estmating stories and deciding what goes into the sprint). The stated benefit is to solve one of the two team's problem with not finishing their stories within the sprint.
The concept seems strange to me and I'm curious about hearing opinions on this app... |
I'll describe the anti-pattern I see occasionally as this.
Rather than using encapsulation or inheritance, a utility library grows with feature specializations directly added to it. Subsequent usage by another component requires a dependency (header, linker, runtime) to that feature code. Thereby increasing developer ... |
This is a question about Android, and iOS apps. The technology is Xamarin (C#) but this is not really important. The app will be deployed to the stores. The client app must be compatible with the back end up. As we know, a user can reject an upgrade at any time, so the client must try to work with the current version ... |
I was watching a presentation by Uncle Bob. In the end of that presentation (last 10 min), He argued that we should abstract everything (Even frameworks) from our business logic.
JAVA EE does a great job in doing so. UI is abstracted by JSF (and other technologies). The database is abstracted by the persistence layer (... |
There is a pattern in C# classes exemplified by Dictionary.TryGetValue and int.TryParse: a method that returns a boolean indicating success of an operation and an out parameter containing the actual result; if the operation fails, the out parameter is set to null.
Let's assume I'm using C# 8 non-nullable references and... |
So this is my DataStructure:
Project
- Name
- ID
- Image
- History
- User
- Comment
When my application first starts it is pulling all projects with all details.
obviously very slow -high RAM (mostly because of images)
For now it is working but as projects add up performance is getting more wor... |
I want to build an app that will have have several monoliths. My question (similar to this one) is, how do I centralize User model between these apps, i.e. how to deal with user management/authorization/authentication without duplicating code. For some context, I'm using code driven development with Django.
This is wh... |
Are there any guiding principles of OO design to take into account when deciding which of two interacting and linked objects should be included as a component into the other (or referenced from it)?
For example, I am trying to realise the A* shortest path search algorithm with classes and objects. Besides a given grap... |
I have a microservice(opsApiServ) which hosts API to do operations(ops).
/ops - POST, GET
/ops-item - GET
ops-item is just a single unit of operation, and ops is collection of operations (ops-item).
Since, there are payload and getaway timeout limits, we just let clients do only 5k ops in one request.
Now, there are ... |
I couldn't find a question on SE but it has probably been asked elsewhere already (in case, please mark it).
A method containing code to run just with specific external conditions can:
decide whether to execute after checking those conditions, or
just blindly run, sticking to the Single Responsibility Principle; and l... |
I know, there are lots of sources on the internet, but I do not understand them.
Wikipedia: "Late binding, dynamic binding, or dynamic linkage is a computer programming mechanism in which the method being called upon an object or the function being called with arguments is looked up by name at runtime".
I do not unders... |
Could someone give a hint, in plain english, what it means to debug an HDL program?
Debugging is understandable as far as it concerns software but at this low level what does debugging means?
|
Suppose I'am writting a GUI desktop application which has a main window with a corresponding presenter. This main windows may host one or multiple panels which each also have their own presenter.
The main window has a an input field where the user can set a global option.
The panel sub views need to react to a change o... |
Before I started using auto-implemented properties, I was taught that when assigning properties in the constructor (because of the potential of making a property read only), I should assign directly to the private member for the property (which we would usually name with the property's name with an underscore in front ... |
For example, suppose I have a class, Member, which has a lastChangePasswordTime:
class Member{
.
.
.
constructor(){
this.lastChangePasswordTime=null,
}
}
whose lastChangePasswordTime can be meaningful absent, because some members may never change their passwords.
But according to If nulls are evil, what ... |
In my current case, I've got two variables. Let's call them action and status for ease of use. They can have any value between 1 and 9. Depending on business logic, I've to either call subActionA() or subActionB(). I'm trying to write this in the most readable way, and so far I'm not happy with the results. What I've e... |
What is the best way to prevent wrong states in an object? This is the source of my question.
Basically my curiosity started with the intention of not letting a class exist with wrong values. Prevent programmers from making mistakes in class implementations and extensions.
I did not want a class to even bother to have ... |
I'm dealing with a higher-level data abstraction that I would appreciate some input on.
I'm working on an application that uses a large data lake. The data lake is consisted of thousands of large binary files (250MB+ up to many GB each), each of which contains a very small amount of metadata (a few kB) that uniquely id... |
I have a single web server running multiple web applications and websites. For simplicity we'll just say I have App A,B,C and websites D and E. All use a shared database and some tables are used in more than one app/site.
I'm at a point where I'm looking at restructuring a lot of this code, but I'm trying to figure out... |
Why do the compile times not vary significantly between different era CPUs, even though disk (NVMe vs. HDD) and CPU benchmarks vary significantly in performance?
Why does disabling hyperthreading affect performance significantly with the Ryzen CPU?
Over the past few months I have seen some different machines all runn... |
I heard that there is some DB design in relational databases where updating a record will create a new record with different timestamp or status. Also, deletion will be soft-delete (it updates the status or effective date to past date). It does not actually delete the record. I would like to know if there is a name for... |
I want to place validation in one layer for the reason of simple code maintenance. I was thinking of entity validation, cause this protects directly database. Am I right, or should I add validation also on dto level? I would be happy, if someone share his experience on the topic.
|
I have a doubt about if there are some recommendations for call directly an attribute in a class
I think that in OOP you always should call an attribute by the get method.
For example:
On set
public setAtribute(Atribute atr){ this.atr = atr;}
On get
public Atribute getAtribute(){ return this.atr;}
On the constructor... |
As far as I know, the single responsibility principle concerns functions, classes and modules. Now I am designing a database and I wonder if this principle should be applied to relational tables.
Concrete example: I see lot of similar design cases as the following table shows:
CREATE TABLE Units (
UnitId TINYINT UNSI... |
(Probably my question is somehow similar to this, but I'm interested from the point of program engineers.)
What are chances and under what circumstances, a computer program could ever made a mistake itself? Like the program didn't evaluate true conditions:
if(true)
{
...
}
I assume that a hardware issue in CPU mig... |
I'm constantly supporting a specialized downloader I wrote 5 years ago! It has to login and download from more then 40 sites. I have kept changing the code over and over as I encountered new sites or when a site's structure completely changed.
This approached worked until now, but recently more and more changes are com... |
Consider two facts of a typical organization:
Some entities are very common (e.g. Order in a POS system)
Some entities might have complex relations (e.g. Order might have a list of Items, a PaymentMethod, the Address of the customer and such)
Say the organization had a lot of (REST / json) micro-services and they all... |
I have been learning to create water waves in a mesh from a paper commonly known as the Tessendorf paper. Which is quite well known.
But those who don't know this is the equations it mentions in the paper:
The paper is here (and is freely available, it is not protected): http://citeseerx.ist.psu.edu/viewdoc/download?d... |
I have n classes that extends from a State class, the purpose of the State class is to manage the state of the extended classes. For each class we need to save it in the database, remove it and select all the data in order to recover the classes to the same timestamp we stopped (in case of system failure or shutdown).
... |
I have a database which stores timestamp, and a UI frontend which contains a date/time field and a time zone field, where the user is supposed to enter the local time into the UI for convenience. Specifically, I am recording the start and end times of past (not future) local events.
The date/time is converted to UTC ti... |
In a software library, I wrote, large parts of the code use x509 certificates for various purposes like signing documents digitally.
Is there a best practice for storing test certificates used for the unit tests? Should they be stored in git/the same versioning system where the code is?
|
I wanted to ask if this is a valid class diagram:
I tend to think not, because it forces a certain wheel to belong to two vehicles at the same time (because of the 1 multiplicity). If the multiplicity on the vehicle side were 0..1 it would be OK. Is this logic correct?
Additionally, if this logic is correct, how woul... |
To provide a bit of context, the system I'm working on is a football database. A Squad has a collection of Rivals. Arsenal (Squad) has Tottenham and Chelsea as rivals, where Chelsea has Tottenham and Leeds United as rivals. These rivals are also Squads.
I'm thinking 'Rival' should probably be a value object, but I'm no... |
I don't have a lot of experience with these kind of issues, but I feel I need to consult on this issue. The current codebase I'm working on is using what I consider to be a questionable technique to reference entries in Database tables.
We have a system where for certain rows the value in that row is referenced with a... |
I am trying to get a database instance via any model-class that uses the database.
This is ideal in my opinion:
class UserAuthenticator
{
private $db;
private $customer;
public function __construct(Database $db, Customer $customer)
{
$this->db = $db;
$this->customer = $customer... |
Given these lines of YAML:
version: 1.00
y: 1
What does this represent?
According to the YAML spec (I'm not a delicate enough to read the spec like a lawyer), does this necessarily represent that a key str("version") maps to a value float(1.0), and a key bool(true) maps to a value int(1)? Or is it up to the parser to ... |
I'm currently working on a protocol which passes automated instructions between separate organisations. I'm looking for a way to delegate authentication of devices to which ever organisation a device belongs to. This doesn't affect authorisation models, only authentication.
So to put this in terms of DNS domains:
or... |
I'm trying to realize a service that executes operations at a certain time, those operations are specified by another service by messaging, here's the scenario:
The service A receives a request to create an object, the service stores the object in its own database
For every object, an operation must be executed at a g... |
My manager recently promoted me to "software designer". I am not aware that this title exists. As far as I know SAs creates high level code design and do diagrams.
I have a hard time understanding what high level code design I should do. According to my manager, I should design all classes and all methods inside those ... |
In statically typed languages or dynamically typed languages that use a type checking system you can guarantee that the input type is the type that you specified in the contract.
However, in dynamically typed languages without type checking systems in place you don't know how other people will call your function.
In th... |
I have created a Angular 7 web app data-driven display of navigation items and content to be shown when a nav item is selected.
I have the following nav item interface:
interface NavItem {
title: string;
icon: string;
link: string;
pages?: NavItem[];
}
Where it can be implemented like so for an Angular route:
... |
I am writing a library call that will allow you to filter and map in the same iteration of the loop, this is async/callback style in Java. The problem of course is that for filtering we usually return true/false, but for mapping we need to return the value we want.
So I am thinking of something like this:
(val, v) -> {... |
I am working in a fairly old code base. In the code base they have the classic source control, gigantic code blocks at the top of the files and above the function definitions that have something like date, name, and what they changed.
I wanted to start refactoring the code and remove these blocks but not lose the histo... |
It seems like HTML5 has about a zillion different layouts and methods for positioning divs, few of which seem to work exactly as described in most browsers.
Imagine an implementation of, say, Tetris in HTML/CSS/JS. So you have some kind of background, some pieces already on the screen, and a moving piece, all of which... |
I'm working for a company with a big ass legacy codebase. Changing existing code is like a guarantee to break things. Most functions are a few thousand lines, using some global flags, having different modes, which basically leading to a totally different functionality. Refactoring most of these things is impossible and... |
I'm relatively fresh out of college so most of my familiarity with relational databases is from my databases course where anything not in BCNF or 3NF is a travesty. Certainly that's one end of the extreme, but my team at work really seems to take it to the complete opposite end.
In our microservice db schemas, entities... |
What is the best practice when it comes to passing variables around? Is it better to pass objects (models) or is it better to pass primitives that will be required by the called method? What are the pros and cons of both approaches? For example one con of passing values (Example 2) when you suddenly require the user's ... |
I have the following case:
We register data from sensors. Let's say that it is a value reported every second, for one hour a day. So we have over 3k values. These values are processed to try and eliminate sensors' faulty behaviors. At the end, there are some performance indicators calculated based on the processed set ... |
I'm trying to create a flexible datamodel and i'm not sure what's the right approach.
My application is used by several clients (big and small). Big clients need all the seperate layers, but small clients only need a few. Here's what i mean:
Flexible requirements
Big client:
company
rayons
locations
departments
users... |
Currently I'm leading a team of 4 developers, all of them started their careers 5-6 months ago. I can consider ourselves lucky, as we've been assigned to a greenfield project, it's completely up to us to achieve the business goals. The company itself is quite small and they have a long history of maintaining legacy app... |
I have written a code in C# to generate the power set of a given input list of integers.
public List<List<int>> GeneratePowerSet(List<int> Set)
{
int setCount = Set.Count;
int powerSetCount = 1 << setCount;
// Temporary list to hold the all subsets
List<List<int>> subsets = new List<List<int>>();
... |
A few developers and I are attempting to refactor a class that has grown too large. Currently this class is around 3K lines long. The goal of the refactor is to make the logic more maintainable.
The class holds our validation logic, which performs various checks to make sure things are good before moving to the next st... |
All of the controllers in our project are as dumb as we can make them. Rightfully so, they simply validate the incoming payload, hand the request over to a service layer, and return whatever response is necessary; http status code, json, etc. I'm trying to see if I can trim down the number of tests we're writing so tha... |
Microservices are the latest software development craze. All the kids are doing it. When I started hearing about the concept, the first advantage that came to mind was the single responsibility principle. If you take the principle from other aspects of the software engineering principle, it seems to follow than a servi... |
On Linux Mint 19 with C++ compiler version: g++-8 (...) 8.2.0
I am compiling and running my project named: getPixelColor
Using a shell script:
#!/bin/sh
g++-8 -std=c++17 -Wall -Wextra -Werror -Wpedantic -pedantic-errors -o getPixelColor getPixelColor.cpp -lX11 && ./getPixelColor "${@}"
Finally, I defined a personal ... |
I have have a business process that receives an order request which also includes full customer information.
In the cases where the external customer ID from that order request is not found in our DB, we need to process that piece of the "create order" command, before we can actually save the order for that customer.
I... |
I have a product which has a un-normalized legacy data model which contain millions of records. This has cause problems when adding new features and with performance. Also this contributes to high storage requirements at data file level on databases. I'm looking into a finding some good architectural patterns which i c... |
I'm moving from REST APIs to gRpc but having a hard time figuring out how to structure my logic.
The basic layout of my solution is having a business layer/API and a few different front-ends (Windows app, console app, Web app, etc).
I would like to have each of my front-ends simply be able to connect to my network usin... |
I have a class Item. Then another class ItemCollection holds std::map<int,Item> item_collection_. The reason to create the class ItemCollection is if I want to do something with collection of type_a I can delegate that task to class ItemCollection. For me this seems normal way of doing tasks on those collection of item... |
I want to know others opinion about this approach that I use in a lot of projects, for example, I can show the last time that I use it:
public class DataStorageService {
private enum Keys {
USER_NAME("userName"), USER_ID("userId"), TELEPHONE("telephone"), EMAIL("email");
private final String key;
... |
Context: I own a service that's distributed across VMs, that themselves are distributed across multiple data centers.
Scenario: I'm adding an API that calls a single downstream dependency. This dependency has a very small throughput (relative to the API). Further, instead of just returning 429 if it's called too often,... |
I am working on my first web development project, SQLite4Web.
Long story short: SQLite4Web is a web interface for SQLite database files. The user can access their database via /db/{dbToken}, where dbToken is the database's unique identifier.
In all cases, the HTML file sent to the user is the same (index.html). The htm... |
I'm giving a talk on concurrency which will cover multithreading, multiprocessing and green threads. I'd like to give simple real-world analogies of single threaded programs, multithreading, multiprocessing, and green threads. These are the analogies I've come up with:
Single kernel thread - A single line of customers... |
I have an in-house built job scheduling application that accepts Job configurations in form of Apache Config files (something similar to XML).
There are tons of configurations (for example a way to specify a dependency on a job, way to provide configurations related to auto-rescheduling a job on failure and many more)... |
For example, I have an interface Requests that basically lists all the requests a client can make to a server program. Now an obvious problem arises where I have to add a new request to the program i.e. the interface. Existing implementing classes would then have to implement the newly added method in order to compile ... |
I am struggling with the clean architecure. I have constructed a minimal example of how a usecase/interactor could talk to the database without being dependent on it:
The use case:
class SaveDatatoDBUseCase:
def __init__(self, AbstractDB):
self.db = AbstractDB
def execute(self):
self.db.save()
The gateway:
fr... |
After doing a bit of reading, I have a vague understanding of the use of a stack in calling functions when one function calls another, where the arguments are placed on the stack for the called function to retrieve them.
So, in the following example, calling the function add, would place the values 5 and 6 on the stack... |
I am currently reading through Robert Martins book "Agile Software Development" book and I am struggling to see how his modem example provides any benefit.
He says that he has an interface that violates the SRP
interface Modem
{
public void dial(String pno);
public void hangup();
public void send(char c);
pub... |
In a bit of a dilemma. At work we are having issues with an API service that communicates with the client side through a WebSocket. The problem so far is that the WebSocket seems to be unreliable. We have sufficient logs that tell us this, but for some reason everyone is on the boat about adding logging to the front en... |
I have a table "products" and a child one "product_modifications"
Some products have "product_modifications": "colour", "size",, .... But not all.
When a client orders a product, views pictures and other things, he might do that with either product or its modifications, depending on whether or not a particular product... |
Algorithm explanation: based on an unsorted list I want to find the indexes of the values in another sorted list. Note that all values are unique and the two lists have the same values, only in different order, for example:
# O(log n)
def binary_search(data, value):
n = len(data)
left = 0
right = n - 1
... |
In an application that doesn't use an ORM, is it good practice to check whether an object exists before attempting to update/delete it?
For example:
@Route(method="DELETE", path="/posts/\d+")
public function deletePost(id: number) {
let post = model.getPost(id) // this method does a SQL SELECT
if (post ==... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.