instruction
stringlengths
34
36.1k
Today the job of most Java-based servers is to translate HTTP requests into SQL commands/queries and send a JSON-ed response back to the client. That's a pretty generic (and honestly boring) job. I wonder is there a mature solution that can generate a working RESTful server out of my relational database schema? Possibl...
I have a web application. I don't believe the technology is important. The structure is an N-tier application, shown in the image on the left. There are 3 layers. UI (MVC pattern), Business Logic Layer (BLL) and Data Access Layer (DAL) The problem I have is my BLL is massive as it has the logic and paths through the ap...
When merging development code into the production code, what is the preferred method for handling items that should not be in the production code branch? For example, I have configuration scripts that are configured for the test servers in the development branch, and I have the same scripts also configured for the prod...
I have searched well before asking this question, and some of the questions look like what I need here, but none of the gave a clear answer to my question. I am writing a web application (in PHP if that matters) that is separated into multiple sub-applications (e.g. Auth, Database, Session, ...etc) Each of of these sub...
I've worked in Agile environments for many years. However, one of the things that I've always felt uncomfortable about is the idea that each story should map to an end-user request.....i.e., an enhancement that is clearly visible to someone using the application. However, a significant part of the work in real-life so...
I have an API that has a POST method to create a new Product. The creation of the new Product is handled by POSTing to a ProductService. Now I want to be able to instruct the API when creating the new Product to also add the Product to each Store. What is the best approach to achieving this in a RESTful way? If I POST ...
So i have a class called VirtualMouse, it is used to perform mouse actions such as moving and clicking. public class VirtualMouse { public VirtualMouse() { } public void MoveByOffset(int offsetX, int offsetY) { // Implementation. } public void MoveToPosition(Point position) { ...
I want to create a medium height panel with a long list on its left side and a details section on the right. This will be the help panel so that any unique command item selected from the left list will automatically display its description in the right hand side. Details are in a xml file. I've searched everything I...
I'm confused about unit testing order. Many posts in StackOverflow say that unit test should be independent and small. IMHO, in the case of aggregation or composition, the member objects should be tested before the container object. Let's say I have a Test_Procedure class. The Test_Procedure object contains one or mo...
So I am debating what approach to follow. My scenario is : Will receive a POJO which I need to validate ( REST end point ) Now I can explicitly validate specific fields ( which I know / are stated in requirements that they are mandatory ) OR should I define the fields in a db table and define which are mandatory vs...
Working on a Rails project at the moment, we're working on some mixin-type methods to provide descriptions for each of the models in the project. There's a method called model_description which returns the description attribute of the instance of the model. I would have expected model_description to return a descriptio...
I previously asked this question on Code Review but was told this was 'off-topic' so I am trying it here. I hope someone can help guide me. As part of an insurance claims system we have created, the claims managers can log incoming telephone calls relating to a claim. The claims manager must validate the caller by aski...
I'm working in a team of 12 where we have around 8 developers and a QA. We do not follow a git flow model but we do have feature branches where individual feature developments take place and then these are merged to master and then released. As there are many developers and only one QA, the QA person always creates a b...
My first time trying to implement API versioning here, and I need some guidelines on how to do it... I know there are many ways of doing API versioning. I'm already decided on doing it by uri (i.e, I'll have something like put mydomain.com/api/v1/resources/:resourceId) The question is not about 'referencing' the right...
Currently im injecting my Unit of Work inside the controller. I figured out that in most of the designs, controllers calls the service layer and service calls the repository/DAL layer. Most of the times in the controller, I don't have/need any logic and just need to fetch from db and pass it to view. I do this by call...
JSON { "hello": "world" } Protobuf message HelloWorld { required string name = 1; } Why do we say that protobuf uses binary format during network exchange and json don't, even though network always will transfer using binary data format?
I'm trying to implement the clean architecture and I'm not sure to quite understand when to reuse interactors (use cases). Considering that we have one use case such as get user information and we would like to reuse it in different location. Screen A: product owners decided to display very few user information (pictur...
I'm developing a microservices based application and having trouble to understand how api calls should be organized between microservices ... Suppose my application is a products management application. As i understood each microservice should use it's own database , i'm going with this pattern. Microservice Category -...
I am working on handling authorization for an application. I need some way for a command handler to ask the Authorization bounded context "Is this user allowed to perform this action?". User account creation, deletions, locks, etc. as well as permission and roll management will generate the appropriate events. The best...
My point is that the actual code is more important than import statements. I often don't even need to change or see the import statements. Also, when I'm refactoring code, I usually finish changing the code first before fixing import statements. I know modern compilers would be intelligent enough to pick up import stat...
I'm beginning a small Web development project (maybe 20 tables initially). I would like to use a relational database for transactions, SQL, indexes, etc. I have limited needs for true objects, though. Although the application will be written in an OO language (Java), most of the domain data work will consist of: 1. Pa...
I'm looking at designing some new software for work, and I have been using EF Core quite a bit in my personal projects. In my mind, EF Core generates queries for the underlying data provider which returns data. These queries are ad-hoc, or the same as running a query on the MSSQL database through SSMS or equivalent. I...
Let’s say I have two larges arrays of users with equals number of rows and I want to match them randomly and one to one(one from the first array,one from the second), I will first need to shuffle one of the two sets because I need to do this every x hours, and i don’t want matchs to be the same everytime.The problem is...
Recently I was asked in a interview to implement to e-commerce site . One of the requirement was to maintain cart details across various devices .(i.e) if user adds a book from his iPhone , and when he again Login from his browser it should be available just like amazon Should I have to maintain a separate table to ma...
I am in the process of building out a private REST API. This API is intended for machine to machine communication. In short someone else's server will kick off a job via CRON that pulls information from my REST API. Reading through the OAuth2 RFC6749 I concluded my clients will be a confidential client since they can k...
I do have this use case. callers(APIs in same microservice or different microservices) wants to report different KEYS and VALUES as an audit as part of their methods. There is a high possibilities that some of KEYS will be very common that majority of callers can report. consistency is MUST when using KEY NAME from mu...
The definition of a MDL from Microsoft is: The operating system uses a memory descriptor list (MDL) to describe the physical page layout for a virtual memory buffer. The definition of a Page Table Entry (PTE) on Wikipedia is: A page table is the data structure used by a virtual memory system in a computer operating...
Here is the known old way to iterate over the string: for (int i = 0; i < str.length(); i++) { char c = str[i]; } However recently I have also seen in multiple places the usage of iterators: for (auto i = str.begin(); i != str.end(); ++i) { char c = *i; } I have no difficulties in understandin...
We have a web application and our partners asked us to log in silently from their web applications, which would allow their users to make a single login on l to access our application instead of two. Obviously, their applications are different from ours and need to remain separated. They also need to have their own sep...
I have the web application that provides user with the interface to edit its character. When user makes some changes and saves them, I store it as delta in MongoDB. UI and backend communicate via REST. But in addition, I want to store any change that user made on UI - like clicking the button, or updated some parameter...
Let me show you the connection/similarity, which surprised me, between Observer Pattern and Command Pattern. The following is the Class Diagram of Observer Pattern: The following is the Class Diagram of Command Pattern, which I have added an red arrow on it to represent there could be an inheritance relation between R...
So I have built a Telegram bot where you can play a rpg. This is the class structure. Creature MobType <-- Creature Mob <-- MobType <-- Creature Mob1 <-- Mob <-- MobType <-- Creature Mob2 <-- Mob <-- MobType <-- Creature Where: Creature contains functions shared with User class MobType contains data from database table...
I'm busy playing around with some training material to help teach some of the juniors the factory pattern. Whilst writing the example, I can't help but think this might be an anti-pattern. Lets say I have iVehicle which is implemented by iMotorVehicle which, subsequently is implemented by iCar, iBike and iTruck respect...
I am thinking about starting an open source project and right now I am deciding what technology stack to use. At the moment, my main coding experience is using C# and I am wondering if I can build a truly open source application using .Net Core? I appreciate that this might sound like the answers to this question might...
I came across several cases where people are validating the saml response (verifying the signatures in the xml using the IdP's public key). But, Why do we need to do that? (unless http is being used) This might be a dumb question, but google is not much of a friend in this case and couldn't find much in saml specs. Tha...
I am facing a design problem related to the design of the user notification messages to be used in a web application. Just for the record, I am working in a JS environment and use a json structure to store user notification messages. However, I think the actual tech stack I use is of no importance here, since this is m...
The COCOMO and NASA datasets are widely used in most of the systematic literature review about software efforts estimations and I want to know the reason for it? I have read many papers which used these two datasets but no author has given any justifications about it. COCOMO/NASA are publicly available on PROMISE repos...
We're implementing a REST service with three main layers: Controller, Domain, Repository. The REST API is supposed to respond to error conditions with meaningful error messages. Suppose the general layout of a payload given to a POST request were something like this: { "name": { "first": "string", "last": "string" } }...
Maybe this is stupid question but if I implement http patch, is there no good way to reduce the number of possible cases without exploding into a large number (2^n) of different cases depending on which parameters are present or null/None. For a simple example consider an SQL table named "User" with columns FirstName, ...
I have a small team where I'm largely the only person who reviews what goes into production and makes sure that the code introduced doesn't contradict business logic, no bugs etc.. I know a lot of this can be improved with tests and we often use them, however I see tests at most complementing the human code review (wha...
In one of the existing batch process codebase, I can see a practice of JDBC Connection String is getting logged and also persisted. Logging or Persisting a JDBC Connection String alone may not be a security issue. Though, it's a little discomforting to make this information available to naked eyes. But is it a best pra...
Which underlying system parameters have most influence on how fast a typical Java project (say dozens of classes and dependencies) builds? There is a lot information on JIT (bytecode to CPU instructions) compiler optimization, but what if you need a large project to compile (very) fast? Say, 10 times faster? 100 times ...
I'm thinking about defensive programming here, through model driven design. I would insert null guards where a property must not be null, but would use a Maybe struct in the cases where it's admissible. However, I'm not sure how to explicitly model in OCL when a property can or can not be null.
Brief background I'm currently designing a COM DLL in .NET for use in MS Access by a few other developers. The Access application is hooked up to a SQL-Server & is supposed to just act as a front-end, but currently it pretty much does everything. Ideally we would like to separate the business logic into a separate enti...
Just looking for some advice. I have to write a Software Analysis Document for a new application, which basically is to write and describe all use cases. First, I have to list all use cases of that application, like this: However, I'm wondering if it would be better to show those uses cases by groups. I don't know if ...
Currently, we had a web app that integrated with SSO through Open-Id protocol Then we got another client that had it's own SSO and need us to integrate with their SSO through SAML protocol so their employees can authenticate and use our site, then another client came with another SSO (SAML protocol). the fast solution,...
We use WordPressEngine and want to have multiple developers and multiple branches using git. One challenge is how do we incorporate the database into the workflow? Should we take a sql dump and incorporate that in the commit? Another challenge is due to the fact that WPE only gives you 3 environments. So, if developer ...
I'm building a web application that has a feature which allows visitors to directly access resources using URL patterns, for example: www.site.com/client/[clientID]/orders www.site.com/client/[clientID]/orders/[orderId]/details These URLs can be static or dynamic links from other applications/sites. The URLs are secu...
This question is related to How should an `Employee` class be designed? In the above question, to uniquely identify an employee, each Employee object has an id field as shown below class Employee { private int id // id is given by the database // Employee data (let's say, dozens of properties). //methods...
Let's say I am writing code to run a machine similar to a 3D printer and I have a routine like: machine.moveTo(x1, y1); machine.alignByCamera(); machine.heatUp(); machine.extrude(amount1); machine.moveTo(x2, y2); machine.extrude(amount2); I want to add a new optional feature to keep track of process history. Let's say...
I have a big codebase yet to be covered with tests and rather limited access to the real data. The code that needs to be covered is very data dependent. And the data is anything but shallow and trivial. So I had that naive idea to somehow make the data up. It worked well for simple data sets, but all goes south when t...
I have trouble understanding why this boolean b = new A() {} instanceof A; is a valid statement and not boolean b = new A() instanceof A; and why the former is true knowing that A is an abstract class.
So I am going to be developing atleast 5-6 Res end points . ( all distinct and stateless ) Now I am debating on the following: Should they be combined as single war / ear or deploy each service separately ? deploying them as single war - down time during deployment should that be a concern ? ( with load balancer - id...
I have a Software. User will use software to process file, But my software will use a other software or "Dynamic Link Library" of 3rd party. Is "Dynamic Link Library" of 3rd party an actor?
I'm trying to pass a point to my team whereas there are two different kind of "programs" we can serve : applications and executables/librairies. An application in this sense is dependent on other parts (think microservices), it has to match certain configurations or enforce certain security fix so it knows how to work ...
I'm working on a Java application, it's a middleware between two ticketing webapps. I want to write end2end tests using Selenium to test functionality. Let's say my testing process goes like this: I manually start a Jenkins Job, it compiles my app using maven, launches unit tests, then if the unit tests pass, deploys t...
My Widget class has a method called loadWidget. This method needs to shuffle an array to work properly, among other things. In Widget, I could implement a Fisher-Yates shuffle as its own static method named shuffle and then call shuffle in loadWidget. However, this looks unseemly to me for two reasons: The shuffling a...
I have an old php web application, with very bad code. While a lot of it just has html and ajax calls in the, the wrapper is still php. I want to develop the new modules in react, and slowly replace the old php modules one by one with react; Instead of doing everything from scratch. What would be the best way to merge ...
I'm wondering how service oriented architectures can follow the 12-factor principles. Designing an architecture as microservices means (to me) that you separate the features in services. This means you have multiple code source for the different services. The first principle of a 12 factor application is "One codebas...
Our current workflow is that we create a Sprint branch and then developers create Feature branches having the user story number. Once the story is complete this Feature branch is merged to Sprint branch by pull request where it undergoes code review. Once code review is complete then we raise another pull request to De...
Recently I learned about GraphQL which claims to be superior to RESTful. However, I started wondering why don't we simply put SQL statements into an HTTP GET request. For example, in GraphQL I would write { Movie(id: "cixos5gtq0ogi0126tvekxo27") { id title actors { name } } } Which isn't much...
I'm writing a simple game engine and after a lot of rethinking/refactoring I settled with sort of a component based architecture (not strictly ECS, but it isn't inheritance based anymore either). So everything in my world is an entity, and each entity has got a bunch of components. Every system/subsystem in my game sca...
In languages such as C or Java we have the concepts of the Stack and the Heap. Are these abstractions the particular language runtime/compiler creates over the plain-old RAM? Or are these concepts inherent to the OS? In other words, do the Stack and Heap "physically" generally exist in any application regardless of the...
I have the following requirement: There are about a 100 recurring jobs that needs to run every one minute. This job has an IO intensive phase, followed by a CPU intensive phase, followed again by an IO intensive phase (total amount of time taken to run the job can vary from 2 seconds up to 50 seconds). Its extremely c...
I have the following homework question: You develop a video surveillance software that must run on real-time data. In one of the steps of the algorithm executed with each image captured by the camera, you have to sort some numbers. Considering that the average execution time of QuickSort is better than that of MergeSor...
Imagine the following situation: 1. Consume a 3rd party WSDL, out comes thousands of classes. 2. There's an opportunity to optimize performance by using a custom paralleled implementation. 3. Wsdl class structure has consistent naming convention: [RecordType][CrudAction] 4. Use Java Reflection to create type-less func...
Do helper utilities like the one below violate the spirit of the Law of Demeter? It doesn't technically violate the law, since the doOperate method doesn't invoke C's methods itself. If so is there a way to work around this so that the container class doesn't need getters and potentially setters for every field in ever...
I need a textual human readable format which is reasonably compact and version-control friendly to serialize a persistent memory heap. My Bismon system (GPLv3) has such a format (it is textual, human-readable, git-friendly, occasionally editable under emacs, but specific to Bismon. It is usually loaded and dumped by th...
I'm developing software that calls a SOAP web service I've created. My questions are about security: Is it "enough" (about securing web service) to have my web site secured with HTTPS, and to call it the web service using HTTPS? If not, how can I prevent "illegitimate" users/software from calling my web service?
Is the following implementation in PHP correct? I focused on what they say about the lifetime of dependencies: “Aggregation implies that an aggregate object and its owner have identical lifetimes.“ The implementation of acquaintance: class B {} class A { /** * @var B */ pri...
I have heard some people claiming that boolean state variables are generally bad and should be avoided when possible. Apparently in many cases it is possible to put state into lambda functions, instead of using booleans. An example to this approach is a conceptual implementation of C#'s Lazy. Lazy<T> gets a function-li...
I'm learning about javascript's event loop, however I'm not understanding what a message is? The resources I find mention how the callback associated with events get added to the message queue, but nothing seems to explain what a message actually is. I'm assuming its different then the callback itself. What is the mess...
I use entity framework with Repository Pattern. while searching for means of writing unit test cases that run isolated from the database I found some people mocking the database context and others mocking the repository pattern. I wonder what's the difference? and which is better?
Is there a generic way (useful formalisms) to think about data synchronization between two systems, especially in the case of slightly asymmetric roles (eg, one system contain master data, another one specialized set of data, overlapping master data), broken down to individual entities. For simplicity, mapped one to on...
I am trying to explore the patterns around data integrity when applying multiple services with access to the same storage. Let's say I have Service1, which runs in 3 instances. Whenever an instance of Service1 persists some data to the underlying storage, I would like to enforce that data is not somehow corrupted based...
I'll first explain the context of my problem. The backend of my current project is using DDD, CQRS and Event Sourcing as a stack (the read DB being a MongoDB, my write DB being an event store). At some point I had to chain multiple commands in a "transactional" manner, did some research and had to choose between listen...
I'm designing an application which accepts a command, processes it and produces a result. Application will maintain the status of the input command as 'new', 'processing' and 'completed' as it transition through the execution flow. When the command processing is completed, status will be updated to 'completed'. But it...
I work for a publishing company that also provides content distribution to their users. In order to access a piece of content the user must be entitled to do so. Traditionally this authorization check has been done with several different ways (most of them legacy, unsecure and, tbh, very ugly). We do support username a...
The team I'm in creates components that can be used by the company's partners to integrate with our platform. As such, I agree we should take extreme care when introducing (third-party) dependencies. Currently we have no third-party dependencies and we have to stay on the lowest API level of the framework. Some example...
as per my current requirement. I would like to maintain common source code for different country releases. Below are the cases which are required to be covered in the new process of code manage. Release new feature for one country only and once that feature works perfectly we will release that feature in other countr...
I am diving in the domain driven design (DDD) and while I go more deeply in it there are some things that I don't get. As I understand it, a main point is to split the Domain Logic (Business Logic) from the Infrastructure (DB, File System, etc.). What I am wondering is, what happens when I have very complex queries lik...
I have an Event Sourced system that has 3 micro services (simplified): User management - Registering a user, change password etc User account - manages debiting/crediting of the user account balance Notifications - email notifications when balance changes I have a requirement that we want to have Demo users that can ...
I know very little about encryption, so I figured I'd ask the internet if it's possible to do the following (and if so, what kind of algorithm should I be looking at): Write some code that saves data to and loads data from a file, however the file is usable only once. What I mean is that the data is loaded in from it, ...
Based on what I've read, user stories are often cast in a "who", "what", and "why" format, i.e. "[Who] wants the system to do [What], so that [Why]". The "who" and "what" seem easy to grasp. For the example of an ATM: As a customer I want to be able to deposit money [Why] The "why" line seems like it could have a...
My team has a mix of software developers and scientists, and version control has been messy in the past. We're trying to do better, which leads me to ask this question. We have a central codebase for a subset of projects that includes code for different tools all sharing common algorithms. Let's call that U1. There are...
I encountered this string that looks like JSON syntax but I've never seen a property with a colon before it and not with a backwards greater than or equals sign: Badge { :id=>36, :name=>"Appreciated", :default_icon=>"fa-heart", :badge_type_id=>3, :query=>"", :default_badge_grouping_id=>2, ...
I came across this word "implementation". CPython is one of the most common implementations of Python. What exactly is an implementation? I researched a bit on how a Python code runs. First, it is compiled and converted into bytecode and then, using PVM or interpreter (not sure), it is converted into machine language w...
I research about [association] in use case diagram : It is a line has not arrow as image: https://www.uml-diagrams.org/use-case-actor-association.html But i using Rational Rose: If i draw a [association], it is a line has arrow: Is it ok? Association in Use Case diagram have arrow?
I had a simple static method which would take a value and a unit type (pounds, gallons, dollars) and would just format a string. A simplified example: public static string Format(decimal value, UnitType unit) { ... if(unit == UnitType.Dollars) { return "$" + value; } ... } Now, the requireme...
I have a simple design question. I have a tree based C++ class. It needs to use a distance function in order to calculate nearest neighbors. But the distance function is available from an external library such as GeographicLib or others. Ideally you want to vary the distance function based on client preferences. If the...
I'm developing a C# WPF desktop application where I need to read/write to an SQL database regularly. Now I want to map the data from the database to objects in C#. I can't use Entity Framework so I'm doing all my data access through Dapper, slapper automapper and stored procedures. I know of this very similar question...
I was looking for an easy implementation of the Event Sourcing and CQRS Pattern in ASP.NET Core using Azure Cosmos DB as Event Store. As I couldn't find anything appropriate I decided to write a solution using the mentioned technology stack on my own. The ASP.NET Core Backend receives commands, creates events and write...
I am working on an internal application that is maintained by the same people that operate the servers the application runs on. We have noticed, while transitioning from Windows to Linux, that some instances of this application are hitting the default limit on the number of open file handles allowed per process[1]. We ...
I'm using OAuth 2.0 with Laravel (Passport) in order to grant access to my frontend app to the API. Access tokens generated this expires after a while. Now, I have a second app that has to consume the same API but sessions in this app must not expire. I need to get tokens with no expiration for this app. Right now, I i...
Many of the server scripting packages/tools out there have the option to have a schema validation before the response is sent out to the clients. E.g. the fastify package for a Node.js has a pretty upfront one. Only two use cases that I can think of is restricting excess data and security. I feel for the first one, we ...
We currently have a customer that wants us to implement push notifications to our app. The problem is that for this customer, security is really, really important... I am not able to find any official documents, that state that the only way to send push a notification to an Android or iOS device via internet is the use...
Let's say we have an application layer with some command handler and we use an Entity Framework database context/ORM context in that handler. I would invert dependencies from the Entity Framework/ORM to the Application layer like this: Create a repository interface with some CRUD functions in the application layer com...
I am writing an app that mainly consists of just creating, editing and reading records in database. I was persuaded that any app has to be covered with tests. I was told that it's a good practice to mock DB out of tests. However in my app if I remove both HTTP and DB then there is almost nothing left. Data validation i...
I was wondering how to updated nested objects/sub-properties when using Entity Framework. But to make things clear, let's start with an example. I have an object, which can own a number of other objects. In other words, an object which contains a list of a different type of objects. This could be a person, who has mult...
I'm actually wondering what are the pros and cons of these two ways to handle client side validations / verifications. Let's imagine an application where there is a contact form that needs these information: An email address (with a specific format) A postal address (with a specific postal code format) I have in mind...