instruction stringlengths 34 36.1k |
|---|
let me state some items.
I have this endpoint that returns a list of objects, and I would like to return only the changed ones.
I have an App calling this endpoint that caches this list, and today it refresh the whole list every time the endpoint is called.
I would like to manage, to return to apps only the records, ... |
Suppose I have a Player class with an Inventory:
public abstract class Player {
private final List<GameObject> gameObjects;
public Player(){
this.gameObjects = new ArrayList<GameObject>();
}
public add(GameObject item);
public drop()
}
I also have two items, Night Vision Goggles and a Ta... |
I lead a small but growing team of developers on an iOS application with a server backend. We have comprehensive unit and integration tests on both ends.
As the product grows, I want the onus of "quality assurance" to fall on all team members -- currently, there is a very "throw it over the wall" mentality after devel... |
I often find a situation where I need to write duplicate codes in a for loop, where the "init step" to identical to the "update step":
// duplicate `next()`
for (let x = next(); p(x); x = next()) {
f(x)
}
// the same in a while loop
let x = next()
while (p(x)) {
f(x)
x = next()
}
It is not much a problem when ... |
My question is about the best way for allowing an unauthenticated user who has created a resource to subsequently access and modify that resource they created via web API.
My web API identifies resources using GUIDs. It supports token-based authentication, and access to particular resources can be limited to certain us... |
How do "you" handle runtime incidents (say, a null-pointer exception, or an API input data validation failure) so that you (a) don't miss any, and (b) aren't spammed by duplicates? Are you doing log file introspection?
We're currently NOT using Jira for managing bug reports. We are going to want to do that.
In reality,... |
I work on (big) codebase that consists out of multiple modules that are all built on top of shared library. In this shared library, is it better to encapsulate dictionaries as return values, instead of returning dictionaries directly?
I do not mean dictionaries that are used internally in one function, or even as a pri... |
I'm using the google maps API, which has a secret key that I need to use on the client side.
I was thinking of some alternatives to store it safely. One of them is storing it in my flask database. Then the front-end can send a query to obtain it.
Is there a way to do this safely by encryption?
|
Since the inception of .NET Core, console apps, function apps, ASP.NET etc. are not using synchronization context in async methods (so they're synchronizing straight to Thread Pool).
This means that using .Result() or .Wait() after async method doesn't cause deadlock any more, and only affects performance (reserving a ... |
If operating systems use 'drivers' to communicate with external devices,
does that then mean that OS's (like windows, linux, & osx) have to come prepackaged with drivers for every single external device, ever created?
I ask this because I have never, personally, had to go download a driver for an external device. When ... |
Situation:
I have a project with a Business Layer (WizBang.BL) that contains nearly all of my application logic. It communicates with a Data Layer (WizBang.Data) that contains by entity classes and DbContext. It is consumed by an MVC app that only talks to the Business Layer.
One of the tasks that I need to add is to g... |
A Java project with maven as build tool needs to be deployed to different environments, such as ci, dev, test, prod etc. Each environment has a properties file with the same set of properties such as:
service.host
environment.suffix
user
password
...
The values of these properties are environment-specific. Currently ... |
Currently working on a Go project of about 10k lines of code. Within the project, there's a logging library that requires a couple steps of initialization in order to actually write to the log according to the project pattern, within the appropriate scope and depth of log message.
As a result, almost every function has... |
Consider the following POJO structure in my main code. I want to create some testing framework for this kind of hierarchical classes, where the calling test method can specify if they want to modify a particular attribute only like for second Attributes set the height to a particular number and using default values for... |
A quick google search shows that the question I have has not been asked directly, and so I ask it here. For what its worth, I am learning react, and I come from a C++ background, where as far as I know, "functional components" are not a thing.
Taking from a tutorial, this seems to be a barebone example of a functional ... |
The first language that I truly learned was Java. In it, it is very syntactically easy to nest classes in an essentially arbitrarily complex package hierarchy, which keeps the code organized. It is easy because the syntactic clutter of a deeply nested hierarchy is all placed neatly at the top of the file with import an... |
Ive brought this up with other developers, and they say while there is no obvious way forward, it seems that they all have an idea of how to go about it.
Is there any way I can implement signals and slots javascript and or typescript?
I want to get as close to this functionality as possible:
https://doc.qt.io/qt-5/sig... |
I have a small architectural problem with MVVM. In this question I will note Model through M and ViewModel through VM.
I have 4 collections that must be synchronized,
and the items in them must have their properties synchronized.
The collection synchronizing part is done. But now, I wonder if I have to change this arch... |
I have been trying to learn Object Oriented Design, but I find it very difficult to model objects that access a relational database and do JOINs.
For example, I am building a REST API, it has User, Admin and Event entities.
Admins can issue Users registration for Events.
This is the database schema:
User:
id
name... |
Which one is better property file, annotations or database tables for storing configurations related to a program? What are the advantages/disadvantages and what use cases are best suited for each of them?
For example -
Spring had xml configuration files initially then it became annotation driven. What was the motiv... |
How can personal information that needs to be retrieved at a later date be stored securely in a database? For instance when companies store social security numbers and use them for taxation purposes. They have to be stored securely obviously, and retrieved later. It seems using hashes and salt as with password storage ... |
According to Software Engineering: Theory and Practice book by Pfleeger and Atlee, Peer-to-peer architectural style is different than Client-Server architectural pattern. But in Mocrsoft's Microsoft Application Architecture Guide, 2nd Edition, it has been stated that peer-to-peer is a variant of client-server (link). C... |
Until now I have been using simple strategy for packages naming in my maven-modular projects. Each package name contains name of the module in which it is placed.
For example, simple project would have this structure:
- smweb-core(module)
-- src/main/java { cz.sm.core(parent package) }
-- pom.xml
- smweb-web... |
De Morgan's laws:
the negation of a disjunction is the conjunction of the negations; and
the negation of a conjunction is the disjunction of the negations;
or, the same:
not (A or B) = not A and not B; and
not (A and B) = not A or not B;
or, the same, applied to the programming:
If !(Var1 || Var2) = If (!Var1 && !... |
According to the Halstead's software metrics:
Estimated program length:
Can you please explain me, why the formula uses logarithm to base 2? Why not something else? Why exactly logarithm? What’s the reason? Is that somehow related to how we think?
I understand that allows to determine internal computer (bits) represe... |
I have two users in my program, one's a Programmer and the other's an Administrator. The Administrator is capable of doing everything the Programmer can do, but also has some additional roles (such as adding new users).
When writing my table diagram, with a use case such as "Edit Program", I need to have it initiated b... |
For binary operators we have both bitwise and logical operators:
& bitwise AND
| bitwise OR
&& logical AND
|| logical OR
NOT (a unary operator) behaves differently though. There is ~ for bitwise and ! for logical.
I recognize NOT is a unary operation as opposed to AND and OR but I cannot think of a reason why the des... |
In C#, if I hide away implementation behind a facade, or the "pimpl" pattern, does the compiler optimize away the intermediate function call if all it's doing is calling an equivalent method from another class with the same parameters?
This is with dynamically created classes.
For example:
class A
{
internal bool P... |
Let's image we have a multitenant(organization) application having a separate database per tenant(organization).
The core of the application is a REST api service protected by an authorization server, in this case Identity Server 4.
For administration purposes a user can login into an administration panel with a usern... |
I´m creating my first eshop / CMS based on DDD / CQS concepts. I want to create application using BoundedContexts separtion as modular monolith at the first stage and maybe latter extract some BC as MiniServices.
I Want to ensure that I´m going the raight way, so I prepare Architecture diagram.
Diagram:
As you can see... |
Maybe this question is a duplicate. However, I could not find a suitable article in my research. If you know an informative, comprehensive article about this topic, please send it to me.
I want to reuse and centralize the utils I created for my Spring REST API for my future projects. That's why I thought I'd outsource ... |
hey i have a difficult question.
class DatabaseHelper
{
Database db;
String defaultShema;
public DatabaseHelper(Database db, String defaultSheme)
{
this.db = db;
this.defaultShema = defaultShema;
}
public void databaseOperation1(String selectData, String FromData, String whereD... |
Maybe that's simple, but I'm a little confused.
I have such a Ruby code:
def my_function(found_objects)
# ...
if found_objects.second
return CoreObjectFactory.get_object(found_objects.second, found_objects.first)
else
return CoreObjectFactory.get_object(found_objects.first)
end
# ...
end
I left retur... |
I really like keyword arguments because it helps me see what the variable actually is... on the other hand, often these variables are not optional, and kwargs are by default optional. How do use keyword args for mandatory variables, in a clean way?
|
Is it a good practice to have a list containing objects of derived types and then filtering it by type checking when need to call methods specific for one of the types? From what I read typechecking is some kind of code smell and it indicates that OOP isn't fully used.
I use common list for object of all subtypes becau... |
We have a pretty big monolith. We're currently looking at carving it up into micro-services.
Right now we have a file server micro-service (FS) that handles delivering files to clients based on certain criteria.
FS has it's own database that contains meta-data relating to each file. So when a client requests a file ... |
In my team, we are maintaining a monolithic application that was started in 2003. It is written in Java and has seen several successive layers of technical changes, growing to a hefty 400k-line application.
Recent business strategies decided by the brass now require that we move to containers. The goal is mainly, if n... |
So I'm trying to figure out exactly what my aggregates/aggregate roots are in my structure, and can't seem to wrap my head around it.
Database contains the following tables:
SALESGROUP
ID
NAME
ITEMNUMBER
ID
NUMBER
SALESGROUPID
DEALER
ID
NAME
BUDGETHEADER
ID
DATE
BUDGETVERSION
ID
... |
I have got a project in C++. Each of my classes has a method void assert_good() const. The usage of that method is solely for debugging purposes: if the object is an inconsistent/impossible internal state, then assert_good(); will make the program abort and leave an error message. Other than that, assert_good(); has no... |
I'm working on a web app where users enter a "room." The state of these rooms is loaded in the server's memory at all times, and is synchronized with the clients via websockets. What's the best way to handle rooms when there are multiple instances of my web app?
Should I...
A. Have some kind of load balancer that knows... |
I have started working with a team, in a scrum master type role, who has been using JIRA for a kanban type framework. Over the last 6-12 months, they have used JIRA to enter pretty much everything they do. This includes tracking whos on call, any HR/personal tasks like training and setting personal development goals fo... |
It’s a bit hard for me to wrap my head around an API that isn’t a web service.
I am sure they exist, because even as I use my phone, I’m sure the developers didn’t need to specify how to use the keyboard to display the letters, they just know they wanted to use it.
So my question is, can someone give an example maybe c... |
I have an ecommerce website wherein as soon as a new user comes on website then a new visitorId gets generated for that user in database and that visitorId cookie gets stored in his browser and in memory session of server. In his subsequent journey over the website we use this visitorId to map and store any information... |
I'm implementing an application that's made of bunch of microservices. Each of them is fairly simple, focusing on its own task. Let's call two of them Service A and Service B. They are both implemented in NodeJs and expose a Rest API. Now I need to run couple of cron jobs (some at 1m interval, others at 5m, 1h and so o... |
I have an entity with around 20 properties. Following DDD, I want to make setters private and allow mutation only through methods, since there are some rules I have to check.
But how should these entities being created? Should they have a constructor with 20 parameters? Should I create an intermediate writable entity t... |
So currently I looking for some hints from more experienced programmers. I am in the point where, when looking into my code it seems not readable, what is probably big flaw. So lets go to the code itself:
In one the classes I have method:
protected void createModelsCharacterisitcListGroup(Map<CharacterType, Map<Str... |
Let's consider the following scenario. I need to access a resource hosted on server X. I want to get this resource in a Y format, so along with my request I send the Accept: Y header. Unfortunately X does not support Y and I'm not not allowed to access the resource on X as well. I've included valid Authorization header... |
At several companies the term "game day" is used to mean testing functionality of a product in a production (or similar) environment. Specifically, testing a that an intended mechanism works as expected.
An example would be shutting down a master database and see that the replica database is being used instead.
But why... |
I am building a service that is servicing a lot of audio files. The issue is that I need to keep a record on what files are being accessed. My initial thought was to use BackBlaze B2 with CloudFlare but I don't really know if I will be able to get statistics out of this.
Do you have any general advice for someone that ... |
I am working on software which supports different hardware device generations. With each software release all device generations are supported, what means that each device generation is also tested.
To avoid huge amount of test we want to freeze development oft he HW layer for some devices, but continue to add function... |
Developing a SPA (with VueJS) that is talking to our own REST API Backend(Separate server). Normal authentication flow in the SPA:
User credentials after submission are sent to the backend and if authentication is successful a token is returned that is used in subsequent calls to the backend.
However we have some cust... |
I'm a front-end developer working as a member of an agile team. I have no clue how much of UI/UX must be done before every sprint and how much of it I can postpone for later.
|
I have a very specific localization problem that I have not had any luck finding specific information about in my research.
I have an app that I'm localizing that shows elapsed minutes(M), seconds(S), milliseconds(X) in the following format:
MM:SS:XX
I've been told by a friend that this will work fine in all European c... |
Are data transfer objects or POJOs meant to be final or can they be extended and create hierarchies for them?
It is not clear to me if such a value class is properly designed only as a final class and what are some good examples/designs of a hierarchy of DTO classes?
|
We are creating a SaaS multi-tenant (separate databases) with micro-service architecture, which causing a lot of discussion between me and my manager trying to determine if it needs to be multi-tenant or the databases can be related to the service no matter which tenant it is (each service with its serving data).
From ... |
I have a huge GIS related project with multiple parts which was originally developed for metric usage (meters).
Now I need to make a comprehensive audit of the system to come up with a plan to let it support imperial unit (feet) natively (not just convert at the display end because of accuracy concern).
What is a good ... |
I'm trying to design a system which can determine whether there is a difference between a field or not given two objects.
In my tool, we get multiple versions of the same title, with minor differences in each field. Now based on business rules, we want to determine whether the difference is significant or not. For exa... |
I have two feature branches that were recently merged, and I'm trying to examine the diffs as an informal code review after-the-fact.
feature1 with about 50 commits was merged into master and a merge commit was made on master. I had reviewed those commits and was satisfied with them. The merge was straight forward easy... |
I've read that the Heap File Organization is usually used to structure a secondary index. This makes me suspect that usually, a secondary index is unordered, as opposed to the primary index, that is ordered by the primary key attribute. Is this true ?
|
Probably best explained with an example:
In a .NET C# project, we have a library class for which several function accept an HttpContext as one of the arguments.
The thing is, that none of the functions actually need the full HttpContext, they just need one item from one of the collection properties on the HttpContext.
... |
I have a view which displays a list of items related to one thing, it allows creation, removal of, and updates to these items. All changes only persists when the user hits save. Is it okay to group all of these methods into a single request? If not, can you explain why not?
|
When creating a new class, should we always override the equals and hashCode even if we don’t intent at that point to use the class with any Collection classes?
Or is it better to wait till such a need arises before overriding equals and hashCode so as to be sure on what the logical equality should be?
|
I am building an application on windows forms C# that will run in real time 24 hours a day 365 days a year. This application tracks the time that components are out of storage.
I am running into a problem with daylight savings time as when it hits, it will alter how long the components are out, which i need to deal wi... |
Suppose I have the following interfaces, GameObject and Enhance.
GameObject:
public interface GameObject {
void prepare();
void use();
void cleanup();
}
Enhance:
public interface Enhance {
int increase();
int decrease();
}
Goggles:
public abstract class Goggles implements GameObject, Enhance {
... |
I am modelling a users management system, where users have a country of residence. I have modeled both User and Country as aggregate roots, and I am referencing the user's country by its ID internally.
The storage is a relational database and I have a UserRepository and a CountryRepository. Whenever I need the user's c... |
The Covariance and Contravariance feature is well supported in C# and Java collections. However C++ doesn't support them in their STL containers. Why is it so?
For example the below code will compile in C# and Java but not in C++. (The syntax will have to be translated to the specific language though)
class Base
{
};... |
We're currently developing a Spring application that uses jdbcTemplates for the repository.
We have a lot of functions that only require specific combinations of columns in our database. It would be wasteful to always fetch the entire objects. But separating the columns into their own table doesn't make sense semantica... |
I am making an online poker server in NodeJS. Currently, the state of the game is being sent to each client. So using debugging tools a client can see all the other player's card IDs. I would like to send the game state but modify it so that player card ID's are represented in ciphertext.
What kind of encryption protoc... |
I thought I understood what abstraction meant - refactoring code so that it applies to more general use cases. However I have recently learned that some types of abstraction may actually be indirection, and am questioning my understanding.
I'd like to see some a specific example (of code in Javascript - not a descripti... |
Overview of application:
A chat bot that connects via IRC, using TPL. As messages come from the socket (from .ReadAsync()), they are ultimately parsed and passed to a handler within the bot itself (Let's call this ChatBot).
An async long running task responsible for reading certain information from REST API's, and upd... |
I'm working on my first big C++ project and while I understand the language I'm trying to learn elegant design patterns using it. I have some low-level networking over a UDP sockets API where each message contains an incremented id to facilitate association of requests and responses. I'd like to use these to create a h... |
I'm trying to design an event-driven architecture based on Kafka for messaging but I'm struggling in managing event dependencies. Let's suppose the following service choreography:
Service A: emits A-created
Service B: emits B-created when processing A-created
Service C: emits C-created when processing A-created and B-... |
I just want to curious about adding a converter is a good practice or not.
I have multiple API and I always convert API return fields to my client fields.
Like=>
function ConvertFromAPI(apidata){
var result= new user();
if(apidata){
result.id = apidata.id;
result.usern... |
TL;DR - When designing classes for MVC use, is there "best practice" for how classes should be structured to eliminate property duplication and/or redundancy? I'm trying to avoid large (one-size-fits-all) classes with many (redundant) properties, but am also concerned about having too many isolated classes.
I've been ... |
I've noticed this while implementing a Rest-API today. We first define interfaces for each API method and the api contract for one endpoint allows (amongst others) two status codes: 200 and 204. Both may be returned when the request was successful, but the returned data isn't really important. The implementation might ... |
upfront I develop software for big data applications of which use is beyond my control (it ends up with a user), but I am not a trained software developer. So I apologize for any wrong terminology.
Now my question is: Is a class hierachy justified when implemented mainly/solely to aide static checking (checking at comp... |
I have been doing a lot of reading/watching on event sourcing but some things still do not quite make sense. My application is a warehouse management system where we have:
Deliveries of stock into the system
Movement of stock around stock locations (pallets and shelving bays)
Orders which contain order items (i.e. pro... |
I'm actually implementing my own Pose-Estimation/- and -Refinement pipeline. For this purpose I use one moving mono-camera. Then I take the consecutive images to estimate the pose and triangulate the points (nothing special). In the last step I refine the poses and 3D-points with a bundle adjustment approach.
Generati... |
As per Wikipedia: A compiled language is a programming language whose implementations are typically compilers (translators that generate machine code from source code). And an interpreted language is a type of programming language for which most of its implementations execute instructions directly and freely, without p... |
A small, neglected project has recently been reported by users as having time out errors and some object reference exceptions. As I am a recent replacement for a developer who was responsible for this project, I didn't have the solution installed on my machine.
In the process of trying to get a local build to run, I'm... |
I'm wondering how best to handle the scenario of releasing a mobile app that includes an incomplete feature behind a feature flag in one version and then the completed feature behind the flag in a subsequent version - and making sure users with a previous version don't encounter incomplete functionality.
Let's say I'm ... |
I'm researching DevOps metrics for school. One metric is called "automated test pass percentage." I found one article that says this metric is useful because it is good to know how often code changes are causing your tests to break. Does this metric tell you how many tests pass in your pipeline whenever code is committ... |
The state of my TypeScript/Angular app contains objects from the UI layer and from the business domain layer. I'm exploring store-based solutions (eg ngrx, ngxs) to keep this state in memory.
As I understand, such solutions define a single data structure for both UI and business objects, eg
export interface App... |
I'm reading some article about "prefer composition over inheritance", and heard about Forwarding and Delegation. After search for the different I found some source:
https://en.wikipedia.org/wiki/Forwarding_(object-oriented_programming)
https://en.wikipedia.org/wiki/Delegation_(object-oriented_programming)
https://www... |
I am looking into ways for implementing maker checker principle for various classes over our company repository. Basically the rules are as follows:
An entity is an object to be seen on a website (e.g. a blog post)
There is a creator of an entity with appropriate permissions/role (e.g. ROLE_POST_CREATOR) (in the origi... |
Introduction: We have a bunch of micro services (about 40) to serve our customers.
To facilitate scaling and audit-ability of selected few micro services we have decided to redesign them using CQRS and event sourcing.
Current Situation: We started out with a one to one mapping between read applications and write appl... |
I want to extend our api to a (better) v2 version.
I came up with the plan of adding a "v2" area and under that, cloning each controller into it. (basically v1 sometimes returns json, sometimes text, sometimes ysod and we're standardising our responses).
So we now support both v1 and v2 via:
v1 "abc.com/billing" <- s... |
How and where to describe data fields and their behavior in business requirements document?
I have business requirements document setup this way:
1.4 General Requirements:
Req # | Ranking | Requirement
1 | H | The system shall be breaking into two sub-systems; one for the POS Admins a... |
The Python Binary File Parsing Deep Dive
Intro
I'm an electrical engineer by trade, however my job has a lot of software engineering overlap. Recently something I've been working on is a Python parser for a binary format that has a varying record format. The format is STDF V4, which is a binary format created by Terady... |
On Wiki page for Factory method pattern, there is following example:
public interface IPerson
{
string GetName();
}
public class Villager : IPerson
{
public string GetName()
{
return "Village Person";
}
}
public class CityPerson : IPerson
{
public string GetName()
{
return "Cit... |
I'm writing a Python library in which various objects are represented as Python classes. However, the user is not supposed to create instances of those classes directly. Instead, there are a set of convenience functions to create them. So my module source currently looks like this:
class Foo:
pass
class Bar:
p... |
As a architecture design brainstorm, I am pondering on how should I define schemas for movie database where heavy text searching is delegated to document based database (eg. elasticseach) while rdbms is kept for relations and querying by ID.
Imagine having following entities...
actor (id, name, dob)
studio (id, name, ... |
Are their any objective guiding priciples to choose between named fields over compactness?
const replacements = [
{ from: 'apple', to: 'manzana' },
{ from: 'banana', to: 'plátano' },
];
function replace(str, replacements) {
for (const {from, to} of replacements) {
str = str.replace(from, to);
}
return ... |
I have a child view-model which notifies on a property change:
public class ChildViewModel : INotifyPropertyChanged {
private bool isSelected;
public bool IsSelected {
get => isSelected;
set {
if (isSelected == value) { return; }
PropertyChanged?.Invoke(this, new Property... |
I'm studying for an exam (software-engineering) and got stuck with the following question.
Developing a web application for stock in order to monitor (automatically) and to trade shares. You are responsible for requirement capturing. Explain why the following requirement is not recommendable.
The shares should be stor... |
When I'm saying "area" I usually mean some relatively large unit or service, which is a part of a whole product, i.e. API service, location service, warehouse service, etc.
Context: a project with 20+ separate services that has been in development for 7 years. It has been rewritten from scratch, so if it counts, its ov... |
First, I know - there are a lot of online resources that talk about the topic Exception handling - but yet there is still something that's unclear to me.
Consider having this code in an external library, called from another project.
public Task<List<Ident>> GetFoo(){
List<Ident> idents = new List<Ident>();
iden... |
I need to build an experiment based on a scientific paper in which a high number of agents have a divided visual field (with limited detection distance) and have to detect other agents in a 2D environment.
The visual field angle is evenly divided in N angles. One just need to detect wether there is an agent (or more) o... |
What is best practice when a unhandled exceptions occurs in a desktop application?
I was thinking about to show a message to the user, so that he can contact support. I would recommend to the user to restart the application, but not force it. Similar to what is discussed here: ux.stackexchange.com - What's the best way... |
I have a class that oversees some process. At it's core, there is a process method which collects data and processes it. There are a bunch of methods for retrieving the results of the previous processing step.
To have a better overview, here is how it looks like currently:
class Main {
private:
// resource1... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.