instruction stringlengths 34 36.1k |
|---|
Apparently, for some built-in type of C++, the following does not hold: a==b || a!=b
Which type/value is it?
The question is originally from
this video:
https://www.youtube.com/watch?v=etZgaSjzqlU&index=4&list=PLHxtyCq_WDLV5N5zUCBCDC2WqF1VBDGg1 at the beginning,
for which the slides are:
http://stepanovpapers.com/Journ... |
I'm designing a REST API using authorization/authentication via an API Key.
I tried to figure out what is the best place for it and found out that many people suggest using a custom HTTP header such as ProjectName-Api-Key, eg:
ProjectName-Api-Key: abcde
but also it's possible and ideologically correct to use the Autho... |
I know this has been asked a lot of times but we are talking about entity classes here. Plain dumb objects containing nothing but primitives for properties. The purpose here is to store data. Our entity can be created in a variety of ways, we never know which set of properties will have a value, it is given by real lif... |
We are planning to use Spring Boot with JPA for our next project and I am wondering how much flexibility JPA gives in reality. If we start developing using a self-hosted PostgreSQL server and later want to change to Amazon RDS PostgreSQL or SQL Server, will we run into a lots of problems? On paper, JPA should serve as ... |
I try to understand better under what circumstances one-to-one correspondence between test code and production code is not needed, after reading Uncle Bob's TDD Harms Architecture. For example, first:
"a one-to-one correspondence implies extremely tight coupling."
then below:
"If you look at part of FitNesse written af... |
I am trying to wrap my head around clean architecture but I am struggling with the concept of how to avoid some dependencies.
I am implementing an API in Java for personal use, however I was trying to find some examples and came across this post:
https://android.jlelse.eu/a-complete-idiots-guide-to-clean-architecture-2... |
My organisation modularised their monolith into maven modules in dependencies up to four deep. Originally we used the maven plugin to auto-increment the version numbers in the pom every time someone did a checkin. Then parent dependencies could pull in the updates by updating the version numbers in their pom.xml.
This... |
This question is not about a specific framework. but I'm currently working with asp.net core.
The problem I'm facing is the concurrent update of a resource in the web application (race condition). I'm not talking about synchronizing edits to a wiki document by let's say conditionals HTTP requests. both requests are rec... |
I am working on a process that requires two different portions of it to make use of an ORM (I am using Insight.Database for this), and I am not sure where this portion of the code belongs, as I am not currently creating an abstraction layer over it but using Insight.Database directly.
An example of the code layout is a... |
Lets say I am trying to design a district.
I have
1) house
2) community (groups of 2 or more then 2 house)
3) city (group of more then two community)
4) district (groups of 2 or more then 2 city)
What I have so far :
class house{
public:
house(std::string name, std::st... |
I come from a self taught background and am trying to shore up my weaknesses in OOP, specifically C# and class design. I've been reading Code Complete 2 and it became apparent that I'm not following good class design principals. I currently have a ReportHandler class that generates a report based on a ReportType enum t... |
Should automated unit tests be a part of the build process, or should they be manually run when someone makes changes to the code instead?
To me it seems like making it part of the build rather than leaving it a manual process has some clear advantages. Running your tests with the build would make them run more freque... |
For instance, if I wanted to make a game which used a Python main file, but have another file with Ruby methods on it, how would I call those methods individually?
Secondly, how could I make a Ruby gem/library with python code in it? I can't find a way other than exec("python file.py") which is not a gem, requires the ... |
If there is tag 1.1 for master branch in github, I want to create a pull request with some commits that only apply to that very tag. Is this possible?
|
In this specific case I'm using C# and Emgu, where I made a wrapper around the Capture() object, purely so that the end user of the library that I made doesn't have to put using Emgu` in their client code.
My wrapper adds no functionality, and I've been debating whether it should even be it's own thing or if I should j... |
I work at a small to medium enterprise that are in the business of handling the processing of transactions for the selling and purchasing of "online, electronic products". Things such as prepaid mobile airtime, mobile data, electricity and even water and gas metering.
We are a Microsoft shop and all our skills and arc... |
Let's say I have a small CD burning library written in Python, with a CD class and a Burner interface + implementation classes:
# Module cd.py
class CD:
def __init__(self):
self.folders = []
self.files = []
# Module burners/burners.py
BURNERS = []
# Module burners/cdburnerxp.py
class CDBurnerXP(CDBurner):
... |
I have a very interesting question that has proportionally blown up amongst my friends and I. This deals with handling user issued tokens from a series of authentication microservices.
Remarks:
Each Auth Service is backed by its own data store
Each Auth Service can issue a token that only its data store knows about
... |
After reseaching the differences between OAuth and JWT, I decided to use JWT on my next project for simplicity and performance reasons.
From what I learned until now, and please correct me if I'm wrong, JWT is self contained data, hashed with a public key on the client. I then can check it against a secret key and ver... |
I am trying to create a device management system for over-the-air updates. The system basically has 3 parts:
Mobile client devices running android located at different places
REST Backend written in Java using Jersey Framework running on Google App Engine.
Web front end running on the browser of the users.
The use-c... |
I’m trying to apply DDD, CQRS (saga, fire and forget principle, etc), ES in my current project, with help of akka. Never done it before in real projects (just played a litle bit), sounds great in theory, blablabla.
But sometimes it frustrates me, sometimes I think it just buzzwords.
Do you have experience with those ... |
Below are the common phases applied, for a real world requirement(data) map to DBMS specific schema.
Conceptual models ER/EER/CODASYL/Hierarchical bridge the gap, in mapping the real world data(requirement) to DBMS specific schema.
In RDBMS world, object-relational impedance mismatch is the cause for applying these ph... |
I have two APIs to follow & unfollow a user.
domain/uid/follow (http POST) to follow user
domain/uid/follow (http DELETE) to unfollow user
It follows user and responds with http code 200.
When user tries to follow again (already followed user) I respond with 401.
Questions:
1 - Should I respond with 40... |
all programming languages have api's to interact various systems
as a example
javascript languge has Dom api to interact with the web page.
C language languge has file access api to interact with Files.
my questions is how to create such a API's From mere programming languge ?
as a example
how DOM APi created in ... |
Let me begin by stating I have already reviewed the following related questions, and just wanted to showcase the software architecture which I have inherited to see how opinions may vary.
When is a BIG Rewrite the answer?
Would you re-design completely under .Net?
To rewrite or slowly refactor old C++ project
So, I ... |
The problem:
Let's say I want to create a java app (currently using java 8) that works like a dictionary. I want the app to give the user the capacity to add and search for words, every word must contain a name, a meaning and zero or more examples. In addition, I want the user to be able to add more examples to a word ... |
I've been working over 10 months on a legacy project (yes, in PHP, what a surprise!) that has database IDs hardcoded all over the codebase. Of course this makes problems like we can't maintain it w/o a production dump, no tests, etc. I already vomited over that.
Moving on, there is one particular case that I can't see ... |
I have an api where visitor can send an email through subscription:
/api/subscribe
To prevent massive load due to public exposure, how can I secure this endpoint? Do I have to use database or can I do it without that with some kind of caching, inmemory etc which releases ever 10 minutes etc?
|
Summary: Is there a good design pattern to reduce duplication of information among tightly interdependant values?
In my line of work its fairly common to have a relationship among quantities such that you can derive one of the quantities if you know the others. An example could be the Ideal gas law:
Pv = RT
You could i... |
By current design, most data is stored in MySQL, and we use the repository pattern in our web app as the layer to fetch data from the DB. We do the same thing when fetching relations, using our framework's models and ORM to fetch models and their relations all in one go.
Some of our tables, mostly log-like tables, have... |
My question comes from this other question.
The first time I read the question, I understood (maybe worngly) that the OP was asking for a different way to initialize the object in such a way that it would allow him to extend and make easier the maintenance. Hence my answer.
However, some comments seem to agree with pas... |
I am trying to develop an API that tries to integrate features of various service providers. I am at the phase of developing a model(class structure that identifies with the context of domain) that helps in unifying the fields for data that gets sent out to different service providers.
The problem I am trying to solve... |
I'm using CMake to build my application and CUnit to test it. And I was wondering if there is a way to avoid including the production source files directly from the test code by name (#include ../src/foo.c strikes me as awfully ad-hoc).
I have heard of collecting the production code into a library and adding it to the ... |
I basically have the following situation:
+------------------+
| |
| Input object |
| |
+--+------------------+--+
unique_ptr<Subobject 1> ... |
I'm building a game with the LibGDX game engine. The engine works by registering an implementation of an interface that receives callbacks on the game loop. The interface looks like this:
public interface ApplicationListener {
/** Called when the {@link Application} is first created. */
public void create ();
... |
Setting
Let's take the following example:
We have a series of entertaining events on the television with each lasting only an hour and this goes on for 3 weeks. We want to create a simple App that displays the name of the next event.
We store the event in the above hierarchy where Weeks can store Days and Days can sto... |
The goal is to take a binary space, say 64 bits, and make certain parts of it "valid" and certain parts "invalid", then increment, starting at 0, through that space, avoiding the invalid areas.
Space is made "invalid" by applying an arbitrary number of arbitrary rules. For instance "if bits 2 and 49 are set, that numbe... |
Most people agree that it is a good thing to split a software development project into many small tasks each of which can be implemented within a few hours. But the finer the granularity, the more total effort has to be put into defining the exact scopes of all the individual tasks in order to avoid gaps or overlap.
My... |
Using python syntax,
threading.Barrier(NUM_THREADS) establishes a control point and all participating threads block until all of the participating “parties” have reached that point. It lets threads start up separately and then pause until they are all ready to proceed.
Can someone explain, a real time scenario(multi-th... |
When I want to make a method final, first of all I ask myself:
Should this method be final?
The answer is obvious sometimes, for example imagine this:
class Dog
{
private $name;
public function __constructor($name)
{
this->name = $name;
}
final public function getName()
{
retur... |
We use the git flow described here. In this way, we have 3 main branches: develop, master, release, and feature branches.
Develop is development. After development starts and features are deployed to develop, QAs merge to release from develop to test on the QA env.
Then fixes go to release, not develop. Release is the ... |
I am working on an App (VB.NET) for my company that retrieves data from a DB about our products (sensors) to make measurements and calibrations.
The DB is part of a software we use, so I have only read access and can't modify in any way it.
At the moment the solution is organized as follows:
BusinessLogic (DLL)
Entity... |
As per wiki,
A dependency is an object that can be used (as a service).
here is the OOP paradigm using C syntax that address 4 roles, shown below.
1) interface (handlers.h)
typedef struct {
int (*canHandle) (char *);
int (*drawImage)(char *);
int (*savefile)(char *);
}imageHandler;
2) Take one Depen... |
Most of the literature on agile seems to be biased towards CRUD type business applications where the user is pretty much aware of what is going on behind the scenes. (That's fine because most of the code being written probably belongs to this class.)
For this type of application the relationship between user stories (r... |
So I would like to model the class diagram for the following scenario:
the client has to manage three types of accounts(Pocket, Postbank, DKB). More types of accounts may be added later.
the client registers movements(expenses and incomes). These movements are what define the state of each account
While income are pre... |
I'm designing a infrastructure to monitor websites and applications. The idea is to build an application which checks the user website/application with a certain interval (30 sec, 1 min, 5 min, etc.). It's important that the website check is close to the given interval. The goal of the infrastructure is to have a scala... |
I use the Entity Framework. Let's say I have a realy complex linq query, that I need in multiple parts of my application, some services, some controllers.
Is there any design pattern I should follow?
First I thought, the Repository Pattern would perfectly be valid:
MyDto myRepository.GetDataFromComplexQuery();
But we ... |
So I tried to access certain website using its server IP address and usually it does not go through. Let's assume IP masquerade technique is not being used such as NAT or reverse proxy.
This makes me wonder:
Does the DNS reply to the client more information than just the IP address? such as the paths to the correct fo... |
It's a C#, ASP.NET MVC Project and here is the problem:
User can enter their email address in the reset password text field and click on the Reset Password button. Each time the user clicks on the Reset Password button a new email will be sent to that email address.
I am trying to limit the user reset password email to... |
I have a web app with an ASP.NET API back-end and React front-end. It also has a mobile app built in React Native.
Question is about date/time values. I have two options in handling time zone conversions and wanted to get some opinions on which is a better approach.
I can store user's time zone in the database and sen... |
When reading about API Gateway, one of things that come up every single time is that API Gateway is a place where you should aggregate results from multiple endpoints. That sounds really nice. However, many popular API Gateway solutions such as AWS API Gateway, Kongo, and Netflix Zuul do not support such feature. You n... |
We've stuck with designing two services. In fact, these two services have been splitted since traffic issues, so they were one before.
I mean, our platform is consumed by two sort of clients: other services and UI clients (web, desktop and mobile).
So services:
Services are using a very short number of exposed endpoin... |
I am looking at a problem where a method can fail in a predictable way. For now I think that exceptions might not be a good way to represent some of the failures (I may be wrong on that). In any case I was thinking of returning a Result type similar to the ones in ASP.NET Identity and the ones discussed in this questio... |
I have a Location Service with an endpoint that returns people near from a given user:
GET /users/near?user=7455
[
{
"userId": 1214,
"location" : [2134983, 89384]
},
//more users
]
On the other hand, I have a Visits Service that manages the visits between users:
[
{
"userVisitor" : ... |
Let's say I have a complex class, perhaps a House so I separate out its creation logic into a factory class, HouseFactory.Build()
However, these classes are for a API DLL, and we've found that many of our consumers are confused and unable to discern that they need to use the HouseFactory, so we add the following static... |
Let's assume that we want to implement a small security subsystem for a financial application that warns the users via email if a strange pattern is detected. For this example, the pattern will consist in three transactions as the ones depicted. The security subsystem can read events from the main system from a queue. ... |
I want to make a dictionary that stores some values I want to use within my code. Would it be better to use an instance variable to hold the dictionary, or an XML file to hold the dictionary, or perhaps another way of storing the dictionary? The dictionary currently has 15 elements and I am constantly extending it.
|
We are a team responsible for 3 products:
2 products are in active development of new functionality and are moving fast therefore work there could be classified as project
3rd product is alive and kicking and here work involves BAU 1 and maintenance
One of the products is new and with great promise to the business, s... |
In general, I like to favour immutability where possible and not allow objects to be created in an invalid state or get into an invalid state. Sometimes though it feels like it might go too far.
Example: I have a User domain object (JPA/Hibernate entity). I only allow the object to be constructed in a valid state, all ... |
I'm developing a web-app which I want to block ip addresses not registered in my database. This web-app should not be accessible for all users, but the users (let's say) I register manually.
The use case is like this:
I create username and password for my client.
They login(first login for the client)
I get the clien... |
I'm going to encrypt the following data (server side):
email, IP, username
{
*IP*: {
email: *email at this IP*
username: *username of email IP*
}
*IP2*: {
email: *email at this IP*
username: *username of email IP*
}
}
I want to keep user name in cookie so I don't have ... |
All the examples I've read and seen on training videos have simplistic examples. But what I don't see if how I do the "real" code after I get green. Is this the "Refactor" part?
If I have a fairly complex object with a complex method, and I write my test and the bare minimum to make it pass (after it first fails, Red... |
I am creating a class which has an instance variable that has many different implementations, but the problem is that all of the implementations have a slightly different interface.
Example:
class GameObject {
virtual Transform * getTransform() = 0;
};
class Transform {
virtual void setPosition() = 0;
virt... |
I'm currently looking into setting up a publish subscribe messaging infra structure for our microservice based platform. The new setup is meant to replace our current kafka based one, with something that's a little easier to maintain. One reason that we initially went with kafka, was the ability to have consumer groups... |
A co-worker submitted code for a PR the other day, which effectively follows this flow:
if (a)
do something_a
else if (b)
do something_b
else if (c)
do something_a
where a, b, and c are mutually exclusive conditions (in reality, they are all checking if a variable is equal to different values).
In my experience ... |
Context
I'm working on refactoring a program that saves data in a DB. This program has a Graphic Interface.
The programmer who did this program ( the one i'm working for) would like me to make this project consistent with MVP.
One of the constraints of my job is to try not change the original business code so even if t... |
Alright, let me shine some light on the ambiguous question. We have an analytics application written in Angular 2 and Scala that's used by quite a number of businesses. Some time last year there was an idea to use the apps' charts and features to display different type of data for a very limited number of customers for... |
I created am ETL that parse various files, transform file's data and then push the lines into a DB, until now I did a manual tests and check that all the values parsed correctly and all the lines (that needed) are insert into DB, of course it's become frustrating and error prone and I want to automate those tests.
I th... |
Imagine I have a class representing a percentage. This class provides self validation through exceptions by not allowing values less than 0 or greater than 100 respectively.
When following TDD the functionality of a method/class should be apparent from the test that are testing the part of the code. Should a test in th... |
So I've been programming for a few years now and recently have started using ReSharper more. One thing that ReSharper always suggests to me is to "invert 'if' statement to reduce nesting".
Let's say I have this code:
foreach (someObject in someObjectList)
{
if(someObject != null)
{
someOtherObject = ... |
I'm refactoring the directory structure of a large Python repo that has a few dozen C and C++ files littered throughout. Is there a suggested architecture for a Python package that contains C/C++ code within it? What I have at the moment for my repo foo is:
foo/
├── LICENSE
├── Makefile
├── README.md
├── docs/
├── exam... |
If usage examples are provided in XML documentation, should those examples be explicitly tested?
/// <summary>
/// Gets a collection of Foo objects.
/// </summary>
/// <param name="bar">The model database connection.</param>
/// <example>Example code for using this method.
/// <codelang = "vb">
/// Dim bar As New Ba... |
A rule of thumb with git is, don't make commits where the project doesn't compile or the tests don't pass. All the commits should build. Then, when you discover a problem that wasn't previously caught by the tests, you can use git bisect to discover where it was introduced quickly. If you are git bisecting for some par... |
For example right now we are finished with the development of our sprint 10 and want to start testing sprint testing in Stage environment.
I was told that we should first test 'Sprint 10 frontend from Stage' against 'Sprint 10 backend from stage'. (I know why we need to do this)
And then also test 'Sprint 9 frontend f... |
The title pretty much says it all.
I have a website hosted with ubuntu with mysql on it. Now I'm trying to figure out how can I use that same mysql with c# app.
I have understood that mysql blocks connections from other IP. The problem is that with c# app the connection can come from any IP Address.
In another ques... |
I am currently reading Why Functional Programming Matters by John Hughes.
In the "Gluing Functions Together" section, after having explained that (foldr f a) is a function that replaces all occurrences of Cons in a list by f, and all occurrences of Nil by a (which I understand), the author writes: "Now it’s obvious tha... |
When building software, we usually go through the requirements phase to design and all the stuff but when we start writing the actual code, how do we decide on which parts of the software will be build first . What is the first line of code to be written? I think we should start by writing tests for the functionalities... |
I'm doing an Android project for an online course. I would like to use DI in that project, so I started to use dagger2, but now I started to have typical newbie problems that are holding me back.
As the project deadline is coming, I decide to abandon dagger2 for this project, but I still like to use some sort of DI.
So... |
Problem Description: We have a big monolith app containing UI components A,B,C,D. You can think of a component as a page for now. Component A & B share a sub-component called SHARED. Now both A & B are planing to move out of the big monolith app. The challenge here is to have same look and feel for sub-component SHARED... |
You can do a lot with Excel. Even without Visual Basic Script. But the data and the logic is in one file, whereas normal programming languages usually have another file (or a database) for the data.
This feels wrong to me, but it might only be that I'm not used to it.
Is this mixture of data and logic a problem? If so,... |
I work with an older framework (15 years+) at work which is fully built on Perl. Its main tasks are calling external programs via command-line calls, parsing their output and presenting some of the parsed information alongside the general output.
Now if I would create a structure like this in something like Java, I was... |
My question is: How can I maximize encapsulation for wrapper-classes that interface with hardware.
The hardware is connected to a PC through COM-Ports or USB ports and I am either reading/writing to it directly or through an API. Either of which I want to wrap in a class.
I have been reading about software development ... |
I have a pretty badly designed system on my hands right now written in ASP.NET MVC.
It does have a lot of logic implemented inside controllers without any outside models with business logic. I would like to change it a little and write a class that would be able to export some tables from views to Excel. Most of the vi... |
I'm developing a google maps application with 50 locations/markers and expecting it to reach about 1000 in a month, each location has a separate database record with properties:
Name, Description, Latitude, Longitude, Address (Country, City, Street,..).
To avoid problems when scaling the application I have 2 concern... |
When we create a Java class for example B that inherits from another class e.g. A, we say that our subclass (B) extends the super class (A). What is this act called in programming. Simply put, for example, when a teacher wants to show this to their student, how should they say this? For example, can they say "Well, now... |
I want to get your clarifications about some points:
Should data modeling (e.g ERD) be ignored at the beginning of a project and then be done later after the project is complete, especially if the project developers don't have all the details about the database at the beginning of the project?
In Agile methodology, wh... |
I have a domain interface ITransformation with several implementing classes such as RemoveRowsTransformation and AddColumnTransformation. The inheritance tree models the command pattern. The ITransformation interface defines an Execute(table). Each implementing class contains different properties it needs to implement ... |
I have a directory which has approx. 100k JSON files.
I want to retrieve a list of file names, where the file satisfies a set of conditions, with a filter condition in same format as we can pass the filter object in a MongoDB find query.
Does the native file system itself have some sort of logic to maintain indexing as... |
I've come across something that I find decently frustrating while adding new functionality to our large existing code base.
Preface
We have a variety of classes (ItemA, ItemB, ItemC...) that inherit from a base class (TheBaseClass). We'll say there are around 10 Item classes. We hold a collection of mixed Item insta... |
My system is importing data from a number of external sources on a nightly basis into staging tables in my local DB. The process backs up the relevant table (by copying all data to a replica table with a special name to indicate it's a backup table), clears the table, then imports data from the sources. If the import j... |
I have an array of records for bids (sample below in JSON). I would like to store this data in a relational database (Postegresql), however, the supplier data is not given with IDs, and there will be some entries that need to be deduplicated. For instance, in the example below the "John Smith and Associates" is liste... |
We have a working proof of concept that implements the sunny day scenarios, but we need to start handling the exception paths. We are contractors and need to put together detailed estimates to discuss this next phase with the client before they renew the contract.
Details
We have spent 10-20 developer months implement... |
I'm looking at designing a multi-tenant application (well I believe it is multi-tenant). We have a single page application, an API and common database.
We have groups of users, each with their own slightly different requirements. A user cannot be in more than one group at the moment.
The key features we have are:
Sear... |
I have a control system and I'm doing a triplet cascaded controllers, I have designed an interface like that
IController
{
void Run();
IController *pFirstController;
IController *pSecondController;
}
My question is for design of triplet cascaded controller, what's the best way in terms of storing a pointer to a third ... |
I'm getting my head around DDD and how to build up an C# Project structure for an .Net Core WebApp.
I searched quite a bit around the web, for example How to structure a Domain Driven Design in an Onion Architecture?, https://github.com/zkavtaskin/Domain-Driven-Design-Example and several Pluralsight courses.
What bogs... |
OK .. after all the discussion I'm changing my question slightly to better reflect a concrete example that I am dealing with.
I have two classes ModelOne and ModelTwo, These classes perform similar type of functionality but are unrelated to each other. However I have a third class CommonFunc that contains some pub... |
Just confirming: The person that acts as a Software Architect should think in non-functional requirements (performance, scalability) in the first days of the project too. Doesn't it? I think that Software Architecture is like building architecture: we can't change the building structure in the middle or in the end of t... |
I'm having trouble figuring how I would test a library that intended to be used for communicating with another web service. For example, I have a Messenger class that initializes a connection and requires a configuration and a remote address to run. How would I go about testing something like this?
import { MessengerCo... |
I often read that each unit tests should test one logical 'thing'.
What do I do when the return value of a function is a dictionary?
Usually I equality check the entire dictionary against an expected result, but this leads to testing for results that perhaps aren't related to one specific test.
Should I be testing ea... |
This question is important for me in growing in my technical abilities. I find I swing from end-to-end, like a pendulum, in writing code that is simultaneously DRY yet readable & efficient. And I'm constantly doing this... which leads to too many re-factors and never a good, satisfied resolution.
The real example is an... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.