instruction
stringlengths
34
36.1k
We're scaling out development on a single product from a single team to multiple teams. What are the patterns to ensure coding style, patterns and technology is used consistently? Is there one person across everything who does nothing but reviews... should more people be involved in reviews? Should reviews take place e...
I've read this example which basically states that, since a method has to hold a single private field.. It is considered a stateful system. So basically ANYTHING system that calls upon some sort of data-storage mechanism to retrieve something to serve a current request is a stateful system?
Scalability seems to be a thing now. I was in a heated argument with one of my developer who insist on using MySQL for a data intensive application we are building. MySql is easy, fits the purpose and etc. And he wants to run it on a single and very "powerful" dedicated server. My experience is limited but I just have ...
We're working with ASP.NET Core web API and looking for a couple of doubts that we have. The versioning documentation recommended creating multiple controllers: Contoso └ Api ├─ v1 │ └ Controllers ├─ v2 │ └ Controllers └─ v2_5 └ Controllers We faced difficulties and challenges to manages multiple vers...
(This question applies to the equivalent code in both Java and PHP) I have a class like this: class Foo { private int $bar; public function __construct(int $bar) { $this->bar = $bar; } public function add(int $bar) : Foo { return new Foo($this->bar + $bar); } } Due to certain reas...
We are trying to migrate from a monolithic application to a micro-services one. On the backend we did a lot of work and now we start splitting it into REST micro-services with a well defined JSON API. Also we have an Auth service and a gateway. But in the frontend part we still have an old solution done by JSP, Spring ...
Context I'm working on a project that pulls data from AWS using the various AWS SDKs for .NET. This specific example deals with the AWSSDK.IdentityManagement SDK The goal is to query information from IAmazonIdentityManagementService and map it to a model that is helpful to the business domain I'm working in I've been ...
preface: I know this topic has been asked about a lot on here in the past. Hopefully I will make it clear that I've read a fair amount of the questions/answers on the topic, and other literature, too. Alas, my questions persist. Some parts of my post written like a hypothetical dialogue with someone who supports the pr...
We have Application service Method, which extracts data from SQL database using Entity Framework Core . Its Async method along with the Async Controller. Service: public async Task<IEnumerable<ProductType>> GetProductTypeData() { var result = _dbContext.Set<ProductType>() .Where(x => x.LkProcessActionTypeId...
I would like to compute cycle times for some manipulator movements. These movements consist of different phases. I have a class that models these phases and this is its constructor to give an idea: /** * \brief Creates a new instance. * * \param name phase name * \param startIndex phase start point index with respe...
The question is: interface Animal { void eat(); } class Lion implements Animal{ public void eat(){ //do somethng } } class Test { public static void main(String[] args) { Animal lion = new Lion(); lion.eat(); lion.eat(); lion.eat(); } } The requirement...
I've been thinking about a problem for a while and I don't really feel that I've nailed how to approach this. I'm trying to work with DDD as much as possible but some presentation scenarios do not really fit with this in terms of performance. Let's say that we have a system for rental cars, and there we have a view tha...
I am implementing a discount calculation model. One item PER order. I do have a Product class: public class Product { public string Name { get; set; } public Size Size { get; set; } public decimal Price { get; set; } } I do have an Order class as well: public class Order { public DateTime Date { get; s...
I been trying to figure out, what i hoped is a simple problem, but am yet to land with an answer. How do you go about designing an entity relationship diagram when doing code first development? The people I've spoken to and things I've seen on google usually refer to the approach of designing for a specific db type (e...
Setup/Intro I have 10k+ nodes in my Neo4j graph in which I need to display a sub-graph (100-500 nodes) between 2 start/end nodes on the frontend app along with info about the critical path and all dependencies (upstream/downstream paths from/to start/end) of each node. I have a list of all possible start/end nodes and ...
I have been working on a blog application with Codeigniter 3.1.8 and AngularJS v1.7.8. It is intended to be versatile and easy to use. The Dashboard of the application is "pure" Codeigniter, with Models, Controllers, and views, while the fronted is made up of JSONs managed and displayed by AngularJS. I operated this cl...
I'm working on a project where I want to display a list of wedding venues within X miles of a users location. My first thought is that I will use some type of web scraper to pull in a list of venues. My concern is that the data will be in different formats and I won't be able to list item with a picture, description,...
I am trying to implement a distributed version of multi-producer/1-consumer for a critical-mission system. I'm looking for good alternatives to the current approach based on RDBMS. The problem The system consists of serveral (50+) producers which continuously produce thousands of instances per second. Each instance is...
I have the following situation in my current project: There is a system A which exports data, that will be consumed by system B. System A is something like a webshop which exports data like orders to an ERP (system B). Unfortunately, system B dictates the export format to work proper. The typical awkward stuff like "yo...
I am putting together a system design for something similar to Tiny URL. It provides an API for mapping a URL to a short URL. Once created the short URL can be used to access the original URL. This system seems to need to be both available and consistent at the same time (which I know is not possible). Available - If t...
It seems like the URLs are always Base encoded yielding a short string instead. Wouldn't it be easier from a design perspective to just use a number instead? Sure your urls could be "browsed" if you do that but the same applies for a Base64 encoded number as well.
Ok so first I want to describe the anti-pattern anti-practice. Company creates system for customer number 1. Then customer number 2 comes along they fork the codebase customize it. (Say for variations in customer number 2s country) Rinse and repeat for the next 14 customers. Now to add an new feature needs to be repeat...
I currently have multiple clients who need to be informed when a customer creates a new order. Each customer is registered to an individual client and customers create orders on my website (each order has a particular client id when created). I'm currently using polling and each client hits my API every few seconds and...
I have a website which uploads job postings to my API, there are multiple steps to doing this: Upload a logo image to file storage. Insert data about the job posting into a database. Process a payment with a third-party provider. Send an email through a third-party provider. In general, you can imagine other step...
I'm developing a new REST API and I've seen some projects place the circuit breaker in the Controller. I used to place it in the DAO. First difference I can say is that placing it in the DAO is that every service which consume this third party will be open in the error scenario. And placing it in the Controller, would ...
I've recently read a great article about unit testing. There was an example of a bad method which is not well designed. It looks like this public static string GetTimeOfDay() { DateTime time = DateTime.Now; if (time.Hour >= 0 && time.Hour < 6) { return "Night"; } if (time.Hour >= 6 && time.H...
Let's assume I have a method that performs an internal operation just the first time it gets called, e.g.: class Foo { constructor() { this._unlocked = false; this._data = null; } bar() { if (!this._unlocked) { this._unlock(); } ... return true; } _unlock() { performSomeUnloc...
Lets say, I have a scenario where I have to expose an api to fetch supported shirt sizes(small , medium and large) My initial thought was /v1/shirts/sizes - But this clashes with the existing fetch shirt by id api. v1/shirts/:id. My friend is suggesting, we can have resource named metadata, which can be used to list al...
If I have a function that never returns (it contains an infinite loop) how do I declare/communicate that it will never return to the user of the function? The user does not see the source code, only the function signature and the documentation. So the user will know to call my function in a new thread else his program...
I am developing an SDK which users would use to access my service The authorization is done using an API key, which is unique to each user. SDK makes API calls to my server using the provided API Key My question is how do I secure the API Key passed in as a header in the API calls? Should I encrypt the key while sendin...
I've a microservice's system at production which provide an API to the outer world. Along with each service monitoring via monitoring tool ( Prometheus, zabbix, etc.) of course it's highly desirable to monitor every single request's round trip time. The requests could have different nature: synchronous or asynchronous:...
When a program loads into memory and starts running, the cpu loads each instruction from the code and executes the instruction based on the opcode and the arguments, so, the program interracts so to speak directly against the cpu. However, the OS (linux/win) doesn't let you do everything, and so you have to ask its per...
Short answer that I've come to accept: Firstly, it helps with readability, being able to see which is the superclass apart from interfaces. Secondly, though 'extends' and 'implements' do the same thing of inheriting from a Type and could be expressed in a single keyword, the different words help to express the differen...
Assume a text file with 150m unique records. Each record has two columns: (1) string and (2) integer. The string is a unique label, and the integer is the label's value. The only query will return the integer value for a given label. We are exploring multiple architectures for exposing this text file as an API. This te...
Assume there is a large corporation with multiple SW systems that all use the same CRM system via a REST API. All systems have their own databases as does the CRM system. Now, system A only holds references to the CRM customer in the form of customer IDs but no other customer data. System A's database holds 10,000 cust...
This is the documentation with the original RPC client API specification. The naming convention in the specification is camel case. Naming conventions might differ in subtle ways for different languages (camel case vs. pascal case), but for some conventions like snake case (Python) or Swift's Fluent Usage API changing ...
I have a checklist system where we are implementing CQRS/ ES (Event Sourcing). We have a command updateStatus(taskId: string, status: boolean) to mark a task or sub task as completed. If I receive a command that a sub task is completed, and all the sibling sub tasks are also completed, I have to mark the parent task a...
I have a .net web application, let's say A and a .net console application, let's say B.In A, I have a queue with multiple jobs to be done by B.Once I select the jobs from A, a queue gets created. Each job in the queue gets picked up by the console application B sequentially in FIFO and performed/processed. If I have le...
I'm using MVVM + Clean Architecture in my app. And I sometimes don't have any idea if my namings are good enough for each Interface Adapters, Use Cases / Interactors, Entities. For View Models, it's pretty simple. I can just use xxxViewModel as the name. But what about those before? FYI this is my usual namings: Inter...
I have a service that makes a request for data from another, and it can be a list like so: POST /getFavoriteNumber { "persons": [ { "name": "joe", "birthdate": "01/01/2000" }, { "name": "jane", "birthdate": "01/01/2000" } ] } And t...
I have seen different approaches and it is not clear to me which one is the correct one. Some developers use lots of small, very specific objects, and compose them in some way to achieve their goal. Other developers use objects as a collection of lots of methods and functions. In this case, an object takes care of a ...
I'm currently a user of a large research compute cluster which has many other users. We all have access to a shared program that is being actively developed and used. Since we are all effectively working on the same filesystem, I was wondering if there is a way to use git as though we each have our own copy of the repo...
I am designing a system with several diagram for a project. I am trying to summarize my question with 2 simple diagram which can demonstrate my doubt. Below are my use case diagram and a context diagram. Use Case Diagram Context Diagram What my question is.., from both of the above diagram (1) Request Quotation and (...
Basically as the title says. Say we have an API endpoint that takes some object as a parameter and passes that object into a service method. That service method then relies on a mapper class to map the object to another type. This leaves three places to check if the object is null: Beginning of the API function Beginn...
First, here's how I understand these two concepts: Service Locators are not Dependency Injection. Both Service Locators and Dependency Injection are applications of Inversion of Control. This is the understanding I reached after reading Martin Fowler's write-up on the topic. If my understanding is incorrect, please exp...
I have the following class hierarchies abstract class Base<T> { abstract T getRelevantType(); } class A : Base<AType> { AType getRelevantType() } class B : Base<BType> { BType getRelevantType() } class A1 : A { getRelevantType() // logic } class A2 : A { getRelevantType() ...
I have a hierarchical relationship between my tables, with the children having foreign keys referring back to their parent ids (assuming id is the primary key for each table): Department has many Category Groups Category Group has many Category(-ies) Category has many Sub-Category(-ies) Sub-Category has many Attributes...
I'm considering HATEOAS for one of my application but for that, I need to be sure that it fits my needs. One of them is the ability to support direct links such as "https://www.webapp.com/user/1" for example. In this case, when the user lands on this page, the js code is supposed to fetch the user with ID 1. How am I s...
I am designing a REST service with multiple end points which will be servicing the following hierarchy: Department has many Category Groups Category Group has many Category(-ies) Category has many Sub-Category(-ies) Sub-Category has many Attributes. Now, all these entities except for Attributes are optional meaning if ...
I've used UML modeling a few times in the about a decade ago and I am getting myself reacquainted with it. I found it clarifies an application's design which results in a faster and easier implementation. I found UML then to be straightforward and simple, but it has grown far more complex, covering more types of modell...
So, I'm making an application which monitors specific things that happen within the area of a user. And I'm really stuck at the approach on how to serve specific real-time data to my users. I am using MongoDB for the database and NodeJS for my API. (I know once it will release it will probably reach about 1.000 users w...
While I know this is the tight coupling example: class User: def __init__(self): pass def get_status(self): api_client = APIClient() status = api_client.get_user_status() return status And this is the loose coupling example: class User: def __init__(self, api_client): ...
I work on both frontend and backend applications and I still wonder how to document those applications. When we start a development, we usually : Start a README.md that describes the application Create an internal wiki page that ... describes the application The wiki page gives a visibility to people looking for info...
So I'd like to build a simple website where there's a given amount, let's say $1. If someone pays that amount a 24 hour countdown starts. Within this window, people can outbid the previous amount and the countdown resets. That said, I have some doubts: Would it be possible to do it using ready to use solutions? (E.g. ...
I want to make a small programming tutorial which will have a number of images visualizing various data types, but I am not sure how to draw these images of the data types. Assume that I have a FileOutputStream object that writes to the file 1.txt. How can I think of this FileOutputStream object, do I think about it as...
I know they say that clean architecture are guidelines, and individual projects will affect implementation, but is there a general thought on the correct implementation? A lot of times I see DTO objects in the application layer, so do you just leave the proto models in the "API" layer and the application layer needs t...
Edit 2: Thinking about the problem some more I realized that "Can aggregates be used outside DDD?" was not the right question, hence I changed the title. For the reasons described on the original post, I did not follow a DDD approach and its entity model. Still, I would like to group tightly related concepts (which wou...
I was checking out a sample project of NetBeans IDE called "Stopwatch". Then ran it! Then I opened TaskManager to see how much RAM it uses. It was using ~110MB. Then I opened the "Alarms & Clock" app of Windows 10 to compare them. Amazingly, "Alarms & Clock" was using only 15MB. Also, it was using way less GPU and Batt...
I'm trying to model online shop catalog using Domain Driven Design. There are three main concepts I have right now: Product, Category, Attribute. Attribute is a characteristic of a product. For instance things such as color, weight, number of CPU cores etc. There are attributes which possible values are fixed, for inst...
Lately I have created some small parsers of data. My initial code structure // more cases here ... else if(!strcmp(X,"somekey")){ // Parse according to "somekey" behavior. } // more cases here ... worked fine for small number of parse cases, but the obvious drawback is that this soon grows into a huge if-elseif-else...
I'm writing in C++, but this problem applies to any language without GC and even to languages with a GC as well. I have a structure in memory in which I create/add objects. The structure takes ownership of those objects. I should never need to use an object after it's removed from the structure. When I first implemente...
This question is an extension to the question here (and follows the same hierarchy) - Multiple intersection tables vs multiple joins based on this answer - https://softwareengineering.stackexchange.com/a/415095/278602 . I am now thinking of designing an extensible hierarchical database. Here's one approach I had in min...
I can easily put together a message handling set of generic apis in C# with the following quick and dirty code: void Main() { var messageClient = new MessageClient(new TestMessageHandler(), new AnotherTestMessageHandler()); messageClient.Send(new TestMessage { Information = "Hello TestMessageHandler" }); m...
Assuming this type of architecture, whether you call it clean, ddd, onion, or hexagonal, where the dependencies point inward and the application logic is meant to be heavily decoupled from the UI / presentation. How do i handle something like showing a popup? A popup would have to be actually implemented in the presen...
A while ago, I saw a Stack Overflow answer (I can't seem to find it now) that says functions and methods have different goals. A method is to change something within the instance, while a function is to change something about the instance. For example: class Animal { int hunger; void eat() { hunger += 2; }...
I have modelled a class structure, where subclasses Rectangle and Circle inherit from an abstract superclass Figure. All subclasses share an interface IGeometry that provides for getArea() and getPerimeter() and needs a different implementation for each subclass. Several concrete classes hold the respective methods, e...
I am a student who currently learning design patterns. One of the major problems I faced when I started learning design patterns is forgetting the pattern immediately. Even though its crystal clear when I studying the pattern, after a few days I forget how the pattern works. As I guess the reason for that is, not pract...
(I moved this question here, as StackExchange fits better, originally I posted it on StackOverflow.) This is not a question about a particular piece of code, rather I ask what is the right design approach in such situations. More on the situation: I am developing a sort of exception handling framework for a Spring Boot...
I'm having trouble modeling the Business Objects of my application. In my domain I have substantially a list of bills of orders, and for every bill I have the pallet that contains the materials to satisfy the orders. A bill is a complex object, it contains several properties, and a list of orders, which in turn are com...
I have a list of objects that have durations, ProcedurePart Start: double Stop: double Instructions: string they occur sequentially after each other: stepOne stepTwo stepThree Start: 0.0 Start: 1.56 Start: 5.443 Stop: 1.56 Stop...
0xF, 0x0000000F (total width is 10 characters), and 0x0000000000000000F (total width is 18 characters) all mean 15 (decimal). Is it correct to say that there is no reason to add leading zeros to a smaller hex number beyond 10 characters in total? In other words, is it correct to say that anything longer than the second...
Suppose I have similar function: Helper2 helper2; public void myFunc(Helper helper) { if (....) helper.mySecondFunc(); else helper2.myThirdFunc(); } In my unit test should I assert that my SecondFunc or ThirdFunc are called once (isn't this tighly coupling and hardcoding) or just mock/stub th...
A container having 2 or more elements could be called a "plural container". A container with no elements could be called an "empty container". But what is the terminology for a container whose current size is exactly 1 element? I would use the term "unary" but that refers to operators that take exactly 1 argument. The ...
As the title says, in a P2P decentralized network implementation how do you ensure that all your nodes are actually connected and you never have a subset of "orphan" nodes at any time (e.g. nodes connected to each others but "disconnected" from the rest of the graph)? Looking for ideas/suggestions/algorithms/strategies...
Consider a poorly-designed interface in which there are two functions (say foo() and bar()) that can be called independently, but in order to get some expected behavior (or in order to keep the object status consistent) the users have to call function bar() each time they call function foo(). Some examples: interface ...
Environment: Kubernetes Cluster with Spring Boot microservices. One microservice contains a database with a date in one column of a read-only table. Problem/Requirement: When the date is reached, an event shall be triggered: some business logic is done containing a call to a third party system and the processing is lo...
When thinking of an application. Let us say an applications user details. Let us say the application allows a user to easily edit their profile. For a field like gender, which in most cases will be marked M F or other. Should those values be stored in a reference table for example. And my over arching question is, when...
When we work with legacy code and need to do changes, we first write tests on the current behavior. That way we can implement new changes with confidence. We can even refactor the code. Legacy code is often bad code, and after some refactoring the code may be simpler, easier to test. Since the refactor has been validat...
tl;dr is there an existing, standardized way to store sequences of diffs to a JSON or JSON-type object? Question: So currently I have something a class that looks something like this (pseudocode): class SwimmingPool { JSON description; void swim() { startTime = getCurrentTime(); enterWater(); flailLimbs(...
I came across a question earlier where someone asked how to create an array list with multiple object types (Create an ArrayList with multiple object types?). The easiest solution is to create a list of objects, but many people mentioned in the replies and comments that using a list of objects is not a good idea, and m...
Context Typical restful CRUD service, including PATCH method, whose API validates fields (eg the "name" field may not contain digits). However, data in the database (from backdoor ETL load) could be "invalid" according to API (eg "name" is loaded in as "John Smith 3rd"). Business requirement: The record is blocked for ...
I have a system which generates pieces of data that needs to be tracked and assigned a specific TTYL value (a value in seconds) for how long they are supposed to live before being re-processed. I decided to push these messages to mongo db and have a run loop to find the messages that have expired and are ready to be pr...
Use case: I need to create serial numbers that are accountable for, so serial number objects, once created must have a destination: either they are used (they get a code) or they are discarded. For now I have an serial number generator which generates them depending on a a few production parameters, now I want to make ...
Why does Microsoft SQL server ( and possibly other SQL implementations ) default to failure when a deadlock is detected? Wouldn't it be more useful, at least as a default, for queries to be retried? For the systems I make for small businesses this would seem to be more useful. Even if it was not the default, it would b...
For code, we know approaches like DRY and we tend to extract common functionality. What approaches are recommended for comments? Perhaps it's a really open question, so I'm going to go with my specific scenario: In a project I work for, we use a library for charts, which has a few bugs. It's not very well maintained an...
I recently finished a course on advanced algorithms, and another on complexity & computability theory, and in the past few days my mind has been somewhat preoccupied by this question. Why don't we just use a different algorithm based on the size of the input? I'm asking this question because I've never seen this done i...
Here is a concrete example of what I'm asking about: MutableList[ImmutableList[Object]] Where ImmutableList is covariant wrt its first parameter, but MutableList is invariant wrt its first parameter. Object is our "root type" that all types are a subtype of. Is the type MutableList[ImmutableList[String]] a subtype of ...
I am building the initial set of unit tests for my team's legacy API client system. We have been writing integration tests, but have no unit tests. It's a Sinatra server that accepts requests from our web app and contacts the third-party APIs. Sometimes it returns the result to the web app. ...
I am thinking of designing a website where people can enter their aliases for games they played in the past and they can search for others around the same time period. FWIW I don't care if it exists already, I am in it for the design exercise. I was thinking how I'd design it, and I wanted to do Django or Flask/SQLAlch...
I am describing systems including requirements and dynamic behavior in SysML quite often. What I come across again and again is the question of how to map the results of SysML structural blocks to an actual UML model, more specifically to deployment diagrams. The idea we are currently following is to use the "allocated...
I have been dipping my toes into object orientated PHP programming and I'm finding it useful but I can't help but feel I'm missing something in regards to how to utilize it. Normally my classes and method result in hundreds if not thousands of queries to the database in order to retrieve information for one day or staf...
I have a class Foo with lots of fields and have two tickets to refactor that class. the first ticket is to rename it to Boo and two move it to another package. the second one is to rename some fields in Foo I have implemented the first one in a branch. It is not merged yet. Now I'm stuck with a second branch. One opt...
Let's say I have a class called ValueSpec with these immutable instance fields: min_value: int max_value: int description: string Each instance of ValueSpec is uniquely named. This unique name is its lookup/primary key in any kind of lookup mechanism we're talking about (database, dictionary, etc.) When should this...
One of my clients has a Restful API on which I'm supposed to work on that only exposes two verbs: POST and GET. The POST endpoint is used in lieu of the standard Rest verbs: PUT, DELETE, PATCH. The request requires a Strategy enum to be used in order to drive the operation type: so CREATE, UPDATE, DELETE etc. This is o...
When I am using the Object pool design pattern, and allowing the pool to grow, by creating new objects when they are required but not available in the pool, and placing them in the pool after they have been used, can it eventually cause memory shortage, or some kind of an out of memory exception/error? It looks very re...
There is this situation We have many business paper forms that needs to be turned into web based Forms with approval workflows Well we have a small development team (2 developers) who are also responsible for all other in-house developed applications. Which leaves us with these options: To develop each form as a web a...
I don't know the technical terms for the title, so please bear with me. In Object Oriented Programming it is a common feature to have polymorphism One Object is another while acting maybe different This is a cool idea, but my instructor told me to not use extend, I figured his reasoning for that rule is since extending...
Ive been reading software architecture in practice and I have encountered the term hitless in-service software upgrade on chapter 5 page 92. What does a hitless upgrade means in the context of faults, failures and the recovery from there? Maybe my less understanding stem from not being a native english speaker. I have ...
I am developing REST API using node.js and Express. I have Houses collection and Rooms collection. Every Room belongs to exactly one House for it's entire lifetime. I'm not sure how to design API endpoints for managing Rooms. My problem is that if I use endpoints like /houses/:house__id/rooms for creating a room, getti...
I was reading about erlang when I read that it is platform-independent, using BEAM as the VM, now I understand that a VM compiles the byte code to machine code and this makes that language machine-independent but that can always be achieved (even in "platform dependent" languages like C) by sharing the source code whic...