instruction stringlengths 34 36.1k |
|---|
I'm working in C++14 and trying to figure out a way to put two classes (with the same name) inside the same header file. In this scenario one class would always be ignored as a result of something happening in main.cpp during runtime. Here's an example of this header file:
// First class:
class foo
{
public:
foo();... |
We have a microservices architecture very similar to the architecture described here
Obviously, it's a simplified diagram of a real system. In our case, we have a requirement to perform background operations in a service in addition to exposing APIs. e.g.
In the Catalog service, if a certain product's count goes bel... |
I read through documentation and searched on google, but couldn't find a specific answer. Currently, I have an object that subscribes to a click event. I am trying to understand how a view that receives a mouse event with an (x,y), determines if it's within that object with the mouse event. To be specific, a view recei... |
Lets say I design a generic read only repository IReadOnlyRepository.
public interface IReadOnlyRepository
{
...
TEntity Find<TEntity>(object id) where TEntity : IEntity;
IEnumerable<TEntity> Filter<TEntity>(Expression<Func<TEntity, bool>> filter) where TEntity : IEntity;
int Count<TEntity>(Express... |
I am creating a library to interact with third party api.This library will be wrapper around that third party library and i want to expose my wrapper methods to client(webapi,winform,console,mvc etc..).
Below are the methods that i want to expose to my clients to perform operations using third party apis but i dont wan... |
I'm working on an overlay/HUD for a Java game, where the user should be able to enable or disable certain components and choose configuration options. One such example is a health bar, which the user can choose to either enable or disable and choose its size and color.
What would be a good design to handle this kind o... |
Few months ago I started working in a team that develops software using Node.js. Quite often we encounter the problem that has been already solved by someone else and the solution is already available in npm registry. Some examples of these problems include: writing deep merge function, writing single value to JSON fil... |
As far as I understand in trunk-based development there are no long lived feature branches, one could even argue that there are no branches because at the end everything will be merged back to trunk very quickly and the only valid version is trunk, thus one can't use previous branches as a reference point.
Usually wh... |
I am using Scala for my example but I believe this probably could apply anywhere.
Say I am using a class somewhere in my project that reads in data from a live stream of events which monitors where a player is in a 2D game at any given moment.
case class Player(player_id: String, time: Long, age: Int, color: String, po... |
I'm working on a project where an increasing number of small mini apps all share nearly the same tooling - makefiles, dockerfiles, jenkinsfiles and webpack configs, along with a couple of scripts, are all rigged for each project to give a standard set of dev tools for each project.
This is becoming increasingly difficu... |
I have an arbitrary number of derived classes all inheriting from the same base class. These derived classes all have the same static variables and static methods, although the implementations may vary from class to class. I'm using pointers to the base class in order to interface with all these derived classes. Ex:
ba... |
I'm building a Spark-based, text analysis package using both Java and Scala. I have a series of transform functions, which take in one dataframe and spit out another, and that can be chained together to perform various analyses.
Each transform and all the methods that it calls are thoroughly unit tested. These tests ru... |
How can we capture the response from REST API.
Here is what I am doing:
React JS page which contains the button for login.
As soon as you click login it will redirect to Ping Identity Login page.
On login page user need to authenticate himself.
In case he is valid user Ping will redirect to REST API which is post inte... |
I have a user feature. user feature also has other subfeatures user application details and user contact information.
Usually, because application details and contact information are part of user feature, we are dealing with one-to-one relation, I would put application details and contact information within user folder... |
I am wondering if I wrote a little simple documentation and provided the JavaDoc, would it be enough documentation for a application GUI manager library for java?
|
According to the AWS feature page for SQS:
FIFO queues support up to 300 messages per second
Standard queues support a nearly unlimited number of transactions per second (TPS) per API action.
I'm trying to build a system that will add notifications to a queue that will then be sent to a customers device using push no... |
I'm working on a project that requires using multiple programming languages. I'm confused about what term to use to specify the interfaces available to bind two languages, e.g JNI, ctypes, jpype, etc. I don't want to limit the meaning to say that the binding exists only between high level and low level languages(java-c... |
HATEOAS is an acronym for "Hypermedia As The Engine Of Application State". What is the "Engine of Application State" referring to, and particularly - how is "hypermedia" the engine of it?
As far as I have been able to understand, HATEOAS, and associated standards like HAL, address the "discoverability" part of REST.
Th... |
I'm a high school student interested in topics of computer programming.
Recently I became interested in file compression, and in my head I tried to combine this with a completely different part of programming I heard about a while ago, hash values.
From my understanding the hash value of a file is created by an algori... |
I am developing a library management software in javafx and I am using sqlite as a database for that. I have to store data of almost 50000 books. And all those books would have a barcode. Obviously, the barcode is a going to be an Integer(PS. Correct me if I am wrong) and it would contain many digits. So I am not under... |
What is the benefit of having multiple implementations just for doing one thing? Are there any other languages that use this concept?
|
Can someone explain concretely why it is not desirable for ViewModels to communicate directly with other view models? It seems to me that for virtually any UX application there will be a “root” view (with its ViewModel) and any further views will be somehow initiated from from this view/ViewModel, or a sub view/viewMod... |
Sorry for this naive question.
Reading some existing JavaScript I see a function with code like ...
async function _load() {
await ensureDir(path);
return await readFile(filename);
}
... why not use readFileSync instead, what's the difference?
When you call await (e.g. in Node.js) does other code become runnable, ... |
I want to ensure that my program code is correctly inserting, removing, and modifying data in my database. Full integration testing can be slow, and I have concerns about keeping mock objects and data current because my database is evolving rapidly.
Is it ever proper to test database interaction by setting a database r... |
Here is the original question from MIT lecture notes :
Write a Spy procedure that takes two positive integers as input and returns True if the first is greater than the second. Use only the primitive functions = and + and recursion.
I haven't figure out anyway to compare two number with these requirements. Spy is jus... |
So I am just starting to use a linter and I like the no-magic-numbers rule in generally. But in unit test files it is giving me 1000 warnings. Here is what they look like:
it('getWeekNumber', function() {
expect(getWeekNumber(1538918924615)).to.deep.equal([40, 2018])
expect(getWeekNumber(1536918924615)).to.deep... |
I was just thinking about implementing a binary tree with its root pointing to the parent folder and then the children pointing to subdirs nested within to store a directory structure in a binary tree.
I am not sure how to cater this problem with binary trees or if its possible?
M-way trees seems like the correct way o... |
I was once asked a system design question during an interview. I don't remember the details, but it was a fairly typical web app, so I described what I thought was a pretty common architecture (users making REST-style requests to the server, servers talking to the database, the database is partitioned and replicated fo... |
The following code causes a memory leak:
#include <iostream>
#include <memory>
#include <vector>
using namespace std;
class base
{
void virtual initialize_vector() = 0;
};
class derived : public base
{
private:
vector<int> vec;
public:
derived()
{
initialize_vector();
}
void initial... |
I am a hobbyist programmer, working on a much more complex Python project than I've attempted before, which is in the form of a Python library.
I find that I'm often passing **kwargs around (as described in this question), but I'm also realising it's bad for readability and maintainability. The answer to the previous q... |
I tested out a few different compiler optimizations on GNU GCC, in the CodeBlocks IDE. With each different optimization I ran the same test: I let my program try to build as big of a tree as it could in 1 second. The nodes of the tree were objects of a class I created.
Results:
[-O1]: 78,235 nodes generated.
[-O2]: 78... |
I'm an academic rather than a programmer, and I have many years' experience writing Python programs for my own use, to support my research. My latest project is likely to be useful to many others as well as me, and I'm thinking of releasing it as an open-source Python library.
However, there seem to be quite some hurd... |
So lets say you want to outsource your database to a third party and be able to query on it on their server
but you want to "encode" the salary column of the users on their server, aka hide the real value from that third party, in a way that you can still query it on that and decode the result
for example one approach ... |
I just started reading more about OOP and its design patterns and is confused with this conceptual question. I am too new that I am having second thought that the proper title should be, "when is it okay to have the constructor function in the interface?"
If interface defines the blueprint/API of your object, how do yo... |
I'm building a home project using EWS and SQLite.
I have a bunch of really similar (and not so similar) Mails (that hava the usual subject sender body etc fields).
These mails contain similar information and i would like to collect them into a sqlite db.
Also i want to separete the collection logic from the main code ... |
Here's the Scrum situation:
A certain task (implement a back end populated data table) is a frequent story
The tables frequently have similar but custom functionality
Each table takes about a week to implement (8 story points)
Eventually the team invests 4 weeks to create a reusable component
Now creating a new table ... |
If a file foo.cpp already includes foo.h, and foo.cpp requires some types from (for example, string.h), which is better, to include string.h in foo.cpp, or in foo.h ?
For example, Guideline#9 in this tutorial recommends to include it in the cpp, if possible, but I don't understand exactly why.
|
I'm designing an API for a Python library. The user will create objects with several parameters. In most cases, the user will either leave these at their default values or will set them globally, for all objects. However, it should be possible also to set them individually on a per-object basis.
The most obvious way to... |
In Chapter 10 of Clean Architecture, Martin gives an example for the Interface Segregation Principle. I have some trouble understanding that example and his explanations.
In this example we have three separate Users (Classes) that use a Class called OPS. OPS has three methods, op1, op2, and op3. Each of these is only u... |
I've made an engine that plays Connect Four using the standard search algorithms (minimax, alpha-beta pruning, iterative deepening, etc). I've implemented a transposition table so that the engine can immediately evaluate a same position reached via a different move order, and also to allow for move-ordering.
The probl... |
I am using Kafka. I am developing a simple e-commerce solution. I have a non-scalable catalog admin portal where products, categories, attributes, variants of products, channels, etc are updated. For each update, an event is fired which is sent to Kafka.
There can be multiple consumers deployed on different machines a... |
I am trying to get my head around "event driven" microservices. I understood, there are several techniques and patterns, like event notification, event sourcing, CQRS, etc that can help us to achive that. Very simply said, it boils down to some kind of a command has been sent, which leads to a change of the systems sta... |
When specifying a period is there ever a case where passing the number of the month as integer is preferred over passing two datetimes? For example GetTotalSumByMonth(int month) vs GetTotalSum(DateTime begin, DateTime end).
It seems to me that the second option has clear advantages since it is more generic and less amb... |
In my understanding of Uncle's Bob Clean Architecture, a Use Case (Interactor) is responsible for orchestrating the Entities. At the same time, it represents Application-specific rules. The business rules live in Entities.
I have a need to orchestrate the Entities to achieve a Business-specific rule. What is the best a... |
I am trying to do the architecture of a new application we are building. We wanted something quite modular. Considering we are open source and we want other people to be able to easily add new features, we opted for a component based architecture.
We have a back end that is made in Java, and a front end that will be m... |
I´m looking for some kind of better compilation of principles which takes the old basic concepts (DRY, KISS, etc...) and applies them to OOP related concepts like abstract clasess, interfaces etc...
Some reasoning behind this quest:
I find some interpretations of the SOLID principles very compelling, but I've found so... |
A lot of tutorials on DDD I studied are mostly covering theory. They all have rudimentary code examples (Pluralsight and similar).
On the web there are also attempts by a few people to create tutorials covering DDD with EF.
If you begin studying them just briefly - you quickly notice they differ a lot from one another.... |
While setting up a nodejs server with a mariadb database, I found this:
While the recommended method is to use the question mark placeholder, you can alternatively allow named placeholders by setting this query option. Values given in the query must contain keys corresponding to the placeholder names.
This seems odd ... |
I have recently graduated from university and started work as a programmer. I don't find it that hard to solve "technical" issues or do debugging with things that I would say have 1 solution.
But there seems to be a class of problems that don't have one obvious solution -- things like software architecture. These thin... |
This is a very broad question, but maybe someone has a worthwhile response.
There is a general synchronization issue that often has to be solved, but always seems to be difficult. Here's an example:
I was working on a remote system and had an ssh-connection and a remote desktop open at the same time for some reason. I ... |
I was hired to program a basic, plain text site for a local business that amongst other things, provides basic pricing quotes through a Javascript Applet. For obvious reasons, it seemed unnecessary to me to in anyway encrypt the traffic to and from the site. However, the person who hired me strongly requested that I se... |
A water user can submit an Application for a water right with the hope of getting a Permit to use water, which might later become a BonaFideWaterRight. The right holder may apply to Transfer any of the above items (or others not listed for brevity) by changing ownership, moving it to new ground, splitting it in half an... |
My question is that is there any reason for Thread class to implement Runnable interface by itself. Are there any specific use cases where overriding Thread makes more sense than implementing Runnable by design
|
New to DDD I have a simple case a I would like to model using DDD approach
2 entities Student and Course
Relevant property for Student are StudentId and Budget
Relevant property for Course are CourseId and Price
Student and Course are entities that can exists on its own and have their own life cycle
Business requiremen... |
Can I draw mutual dependencies between two artifacts in a deployment diagram as a dashed line with two arrow heads? Or is this a no-go in UML?
|
As the code below, class Foo1 implements interface IFoo, which has a property of IData.
public interface IFoo
{
public IData Data { get; set; }
}
public interface IData { ... }
public class DataA : IData {...}
public class DataB : IData {...}
public class Foo1 : IFoo
{
private DataB _data;
public IData D... |
I am trying to figure out the best way to decorate html. What I mean is replacing specific syntax string with the actual content.
Kind of like, razor syntax in Asp.net MVC using <%= %>.
Currently, I have an HTML page with design and I just need to replace tags (for ex: <%HISTORICTABLE%>) with actual content.
I have 5-... |
Emacs loads into memory as:
An editor that has m functions with n inputs.
An elisp interpreter that can be used to change the behavior without restart.
Why do programs need such an extension that is an interpreter all by itself? What feature does it provide so that I consider adding it to my own project?
What I under... |
I have a main window and I amgetting data from http client service while form load.
public class MainWindow: Window
{
private IClientService service;
public MainWindow(IClientService service)
{
this.service = service;
GetClient();
}
public asy... |
I was given a more or less complex task. The goal is to interpret a SQL Check Constraint inside my C# .NET libary. In our case we have a simple UI that displays what is inside the database. We do not want out UI-Components to allow any values that wouldnt even be possible because there is a check constraint. Since ever... |
I have a class Person.
Person {
String firstName;
String lastName;
String Date dob;
String email;
String mobileNumber;
String address;
}
To add a person, I have following REST APIs:
POST /person
{
"firstName":"Donald",
"lastName":"Trump",
"dob":"01/01/1990"
}
PUT /person/{id}/addContact
{
"email":"donald.trump... |
I am writing a potentially large web application using Angular 7, where I came across a design problem. My angular applications until now have been relatively small, so there was no problem keeping whole code in one project (divided in modules with lazy loading). However now that an application can grow in size I find ... |
Currently, my thoughts are that GET requests would be feasible by using the concept of screen scraping combined with a cron job that runs at a set interval to scrape data from the GUI and sync to my own database.
However, I'm not quite sure how I would handle actions that seek to mutate the database that sits behind th... |
In laymen's terms, what is the difference between opcodes and operands in assembly language programs? I understand that one involves where to get the data and one involves what is to be performed on the data, but is there a way to understand it in more detail?
|
Yay or nay? I have several related but separate services that are to be run in different processes. They execute a particular task unique to the service. Their call signature is similar, but the name of the service changes. For example.
Service 1:
:5000/Invoice/<id>
:5000/Customer/<id>
Service 2:
:5001/Invoice/<id>
:5... |
Let's pretend I have an 'Book' entity, that can contain many 'Chapter' entities, having both their own unique IDs. A chapter must belong to a book, it cannot exists on its own (ie: there is a required foreign key in the chapter's table).
There is a screen where the chapter's content can be edited. So far, we considered... |
I am in search of information on how I to manage code in git flow and methodology to test and work with it :
I have an API in place to build and manage a product catalog and it was designed around the business needs of my first client project (let's call this the master branch)
For a second project with another client... |
I have just created a function which checks whether a ipv4 is public or not. I have not heavily tested it yet since it is kind of practically impossible to do so (because I do not know where to start).
My algorithm is based on an article from this website.
Public IP addresses will be issued by an Internet Service Prov... |
Can anyone tell me what does "machine" means in Compiler Theory? Does it mean computer in general or operating system? Actually, the problem is I understand the definition of machine language as "the language understand by the computer". But does machine here refers to anything specific other than computer.
I was readi... |
I'm not sure what the correct procedure is, when you have a question based off an answer you read but it is a seperate question that arose because of the answer provided.
the answer in question Which HTTP verb should I use to trigger an action in a REST web service?
Walkthrough of my method, where this is relevant
[Ht... |
I have a base type of Entity, and multiple implementations, Enemy, Bunker, Projectile
I have separated these entities into their own containers so I can pass them to different classes to perform different actions on them. However it is becoming clear now this may not have been the best approach. I am currently writing ... |
I currently have two derived classes, A and B, that both have a field in common and I'm trying to determine if it should go up into the base class.
It is never referenced from the base class, and say if at some point down the road another class is derived, C, that doesn't have a _field1, then wouldn't the principal of ... |
In my application, I have a finite number of question types, but the order in which they're asked and whether they're asked at all is not known up-front.
An example analogy is a hotel booking process, during the process you may be asked a number of questions, like whether you want late check-out, rent-a-car, breakfast-... |
I know the sites are not geared for recommendations so I am hoping to pose this question in a way that doesn't ask for recommendations. Questions comments are welcome.
I am just getting involved in wanting to create a .net Core API for one of the projects we are working on. I have read a little on the topic and what ... |
I may have a tough one for you.
I have a machine in the wild that is and will probably continue to be compromised. The machine is owned by a user who will be unable to keep it secure.
I must have this machine pull from git. It must also automatically install all pulls without restart (no startup solutions).
I would p... |
I'm developing a Python library, and I'm also developing some code that uses it. Currently they are in the same git repository, but I want to separate out the library part into a separate repo, in preparation for eventually* releasing it.
However, I'm unsure of the right way to work with two repositories. The library h... |
We are building a new application for a client to manage their cases. They are already using their existing system in which they are storing files associated to the cases in an FTP folder. There is an attachment table (~1M rows) which maps the cases with the ftp file location. As part of the migration the client also w... |
Hopefully, this is the right forum for this type of question..
We have a set of common entities which are 'shared' throughout the company - much like Master Data Services (MDS) data. Everyone has differing ways of maintaining said data...most of which are painful and/or lacking.
So...I created a working 'demo' using th... |
Clean architecture decouples an app's core from the presentation/UI layer. The UI is just a plugin, replaceable (eg, web-based to desktop) without impacting the core.
Many data science apps mix code, user inputs, text, graphics and other outputs in one notebook, eg, Jupyter. Everything seems coupled: the domain, UI, p... |
I would like your tipps about implemening a command line interface
to interact with a running java application.
Example:
The Java Application is a webserver and a cli-client should interact with it:
1 ) Start server application:
java -jar webserver.jar
2) Get status of the running application: java -jar webserver.jar -... |
I have a question about architecture in .NET.
My architecture is like this :
Projet :
- DAL (Data Acces Layer)
- BLL (Business Logic Layer)
- DTO (Data Transfer Object)
- IHM (man/machine interface)
DAL : Acces to the database (CRUD) It reference DTO
BLL : Logic Layer do all logic process and make the connection be... |
When I develop apps I reach situations like this frequently but I never found a best practice to solve it.
Imagine:
We have chats, each chat can have many message.
We have tickets, each ticket can have many message too.
Solution 1:
We create 3 tables: chats, tickets, messages, and we link each chat or ticket to its m... |
Apologies if the title is incorrect, I couldn't think of better wording. I have the following code
template <class E>
void ResolveEntityHit(E& entity, Projectile& projectile) {
static_assert(std::is_base_of<Entity, E>::value, "entity must be of type Entity");
entity.DealDamage(projectile.GetProjectileDamage())... |
I'm designing a system that acts as a master data service for what I shall here call boxes. The system is to be implemented in Java with a relational database (SQL) as the main storage. Each box has a ~dozen different top-level properties: ranging from simple primitives (booleans, integers, etc) to other objects and li... |
I have read on several methods to securing an API key like gitignore or placing in another file if using an application, but at some point if taken the time, anyone can get the key, even when apikey is in use or called, right? Other methods explain using a proxy which is well beyond my league. I am only aware of unders... |
I have to define the new way of working for a development team which goes from a one man unit, to a distributed team with programmers al over the world. The team will work with svn. This is a non-negotiable thing. I recommended that they switch from svn to git, but that is not going to happen. This is the first time I ... |
my requirement is i want to delete a Object A
A-> B-> C-
here if you want to delete A you have to delete B which is dependent on B , then If you Want to Delete B you Have to Delete C which is dependent on B and The Chain goes like this
i'm planning to Solve it using chain of responsibility design pattern , or is the... |
I'm currently testing a web service and I have noticed that there is only one error code ever return: 400.
However, the error message return isn't always the same. Here are some examples of the error messages I got:
XXX must contain only digits.
YYY: This value is not valid.
XXX: This value should not be blank.
Etc..... |
I need to produce some documentation to be compliant with IEC 62304 and, while reading all of the processes needed to be documented, I'm having a couple doubts about how to structure the whole lot of documentation.
My concern is about how to divide all of the documentation in separate documents and what should be inclu... |
I have few strategy class that calculate ranking. Those class implements interface with method scoreUpdates. Method scoreUpdates take two parameters( winners and lossers). Now i need add new strategies and some need more parameters. Should i add methods to base interface for this new strategy?
What is best solution fo... |
I recently came across a set of possibilities for creating rows in a table in my database. the scenario is that I am trying to populate a notifications table by different types of notifications data based on different tables.
Adding to the notifications table is done instantly after the adding of rows in other tables ... |
I've noticed this style of code a lot in frameworks like Symfony and Magento 2 (which is based on Symfony):
<?php
class Foo
{
protected $foo;
# construct function - not needed for question
public function getFoo()
{
return $this->foo;
}
}
Which makes th... |
I want users to be able to dynamically add 'columns' from the front-end of the website. I understand that it is probably not best practice to actually add columns to a table from the front-end, so I was looking for a better way to handle this.
The use case:
I am making an app with a determination table. The user can fi... |
Is there a protocol or a convention that supports REST (ok, maybe we should use HTTP here instead) processing chain and some neat features to help with that? Let me explain what I mean.
Let's assume I have some public REST service available. Using HTTP GET, I have multiple static pictures, GIFs and movie clips availabl... |
Let's say I use a Pair in this way:
Pair<Long, Date> signup = getSignup();
System.out.println("User with ID " + signup.getLeft() + " signed up on " + signup.getRight());
Is it a form of Primitive Obsession?
I could have something like
Signup signup = getSignup();
System.out.println("User with ID " + signup.getUsrId() ... |
What is good practice of settings up a database in potentially large project - creating tables and updating them - should it be done in code of the app or should it be done by external database related tools like phpmyadmin ? I mean I have two ways - create tables and set them up when the app starts, or I can do this s... |
This is a best practices question for release management of an app. But this scenario is a bit different than what I've been able to find myself.
Essentially my company maintains a fork of its own app. There are two versions of the app that will have different configurations of bug fixes / features. These fixes and ... |
Should I run my own webserver? If so, how do I do that? I'm running on Windows 10 with VS2017, IIS Express and MS SQL Server.
I don't need a domain name. Just providing access via IP-address is fine. I'm just looking for a cheap and easy way of enabling other people to help me beta test my apps.
Can Azure be used for t... |
Considering this pattern is used to support CQRS message bus, examples are buslane Python or MessageBus PHP
It uses commands to change the domain model, and publishes domain events
This looks great providing the separation, and encapsulating each domain write operation on its own classes, but doesn't that make an anem... |
I just started a new job and one of my first tasks is to create local nuget packages from the existing libraries, to help with versioning, maintenance, etc. This task had already been started by another engineer. However, he chose to grab many libraries that relate, create a project holding all these libraries, and pub... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.