instruction stringlengths 34 36.1k |
|---|
My UI components are tightly coupled with my UI framework (i.e. Vue + Vuetify). The framework provides some testing utilities that allow you to fake the rendering of these components without the need for a browser. Then, I use a testing framework (i.e. Jest) to take a snapshot and assert specific values and behaviors o... |
This is a simple scenario in an office with employees and their manager.
In this scenario, both managers and employees have a name attribute.
Only the manager can change his own name
Only the employee can change his own name
Only the employee has a designation and a workStat attribute.
The work status indicates wheth... |
I understand that DDD is a design concept and implementation through ORMs are tricky but help me understand how would you solve this problem?
So here is my confusion on changing on aggregates only though aggregate roots. Given my case(rehashed through JIRA case). I feel this aggregate and DDD feels good about how we mo... |
I have been learning about stateful apps vs non-stateful, but I am still a bit confused on this topic.
For example, let's say I have an app running on Node where users are assigned to random rooms as soon as they connect through socket.io. These are rooms of 4 and not persistent in any way, but they are stored in a glo... |
We are working on an event driven system that works a streaming technology (eventhub/kinesis/kafka). Imagine some system is generating events that are sent to the event stream. Then there are multiple diferent processors that are doing something different with the events and based on the events they update some intern... |
I'm new to Machine learning or Ai but I have been a developer for almost 10 years.
I have a news aggregator application that grabs and save articles from news websites, And I have developed an algorithm of my own that categorizes the news based on it's titles.
The way it works is when I grab a new title I split the w... |
I tried creating an Entity-Relationship-Model, but I just don't get if I have to connect some tables and if I have to connect all, how do I connect tables which don't use attributes from another table.
So this is how far I came, I have 1 main table "inventoryManager" and inventoryManager is getting 2 attributes from ... |
It's a bit of a moot point now that async/await is supported by all major, modern JavaScript engines, but I've always wondered why Babel converts async functions to generator functions rather than to Promises, since async/await is just syntactic sugar for promises in the first place.
It looks like generators came in in... |
After reading this guide on how to mitigate markdown's XSS vulnerability. I've been struggling to find the right way for my scenario. Specifically with one of the points discussed in the guide: the best way to find out if markdown contains any XSS attempt is to first convert it to and check the HTML.
Let's say i am bui... |
Let's say we have the following Python class (the problem exists in Java just the same with equals and hashCode)
class Temperature:
def __init__(self, degrees):
self.degrees = degrees
where degrees is the temperature in Kelvin as a float. Now, I would like to implement equality testing and hashing for Temp... |
I have a conceptual question about SW design.
I prepared the following example:
One abstract base class:
internal abstract class BaseFamilyObject
{
//
//...
//
internal abstract IEnumerable<Device> GetCompatibleDevices(OtherDeviceClass otherDevClass);
//
// other methods
//
}
Six object f... |
I'd like advice about on the best practice for Pull Requests organizing on middle size project. Especially relating to Unit Testing.
Currently we create branch for each feature, what is practically good.
Is it acceptable to send PR with random Unit tests (do not follow feature-model)? Is it okay to save time on creatin... |
I have a structure which looks like
Person
ID int
Name nvarchar
Phone
ID int
PersonId int
Number nvarchar
Make nvarchar
Model nvarchar
MultiSim bit
One person can have many Phones
At the moment, the logic I have is when ever the user clicks the save button, the application receives a ... |
I want to use flyweight pattern to return the same instance of my object each time.
public class ThingFactory {
private static final HashMap<UUID, Thing> things = new HashMap<>();
public static Thing getThing(UUID id) {
Thing thing = things.get(id);
if (thing == null) {
thing = new Thing(id);
... |
I've seen a lot of good questions about similar problems but not exactly what I'm looking for.
Given: a non-unique set of symbols (or characters)
(1, 1, 2, 3)
Expected: an output similar to this (the order isn't important, only the elements outputed)
1123
1132
1213
1231
1312
1321
2113
2131
2311
3112
3121
3211
I know ... |
For example, let's say I write a container class, which supports 2 kinds of operations:
insert(x): inserts an element
get_all(): retrieves all previously inserted elements
Maybe it has some kind of hash set under the hood, or maybe an SQL database, doesn't matter.
It works, it's unit tested, everything's fine, but th... |
I am developing a web app that uses a mysql database. I recently encountered some changes that require me to store 3rd party data having an inconsistent schema. I've decided to use mongodb as a solution for storing these entities. Furthermore, these entities have a many-to-many relationship with an existing table in... |
I am working on a desktop app that offers uploading to the cloud storage. Storage providers have an easy way to upload files. You get accessKeyId and secretAccessKey and you are ready to upload. I am trying to come up with optimal way for upload files.
Option 1. Pack each app instance with access keys. This way files c... |
Suppose I have a method in client code that expects an interface...
void DoWork(IDataManager data) {
//use IDataManager interface in the DoWork method
}
And the IDataManager interface looks like this...
public interface IDataManager {
ITypeAData TypeAData { get; }
ITypeBData TypeBData { get; }
}
And each ... |
I have one function that is used to compute distances of an object in 3 different ways.
Is one of the following two methods considered better practice:
Creating 3 different functions, one each for calculating a type of distance
Creating one single function with multiple if-else statements?
I am using python, and hav... |
I come from a webdev background so I'm used to MVC to handle the separation between the views and the logic (and the data/models).
I'm starting to develop using Winforms in C# and I want to know what's commonly used to develop a scalable, maintainable piece of software.
For example, if I want to make a bussines managam... |
A long time ago when starting learning programming I remember a teacher saying that compiler do not care about whitespace and they are useful to make code readable for human beings. It made perfect sense back then, but I only knew some Pascal and C++.
Many years later, after diving in many other languages I began wonde... |
We have a web service that accepts images and metadata uploaded by end users, and the uploaded images would go through multiple steps of processing / reviewing with human involved.
To monitor the status of the service, one of my colleagues suggested we should develop a monitoring program that emulates the behavior of e... |
// Default initialization
int i; // i has an unspecified value
return i; // Probably 0, but Unreliable
i = 5; // i has a specified value
i = int();// This will give it a specified value, 0
i = int{};// This will give it a specified value, 0
return i; // Reliable, no good!
int j; // Workaround, obvious performa... |
One of the guidelines around building ubiquitous languages is that there should be one per bounded context.
In a domain that has more than one bounded context, and therefore more than one ubiquitous language, how should you deal with vocabulary that is different in each context, but related to each other with respect t... |
I have recently started reading about domain driven design and most of the places it's explained or discussed more in conceptual terms. Being a design philosophy it helps to understand the concepts but I was wondering how should I structure my project according to DDD.
For example in a typical structure used in most p... |
I'm working on a reusable client library to abstract a REST endpoint that we use in many of our in-house applications. It is actually split into 3 APIs, and certain endpoints/resources require different types of authentication (OAuth, JWT, and OAuth + additional BASIC). So to simplify all of that, I'd like to JAR up a ... |
Lets say there are two services. One generates event A and the other event B.
We need to build a new service that implements the function C = func(A, B) , which produces the result C.
But as A and B are asynchronous events, they may reach (and invoke) the new service separately.
Depending on what is required, it may b... |
is there anything wrong with writing code in a way that merges view, repository, controller in the same file?
i.e.
global $db;
// or $db = DBSingleton::get_db_instance();
// or global $container; $db = $container->get(Db::class);
$id = filter_var($_POST['id'], FILTER_VALIDATE_INT);
$record = $db->parameterized_query("... |
I'm designing a service that contains different plans and features. I want to freely assign and remove features from plans. The service needs to tell the client both an ID's plan and the features it should have as a part of its plan. I came up with two ideas for how to accomplish this.
The first idea is to store the ... |
To cut a long story short, assume I have a Register, a Provider and a Generator class.
In my Register, I have the addItem method that allows me to add items to a collection. The Provider's job is to access the Register's data and after some logic, provide items from its collection, basically we have the method, in the ... |
A very common pattern in python is:
for something in ['an', 'iterable']:
func(something)
I almost always see the iterable as a list (like in this example), but it could very well be a tuple, set, or something else. Is the list the most performant and pythonic way to do this?
Similarly, I often see the following:
i... |
I understand this is the place to ask questions pertaining to software design. If my question is considered to opinion-based, is there a forum or something better suited for the discussion?
Objective
My goal is to develop an application which can store & manipulate "historical data" covering the full range of time fro... |
In Section 1.3 Terminology, RFC2616 (HTTP/1.1) says:
client:
A program that establishes connections for the purpose of sending requests.
user agent:
The client which initiates a request. These are often browsers,
editors, spiders (web-traversing robots), or other end user tools.
Can someone provide examples of a clie... |
Everyone knows that new developers write long functions. As you progress, you get better at breaking your code into smaller pieces and experience teaches you the value of doing so.
Enter SQL. Yes, the SQL way of thinking about code is different from the procedural way of thinking about code, but this principle seems ... |
Consider several C++ classes which are all defined in a particular namespace. For cleanliness, each class is located within its own file, and are each well-documented.
For the purposes of completing the documentation with Doxygen, we'd also like to add documentation for the namespace itself.
Does anyone have any sugge... |
Say each microservice is using event sourcing which means it has it's own event store, do you typically add another "mother" event store that contains all events from all microservices as a source of truth on how each system communicated?
E.g.,
|
I am making a web UI and an HTTP API for editing JSON documents in collaboration (role and versioning system).
There are several types of JSON documents. Each type is described by a JSON schema, let us say:
schema_a, schema_b
Each user is assigned a role for editing a JSON document, among:
editor_1, editor_2, reviewer... |
I'm currently working on the control software for a system that includes a lot of user controllable hardware and also has many configurations. Configurations in this context refers to a specific combination of hardware. Each configuration can be thought of as it's own "product" for arguments state.
In previous iterati... |
I am thinking of a very flexible application that will build a single entity object from a lot of tables joins. example for an object "Car"
with a code something like this
SELECT e.id, a1.attr_value as "cost", a2.attr_value as "color",
a3.attr_value as "size", . . .
FROM entity e
LEFT OUTER JOIN attrib a1 ON (e.ent... |
Absolutely academic context question-
I found countless articles listing the order of operator precedence in all languages, but what is the logical reasoning behind that specific order?
For clarity of answers, let's talk about the C/C++/C# precedence table, even though it is pretty much the same in all other languages.... |
I designed a Snakes and Ladders game. I divided into a reasonable amount of classes and I believe I did a good job regarding the OOP design.
I have one question about a decision I made for the design, though. I have a class called Config. This class contains a bunch of global variables regarding Window Resolution, amou... |
I have a reporting system which gets time-series data from numerous meters (here I am referring it as raw_data)
I need to generate several reports based on different combinations of the incoming raw_data
eg:
report1 = raw_data_1+raw_data34-raw_data15
report2 = ....
Also there are several higher order reports dependin... |
I've seen here that it was a dividing topic to use "should" as a prefix for a boolean because it could mean that we're unsure.
Then how would you prefix a boolean such as "myButton.shouldShow"?
I feel indeed that it's a little bit weird so I was hoping to find another solution.
|
Assume a Javascript plugin, for a developer, that's included on their website.
<script src="https://external.com/plugin.js"></script>
The plugin makes a XHR request to a 3rd party endpoint (API). So, which IP is detected at that endpoint? Is it the developer's host IP, the client IP running the script, the external sc... |
Let's say you have a ForeignKey MyModel.related_model and this related_model has all fields either null=True or default=something.
Like User.userprofile which I use on several places in my project. Is it better to create it immediately after User has been created?
either this way:
def save(...
super().save(...
... |
I'm doing a project in unity where I turn off the general gravity and implement it myself. What I'm trying to acheive is to have GameObjects be affected by several gravity sources on every tick. I got to a dilemma where I'm not sure where the responsibility of the physics calculation should rest.
Should I:
a) Have Game... |
Suppose I have the Service that receives dependencies via constructor but also needs to be initialized with custom data (context) before it can be used:
public interface IService
{
void Initialize(Context context);
void DoSomething();
void DoOtherThing();
}
public class Service : IService
{
private rea... |
So I am trying to mix my software skills with my electronics skills, and I want to try something a bit different. Basically: buy a walkie talkie, take it apart, remove the microphone and put a rasp pi or arduino between the mic and the cuircuits, encypting everything sound. On the corresponding device I will do the sam... |
To provide zero downtime upgrades of my highload service I use blue green deployment strategy.
Every moment data changing happens, so how to migrate all data consistently? In the moment I switch between blue and green the data is changing.
What is the best strategy to maintain data consistency (as much as possible)?
|
Consider code below
MyController //MyAction //MyHandler
{
public function processRequest()
{
// ...
$myObject = new MyObjectClass();
$myObject->methodCall();
// ...
}
}
Should such code be refactored to use dependency injection instead? If so, for what objects? All of th... |
Consider two strategies for implementing an upgrade of something with multiple versions (e.g. upgrading an installation of some software).
From any version, upgrade directly to the latest version.
Progressively upgrade through intermediate versions, until you get to the latest.
Is there a generally accepted name for ... |
We have a layer that exists in our architecture that, for lack of a better term, bears the responsibility of defining the common models. In other words, when systems need to communicate, rather than point-to-point, this layer is used.
|----------| |--------| |----------|
| System A | ==> | Common | ... |
Some one help me with my design paralysis!
Assume a microservice (probably going to be implemented in Spring Boot) that has implemented an run of the mill REST API, and after receiving an initial request, it then talks to maybe 2-3 other external services(as a REST client to those services) to look up data to do whatev... |
So I was studying here and I was thinking if the whole point of recursion is to break the problem into multiple smaller problems, what if those problems were solved in parallel? A quick search lead me to links like this where people say it's not worth it because of context switching which makes sense, but what if inste... |
There are languages for which functions take exactly one argument and return one argument. This is nice and symmetrical, and there is no need to accept more than one argument because we can use currying: If we want a a function to take two arguments, we can take the first and return a new function (that has the fist em... |
After the sequence diagram are made the sequence methods become code, before writing some code that would alter database records I would like to know how to detect if a sequence is doing the job without damaging some other part's of the system, what comes to my mind is that there must be a way to relate the sequences t... |
My question is, how would I go about making a function that serves the same purpose of the for loop, without using any loop method.
function fl (initial, condition, iterator, code){
i = initial;
if(condition){
code()
}
i = i + iterator
// Somehow repeat without using any loop
}
// The funct... |
Is there any guideline on writing message which are shown to the user of an app using toast?
For example, if an error occurred, should the app display
Failed writing to the file
or
Failed writing to the file.
Should sentences use full stop? I don't see full stops used in some language REPLs when there is only one ... |
I was wondering, are these 2 class diagrams equivalent EXCEPT the fact that in diagram A, a student doesn't have to have a study program?
The way I see it - for example in diagram B a study program can have many students, and for each one of them, an enrollment is created. Diagram A states that for each pair (Study Pr... |
I want to create an application that will run as a service that subscribes to a Google Cloud pub/sub topic, and delivers emails based on 'alerts' that it receives through the pub/sub subscription. It will read from Cloud DataStore to determine the email addresses to mail to, and it will probably use some type of 3rd pa... |
In my application, the transaction id's sometimes skip i.e. 3314, 3315, 3317 ... I think this happens when a payment is made, but mysql rolls back the transaction because of an error down the line.
I was perfectly fine with this.
However, an accountant working in a company that uses my application said the id's should ... |
I guess it was Robert C. Martin who campaigned against using SQL in one of his apps, where he was just fine without DB and SQL initially. Later, thanks to the abstraction a DB implementation could be built out on a single day (which later turned out to be unnecessary). I think his main point was just to not start out w... |
I'm wondering if you would use the mediator pattern on the following scenario.
First of at all, the program must call an API, and persist this response on somewhere (it could be a database, a file, on a blog storage, and so on).
I see two responsibilities involved here:
pull data from the API, and
place it in some ... |
I think I know the answer to this, but it's particular enough that I don't want to go telling other people stuff until I'm 100% certain.
Suppose I have a class with some dependency:
public interface IDependency
{
int DoSomething(string value);
}
public class DependsOnSomething
{
private readonly IDependency _d... |
I was tasked with writing software for my company. As I am now writing a third program (with many more coming), what's the best way to control the distribution/usage of our software?
The software I'm writing should only be used on our network and shouldn't run elsewhere. We are a small company and don't have the infr... |
Not sure if this is an appropriate question for here, please let me know!
In Scala, the ever so useful Option class has an apply method in its companion object that allows us to quickly wrap any value into an Option:
def apply[A](x: A): Option[A] = if (x == null) None else Some(x)
This is super helpful when dealing wi... |
As of right now I am building authentication library for let's say programing site(It needs to be included in the program).
The problem is that there several languages are used and I want to make authentication library that can be referenced in some of bigger languages like c#,java and python(all in one dll).
I heard t... |
When I was building my backend API I used Django combined with django-rest-framework (DRF) because it was the easiest and fastest way to create what I needed.
And I haven't thought about an architecture of it.
And if I understand correctly DRF provides some kind of Model-ViewSet-Serializer pattern.
So my question is: ... |
So I've been reading a lot about this new front-end architecture called the JAMstack, which is basically the modern way of building static web applications.
Any dynamic pages are pre-built at build time and served as static pages instead of being built on request at run time. This way, sites can be hosted on a CDN and ... |
I am developing a web application where users can upload images and add tags to them. Because the audience is very international, I want the app as well as the content to be localizable.
Most of the tags have a counterpart in all/other languages but some won't.
Current situation
Images table
+---------+--------------... |
I have the single big file (1.2GB+) hosted on the server to download currently served using HTTP/1.1.
We are exploring if we can move to HTTP/2 for better performance and security.
All the places on the internet I see people talking about improvement in speed if there are many small files I need to download. What about... |
I've microservice, let's name it Employee. It only has employee logic, but there's a "foreign key" to the (not really) related company. There's no company resource and no company logic in this microservice.
For adding an employee, there is an endpoint like so:
POST /companies/1/employees
For updating an employee, there... |
I have a task where I need to read a big data file and process the data in it. Every row in the file looks like this:
CustomerId ItemId Amount Price
I need to calculate the total cost for the customer, but first I need to determine the most expensive item purchased. "Most expensive" means the item with the highe... |
If the entity should be always in valid state (therefore the properties are readonly and can be set only by methods which contains validation), How can I build this entity inside Repository without executing validations, because I suppose that database state is always valid ? Or should i always excecute validations eve... |
I am currently working on a report regarding a matrix multiplication distribution system I have been working on. But after reading a lot of somewhat contradictory sources online I have become in doubt whether the network created by the system would classify as being decentralized or distributed.
As I have attempted to ... |
I understand the principles behind opaque data types, encapsulation, information hiding, etc. in theory: preventing alteration to parts of a program can prevent people from accidentally messing it up, and hiding the information is basically just to make it more readable. The thing that I just can't seem to wrap my brai... |
I am not looking for an opinion about semantics but simply for a case where having getters sensibly used is an actual impediment. Maybe it throws me into a never-ending spiral of relying on them, maybe the alternative is cleaner and handles getters automatically, etc. Something concrete.
I've heard all the arguments, I... |
We tried to develop a kinda-real-time statistics module to measure how hot/trend a content is. We know it is hard to achieve high end stuff like youtube/FB/twitter, our goal is simpler :
Count click/read/like/etc.. during the last hour/day/week/etc..
Calculate some basic indexes such as likeCount/clickCount, readCount... |
I'm working on a Game Engine (more like a Graphics Engine for Physics simulations) in C++.
I know a bit of Unity and I like the concept of GameObject and Component Unity has and I wanted to use that in my project too.
The code structure at the moment is as it follows:
Newtonic::Engine: owns the scene, the engine's mess... |
The thing that I don't understand is the prioritization between MVC Controllers and Web APIs.
Consider I want to make a website. I can either program to APIs and for the presentational layer, force the MVC controllers to consume the APIs OR simply go with controllers and don't bother with the APIs for the time being.
W... |
going through the web I always read something like
Java Interfaces have no state and no behavior
If you look what the common definition of state is then you likely end with
what the objects have, Student have a first name, last name, age, etc
The thing is I guess since Java 8 with their default methods I can also d... |
Ideally, functions should do one thing well, and only one thing. Does the same thing apply to what a module should export? Of course, modules aren't always the same thing as functions, but they often are (at least in my experience).
This rule (prefer-default-export) encourages more files that only ever export one thin... |
I am prototyping a social network as part of a project I am working on and want to learn the right way to do it as if it were for an industry leading company.
I've decided on implementing the social network in a graph database like Neptune or titan db.
I also intend to do full text search on posts using a full-text ... |
There are 3 branches involved in this question. I have the master branch, I have a bug-fix branch, and I have a refactor branch.
This is the timeline:
Created bug-fix branch off master to fix a bug.
Created refactor branch off master to do some refactoring.
bug-fix branch has been merged to master.
Now in the refactor... |
I really don't know which StackExchange site this belongs on. It didn't seem to match the "on-topic" list of DBA.SE or SO.SE ... so please let me know if I should move it. I also couldn't find a similar question but am happy for this to be a duplicate so I can close it.
I have been writing SQL for almost 10 years but I... |
My team is developing a web application, where we have in the requirements to display the data in multiple unit which is set by the end user.
Where should we write down the unit conversion logic, on front-end side or back-end side.
What is the good approach of doing the data conversion?
We should perform on the fron... |
I don't quite understand, how the following typedef is parsed by a compiler to call code at a specific address. I guess I understand that a function is just a pointer and we're typedefing such a pointer. But what actually happens at compile and run time and where will the arguments get placed?
From the SAML10 Family da... |
I have an invoice root aggregate that has many invoice line entities, a due date value object and two reminder entities. We're not using event sourcing yet.
The post data I receive from the form the user has filled looks like this. I simplified it, the important part is that when I create a NEW invoice I don't have any... |
I am developing a microservice platform with Spring. So far I have a few microservices and a service discovery server where all microservices register themselves. I also have an Angular client application, which right now is calling the address and port of one of the services. However, what if the service gets replicat... |
I have an application that writes data to database. In case of network breakdowns, the connection to database gets lost & my db queries freezes the whole application.
So, in order to make it asynchronous, I've used a message queue mechanism to separate out the "db queries" part with my "core application part".
The prob... |
I'm creating a simple Dependency Injection library for Unity (no constructors available) and I want to use a generic class that implements a generic call for each class that would inherit it allowing changes and scalability.
This would be my generic class
// Class with a generic type
public abstract class MyGenericClas... |
I'm developing a multi culture application with different microservices,
The microservices communicate with each others with integrations event, so when a new record is inserted the owner of the data send an integration events on a bus and the other microservices who need that record integrate in their storage.
My qu... |
Some background information to our actual situation. We are migrating from TFS VC to git. We've a ASP .NET Web API with many different Controller Libraries (>30 assemblies). Many of them are referencing some Core assemblies like our data model. In TFS VC those Core Assemblies where checked in relative to our projects i... |
I'm trying to understand containerized apps and databases and I'm trying to understand the microservice architecture using kubernetes. One thing that I couldn't get my mind convinced is the database part.
For example I have a Venues database and a Venues REST API application in a container, which also has the database... |
Using GitFlow, I created a new class on the develop branch and gave it a property:
Public Class Class1
Public Property Property1 As String
End Class
I committed that change and created a new feature named feature2. In that branch I added a property:
Public Class Class1
Public Property Property1 As String
Public ... |
I'm writing a program in Python that has two different entry points. There's a CLI that processes some data and needs to be installed to run hourly on a server, this populates a database. There's also a web app that has a front end for viewing the data in that database.
I'm using sqlalchemy as an ORM for the database t... |
The issue
I am building a server-side system that handles streams of time-series events from multiple users and I'd like to perform an action after a certain quiet period has elapsed in the event stream of every user.
For example, a user emits this stream of data:
-[5]------[4]-[3]--[2][1]-->
My consumer will handle t... |
In this answer to "In C++ why and how are virtual functions slower?",
the author mentions below point:
"Get the right function address from the vtable into a register (the index where the correct function address is stored is decided at compile-time)."
As a follow up of this comment, i have some questions:
What is th... |
Say I have 500MB of memory to work with, but 100 terabytes of IDs I want to generate. I want these IDs (GUIDs) to be randomly selected and applied to records, so they shouldn't appear in order when selected. Also, I have 1 billion petabytes (in this example) of possible IDs, which is way too many to actually generate. ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.