instruction
stringlengths
34
36.1k
I frequently encounter situation where I have very basic tests, and if those fail, it doesn't make sense to run many other tests. Therefore I want to declare a tree of dependencies between my tests, where tests are only run if all pre-conditions tests are passing. two big advantages I can think of are: During debuggi...
I've heard that companies store their private keys offline "in a safe that will never be opened" and stuff like that (the context for this is a console developer like Microsoft keeping the Xbox private keys offline in a safe). How would they still sign code with their private keys if they're fully locked away? Does som...
I have an application where the requirements are to show a list of (just for example) car manufacturers. When you click on one of the manufacturers, a list of car models show up. You can then click on the car model to show other data related to the model. My problem is that one of the manufacturers is to be treated as ...
I've got a requirement to create a data structure that allows for users to view revision history. Not just the history of a table, but the history of the entire structure at a given point in time. A pure database solution would involve massive recreation of records. For example - say I'm building a check sheet. Sheets ...
The backstory is long but the general idea is that I'm beginning an iterative refactoring process to replace a poorly designed data access layer with a new one under constraints from above. We can't fix everything at once but need to slowly phase in the new changes. The old DAL contains several classes each containing ...
I am self-learning robotics, C++ and good object oriented design. I have asked various questions over the past couple of weeks: 1 and 2 that have lead to the following design. The design goal is for portability. It is a Go-To-Goal Differential Drive Robot with PID to regulate the behavior. I am hoping my design is ro...
I wonder how should we manage the commits we make AFTER a version is released, according to SEMVER. For example, I just released 1.0.1, now I have 2 choices: Immediately change version to 1.0.2 and start working on this version. Once the work is finished, I'll just tag the last commit to be officially the version 1.0....
I'm designing an Event Store on AWS and I chose DynamoDB because it seemed the best option. My design seems to be quite good, but I'm facing some issues that I can't solve. The Design Events Events are uniquely identified by the pair (StreamId, EventId): StreamId: it's the same of the aggregateId, which means one Even...
I have a question about using databases in my application. I have the User table which stores passwords for my users. I know how to handle user authentication, but how to handle the password for the database itself? I searched online, and all articles mention only storing user passwords, not the database password itsel...
I'm building a simple app that is a client web application and an API behind it. I'm combining two third-party APIs, one needs to be called from my client application (for ease of authentication) and one needs to be called by the server. The data I receive from my first API is a list of strings - it will be between 0 a...
My team is debating how to transition a portion of our Rails application to allow "drafts". For simplicities sake, we can imagine a Post object where we want to allow a kind of draft mode. Our real model contains, say, roughly 20 fields and 5 has_many relationships. There are some reasonably complex business rules (i....
I am doing research for developing a software platform and I have created some class diagrams for the platform. My supervisor adviced me to use UML profiles as well to describe the platform in a more detailed way. However, after googling i still do not really get the difference between the Class diagrams and UML profil...
I need to determine the average miles per hour for a trip and an object containing a list of trips. I'm thinking of two approaches. First approach, have a MphCalculator class that I would inject into each class such as public class MphCalculator { public BigDecimal calculateMph(int durationSeconds, BigDecimal mile...
I am currently a Junior back-end developer, I write Java and Scala and I love it. I really want to get into web development, but it seems like every time I look up some guide, it is really just a guide for a specific framework. I totally understand that the way the web has evolved over the years has forced developers i...
Imagine an application that consumes an external data stream and creates objects of this type: @Entity public class Event { @OneToOne(cascade = CascadeType.ALL) private EventInfo info; @OneToOne(cascade = CascadeType.ALL) private EventSource source; ... } Later in the DAO: session.save(event); In the da...
When using Terraform instead of Cloudformation on AWS, I usually get immediate feedback on the terminal, which makes the work very productive. With CloudFormation, however, I tend to edit the file in my computer, upload it to Cloudformation console on AWS, and keep watching until I get an error/success. Even using CI/C...
I'm a student, and I don't have much expirience with the building process. In the last few days i've read something about CMake and others build system generators, but other than that I don't know anything about this world. I realized that i should learn something about this topic because I wanted to use a third party ...
I'm working on an asp.net core application, using Identity as authentication/authorization management. Depending on the role the user can do "some thing", this is the normal way of authorization. But when the user is an entity related to other entity the business logic get ambiguous. This is a pseudo code example: ...
I have a project to build, which has the following requirements: topup a wallet by paying money in exchange for credit; this has also the constraint of needing an approval from the finance team, if the payment used is bank transfer. The finance team will then (in the future) issue invoices. transfer credit from one wa...
I'm designing a game engine that is supposed to be overridden. I have, for example, a class called Character. Should I prefix this with BaseCharacter or should I expect that whoever uses the framework prefixes their classes with GameNameCharacter or CharacterGameName? What would be most convenient to you?
What are the benefits of aggregating a structure and functions associated with it in one object? What are the benefits of explicitly decalring a class. If i write procedural code i already know that some functions are working with specific structures. I just work with it and that's all. For me the only benefit of OOP s...
Assume you have a library in which every function is public. Sooner or later developers who use your library will come up with a stable pattern of usage. In that terms external information of how developers are using you library already defines the public interface. If your function is dealing with only inner context ...
I'm playing around with DDD in a node.js project and struggling with updates to child entities from the aggregate root. For the sake of example, let's say I have two domain objects where Event is my aggregate root: class Event { _id _date _comments = [] } class Comment { _id _name _content } I understand ...
Right now we have a set of micro services with a client-facing gateway responsible for authentication and routing. MySQL database and RabbitMQ for the message queue. Internal services may queue up requests as necessary but the gateway never does. What I’m finding is that the time for the gateway to respond is too long....
I am wondering where does the fxml controller belong in the Entity-Control-Boundary model? When designing a JavaFX application with the help of Scene Builder, Scene Builder generates an fxml file which represents the GUI. In addition, a controller is needed to make user interaction possible. An example would be: LoginS...
The product is water purifier, and we are selling packages included support for changing filters. Serial is a unique number identifying a single produced item and it's only for water purifiers not packages. My current solution is like this: order_product table: id | order_id | product_id | quantity 1 11 2 ...
My organization is developing a Web API server. We will also develop the only clients authorized to access the API. We will follow the usual technique of returning Bad Request (400) errors for data sent from a client to the server when the data doesn't pass validation at the server. There will be a number of valida...
As the title says , Why are the instance variables are declared as private in immutable pattern ? I think that the keyword final is enough to avoid any changes that can be done to the value of the instance variable. So why do we also use private keyword with it ?
I understand that directly instantiating dependencies inside a class is considered bad practise. This makes sense as doing so tightly couples everything which in turn makes testing very hard. Almost all the frameworks I've come across seem to favour dependency injection with a container over using service locators. Bot...
Assume you are tasked with implementing a "cronjob as a service" where you are supposed to be able to run potentially millions of periodical tasks (to simplify, making HTTP requests to URLs) with different schedules. For example, these tasks could be: every minute (* * * * *), query http://url1 on Mondays 2:30am (30 ...
I've been working on the architecture of my Apps for a while. In the past I've used a SQLite database which I opened in the AppDelegate (Oh dear), and then created a global variable (really!) to store the questions. I'm going to re-write this. My thinking around the structure of this is to create separate modules for...
I am making a microservice based architecture and I'm actively seeking antipatterns and trying to avoid them. In multiple scenarios, I have a database commit followed by a message that is produced to Kafka (but it could be any message broker, really). If the db commit fails, an error is returned as one would expect. If...
I am writing a class FileFoodReader (in java if that matters) that reads input from a file containing information about foods and their nutritional values. The file has to fulfill some requirements about how it is formatted. For example there must be a column containing food names and a column for each nutritional valu...
We develop two projects (and more in future) with JS, Vue.js, using npm, and we store each project in its own git-repository. We want to place common components (buttons, page-parts and page templates) in a separate git-repo. How to use the files from this repository in our projects? Create a subdirectory and download ...
I'm involved in a microservices based application. I'm trying to apply the BDD process for this. I need a recommendation how to apply this process correctly given this type of architecture. It is recommended to avoid or keep at minimal level the end-to-end tests that span across many microservices. I agree with that. F...
I have data structure queue with 2 operations: typedef struct queue queue void enqueue(queue *q, void *elem); void *dequeue(queue *q); queue *read_from_file(const char *path); I want to write assert for the queue like: bool assert_queue_equals(queue *q, ...){ //dequeue and compare till the end of varargs } The...
I'm actually working on the web application which was made using technologies such as asp.net core, c#, angular, ef core. For the version control and CD we use Azure DevOps. As a team we try to follow Agile rules. When the developer starts the ticket, he creates a new branch forked from master and when he finishes he m...
I have studied complexity of algorithms that how long an algorithm will take to execute completely, then why it is said that certain programming languages are faster than others such as C++ is faster than python.
I'm struggling a bit to grasp all DDD concepts and apply them to a real project. Let's say I have the following domain concepts: Car: a vehicle moving inside an area Path: a journey made by a car, from A to B. Each car can have many recorded paths, but only an active one at a given moment Position: the GPS position of...
My team has a problem with making code review. Everyone is constantly busy with their tasks and only few of developers do review on a daily basis. As every merge request needs 2 approvals, some of them stay in review for days if not for weeks (!), which slows down the project. Everyone understands the importance of ...
This is a question about SSIS package design. We have an SSIS package built in VS 2008 that loads ~ 22 tables from as many fixed width files into a data warehouse. Each file has its own data flow task. All of the data flow tasks are inside a single control flow. Would it be better to create a separate package for eac...
We have a piece of code that looks something like that: std::vector<int> computeGlobalResult() { auto globalResult = std::vector<int>{}; while (myCollection.size() < 100) { auto localResult = computeLocalResult(); globalResult.emplace(globalResult.end(), localResult.begin(), localResult.end()...
I run into a quite common case of handling Video files with different quality of a video, when the app (on android in this case) should save and use one or another video file depending on a user choice (global app's setting). I can’t find some best practices and I think that I'm just googling it wrong. Anyway, both par...
I have joined a team in company and this team owns few services, which are used widely by many other user facing internal/external UI apps and other internal apis. My manager gave me rough idea that these services are responsible for, let's assume, around $1B worth of traffic, or something like, so idea was, it's supe...
I'm currently developing an application using the Dear ImGui library: https://github.com/ocornut/imgui/. And I'm trying to figure out how exactly to access state vs domain data. I'm trying to write it in a purely functional way, using something like: function View1(DomainModel & model) { ImGui::Begin("View window")...
in C#, suppose I have written this function public void TryToTurnOn( Device d ) { // some common logic // some more common logic } I then have a class that inherit Device that is DeviceWithAButton, I can write something like this public void TryToTurnOn( Device d ) { // some common logic if( d is Dev...
I am in the process of creating an android app for our clients that would replace the paper-trail in their facilities with electronic inspections. Although I have coding experience, I have little knowledge on how I would structure the data received through these electronic inspections. We will set up electronic inspect...
Note: This question might sound like a duplicate, but all other similar questions did not take into account (mobile apps, iot's, web, 3rd party usage). Specifically, in dealing with the clients together with cookies. I'm building a REST API (laravel based) that is to be consumed by multiple clients like web, mobile app...
I have a project where I work with generated classes for some web interfaces. Some of these classes are (almost) identical and most of the functionality I need them for only use the identical parts. Currently that functionality is implemented for each class separately. I want to refactor it in a way that I only have to...
I currently have an AWS Codepipeline that is setup to automatically pull an Express, NodeJS API and deploy it with Lambda and API Gateway. It pulls the code from my GitHub repo production branch and deploys it. The project was created with Codestar, which creates a cloudformation stack and all the resources necessary t...
As I fool around in Swift I have come to absolutely hate variable declarations. int c = 0 seems easier to read than var c:Int = 0 and more informative than var c = 0, and int some() is radically better than func some() -> Int. As has been pointed out in other threads, the reason for the type at the end is that the type...
I'm learning the MVVM pattern and something that comes up often is a duplication of data-types. Say I have a Person datatype. Intuitively I want it to look like this: public class Person { public string FirstName { get; set; } public string LastName { get; set; } public uint Age { get; set; } } But instead...
My understanding is that trunk based development should rely on direct commits to master or short-lived feature branches that are merged with master. Incomplete work can be placed inside functions that are then toggled off with feature flags. For short-lived feature code review: developers can work together in person ...
Background I'm designing a round-based game where one of the core design goals is to have a highly exchangable UI. For this, I've defined an interface which allows implementers to only focus on drawing the UI and processing user input - Everything else happens behind the interface. The general idea is to have a control...
What are the distinctions between physical threads and logical threads? The clearest definition of a physical thread that I understand so far is the one here: https://stackoverflow.com/questions/18857107/logical-thread-vs-physical-thread "A physical thread is a thread that a processor context switches to and processes...
My question is similar to this one, but a bit more specific to one case. Let's say I have a payments model, and this is used by my reporting service, as well as my accounting service. Is it inescapable that these two services are now coupled by their mutual dependency on the model?
I have the following setup for my application: A User logs in and is granted a Session Token. When making API requests to Service A the User provides the Session Token. All requests go through an API Gateway which internally re-directs the request to an Authorization Service which authenticates the Session Token and g...
I am practicing socket programming in C language. I have two codes - server and client (based on TCP) on two different laptops. The server forks a new process for every new request. For simulating multiple simultaneous clients, I have used pthreads library in my client program. I have a lots of files at the server, ea...
I'm working on a project and trying to understand the differences and trade-offs between variations of trunk based development and feature branching like git flow so I can help implement an appropriate solution for the team. Would the first diagram of GitFlow below also be a representation of Trunk Based Development? N...
I understand there are three flavours of CQRS: 1) Separate models only i.e. a domain model and a read model. 2) separate models and repositories. 3) Separate models; repositories and physical database. Is there ever a scenario where the controllers are separated into read controllers and write controllers? I have neve...
I have a question about best practice and Azure Pipeline. I have a web site (ASP.NET API old version) I need to publish on 2 environments staging production I think this schema is classic. At the beginning I decided to create one build in release mode and deploy it on staging first then manually on production after v...
Suppose I have an algorithm that has N blocks of data, and an operation needs to be performed on all blocks such that it requires 2 blocks to be in memory at any given time to be done for all possible pairings of the N blocks. When N is large such that not all the data will fit in the memory of the machine running it: ...
Say I want to be able to create objects for a range of template parameter template<int a> class Myclass : public MyclassSuper{...}; And I want to create objects like Myclass<runtime_dependent_int> a(b); Now this is not allowed because runtime_dependent_int is not known at compile time. How can I circumvent this limit...
Imagine that you are using a tool that automatically applies a set of refactorings of your choice. If the refactorings breaks the existing API for whatever reason (e.g. change method name, parameterise method or a refactoring that makes some structural changes) do you expect the tool to also automatically change your u...
I'm following the code from Vue.js in Action, Chapter 3. (much deleted for brevity...) var webstore = new Vue({ el: '#app', data: { sitename: "Vue.js Pet Depot", showProduct: true, product: { id: 1001, title: "Cat Food, 25lb bag", ... deleted for brevity }, cart: [] } m...
I'm working on an app that will have messages exchange and which have a database with several tables to all users data and preferences but I got thoughtful about the table of messages. I will have about 10k users that will exchange about 500k messages per month. I have saw some questions in concern of this but are abo...
I can't find anywhere else where I can show an OO system design and get feedback on it. Could you identify any major issues with my design and how to fix them? The description of the problem is as follows: Create a class diagram of a restaurant system. There are employees and they can perform many roles, depending on...
Say you have a Users and Orders service and they have their own database. Since microservices need to stand on their own even if another service is unavailable, does the Orders DB need to have all the complete details of the user who ordered instead of the usual foreign key reference (e.g., user_id) ? Example: Users D...
Suppose I have a house-lending service, like Airbnb. I have a House entity, which can have a name. There's also the Reservation entity, which has a start date, an end date, and a name (which isn't needed but it's to ask the question). The business rule would be then that no two reservations can overlap. So my aggregate...
Say I have a Student who has a ID number, a name, a profile picture, some contact details, and is enrolled in several courses. From the perspective of a Single Page Application there are different scenarios where I might want to see different views of this student object. For example: An admin page might want to se...
I am working in an event-sourcing architecture and while creating the aggregates I came to an interesting challenge, disclaimer I'm new to this. I have a UserAggregate encapsulating the logic for commands, the user has a relationship with campaigns but not really owned by user. Campaigns are created by an admin system,...
I am developing a chat application as my the first project. I have never had experience of establishing a connection to the remote database server before so I don't really understand who should have access to that DB. I have a user part (with GUI), server part deployed at the remote machine (to send messages from one u...
I am writing my first R package, converting my existing scripts into a bona fide package. I frequently use the magrittr pipe operator %>% in my code because I find it makes code more intuitively readable and saves typing. However, in order to use this pipe in the code of an R package, I would need to force all users of...
I 've a pair of private and public ssh keys, which I'm using in encrypting and decrypting my JWT. So I'm creating and signing my JWT with my private key and shared the public key with the client who then use it to decode the JWT. Now, I'll be frequently using the private key to do this, so, how/where do I store my priv...
I know that doubles are more precise than floats and that they should be used for financial stuff and other things that require precision, but why do we use floats? Why not just get rid of floats and use doubles for everything since they're more accurate? Sorry, if this should've been asked somewhere else. I feel like ...
After reading the pros and cons of both camps, the consensus I gather is that, go monolith first then microservice only if you really need to. But then those transitioning from an already big monolith are often struggling. That said, if you're starting something from scratch, what are ways to design a monolithic app so...
Why do you think the definition of Comparable<T> lacks an upper bound on T? That is, why is it not defined as: Comparable<T extends Comparable<?>> or Comparable<T extends Comparable<? super T>> Wouldn't the latter two proposals be closer to the intended correct use of the interface? The interface documentation starts...
Let F(x) be a function that calls G(x), in which x must be greater than 0. If G already does assert(x > 0), should F do it as well?
Currently I use SVN for my project and the structure looks like this: trunk/SharedLibrary/ trunk/platform/wordpress/ <- platform base directory trunk/platform/wordpress/SharedLibrary <- external with relative path ../../SharedLibrary trunk/platform/joomla/ <- platform base directory trunk/platform/joomla/libraries/Sh...
I've been reading up a lot on the subject, and from what I can gather the following statements 'should' be true in scrum: 1) Estimate user stories in story points at the product backlog level. This allows abstraction of the estimates, and the team can estimate together without dispute - e.g. one developer may complete ...
I am making a card game, it is similar to Bang. You have a boss, which has some HP and you are getting cards with abilities, HP,DMG, etc. I want to make it as a .io game or maybe just a web application, it doesn't matter now. So the language I am building it in is Javascript + Node. But I ran into a problem with struct...
I have a REST API written using ASP.NET Core Web API. There are a few business logic based messages I want to send to the clients from the API. I am in a dilemma on which of the following ways I can use to show the messages: Method 1: Assign a unique code(number) for each message, send that code to the clients and deci...
I have stumbled upon the following problem: I have one list of containers with "capacities", and a list of items with quantities. I want to assign those items to the containers. The total capacity of all containers equals the total number of items. Here is an example. That's the input: Container A: 50 Container B: 50 ...
Assume I have a canvas that has rendered shapes. I can drag-move around that canvas as if I was in a zoomed in image to move all shapes around. Between the Model and ViewModel I have a ServiceLayer (or Controller, however you'd like to call that ) that generates shapes based on generic object-logic and applies the nece...
I am trying to plan out php class structure for an order processing project. I've used classes before but I'm still not an expert on OOP yet. I've been searching for hours and can't seem to find the answer to this particular scenario, despite it being very common. One of the main objects will be an Order. As such, tha...
So I'm developing a GUI that consists of many widgets such as checkbox, buttons, radio-buttons, combo-box using Python Qt5. This GUI is to perform some calcualtion based on user choices. I'm trying to figure out how to go about saving all this data in a file and then repopulating those widgets when the user opens the s...
I used to work for teams that built software as a service applications. Our requirements, regarding production, were often the same : A complex service (web application, database, daemons, typically) to be continuously available. Bugs to be corrected in fast cycles (and to do so, full specification of production bugs)...
To the best of my understanding Monads were created to allow for composing functions with those that had potential side-effects - loosely speaking. For me composition implies code like so: f(g(h(x))) In order to achieve this in a programming language one has to "line up the types" correctly, so that the output of h(x)...
I have to use a built-in API that works like this class MyAPIWrapper { func callAPI() { apiObj.delegate = self apiObj.doWork() // returns immediately, eventually calls self.delegate.workDone with the result on another thread } func workDone(result) { // do something with result } } You interact wi...
I came from a monolithic world and am finding microservices architecture very refreshing and revolutionary. Since Microservices are hailed as transformative, as opposed to the boring monolithic (no one will get a pay raise from proposing to their manager a monolithic architecture), why weren't Microservices proposed i...
I am new to rest, I have an entity called availableJobPositions. I want to get most Interesting job by sending a person skills. which url is good in restful: api/positions/skill/most-intersting?skills[]=php&skills[]=mysql or api/most-intersting-job?skills[]=php&skills[]=mysql
When testing an API (with, for example, Java), what parts should I actually be testing when calling methods of my Controller class (e.g. a Spring RestController)? For example, lets say I've got a logIn method in my controller. Said method calls some methods of another class (i.e. my Service class), ultimately returning...
We developed our app for iOS and Android in native code. Before using scrum we had the following development logic: We define the overall product requirements (for iOS and Android app) The iOS developer gets some aspects of the implementation and starts defining the data structures, classes, algos and starts implement...
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 ...