instruction stringlengths 34 36.1k |
|---|
I want to use a physics engine (like bullet or PhysX) in my program, however I want to hide the actual physics engine from it, so I can easily swap it out with another during run-time (e.g. switch between bullet and PhysX without requiring any changes to my main program).
To do so, I have created some abstract classes,... |
We are working on a transformation project
It has records in table entityA and entityB, which has a relation entityAB.
We need to delete records in table entityA and recreate them with some other parameters, lets say new records are rowA'. Now based on user input of matching between rowA and rowA', we need to update re... |
I work with a small team of software engineers. Each one of us handle different projects without much interaction. We all report to the same supervisor who more or less understands the requirement of all the projects each one of us are working on. He used to be the only person that would review our code.
Seeing that... |
I need to implement some system (using python pandas dataframe in my case) that parses raw data, then adds on calculated data, and then validates that calculated data (boolean output on some columns)
I couldn't make this problem simpler than what is below, so please bear with me.
Assumption: this is and always will be ... |
I have multiple projects in different programming languages that I will upload on online code hosting platforms as Open Source projects.
What file permissions and ownerships should I set on the files before uploading them? I work on Linux-platforms. It feels wrong uploading files with permission MYNAME:MYNAME as owner ... |
I need to validate a value with data from an external API.
The easiest way would be to add a validation rule in my model, call the external API and do my check.
But it feels very dirty to call an API within my model.
(Also a lot of specs would fail due to missing api call mock).
What other options do I have within the ... |
I’m building a web app using Rails API on server side. The goal is to make a planning manager. I want my users to be able to plan ‘daily’ events, which will display at some specific weekdays, with some specific member in charge.
Here’s a quick example about what data should look like :
event_name
- Monday with UserC
- ... |
We've stumbled at an inconvenient design in a game and wondering, whether there is nothing simpler. The background needs some explaining so I'm sorry for the wall of text.
The setting
We have a player class. The player knows how to walk around in the world. At certain occasions, we want to disable the player from being... |
I was writing some code and came across a scenario that I was thinking about doing a circular dependent class, which I have not done before. I then looked circular dependencies up and whether they are impermissible, and found that it is achievable but not desirable. But I have some dilemma regarding how to implement it... |
Background
I have a relational database an I want to have a table that contains flags. I want multiple tables in my database to have a many to many relationship with the flag table.
Options
I could go about this two ways (I think):
I could create a join table between the flag table and each table I want it to have a ... |
for (int i = lstReportCount - 1; i >= 0; i--){
if ( (input.ServiceTypes == "1" && lstReport[i].A == 0)
|| (input.ServiceTypes == "2" && lstReport[i].B == 0)
|| (input.ServiceTypes == "3" && lstReport[i].C == 0)
|| (input.ServiceTypes == "4" && lstReport[i].D == 0)
|| (input.ServiceTypes == "1,2" && ls... |
Two things you can do in Java:
Send a gzipped JSON body in response to an HTTP request
Send a StreamingOutput response to an HTTP request, where you begin sending a response before you know the entirety of the response (e.g. if reading entries from a database)
According to my testing, you can do both at the same time... |
the reader is expected to be an advanced Linux developer, having read ALP and having developed advanced GUI applications on Linux using GTK or Qt; notice that sadly I am not a native English speaker (but French).
I have difficulties in understanding the conceptual model of the copy/paste clipboard in recent HTML5 brows... |
I've been working on an open source project recently and have been checking out Core Infrastructure's best practices checklist.
One of the items pertaining the "Change Control" checklist is as follows:
To enable collaborative review, the project's source repository MUST include interim versions for review between rel... |
I have a design dilemma in deciding the response status code and architecture for a middleware we are designing.
So the Client Calls MiddleWare, And middleware calls the 3rd party service to get car-values for a particular car-reg.
If everything goes right and we get car-value, we are sending the status code as 200.
Bu... |
I have the following simple activity diagram:
My problem / question about is the last activity and its incoming object flows:
how to model proper UML here?
In UML-Spec 2.5.1 I find these quotes:
[15.2.3.1 Activities]
An object token is a container for a value that flows over ObjectFlow edges [...]. An object token ... |
I am writing an API (web-service) for my customers and there is an endpoint which allows to search for the documents in my storage (files, folders) by applyingg complex filters.
Initially, client need to send the following model to my API:
public class GetFactDocumentsTableWithFilterCommand :
IRequest<GetFactDocum... |
Let's assume I wrote an extension method in C# for byte arrays which encodes them into hex strings, as follows:
public static class Extensions
{
public static string ToHex(this byte[] binary)
{
const string chars = "0123456789abcdef";
var resultBuilder = new StringBuilder();
foreach(var... |
I am building a WebApp which has a list of Assets. I have a peculiar requirement and I am unsure of the best way to store the data in SQL.
Requirement:
My Asset Headers currently have a relation to a branch, and that branch to a multiple entities (see diagram).
However I need to be able to work out from a given date ... |
I am trying to architect a stand-alone WPF desktop app, but the question could be applied to any programming framework.
This app has an UI where user interacts to send commands and receive/view output.
On the other hand this app also talks to some hardware devices. Now, this hardware devices also have a UI which user c... |
Say I am a QA person so I have no control over the complexity of the code in the following example.
I have a datatable widget with many different filtering and searching options. All the columns on my data table are also sortable.
There are many issues with components not working together. For example, if someone uses ... |
I am trying to create a library where I need to validate and parse a file in a CSV-like format and then use this data to generate a Tree data structure.
At the moment I split the process into two steps:
Validate the file and store its lines in a list (in the parsing package)
Read the list plus a string array containi... |
I'm just learning about dependency injection. Unfortunately, I don't have the luxury and time to learn a DI framework right now so I am attempting to do DI through some simple means.
Say I have an object A, that requires a class B, and class B requires class C. When I go to create Object A, is it best practice to creat... |
We are building a small social media platform for collaboration among a group of similar (but disparate) organizations. Each organization will have a small group of users who will be able to post content on this platform.
What would be the recommended ways for these users to create accounts on our social media platform... |
I really need some advice as I've recently come into a conflict over a difference of opinion on the SOLID principles and writing clean code.
One of our, relatively new developers but senior, does not agree with me that it is not a good idea to inject the Database context directly in the controller and then have all the... |
Overall situations:
The plan was to build a large system (Management Information System or MIS type) to be used throughout the country, by say 100,000 users daily. The team decided to split that into small MISes (something around 15), each of which with perfectly divided business specifications and roles. Each MIS work... |
I am implementing a library that:
Takes some input data (I put data structures and classes in the parsing package)
Stores the data in a structure (I put data structures and classes in the storage package)
Present the data in some meaningful way (chart package)
I divided my code this way because if I want to add anot... |
Context
I'm currently developing an application following the Clean Architecture principles (at least I'm trying really hard to follow these).
All my Dependency Injections are done manually, without any Framework.
One of my Use Case consists of the user being able to answer to a question he was asked.
If he/she is wro... |
I'm often finding that my classes end up with many (10-15) dependencies being injected. I realise there is no hard and fast rule, but someone once told me that more than 4 or 5 can be a code smell. The classes themselves typically aren't that large, at least in my opinion (1000-1500 lines).
Such classes aren't your ty... |
I would like to model the following entities:
"Person", "Company" and the aggregate that ties the two together "Membership". I have identified that Person and Company are aggregate roots. Thus, "Membership" would hold a reference (id) of both those aggregate roots, plus other value objects/entities that a membership ho... |
At a conceptual level, what ways can a subscriber catch up with events it has potentially missed but needs to know about at a later time.
For example, a service is running and subscribes to events on an event bus. When the events arrive that it's interested in, it updates its persisted data to keep up-to-date. However,... |
This is a question for people who are familiar with how HTML typically is built and behaves on webpages.
Backstory and requirements
I am building an HTML tracker with a C++/Qt backend. I am trying to track when Elements are destroyed and created simply by interpreting the html string, to which I will send signals off w... |
I'm trying to build an web API that closely represents a library of books. I currently have the following routes.
GET /api/books
GET /api/books/:bookID
GET /api/libraries
POST /api/libraries
This route currently accepts a books parameter in the body (with the body represented as an object), that should be an array o... |
I know it's a broad question so I'll try to be as specific as possible. This question is probably as much an "organisational" question as a technical one.
Our company is selling our software/platform to let's say 10 customers (also companies). These customers are all running their own installation of our platform, and ... |
I have a requirement of developing a service that must generate each day few millions of random and unique alphanumeric String of length 10 (I can't increase this length, this is a customer prerequisite). Having a ID, the next ID must not be guessable.
I want to be sure that all IDs will be unique because thoses IDs wi... |
I am trying to gain better understanding on SRP and when I was checking out a Pluralsight video by Scott Allen, I saw code like this:
https://github.com/OdeToCode/cs-fundamentals/blob/master/src/GradeBook/Book.cs
https://github.com/OdeToCode/cs-fundamentals/blob/master/src/GradeBook/Statistics.cs
public class DiskBook... |
Let's assume that I am working on a small project that uses feature branches to organize tasks. For example, feature/login would be for working on the login functionality and feature/create-new-post would be for adding functionality to allow users to create new posts. When a feature branch comes to a relatively stable ... |
I'm currently building a facade that's supposed to be in front of a system we are currently using. This system has its own API, but we have decided to simplfy things, and therefore the facade.
However, this system requires the consumer to log in using Forms authentication. Once the consumer has signed in, the system s... |
If you have two positive numbers that can be represented exactly by the finite arithmetic of your computer, that is, two machine numbers, if you perform their sum or subtraction with perfect arithmetic, is the result a machine number aswell?
I suppose that in the case of multiplication the answer is not necessarily, bu... |
I've always know Unit Tests to be something you do in code. You write functions to test other functions. Our team has been working with the same project manager for a while now and he's always referring to system tests as unit tests. By system tests I mean the kinds of tests where a user follows a test plan and perform... |
I am reading through this bit of the Jenkins Docker README and there seems to be a section that contradicts itself from my current understanding.
https://github.com/jenkinsci/docker/blob/master/README.md
It seems to me that is says to NOT use a bind mount, and then says that using a bind mount is highly recommended? I'... |
I have a Spark Streaming Job which processes messages coming from Kafka.
My incoming json that I process sort of looks like
{"sv" : 1.0, "field1" : "some data"}
The only thing I do is put these in a MYSQL database.
However, I need to process these messages differently based on the schema version number!
For instance,... |
I've recently started applying the Clean Architecture while developing an Android application. And so I divided my application in 4 different parts.
Data layer
Contains the implementation of repositories.
Device layer
Contains implementation of android related stuff like AlarmManager, not related to storage of entitie... |
There are a number of CSS frameworks that have a one-to-one correspondence between many of the classes and a single style. For example, in basscss ".inline-block" is defined as "display: inline-block;".
What benefit is there for making a class that matches one specific style?
Usage of such classes could be replaced wi... |
I am trying to switch to semantic commit messages for project. While the idea is good, sometimes I find it is difficult to properly categorize changes like a configuration value change.
If I commit a change in a database password or raise the size of a worker pool, what is the appropriate type for it? Is it a chore, fi... |
I need users to be able to create an organization which will have some preset fields such as Name, Address, and Type. But depending on the type, the organization can have type-specific fields such as as President, Manager, or something that I can define at a later date that the user can also fill out about their organi... |
I'm having struggles how dealing with inherited roles. Here is an example :
As an admin, I want to do something 1
As an admin, I want to do something 2
As a super admin, I want to do something 3
So basically the super admin has the same privileges as the admin with some extra features. My problem is, how can I express... |
I have a frontend application, that only knows about and communicates with a single backend service. This backend service serves only this frontend app and no-one else. Backend is completely stateless, no user session or response caching.
Backend exposes a few operations, mostly commands that go to external SOA service... |
I just read documentation and tutorial about dependency injection (DI) and the singleton pattern (SP). Everybody seems to says DP is bad and DI is the way to do it. Tutorials about dependency injection use some framework like Autofac or Ninject. They also all explain DI don't need a framework, container. I understand.
... |
The project is using C++ and the code takes around half an hour to build on a 32 core box. That time can be longer, e.g. 1 hour+ on a developer's local machine.
I notice the efficiency is low when one is doing the build. Just sit and watch it is waste of time.
A typical case is: modify some code, then build, if build f... |
In a particular program I had written, I noticed I had a few classes with this pattern:
class IdObject:
'''Objects with generated id properties'''
def __init__(self, id_generator):
self.id_generator = id_generator
self.id = id_generator()
class Node(IdObject):
'''Represents a node in the gr... |
Suppose I have a function (or object or module) that is imported by 100 files, and that making a change in the function will affect all these 100 things that depends on it, possibly breaking them. What is the word for this situation?
|
Say for a given positive integer number n, you have to find a level k so that
1 + 2 + 3 + ... + k = S is below or equals n
but S + k + 1 is above n.
For example in python:
def find_level(n):
level = 1
while n > 0:
n -= level
level += 1
return level - 1
What is the O magnitude of this func... |
I am in the process of building an API in Laravel and my server is currently stored in the UK. Now I have read some of the posts relating to this topic on Stack but I am still a little unsure as to the best approach.
I am wondering whether to make single or multiple calls to the API when loading screen data for the app... |
What is the difference between buffer overflows and out-of-bounds writes? Are buffer overflows a kind of out-of-bounds writes?
|
tl;dr
Which is the best server response for an endpoint to get a user's age?
30 or {"age":30} or {"metadata":{"time":1561919615,"status":200},"age":30} or something else?
I am writing a server using Firebase Functions. I am trying to determine the best way to send my responses. My server-side experience is minimal.
... |
I am currently building a microservice-based system to learn CQRS/ES, Docker, AMQP and all the other goodies that goes with it.
I have never asked a question online before as I am usually pretty good at finding answers to my queries by reading what that others have asked.
This time, I am stumped by what seems to be ver... |
I am working on the project where currently we have following three fixed branches
Develop - The code is deployed to development environment. It's a base branch for anyone who want to add new feature.
Release - Deployed in QA environment, and QA can start testing on.
Master - Deployed to Production environment an... |
There are plenty of examples of both associative table and one foreign key designs out there, but I can't find clear any explanation of when should each of them be preferred.
For example let's assume my database needs to store the following information about people: first name, last name, address. I have 2 options of i... |
I believe, for PHP, that I've found the worst culprit when it comes to bad code: not being able to declare (return) implementation details through interfaces. This makes it unpredictable to see what you're working with if you go beyond the basic interface that (in 5.6) doesn't even support return types at all.
An argum... |
I'm working on a software in which the client wants the admin to have all the rights to view and update the info of other employees. The admin is an employee itself so this is what I've come up with but I wanted to confirm whether this is the right way to do it or not? What could be the potential issues with it if any?... |
In a testability perspective, would this logic be appropriate?
public class Foo {
public List<SomeClass> Elements {get; set;}
public Foo(IServiceInterface service) {
this.Elements = service.GetElements();
}
}
or this would be the right way:
public class Foo {
public List<SomeClass> Elemen... |
I would like to be sure I understand the concept of dependency injection (DI). Well, I actually understand the concept, DI is not complicated: you create an interface then you pass the implementation of my interface to the class that use it. The common way to pass it is by constructor but you can also pass it by setter... |
Context
I am building an application for searching places 'Nearby' akin to Yelp/Google.
Objective for this question
Recommend a strategy to do paginated searches based on location and ask for advice on the same. Further, ask for frameworks and tooling that support the design.
Please note: I do not want to complicate th... |
For the discussion, I will provide my example. But I am interested in the broad guidelines.
I save in my postgres DB legislation (law texts) composed of a single header (H), paragraphs (P), sub-paragraphs (SP) and sub-sub-paragraphs (SSP).
Every level owns some content, rules, applications, etc.
Every block has the ... |
This is the case:
We have one Scrum team of 7 members (developers and QA's) plus PO and SM
We have content team of 3 members that are responsible for portal ''look'' (banners, pictures, copywrite etc.)
This is the problem:
We have situations where development team is working in the sprint and we only use lorem ipsu... |
I am a student working on a personal project which is essentially a location finder that will be on a website. I have a data set of over a million addresses and I want to display the closest N locations to a given address or current location.
I would greatly appreciate some examples of the technologies/stack that an e... |
I'm modeling a system while improving my knowledge of software engineering. I am building a class diagram and a component diagram, but notice that when I tweak one, I have to alter the other. Also, I feel like I can represent the classes in a component diagram. How do you do this? Do you make them both or only one? If ... |
I have different equations to compute the same quantity. For example, val = my_func(a, b, c) but also val = my_func(x, y), where my_func represents the quantity I would like to compute: it could be Velocity or Momentum or something completely different. I have dozens of quantities to code, each with multiple equations.... |
I am not asking whether to do server-side validation or not.
My question is whether any solution or better practice exist in the software world to address this repetition of code.
|
This is quite basic question that started puzzling me recently while studying Lisp (and derivatives). I have read some Lisp books and web sites and this subject is somewhat obscured by other Lisp properties that seem to be having more meaning to the authors so they give them more attention. So I cannot find this subjec... |
We developed a generic .NET library for our line-of business applications. This is what our namespace/class structure looked like 5 years ago:
...
AcmeCorp.Tools.ExcelWriter
AcmeCorp.Tools.Code128Barcode
...
5 years later, the number of classes in the generic Tools namespace has grown (e.g. there's now a CSVWriter in ... |
We have started using a "micro service" architecture and we have multiple services. Each service owns the data and the business logic for a domain and only entity ids are shared across services.
Everything was perfect until 1 requirement came in...
On the UI, when a user is about to delete an entity, a warning listin... |
In my case I inherited a poorly engineered code, on that piece of code I have been tasked to increase the code coverage in integration tests. But instead of the usual pattern:
Create/Populate a test database with specific test data
run the test
Delete the test data or Nuke the db
Repeat step 1 until no more tests.
Th... |
I am working in a purchasing system where we take calls:
public class Call
{
public List<CallItem> CallItems { get; set; }
}
The calls can be turned into quotes, where call items become quote lines:
public class Quote
{
public List<QuoteSegment> QuoteSegments { get; set; }
}
public class QuoteSegment
{
p... |
I have a system where a user uploads a file to import some users but it's necessary to do some validations and this take some time. I would like to create a work queue with RabbitMQ and the user will upload de file and I'll send to the queue and then process it.
What is the best design to use in this case for my prod... |
I've struggled to find any discussion on this.
If you have a simple MVC page for updating a User, and you put a dropdown list on it of Country, you need to populate the dropdown list in the viewmodel. Let's call it List<Country> countries {get; set;}
If the page is posted, and there's an error like they forgot to put a... |
What are the pros/cons of having a serialization function accept a sink:
class Foo:
def toString(self, stringIOSink):
pass
def toBytes(self, byteSink):
pass
versus having the serialisation function return the result:
class Foo:
def toString(self):
# ..
return s
def toBytes(self):
# ..
... |
Continuous integration with testing is useful for making sure that you have "shippable" code checked in all the time.
However, it is really difficult to keep up a comprehensive suite of tests and often, it feels like the build is going to be buggy anyways.
How much tests should you have to feel confident in your CI pi... |
So let's say I have a view model, representing a student. The view model is corresponding to a student model, from which the data comes. What I am struggling with, is how to populate the fields in the view model. Do I simply forward reference the fields from the model (where possible) or do I have actual fields in the ... |
I entered yesterday to my new job and while browsing their repositories, I noticed they have a project for every resource of a REST API. For example, if they need to add a REST resource called "people", they proceed to create a whole new repository that contains only the endpoints of the resource "people".
Honestly I'v... |
public class LDLTrackViewModel : RailwayViewModel {
private LDLTrack _ldlTrack;
public LDLTrack LDLTrack {
get => _ldlTrack;
set { _ldlTrack = value;
OnPropertyChanged("LDLTrack");
}
}
public LDLTrackViewModel(LDLTrack ldlTrack) {
LDLTrack = ldlTrack;
... |
Assuming we have following message that will be used to update data and it just got updated to version 2.
message HelloRequest {
string name = 1; // version 1
bool is_valid = 2; // version 2
}
Now assuming we updated our apps like so:
server : version 2
client A : version 2
client B : version 1
We don't have any... |
I have a web app that connects to a MYSQL database which has some encrypted data in it. The encrypted data is encrypted using the the mysql AES_ENCRYPT function and a key.
Now, this key has been static for a while, and we're looking at methods to change the key (and ideally change the key periodically). My problem is t... |
If I write this code in a function:
void func(void)
{
int x = 0;
int y = 3724832+x;
}
It would (probably) optimize the variable y out because it isn't being used. Even if I'm wrong about this specific case, the point I'm making is that the compiler has the ability to optimize out variables.
My question is does... |
I have a small library where I am performing 1 long running operation and based on that operation,I am saving some data inside database tables.Now this is small library which does not include alot of database tables operation hence I have used Ado.net to manage data access layer.
I have created base class where I have ... |
I don't use SSL on my website currently. It's a small hobby site with no online store or anything of that nature that would need it. I've read that Google Chrome will stop loading such sites sometime in the near future. Are there going to be additional future consequences if I don't purchase a signed SSL certificate?
|
I have a question about Fluent Interface Builder.
I have a simple object like this:
public class Person
{
public string Name { get; set; }
public string Surname { get; set; }
public int Age { get; set; }
... other properties
}
and I have a simple UserBuilder class:
public class UserBuilder
{
priv... |
I am implementing a Binary Search Tree and cannot decide if it would be good practice to constrain the generic type of the tree to a comparable item, i.e. IComparable<T>. Or, to just use the default comparer, i.e. Comparer<T>.Default. To me they are functionally the same and they both provide a method to sort with.
Can... |
Here's a snippet of code:
An inlined function:
inline void rayStep(const glm::vec3 &ray, float &rayLength, const glm::vec3 &distanceFactor, glm::ivec3 ¤tVoxelCoordinates, const glm::ivec3 &raySign, const glm::ivec3 &rayPositive, glm::vec3 &positionInVoxel, const int smallestIndex) {
rayLength += distanceFacto... |
I have decided to try to create my own board game implementation. Probably going to use a REST-api to expose the contract. I'll figure out what database, communication, ... tools I'm going to use once I've got my business logic set.
Now, to achieve not being dependent on tools/frameworks in my business layer, I need to... |
Let's say a user goes to the log in page of my website and creates an account. Instead of entering their real name, they decide to write some sql code and try to gain access to my database.
I have prepared statements to prevent any harmful code from altering my database at the signup process, however if the user goe... |
Do I need unit testing for everything? I know that Unit testing is not necessary for really small tasks, but what about for bigger stuff? How do I know I need a unit test?
|
I generally try to adhere to the 80 character limit for each line of code to satisfy my colleagues, to satisfy the linting tools, and to maintain an image of professionalism when random people look at my code.
However, sometimes I have URLs that I wish to embed in the comments, and some of these URLs are very long (exc... |
Hello I am building a demo project to teach myself about clean architecture and unit testing. My setup is very similar to this github repo https://github.com/mmacneil/CleanAspNetCoreWebApi
The important parts for this question are the following 2
The Core project which should contain the business logic
The Api projec... |
Throughout the course of programming, you will end up with some comments that explain code and some comments that are removing code:
// A concise description
const a = Boolean(obj);
//b = false;
Is there a good method to quickly parse which is which?
I've played around with using 3 /'s and /** */ for descriptive com... |
I am currently building an Entity Component System (ECS) in cython in order to speed up operating on large numbers of game objects in python. In the process of building this system, I ran into the following architectural issues that I would appreciate shedding some light upon. I have read through lots of online blog po... |
In our current project we are versioning software using gitflow as process and git/gitlab.
We had some trouble managing multiple release at the same time, but nothing we couldn't survive.
Until now we had only client A and the project is very oriented to it.
But client B will join soon. Also, we want to start to build ... |
tl;dr: I work at a small company with a development team of 5-10 people, lately we have been asked to present "scope documents" for effectively all of our work before we carry out the actual work, with seemingly no regard given for the magnitude of work required.
I worry that I am often spending more time writing scop... |
I'm new to Core Data, and am not sure how to reconcile the need to inherit from NSManagedObject with the fact that my model is a Swift struct composed of structs. I chose to make my a model value type so that it would be simple to push and pop it onto an undo stack. But since a value type can't inherit, I'm unsure as t... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.