instruction
stringlengths
34
36.1k
I have learned graph theory, and am using it to solve the classic Fox, goose and bag of beans puzzle. If we consider that there are three locations for each of the fox (X), goose (G), farmer (F) and beans (B) (near side of river, in the boat, far side of the river), and there are four characters, there are hence 4^3 =...
I've been working on a C# class library with the mindset that we will have new developers to work on it later. While I tried to keep the class/file name as descriptive as possible, the length is starting to get out of hand. Here's a snapshot of what the project structure looks like: MyCompanyName.ClassLibrary FlightP...
I have a database with data that "expires" in a way -- after 10 days, the status changes from "Completed" to "Archived" and after 30 days rows still marked as "Assigned" get unassigned, for various reasons. I'm trying to figure out the best way of handling this. (Affected row count each day would be in the thousands.)...
In The Phoenix Project the author describes an interesting antipattern: Brent is a super-important dev-ops engineer that personally knows the details of every new and old implementation and setup, but he does not share, document or distribute his knowledge. Ultimately every small task or large project crucially depends...
We have four repositories in SVN, in which most of the files are same in all four of them. The reason why we are using four different repositories is, we have four different software products which share a lot of common files. Those files are not part of a common library because all four products are going to be built ...
I learn C# and try to understand the logic between static and Constructor right now. One thing I need ask you about an example which I will give at below. (please ignore the quality of code or how could be written better things, I just need to understand the logic which I am asking) There are 2 classes named Computer a...
First, let me set up some context. I have a function that simulates a user typing a string, printing each character of the buffer at a fixed delay. But now, I want another behaviour. There has to be a random delay if the user wants, so it will now print each character at a random delay between two numbers. If you add ...
I've worked at the same employer my entire career (going on 13 years now). We're big and deal with sensitive data. Technology is not our product, but it helps support our main product. I want to know how other large organizations are structured. Here we have silos of functional areas within IT. We have separate u...
The user of my app has access to two tools within my app. Each tool is comprised of multiple tables that the user has to fill with information. The app is more complex but that's roughly what's it's about. This is the UML Diagram that I have designed based on the app: I am wondering whether the use case diagram should...
I have a shared object that I developed. This shared object is packaged in two forms, a Conan package, and an RPM. It is a Qt project, so it has a .pro file associated with it. Up until now, we have managed our dependency versions through the .pro file by defining: MAJOR = 1 MINOR = 2 PATCH = 3 but now, with Conan ...
I'm working on a small e-commerce solution which uses MySQL. At first there was an initiative by the boss to use MongoDB but I suggested relational database because there are lot entities with relations between them. He then told me to just store everything in form of JSON so we can easily add new attributes. Now we ha...
I am learning about Use Case diagrams and UML. In a Use Case can actors be an external 3rd party system? For example, in an ATM a user is an actor, but the SWIFT network system it communicates with is an external system. I cannot think of a better example, sorry.
A commmon pattern I've noticed in my Python code follows this simple structure: value = get_val_from_thing() value = mutate_that_val(value) I find myself first grabbing some specific value(s) from some data structure and then I set the reference to that value to a mutated version of the previous value by passing the ...
Context: For a video game, I need to load an arbitrary amount of resources which when combined would form a complete level of the game. These resources would be 3D models, textures, sound, etc. Some resources depend on others, e.g. a track needs its textures to be loaded first before it can be loaded. What I've done so...
To keep scope small I will talk about UI race conditions initiated by the same user in the same app sessions. The question is general and not specific to mobile, web or desktop UI. The issue Modern UI expected to be responsive i.e. commands triggered by user executed asyncronously while UI remains responsive and avail...
I'm working with a team of non-native English speakers and I'm struggling to come up with a rule that explains why a method should be called getFilePath and not getPathFile. Examples of this bad naming come up on a daily basis and except for just pointing out the better name, I cannot figure out a good way to explain w...
I was reading this page, about when getters/setters are justified, and the OP gave the following code sample: class Fridge { int cheese; void set_cheese(int _cheese) { cheese = _cheese; } int get_cheese() { return cheese; } } void go_shopping(Fridge fridge) { fridge.set_cheese(fridge.get_cheese()...
I am developing a SaaS product for multiple tenants. Each will be able to upload their data to BigQuery via Google Cloud Storage. However, for the users it would only be an "Upload" button on a front end and all the wonders of GCP will be abstracted away from them. Once they have uploaded their huge datasets (5GB for ...
We're trying to develop a comprehensive system which has broken down to multiple microservices. So we decided to use CQRS and DDD to tackle the complexities of the domain. Also we’re about to launch Generic Domains (e.g. Authorization, Tracing and Logging) to minimize the size of microservice. Everything goes fine unti...
I'm trying to apply DDD to a Golang service and sometimes I find that I have too many structs. For example, I need to satisfy the requirements (for simplicity, I reduce the number of required fields): Create user with name, email and password Update user name Tracking creation time and modification time on database ...
I've been thinking about how to map user claims to permissions in a way that scales from a read and write perspective, probably using a stand-alone service. What we have today doesn't scale for reasons I'll mention in a moment. At the core, we have this: User data Object data (it's metadata about indexed content, whic...
I was wondering if there are any calculus relationships implicit in Big-O notation. For example, an algorithm linear according to Big-O notation reduces the size of the problem by a constant amount at each step, and also involves looking at each part of the input a constant number of times. The derivative of a linear ...
We are trying to develop a microservices based application. The idea is to come up with a good pattern and would ideally like to develop it so that each service is loosely coupled with its own database. But how would we handle data that is common across multiple services. Let's consider an example of country and state...
I'm currently making a REST API, using DDD. As ORM i use Entity Framework Core, this ORM has easy mappings for navigation properties, as you sure are familiar with. My question is about navigation properties and aggregates, what's your take on navigation properties inside the domain model? Next question is about aggr...
Im a bit confused about what is best practice when working with Entity Framework and ASP.NET Web API. I am working on a project that contains a iOS/Android app and an API the app will use to communicate with. For now the project is seperated like this: Project.Core (This project contains all database access like DbCon...
I need to find a software architecture to support object configuration and validation in a dynamic environment. Lets say I want to configure a bike where I have many physical components available to be used. Componentes like, tires, frame, gears, brakes, etc. And each of this components have their own attributes, for e...
Say for example, in this mock bank ATM app solution, I have 3 projects: UI Console Domain Model (POCO) Persistence (Entity Framework for CRUD) Domain Model (POCO): I have 2 classes public class BankAccount { public int Id { get; set; } public string AccountName { get; set; } public decimal Balance { get;...
I have PERSONS entity and I should add ASSIGNED_LEVEL (INT) field to it and keep the history who assigned the level, when assignment was done and what documents were used in the assignment. My proposed solution is to add ASSIGNED_LEVEL to PERSONS entity and then use after insert/update triggers to fill automatically PE...
Assume I have an Ingest object that will only work with objects that implemented the MyInterface interface. The ingester takes all the said objects but our language does not have complex return types, as such, these objects, when implementing the interfaces, can only be "forced" to implement basic return types. Our int...
I'm still learning C# and best practices around it. Consider this block of code public class Counter { private int _value = 0; public void SetValue(int x) { _value = x; // Validation check if (_value < 0) _value = 0; } public Counter() { _value = SomeSingleton.Instance...
tldr: In building a platform where users can create private groups, and invite other people to those private groups, how is it be to secure those groups? I'm building a platform around private groups and communities. I'm not really sure on what is the most suitable pattern/mechanism to secure groups so only those invit...
In the classic 3rd party shopping cart, you create a pending transaction with the amount, redirect the user to the 3rd party shopping cart, they complete payment, and then they are redirected back to the calling application. Let's say the calling application handles its own catalog, and tracking items the customer has ...
As far as I understood, synchronous messages will be handled one after another. Then we have the interaction operator for combined fragments called "strict" which states, that the operands inside the fragment should run one after another. I can't see the difference to the normal behaviour with synchronous messages. ...
I am using PlantUML and it unfortunately does not support qualifiers on a class. I simply want to show in PlantUML that a Task has a qualified association to User through the Task.userID property. A link to quick explanation of Qualified Association Here is a simple snippet of the two classes which can't be associated...
My research team and I are using Git to manage our various scripts and notes/publications for our on-going projects, and I'm wondering about what is considered best practice for the situation we are in. Until now, the scripts we were using were fairly small and did not require too much computing power. We were usually ...
I'm expressing my frustration here somewhat, but why do many new libraries only have asynchronous APIs? For example I'm creating a small utility to fetch a web page and parse some data from it. However, making use of HttpClient from the System.Net.Http namespace in .net core requires a lot of async and await boilerpl...
The fifth concept in the SOLID principle is the dependency inversion principle. It is heavily related to dependency injection, and Inversion of control, and when any of these concepts are mentioned, they are often used in a way that makes them synonymous with each other. Example: Autofac is an addictive Inversion of C...
I am trying to design a system where a Product can only be sold while inventory is available. This is an e-commerce platform where users can buy specific products with designated inventory. A similar example would be someone purchasing a seat in a movie theater. No two people could ever get access to the same seat at t...
Scenario After having written an integration test in in JUnit 5, that executes the compiled project.jar, I used to manually compile the project after modifications, then manually execute the integration test. However, it is part of an click once installation, which automates the project compilation and execution using ...
I'm having an issue with a junior developer bikeshedding PRs. They are the primary approver for one repository. Things that should be up for an hour or minutes on PR spend days sometimes with back-and-forth comments. An example from yesterday: I added an artifact to our build system. One line change. Get three back-and...
I want to model an XML schema that has the following composition relationships: A can contain B, and in another case B can contain A. Using a bi-directional composition is not an option here as it is not allowed by UML and does not reflect the two different cases of inclusions. Is using two compositions, as the followi...
I am trying to apply Domain-Driven Design here in this bank ATM mock app. I have 3 layers at the moment: Domain Model Entity layer (Pure POCO classes) Persistence layer (Entity Framework) Console UI layer In Persistence layer, I have RepositoryTransaction class which perform CRUD operation. namespace ATM.Persistance....
Variables in JavaScript are lexically scoped. But, I wonder, is the this keyword, referring to the receiver of a method, an example of dynamic scoping. Or is this unrelated to the lexical/dynamic scoping discussion? var foo = { x = “how am I scoped?” } function bar() { console.log(this.x) // the free variable this ...
In his DDD book Evans promotes the idea of layered architecture, and in particular that the business logic should be confined to domain layer and separated from UI/persistence/other concerns. He also introduces Repository pattern as a mean to abstract access and persistent storage to Entities and Value Objects. To me t...
Say a dictionary belongs to a language. For the endpoint dictionary/{id}, which is preferable out of: {..., 'language_id': {id}, ...} and: {..., 'language': '/language/{id}', ...} ?
I have dynamic IP provided by ISP. Say IP is x I type google.com in browser. Http request goes to google server IP changes to Y. How does http response comes back to my laptop/broswer when IP changed from X to Y ? Does google continue to send to X and NAT layer in b/w play the role of switching it from X to Y ?
Our main product is written in C++ MFC and follows the same code standard as MFC. Now we will start to develop new components, and think about whether we should continue to use the same outdated standard, or whether we should write it with modern C++ according to modern coding standards. The disadvantage is that ther...
I'm working with a C# API Wrapper project that is entirely flat, meaning 1 project and namespace for all the files. I'm attempting to put the Models into a separate Models project, but I've hit a design snag. The Model classes all have a static Parse method for loading the properties of the Model from the JSON. Ex. pub...
Preface I'm currently building a very small scale platform I plan on bringing into a trial-production phase here within the next month. As of now, it's just a simple web application. It contains things like: Users/Profiles Commenting Systems Posts created by users Nothing too astounding or complicated. I have more fe...
I'm looking for a bit of guidance or someone to point me in the right direction. I have a C# WPF desktop application which accesses a local SQL Server Express database. The application is on a single computer with a generic login and not connected to the internet. Users enter a username and password to log into the app...
I would like to ask for help with activity diagrams in EA and decision block (branching). Lets assume we have simplified activity diagram with decision block "Is working day today?" with 2 branches "Yes" and "No". Lets assume that we need to change it to "Is working day or saturday today?" I am supposed to add to the ...
I had asked a question here, and someone had recommended that OrderLine be a Nested class within Order Header. Is that a standard practice in Domain Driven Design, or more one of many debated methods of conducting DD, with nested class? Just want to validate if this is industry wide practice recommended from DDD Autho...
In our Ruby on Rails projects we use a linter for our slim templates: slim-lint. It doesn't support any automatic fixes, not even the easiest ones. So I'd like to abandon it because I don't like to go line by line through the report and fix small things in the slim templates manually. After all code formatting tools sh...
Currently I'm working with a lot of modules where the original developers used global variables to control states and to exchange important information between functions, like so: STATE_VAR = 0 def do_something(arg1): global STATE_VAR if arg1: STATE_VAR = 1 def say_hello(): if STATE_VAR: p...
Suppose I have a entity called Appointment. This entity represents an medical appointment between one Doctor and one Patient. To create a new Appointment, I send somethind like: POST /appointments { "doctorId": 98173821, "patientId": 2138212, ... omitted for brevity } Works well. As you can see, this object is n...
The specific scenario in my case involves PayPal but it could easily be any other external system. According to a lot of sources on the Internet, including the official documentation, a basic PayPal integration (say, for an e-store) would look like this: Call the PayPal API to execute the payment for an order. Save th...
I am working on a microservice architecture using CQS and with domain objects built using DDD aggregates. I am just beginning to learn about CQS, CQRS, Domain Driven Design, so excuse me if what I post is completely wrong from either perspective. Currently, the architecture within a microservice is as follows: Write si...
In my code let's say I have a function which does most of the work: def compute(x=3, y=5): ... And I have a CLI wrapper program using argparse. I intend end users to use the CLI program and not the function directly, but also other developers may work on the source code. Argparse has the capability to add default ...
I have the following interface, it defines a loadable resource that depends on other resources that should be loaded first so it can load itself: It does its job, the Find method allowing to search for a particular dependency for Load method. Now I have another problem for which I haven't found an elegant solution for...
You are given an arbitrary function f. You may invoke it with arbitrary parameters and read the return values, as well as record any exceptions it raises, but you may not read its implementation. How would you go about writing a function g that replicates f's implementation? Note that by "function" I do not mean to res...
In my project, I found one of the project's classes reusing the same name as an official one. For example: from django.db import models class Model(models.Model): class Meta: abstract = True created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) I ...
I just started my internship as a computer science student. The project I'm working on is web based price calculation. Previously, the price calculation have been done in a quite huge excel spreadsheet, taking a ton of factors into account when calculating. My first thought when tasked with this, was to study the sprea...
Background Our users can have a single role per account (internally an IAM domain), but may have roles across multiple accounts. Each role is defined as a list of permissible actions. Problem In certain cases such as failed payments or suspicious activity, we'd like to limit some of their actions. We can also imagin...
I want to make three layers of application all served through Rest API. For a user case we can say it's school management system where there could be multiple schools where the teachers are administrators of different classes. Super super admin: Is the service provider (me) creating the account for the schools which w...
I have a static class that performs xml serialization. Is it better for the static class to be responsible/implement for converting objects of type foo to their proper xml representation or to have foo implement its own foo.ToXml() method? The conversion just transfers information regarding foo into a data class with c...
I have two systems (for sake of example, and orders and an account domain). Their interfaces consist of an api per system (an orders api and an account api). I have a UI that is sitting on top of both of these services. This ui provides search functionality, which provides visibility into both domains. The problem I...
I am currently creating an Android application and I have the following questions: We have a server which provides data for the app in form of a REST-JSON-API. The App is following the MVVM architecture. Now my question is: When should we fetch data from that server? We could fetch all data at once when the user reache...
I'm a Rails developer and I've always had this doubt, let's say I have to develop things for the user's controller and views (branch feature/users-endpoint) and imagine I end up developing several helpers (sorters, paginators, etc.) and concerns to modulate the code a bit. Then let's say I have to do the admin's contro...
This is maybe a strange question, but I just trying to understand my colleague. I know what is DTO, and what should be on it, but not that long time ago I found the whole micro-service written on the way where all DTO classes had just protected properties with public methods that throw *DTOException (there are multiple...
We are currently working on a Xamarin Forms (.NET Core) application. We use Microsofts DevOps for the code repo, building and deployment. Since we want to test newly developed features in a safe testing environment, we need to configure the app before building. At the bare minimum we need to swap out the backend uri (e...
I am currently on the decision, whether to use interfaces throughout my whole spring project or not. I scouted some open source projects and saw, that many big projects are handling that quite heterogenously. All the big sample Spring apps aren't really doing that, although I thought that this would quite improve maint...
Like for example, /api_1/login and /api_2/login writing in the same table of the same database.
I am having a lot of trouble understanding the logic behind the infamous "Find total ways to achieve given sum with n throws of dice having k faces" question. After extensively searching for explanations, I have come up blank. My confusion stems from the fact that it does not seem to follow the same logic as the "nu...
In Domain Driven Design, should the specification pattern for paging/pagination exist on the Repository level or Application level, or another layer? Trying to see what Eric Evans author of DDD stated. Then I can implement the code in correct layer. Sample code below. Paging meaning, example have 100 products, and want...
As far as I know, most "serious" VM implementations, such as CPython and the Oracle JVM, do not request new memory from the operating system ("malloc()") each time they create a new object. As far as I understand it, these VMs usually request a large chunk of memory once, and then manage it internally for allocating ob...
I am using unity in C# to achieve dependency injection and inversion of control. What if I have a class, let's say a viewmodel, that depends on several services like a repository, a validator and a log BUT its also dependent on just a simple list of data objects. So I would have a Constructor like this ClientVM(DB...
Tiled images Tiled images are large images that have been split in smaller square tiles. There are several tiled image formats, with different ways of organizing the tile files. A tiled image on the web can be downloaded only by finding all the individual tile URLs, downloading them, and stitching them back together....
I am working on refactoring codebase for a JAVA API thats used by multiple clients. Though the api provides the same overall functionality for all clients, actual flow changes a little bit between some clients. Two major examples are old clients using older version of dependency services and some functionality applies ...
Which layer should hold pagination information? (Page Size, Page Number), Eg say 100 products, 5 product per 20 pages. User can type in API url layer. api/Product?Page=1&Limit=2&ColumnSort=Name Our current architecture is this: DomainClasses --> (Domain Repository Place in DTO) ---> Business Application Layer --> (A...
I'm interested in knowing what is a good way to architect a system that can act differently based on the subclass being passed in. I assume polymorphism is the least computationally intensive. I'm going to paste some short, functional code. The Program class is the same for both snippets. I deliberately left out Interf...
I saw a lot of discussion, but I don't know how to do it in a real world. I understand that validation duplication in the client and server is needed. But how to elegantly validate in server and return friendly messages to client. I have a value object like this, it has some business rules. public class OrderId : Value...
In my Springboot project I need to perform a validation of the type validFromDate<validToDate. I was wondering whether would it be a good or bad practice to place a validation in the model itself (pros and cons?) or should it be in the controller which feeds the value in model. I have taken reference from this questio...
I am new to mobile development. As i understand the best way to authenticate/give authorization to a user is using OAuth2.0 with the social providers as Facebook, Google ect ... When we enter the credentials the server returns an access token which is stored in the device so we do not need to re enter every time the cr...
I'm creating a chrome extension which needs a large local database. After researching my options, I figured my best bet is probably to use the chrome.storage.local API and give my extension the unlimitedStorage permission. As far as I understand, this API lets me get and set individual objects referenced by a key. I ne...
When I was looking this question, a question comes my mind. Think about using an interface like : public interface ICommandProcessor<T> where T : ICommand { void Process(T command); } When you think about just interfaces, is there any advantage over direct using? Like : public interface ICommandProcessor { voi...
If logical not ! will switch a boolean value from false to true or true to false and a double not !! will cast a value from one primitive type to boolean is there any reason one can not use a logical not with a double not to create a triple not !!! to cast a value to a boolean and then switch it!?! Is this what creates...
Had a discussion that i felt i needed some external input on. Normally always use interfaces instead of concrete types (on lists, injectable services and so forth). For example in lists i just pass around IEnumerable instead on List and so forth. The same applies for custom types (ICustomClass instead on CustomClass). ...
Good day, Please help me solve the dilemma. I am trying to write an e-commerce engine relying on DDD. Problems associated with two aggregates, ProductType, and Product. Product is a classic product like in any other system with the exception that it can have a different set of additional properties. Features and compos...
I'm working on a new project. It is a smartphone application made with react-native. In the app, you can create "cards" which are having a title, a description and a photo, taken by the user's phone. I will use a SQL Server database, hosted on Azure and I'm currently working on the REST-API whit ASP.NET core with the E...
Say I have a controller public function someAction(){ $something = Helper::something(); } And I have a test to check Helper::something()returns/does whatever it should. Down the line I refactor someAction() to not need that method anymore (and for arguments sake it's not used elsewhere). When I run tests/coverage,...
I want to follow the MVVM app architecture. I also need to have some communication between some fragments. But the official approach is pretty confusing. Taken from the docs (https://developer.android.com/training/basics/fragments/communicating): "The recommended way to communicate between fragments is to create a sha...
After recent years working mostly with SLA, Incident Management and ITSM, I'm considering moving back to software development management and agile methodology. I'm returning to SCRUM lessons and would like to learn another framework alongside. Considering Dynamic Systems Development Method (DSDM), is it industry releva...
I would like to collect feedback on possible solutions for creating testable classes/interfaces. In a normal C++ development we can use references/pointers and forward declarations to achieve dynamic polymorphism (see "Solution with references" below). However, certain types of embedded software have constraints that p...
I am recently having a discussion with colleagues about where should a piece of code reside within our django project. For the sake of the question, let's say we are creating APIs for uber-like quotation feature We have the following modules(an app in django's lingo), each concerns with persistence, business logic and ...
I am trying to separate my domain model and associated business logic from my persistence model, particularly such that the domain model has no dependency on the ORM. One apparent way to do that was to make an ORM-coupled subclass of my POCO domain model object, with persistence layer specific properties and logic in t...
Should documentation be added for constructor parameters that are passed via dependency injection? In my current project I have decided to omit documentation to describe each of these parameters and my reasoning for this is as follows: These constructors are not meant to be called by a developer (outside of unit testi...
An application App-a I maintain publishes some events to an event bus for other team's application App-z. So far, the events were published right after being generated. Now, I need to delay events ~30 minutes before publishing them. This is fairly easy to implement, but my concern is, that when App-a shuts down (restar...
I am trying to make a system where a user can view/download his statements (say salary slips). The user will have ability to download PDF versions of these statements and can also save them to Google Drive. I had some questions regarding Authentication and the Architecture of the application. These are the components o...
I'm building a web app, where users can create locations, which are displayed on a map. Also, users can click on the map objects in order to get to a place details page where further interactions with the server can be done. Users also can delete the places they added on the map and this could happen pretty often. Al...
Say I have total RAM memory of 1GB , HD of 10 GB with 250 MB swap space Say I have two files(f1 and f2) each of 500 MB opened on my my laptop. Now both files are in memory and have consumed 1 GB of RAM. Currently f2 is in front of me. Now I start writing in f2 with 100 MB of characters. Now will OS will swap space he...