instruction
stringlengths
34
36.1k
Consider endpoint /projects that returns a list of projects with the following headers: HTTP/1.1 200 OK Etag: "superEtag" The etag value represents a hash of the entire collection and it does not allow a client to update a single resource e.g. /projects/1. Fetching the resources individually makes no sense, so how can...
I'm fairly new to DDD and have been building a virtual airline app for flight simulators and I'm having trouble modelling the scheduling part of the app. A bit of the domain details: first you start an airline, then you use your money to buy aircraft. Then you schedule flights, fly them and earn money. Any clashes in s...
I am trying to define the boundary between two broad types of users. The first are those who make use of corporate systems (accounting, ERP, CRM, etc.) and this also includes B2B users, for example external consultants, market partners, businesses which use our corporate services, and so on. The second type are end-use...
My question relates to usage of delegation together with inheritance and dependency injection. I have a MailerService class that requires a delegate in order to do its job. Furthermore, I have a hierarchy of delegates with an abstraction: MailerServiceDelegate together with a number of implementations amongst others an...
TLDR: not quite sure whether I got my Bounded Context right. Situation I have a domain model in one Bounded Context: Entire model is in the same bounded context. Bounded context has two responsibilities: administering products/rules/parameters parsing/executing products' rules Business invariants pertaining to admin...
I am experimenting with an web app for searching and buying bus tickets. I came up with a few objects like RequestedRoute, Passenger, and Ticket: I have some Flask view functions as well. The home function is called when the user visits the home page. The home page has a form where the user can enter the departure, des...
I'm developing backend for a dating app, in which each user has a profile of his/her characteristics a profile of ideal match's characteristics There are dozens of characteristics like gender, height, looks and so on. Some characteristics are strings, others are numbers or arrays. Each characteristics has ascribed...
I do not follow SOLID strictly in general, but I do try making sure to separate responsibilities of my classes. I was developing a small app with a Windows service powered by Topshelf and realized that I don't quite understand what should Program class do. Obviously I could probably shove most code into Main, but what...
I have a personal finance 3-layer application setup as: UI, BLL, and DAL. My domain looks like: // Write Model public class Account { public Account(AccountId id) { _id = id; } public AddSubAccount(Account account) { // add subaccount to this account } // more business logi...
In the JEE World, we were used to write front-end application with Struts, JSP, JSF. But now, we are following the trend of modern front-end applications with modern technologies (Angular, React, etc.) in a NodeJS ecosystem (npm or yarn, webpack, etc). Theses new technologies change a lot, and make the maintenance of a...
Modern languages like Rust, Kotlin, and TypeScript, define their syntax to declare variables as: myVariableName: VariableType As opposed to the C-like approach not so old languages like JavaScript, C#, and Java take: VariableType myVariableName My question is, why the new trend? What was wrong with the old syntax and...
I'm beginning a new project at work, and will likely be nearly the sole developer on the project, though one or two other developers will need to integrate existing applications or simple scripts into the main project. The project needs to handle small-scale bulk and streaming data ingest/processing, and both event-dri...
I'm developing an API in Rails and the following requirement is established (it's really more complicated, but I want put a simple example): There are users and messages. users have a gender (gender_id), belong to a country (country_id) and also have a civil status (civil_status_id). When a message is created, these c...
Building my last application, everbody started to lose control over the increasing complexity of business rules, which would be added every week - most of all the app owners themselves. In the end, we had to explain the behaviour of their own app to them, because they forgot what they had defined a few weeks before. Wi...
I have this following scenario: A user makes a GET request to /projects/1 and receives an ETag. The user makes a PUT request to /projects/1 with the ETag from step #1. The user makes another PUT request to /projects/1 with the ETag from step #1. Normally, the second PUT request would receive a 412 response, since the...
I have a mail_queue table that is written to by web requests then worked on by a worker to send the mails. I've now had a moment of enlightenment re. what I was not comfortable with in the design. Before: One database table called mail_queue, which the worker processes, & adds a sent_at field when sent. That means to ...
I recently came across Herb Sutter's video from about how the meaning of const and mutable has changed in C++11 to mean bitwise const (and thread-safe, as a consequence) instead of the traditional logically const. Five years later, have programmers migrated to this new meaning of const? I've tried using this while writ...
I have public class SomeDomainService { public SomeDomainService(IDependency1 someDependency1, IDependency2 someDependency2) { // ... } public void TestableMethod(int parameter) { var result1 = this.someDependency1.Method1(parameter); this.someDependency2.Method2(result1); ...
I'm trying to determine if using '-1' in an Identity column has any drawbacks, or if there is a better way to do what I want. In my database I have User table and a Group table. All users must belong to only one group. Table definitions look something like this. CREATE TABLE User ( UserId int Identity(1,1) not null...
I'm writing an API in JavaScript, and I'm confused whether or not I should check if the API user is passing me the correct type on which the API expects to work. Actually not the type, but if you are passing me the object with the properties on which API will work. Is it a good practice for me to issue an error if the ...
I am building a slot machine game for a client (virtual money, not real-money gambling). They started out with a template game and hired me to reskin it and make "minor" changes for a "quick" release. Unfortunately, there are no brakes on the scope train. The original template was very basic. Count the number of consec...
I have recently started updating portions of our corporate platform, and I've been trying to find ways to make the entire platform more efficient, better structured, and just cleaner in general. With SignalR finally being pretty well ready for our version of the MVC framework, I decided to get my feet wet with it by at...
In our monolith application, the piece of code that used to handle sending SMSes and emails was written in our business layer. Now the responsibility of sending emails and SMSes is handled by a microservice. Lets call it SendMicroservice. Now other microservices call SendMicroservice if they want to send any emails and...
On an 8086 CPU before the flat memory model had been adopted, when the OS wanted to create a new segment for a process, how did it know what virtual memory ranges were already covered by existing segments; how did it find a suitable base address to use for the new segment descriptor that had suitable room? Also, imagi...
Recently began implementing domain events in my domain layer which really allows me to decouple the application from the domain. Eventually, I would like to get a full-scale CQRS w/Event Sourcing infrastructure. The question I have is that I have an Account class and one of the use cases is to be able to rename it. How...
I am working on a small plugin for a DNS server. I have a static list of domain (sometimes subdomains too) names: gaming.xyz.com facebook.com mail.example.com blog.example.com I want to check if a subdomain has a match in the above list. For example: abcd.gaming.xyz.com and def.gaming.xyz.com => gaming.xyz.com a.b.c.f...
I am implementing a messaging protocol between nodes on a network and i am wondering how to expose the messaging system interface to the programmers. The messaging protocol supports a set of commands that the clients and servers can exchange to get jobs done. To be generic, let's says, for instance, the system support...
I'm writing a mutation testing system for Clojure and I was wondering what the general consensus is for when a test causes a mutant to throw an exception or enter into an "infinite" loop (my system judges any run of a mutant that's significantly longer than average to have entered an infinite loop) which would not have...
I'm working on staff management application for a clinic, basic scenario, but learning about JPA inheritance lead me to over think some parts, and I need help to clear my thoughts and design. SCENARIO: I have some obvious classes: employee, clerk, medical staff, nurse, doctor..etc... the conform to a class hierarchy wh...
What is your suggestion on where to put cross-cutting concerns in a package-by-feature structured app? This aspect seem to be missing from most of the pro package-by-feature articles I have read. Consider for example a Java REST api: com.myapp.authentication AuthenticationResource.java Token.java TokenDao.j...
My team has been trying to transition to Scrum for some time now, but it seems like the preexisting culture is preventing the team from switching to a new mindset or even causing it to move in the opposite direction. For reference, the team has two line managers, a project manager, a product owner, and five developers....
I use Python sqlalchemy to store my model in a MySql database. One of my objects has a 'state' field (for simplicity let's assume there are two states: AVAILABLE and UNAVAILABLE). There are different micro services which can modify the states of the objects - such as the API service, periodic tasks, background tasks, ...
I frequently work with very numeric / mathematical programs, where the exact result of a function is difficult to predict in advance. In trying to apply TDD with this kind of code, I often find writing the code under test significantly easier than writing unit tests for that code, because the only way I know to find th...
We are using verification statements which describe how the requirement should be tested. These statements are co located and associated with the requirement. How is this different than a set of acceptance criteria?
I have security question that i am not sure if this approach is safe and secure way to download a file and present to a web user ? We have customers invoice files stored in a server location (publicly inaccessible location), then we do read them via the PHP code in a file (in public accessible location) like below, I...
My team has a Git repo for a large service that incorporated a related, but fairly unique, micro-service. We recently decided to separate out the micro-service into its own service in terms of release branches and deployments (so we can deploy the micro-service independently of the large service). The gotcha is there’s...
As a small snapshot of my product, I have 2 bounded contexts, one which is a rich domain with defined events and invariants, operating on files implemented as CQRS/ES, and the other a CRUD store of corresponding files and data that will be used as a Customer/Supplier relationship with other exclusive contexts in the pr...
I'm developing a WebSocket API and I was wondering if there was either a standard or best practice for responding to client messages. For example, if my API is expecting only stringified numbers but receives a word, what's the best way to respond? Is there something analogous to a 400 response? Conversely, is there ...
I have a web service that implements Repository Pattern and I was wondering if there is a design in C# that can remove the need for 'dynamic' when injecting it in my method. public interface IRepositoryPlan : IRepository<PlanDetail> { // methods... } public interface IRepositoryFlan : IRepository<FlanDetail> { ...
I have started using the following in my automation code in instances where I'm not interested in keeping the object 'alive'and just using it as a means as a type of precondition. For example: Instead of the following: Login login = new Login() login.SetUserName(username).SetPassword(password).Submit() I do the follo...
When reading code, how do you say the following statement? (It was taken from some C# code, could be many languages, though). List<string> Do you say: List of type string? or List of string or List of string type or Something else
in my company we are using different 3rd party systems, for example: a CRM, where we sync information about the customer; the goal is having a 1 to 1 syncronization. a transactional email system, with whom we can send email to the customer. At the moment we are having several timeouts, because these systems have a fi...
Most Defect density metrics are like this: Number of bugs / Size (KLOC, Story Points, Function points..) I have read that it measures the effectiveness of QA but I do not get it: I can have a super senior developer and a sloppy QA. Therefore, the sloppy QA guy finds nothing because there is nothing. I can have a ba...
KLOC has been - I think justly - criticized as too inaccurate to express size when comparing several projects. In only one source I found a calculation that uses Story Points and thus allow to compare small/large projects with respect to their Number Of Bugs per 100 SP. Providing that the teams all have a common defini...
We have some linux(ubuntu) based VMs running in the cloud in a private network and they do not have external/public IP address. We have some apps running on those servers and everything is working fine. My question is: are there any arguments for doing regular updates on those machines? How about security patches only?...
I'm trying to understand the difference between terminal and non-terminal values in a real language. I wasn't able to find enough examples on real language CFGs on the internet, most examples are abstract. Assume we have the following int main(){ int a = 5; return a + 6; } Are the following statements true? Term...
I'm currently working on a project which will use a REST API and that's exactly what I'm working on and I'm using nodejs with express, mongodb and mongoose. I've users that can have 4 different roles: user, secretary, worker and manager. Let's say they can all access the kits document but they can do different actions ...
I'm considering two types of notifications: Domain events used internally within a bounded context Application events used to exchange notification messages between bounded contexts Each aggregate in my bounded context defines its own transactional boundary, so that only one aggregate is modified per transaction. Whe...
In the book Building Microservices by Sam Newman, on chapter one in the section Ease of Deployment there's a sentence that has left me bothered: "A one-line change to a million-line-long monolithic application requires the whole application to be deployed in order to release the change." This doesn't seem true to...
I am pretty new within our Scrum team. (Round about 4 months) Whenever I suggest some paradigm like "DevOps" or technology like "Kubernetes" to solve issues I am criticised at least from a part of the team. Arguments are "these are just buzz words". Other times the team just does not react to my proposals. I am really ...
I'm developing JS and PHP scripts and selling them on various marketplaces. But I need to track/monitor errors on my scripts. Usually, I use Sentry for own web apps, but I'm not sure if it's okay to use it for the scripts which I'm selling. Because this scripts will contain some authentication tokens with write permiss...
I'm becoming addicted to writing fluently (perhaps incorrectly originally said "declaratively") and I'm taking it to possibly unwise extremes, but the more I write this way the more one thing stands out as being completely unable to write in this fashion, and that's the return statement. Something like what I want to w...
I have 2 sequences: One is a videoclip with the image taken by a drone's camera The other is a file with a list of chronological data from the sensors Example: time 0: speed_x=1, latitude=0.001, longitude=0.2, altitude=40 time 112: speed_x=3, latitude=0.0021, longitude=0.221, altitude=30 time 232: speed_x=3, latit...
How can I give complete control of one folder to one person, while the rest is in the control of another person. Control means they have the power to approve pull requests and commit to master and development. I think the answer is git subtree or git submodule but I'm not sure which or if there's something better. I'm...
Question probably sounds confusing so let me clarify. Let's say I have an object containing keys and values for my project's font sizes: { small: '8px', medium: '11px', large: '14px', } This is fine, but it's not very flexible or scalable; it would not - for example, allow me to insert a new size between s...
I am looking for an efficient way to handle a calculation. I have lots of timestamped events, representing loading and unloading of trucks. I need to construct the filling rate of these trucks over time. This picture represents data and the wanted result. Keep in mind that the dataset is quite huge, and lots of events ...
I know many despise KLOC as some managers attempt to correlate that with productivity. But when we speak only comparing sizes of projects using the same languages and coding standards as well as the same tool for LOC calculation. Unlike story points, this seems like a more reasonable way that size of two projects can b...
For example, suppose my application have some sound files, now I define all sound file references in a single class: public class SoundHelper{ public static Sound buttonSound=new Sound("(some url)"); public static Sound alertSound=new Sound("(some url)"); . . . public static Sound pageChangeSoun...
So, I am more or less voluntarily learning NASM, and I have problems finding sources that really explain it. Unlike with Java or C# I can't just use google as well, since Assembly just isn't used by many anymore. I need to prepare a presentation about an "Introduction to Assembly/NASM" without explaining code but rathe...
I read about microservices and it seems illogical to me to create a separate DB per service just to achieve isolation. I can achieve the same using only web services and a single database. Why do we even need it? The thing that separate database is beyond discussion. Or I am plain wrong? Can you guide me on this?
I've seen Singleton design pattern represented like below. Always with just getInstance() method. My doubt is: once I get the instance of the object I need, if I would like to modify it don't I need to add other methods to the Singleton class? Like setField( Type something) ? Or is against the pattern? In this case wh...
Almost every software has a number of internal data structures that we don't want to expose externally (through APIs for example). Let's say we have a few classes representing 1:1 database tables - User, UserGroup, GroupPermission, etc. Then we can have an external class ExternalUser that will be exposed on an API, exp...
Recently, I've stumbled upon an old interview with Dennis Ritchie, Bjarne Stroustrup and James Gosling, published back in 2000. Each of them talked about the language they were most involved with, namely C (Ritchie), C++ (Stroustrup) and Java (Gosling). It's a very interesting article in itself, but what caught my atte...
I am writing an application using the Model/View/Presenter passive view pattern. I have view that contains multiple items in a list. My model is of type AudioDrama. For filtering that list I have classes that implement the interface IAudioDramaFilter. public interface IAudioDramaFilter { EAudioDramaFilterMode Filte...
I need to implement a rollback system and the memento pattern gets mentioned regularly as a solution to this requirement, but in all cases a single object is used and it works in memory, persistence is never discussed. But what if I need to store the memento/state in a database? What if multiple objects are involved? ...
I have a similar question to one already asked about SQS to Azure Service Bus - https://stackoverflow.com/questions/51650073/consume-aws-sqs-and-publish-to-azure-service-bus. I want to get messages from AWS SNS (hosted by another party) into an Azure Service Bus and wondering about the best approach. Ideally, I don't ...
While creating tools for an api, I've noticed the following inside the api specification: GET /cookie-orders returns the following structure as a 200 result: { "first":true "last":false content:[ { "id":0 "customerName":test ... } ... ] } I find this a little contradicting as I think that a rest...
If .catch catches any errors upon request attempt, why would I need to use Throw Error... with .catch? For instance, what is the throw Error used for, that the .catch doesn't handle automatically? fetch(...).then((response) => { if (!response.ok) { throw Error(...) } else { response....
I'm designing a new application that is very basic however I expect it to grow and don't want to have to refactor down the line. My challenge is that in one method, I either need to retrieve thousands (e.g. 20,000) of records from the database and iterate through them in memory or, make multiple calls in a loop (e.g. 2...
Recently I have worked in a small standalone Python console application and have inherited some code from another team. Although some of us have written small Python scripts in the past, none of us are experienced in Python. One thing that bothered me was the way logging was done - the start module would configure the ...
I'm trying to write good code to make extrapolation on economic data and I have a hard time finding an efficient/ingenious way to do it. (to have a nice code that can be used in a different way later with ease) Example of economic data split on an Country => year => value structure ['FR'] => [ 2008 => 50, 2009 => 100],...
We have a webapp (ecommerce webapp) where we are currently working on. For some functions we wrote UML diagrams and ERD diagrams. We just made a high level architecture of the website. But the question is, for future proofness what type of documentation which describes the complete system will be best to write in this ...
I am part of a software team that is writing a console application (no UI) in C#. My part in the team is to write code to call RESTful APIs from a third party site, process the returned data and save it to the local database. The third party API has a cap on the number of items returned in a single call (100 items max)...
This is a hypothetical scenario with some concrete parts. Say that I have built a system that allows users to interactively arrange living room layout. The result of this arrangement is presented to user in a form of a RENDERED preview image. The system is built using best practices, SOLID principles, and taking the Un...
My project aims to provide a common interface between multiple different HDL simulators, so users can write test benches that will work no matter the simulator used. In this situation, it is the simulator, not the user's code, that is the driving application. When the simulator starts, it loads with it a library that a...
I've been investigating various distributed file systems, like Gluster, Ceph, Moose and Lizard. I'm also familiar with various key/value store type systems, some of which do not perform any system calls related to durability (such as the fsync() function) because replication reduces the likelihood of data loss. E.g., i...
We are building API which mainly passes database objects back and forth between user and database, so the main flow of information is quite basic: Table (view) <-- ORM --> C#/Java/etc. Objects <-- JSON serializer --> JSON objects <-- HTTP --> User We are using ASP.NET Core with Entity Framework Core if it matters, but...
Assuming OldModule.oldFunc, if we want to move oldFunc to NewModule and, for backward compatibility, keep oldFunc there merely calling NewModule.newFunc by passing the exact same arguments and doing no tampering whatsoever -- do we need to still write unit tests for oldFunc? Or will having unit tests for newFunc suffic...
I am working on a project using C#/WPF and following MVVM pattern. This project is designed for touch screens. The major objects of the program are the following: We have Programs which contain Channels which contain Functions. All these should be able to be copied/cut/pasted. I have to implement a copy/cut/paste funct...
As a developer who has primarily been doing functional programming in F# for the last several years, I'm very attached to my REPL and use it run my code as I go, testing and refining each function as I write it. However, one area where I often fall short as a developer is in creating good unit tests for every function...
We had a discussion about the real value of effort estimation (EE) for SW development tasks, and I like to get some feedback from the community. The major questions in hand are: Should R&D team provide effort estimation to R&D tasks? Can you learn and get better at EE, by extrapolating from task A's EE vs. actual dev...
I have this question, is more about pattern and in theory what is wrong or not instead of if is possible or not (because it is). In a DDD design, I have a DTO that I am validating, to check not nulls, and other certain values. There is a field that I just realised needs to be validated through a service that will make ...
I'm writing an application which would allow users to access the databases over the network. Currently the user enters database details in a form which are later used to establish a JDBC connection. The details I obtain are (1) database host name, (2) username, (3) password, (4) certain other config parameters. Apart f...
I work for a Rails SaaS platform that was recently acquired by a primarily Microsoft shop. They are pushing the issue we need to rewrite the entire application in .NET. It's very clear they know nothing about Ruby or Rails and are simply scared of something out of their norm and have heard the common thought of "Ruby /...
Contrapositive-ish question: What is the design reason a library class would not implement an interface as a convenience to the developer? (e.g. the .Net library class FileInfo) The FileInfo class necessarily is dependent on the file system. This obviously present problems when unit-testing. If I had to design and imp...
I'm currently writing a design to add the possibility to mark a field or attribute for an entity as read-only in preparation for imminent removal. The idea is that, once the field has been thus marked and the change has propagated everywhere in production, we can run a job against our database to remove that field from...
In OOP, is it possible to have a class that inherits from multiple other classes? And if yes, how is this situation called? For example, suppose I have the following classes: Eye Nose Mouth Eyebrow Ear Hair Skin Now I want to have a class called Face which should inherit or depend on all these classes to make a Face o...
We recently migrated from SVN, with most code in a single repo, to git, with most projects in their own repos (about 70 of them). We build about a dozen different apps from this java source. The apps all run on *nix servers. We use maven and nexus to build. Many of us are struggling with developing features when that f...
I have a single linked list of elements. Each element has a unique ID (positive integer) and a type. Each element may have a "sister" element, associated by its ID, that may also be in the list. The sister element is always of a fixed type and it does not have its own sister. The sister element may be in another list a...
APIs vary in their complexity, functionality and also usability. In Mobile Cloud Computing (MCC) applications, which are mainly mobile applications that offloads processing / storage to the cloud, APIs can be complex as they may span across both Mobile and Cloud. Therefore, adopting these APIs may be difficult. My ques...
Problem statement - I have to construct an invoice (having line-items, legal details, payment details etc) using booking and payment information of a hotel booking. There are two sources for these two data points (payment+booking) - a third party tool that gives you both and an in-house application that gives you the s...
I am working on a project where a user can send email to either a contact from his directory (Internal) or type an email address explicitly (External Contact) or a mix of both. We also show the read stats of the mail (who read what and how many times) this object somewhat looks as follow class X { String text; ...
When an application A communicates with an external/3rd party system B, there is always a chance that B is down. Say that A raises an event that should be sent as a message to B via HTTP, what is the best way to guarantee that the message is delivered? One possibility is of course to have some retry logic to resend the...
Does it make sense to declare a async method as private and then create a public method to act as a wrapper that calls the private method with ConfigureAwait(false)? The intended purpose is design an intuitive API that hides complexities and doesn't require the user of the API to have to think about ConfigureAwait. Is ...
I'm trying to build an appointment system but at one point I stuck Problem: I define available slots for the next 7 days with help of a cron. I have multiple users serve service more than one location. Now for example if - P1 location have two User U1 and U2 - P2 location has the only U1 user now for P1 location, I...
Ive been looking around for a way to design a database for large amounts of leads (users) with custom fields. Ive check this out (How would you design a user database with custom fields), but this solution would limit the amount of custom fields. So far ive been designing it in three tables: leads (I...
Consider an application where you can create and edit a SVG file (e.g. draw.io). How should the SVG be stored in the database? With SVG (image/svg+xml) Thus no further processing is required before the data is stored. But after the data is retrieved the SVG needs to be parsed so the application can set up event handler...
I am currently building a finance application that contains "accounts" Each account has a balance that is dynamically generated based on platform charges vs payments. e.g simplified example. $account->balance = $account->transactions->sum('amount') + ($account->charges->sum('amount')) It's obviously very simple how...
I work at a company where we have wrappers for pretty common things: pthread library and time.h functions. Management claims that this was done so that if we ever need to switch to another thread lib or use a different set of time related functions, it can be done easily. I understand that doing this for third party li...
I come from a Java background, and my colleague is from .NET. We are working on a Java project and I saw him create a method like this: public Object myMethod(Object[] param1, ErrorMessage errorMessage) {...} ErrorMessage is a self-defined object that just holds a String, and is checked if empty or not in the caller. ...