instruction
stringlengths
34
36.1k
This question is an extension to this question. I am also brainstorming on this problem statement wherein a 1-dimensional parking lot having N slots will be having varying size parkings to do. A two-wheeler occupies 1 slot, a car occupies 2 slots and a bus occupies 4 slots. We have to design a system that efficientl...
I'm making a rental app which has many categories with unique properties Example: Category 1 Car which has Fuel, model, color, speed Category 2 Apartment which has Rooms, lift, generator, floors I've been thinking of a db architecture for this type of project, but I couldn't find any which could man...
Computer-science wisdom says that a lock-free FIFO (queue) is the right way to synchronize shared data between two threads in a lock-free manner. I know what a queue is and how the lock-free property is accomplished, however: how a FIFO queue solves the problem? How to practically use it? What data should go into it? ...
Say that I have a repository that is used as READ-ONLY data provides (never for the writes/updates) - the query part of the CQS, NO event sourcing, hitting relational DB. One of the essential rules - application logic is dictating the interface and the models to be restored from the repositories, no exposure of the und...
I'm working on a project with others and we have a discussion about information hiding and static type safety. Our scenario is described below. Language: C++11 Scenario: We want to create a tree-like structure. Each tree nodes has its own class, which all are sub-types of base class NodeType. Each sub-type has its own ...
So for example if I have a producer that sends a message {id: 1} to a consumer that expects that json object. And there's a ton of messages sitting in the queue waiting to be processed. I'm also writing some code in the producer & consumer so that it accepts {project_id: 1} instead of {id: 1} now. This will cause al...
I am confused , Why Software that are developed using the evolutionary approach are harder to be maintained ?
I am developing a virtual machine for personal use (open source of course!) In researching and looking at the source code of other virtual machines, especially those of scripting languages; I noted that all the VM archs I perused used a load/store architecture but I've never seen a VM arch use register/memory architect...
Is this requirement: The system is required to have an easier GUI to make it more usable by any kind of user (normal or disabled user) a functional or non-functional requirement ? And Why ?
I want to expose APIs in python for my workload automation software. I have a Job class as defined/outlined below. Instance of this job class represents a particular Job run. Job can have multiple checkpoints and each checkpoint can have multiple commands. Job - JobName - [JobCheckpoint] - StartTime - EndTime - S...
Calling out the tech: C#, Newtonsoft.Json. We have a class which contains a property named SchemaVersion that we use to inform of the Json document version once that object is ultimately serialized in to our CosmosDb. Currently this property is set in the object class constructor, and for simplicity assume it's "1.0" S...
I am arguing with co worker that a bounded context can be made of other bounded contexts. My example is: I am having a tour context made out of flight bounded context hotel bounded context visa bounded context and he argued that tour is a domain or subdomain, but I think we can interchangeable use domain and bounded...
I'm diving into the concepts to Domain-Driven Design (DDD) and found some principles strange, especially regarding the isolation of domain and persistence model. Here is my basic understanding: A service on the application layer (providing a feature set) requests domain objects from a repository it needs to carry out ...
I'm no software engineer. I'm a phd student in the field of geoscience. Almost two years ago I started programming a scientific software. I never used continuous integration (CI), mainly because at first I didn't know it exists and I was the only person working on this software. Now since the base of the software is...
I was reading this page and came across this sentence in the accepted answer: I don't like A directly knowing about B. But that's a DIP thing not a POJO thing. What if you can't abstract out B so that A isn't aware of it? Suppose if I have the following Book class: public final class Book { private final Autho...
In Git, I have a master branch (release) and a dev branch (development) for a C project. In the master branch, I want gcc to only be passed the compiler flag -Os (optimize for speed) and not -ftest-coverage -fprofile-arcs (when compiled, a .gcno file is created, when run, a .gcda file is created and when gcov executabl...
As the title implies , what is the difference between these both concepts? According to my understanding , Agile software process uses increments , where some requirements are first implemented and checked. The same for incremental development.
I'm starting a new project and there is some internal debate on the right approach to writing objects to a database. CRUD operations require 3 parameters: DB Handle, DB Name, Collection Name. All objects are derived from a BaseEntity object (which has the standard Id, Creation Time, Update Time, etc). The first approa...
Background I'm writing C++ firmware with freertos to penplottingrobot. It's a makeblock XYplotter and the firmware is connecting to mDraw software for command instructions thru USB drivers. MDraw program sends Gcode commands. If you must know, there is a pencil which is controlled by pulsewidth modulation servo, and th...
I am in a situation where I can use an open source JavaScript plugin to fulfill a task. But when I tried to use it,I found myself I have to redesign lot of things of what I already have done,and it adds a certain complexity, in my humble opinion, to the project. Whereas I can achieve the same task with a clean code I c...
I have a public project that I'm the single developer. I love updating packages to new versions regularly and keep the project up to date with the updated environment. This is probably not always a good approach as discussed in this question and this question , but I do it currently, because as I said , I love upgradi...
It's a sort of simple compression where you use one numeric variable to store many boolean / binary states, using doubling and the fact that every doubling number is 1 + the sum of all the previous ones. I'm sure it must be an old, well-known technique, I'd like to know what it's called to refer to it properly. I've d...
Currently I have implemented a method in to a model to take a screen shot like so E.G. Interface public interface ICapture { void CaptureMethod(); } This is the model that implements that interface public class CaptureModel : ICapture { void CaptureMethod(){ //implement the code to take screen shot } } Now I wan...
Here's an example: GET /posts POST /posts GET /posts/{post_id} PUT /posts/{post_id} This api is being used by SUPER_ADMIN as well as CONTENT_WRITERS. Its working great. If user is logged in as a SuperAdmin, he sees all the post, and if user is logged in as ContentWriter he sees only his post. But, now the requirement ...
I wanted to check commits to a branch, and I saw that there were commits that appear in 2 branches. Why? What does it mean?
I'm working on a software product that entails users opening up a case and taking actions to process the case, changing the status, creating tasks, etc. I'd like to provide a history of the actions taken to process the case in the form of chronology entries. I'm trying to avoid having my controllers get too fat and wa...
The behavior of Java is explained in this topic. But, is Infinity useful for something? Float: public class DivisionByZeroFloat{ public static void main(String[] args) { System.out.println(1.0 / 0); } } Console: Infinity Integer public class DivisionByZeroInteger { public static void main(String[...
I've been going through all the design patterns in context of game programming form this book, before starting my next big project. Apart from that I've been reading about them in more general context. The one I have trouble undertanding is the command pattern, specifically the part about using it for game AI. The auth...
I have a Spring based java webservice which is returning JSON response. The problem is that the JSON response takes long time because the SQL involved is querying huge chunk of data and it takes 4-5 minutes. I am wondering if it's possible to store the data in a flat file somewhere using Javascript so that next time if...
I have an Asp.net MVC application and sometimes I want to give a descriptive error message to the user, but the condition of it is discovered at the Data Access Layer (DAL). So for example, I have a conditional search functionality based off form field input from the user. The DAL will fetch the results, and store and ...
I have a legacy service that is running on-prem and have built a new service that runs on cloud which provides the same functionality. I have another java (spring) service which consumes the on-prem service. There are number of apis exposed by this on-prem service which is being called in multiple places within the con...
I'm making a medium sized application to be distributed privately to several Churches. It connects to an Azure database but it does not have any server managing the information (apart from the SQL server). The application is highly dependent on the information stored in the databases as very little data is saved client...
I need to work on android mobile push notification. I have recently gone through some of the tutorial on google. I would like to summarize the my understanding first Developer registers the app with play store and get some unique code called Application_Id Once the end user downloads the application from store and log...
I found a function in c# like this: private Dictionary<string, Func<string>> ObtenerExtraCfgCampo(MsgDefCamp camp) { var extra = new Dictionary<string, Func<string>>(); extra.Add("Oddity", () => camp.Order % 2 == 0 ? "Even" : "Odd"); extra.Add("Odd", () => camp.Order % 2 == 0 ? "Odd" : str...
I am making a shopping cart. A shopping cart will have a total amount of money you've got to pay for the products you've selected. I'd like to approach the problem using both OOP (encapsulating it) and more anaemically or functionally (without encapsulation). I'm using the simplest Product model: public class Product {...
I get to review code that often looks like this: class MyClass1 { constructor MyClass(initialiseParam1: Object) { // do something with initialiseParam1 } initialiseStep2() { // do some more initialisation } } To use MyClass1 you need to do two steps, first to create an object and seco...
I have an Android application (E-commerce) in English, Now I want to change language to Arabic and RTL(Right to Left) I am new in that, where and how much efforts it take? What specific problems should I look out for?
I work in a small company and we are about to delve into the Microservices world. As expected, we are hitting a few bumps. Let us focus on a small bounded context: work order. This bounded context is composed of a technician, a team and the actual work order. A team is composed of a group of technicians and a team mana...
I'm trying to use RabbitMQ for two-way one-to-one communication between clients and servers. So, Client 1 should be able to communicate only with Server 1, and vice versa: The servers stay always connected to RabbitMQ, whereas the clients are started up and shut down on demand. This is because a server should receive ...
Functional programming strongly suggests to separate data from behaviours (functions). However, I can't see the benefit of this for an algorithm's implementation intrinsically tied with particular settings data. For example, suppose there's a trait LagrangeAlgorithmOOP with immutable data being the algorithmic setti...
ABOUT: My business partner and I have been building websites for small businesses since we began our company. Out of the blue, we were approached by an HR company to provide a quote for a software project they are looking to have built. Most of our work to date has been front-end work, however, this is the kind of proj...
How can a factory also save the object in the database? I want to create an object that consists of other objects. Pseudocode: firstObject = db.get....; secondObject = db.get....; expectedObject = new ExpectedObject(firstObject, secondObject, userId, datetime); This is the task for the factory pattern. But I would al...
I have an API written in SOAP 1.2 that I am trying to give to a developer whose website is written in Javascript and said they can not request the file because they do not know PHP. From my understanding the API is already written and we just need to fill out the place holders (username,password). Since they do not k...
I've recently learned that setTimeout is not part of Ecma 262 standard but takes part of WhatWG one. I have one misunderstanding concerning these two standards and I can't get how they converge. For now, setTimeout or setInterval, two ways of making Javascript asynchronous are part of the WhatWG spec. Then and Ecma(scr...
I recently got into discussion about how the method signature should look like for an API method which doesn't expose internal objects used by application to caller. Here is how situation looks: Our API should expose one method say, public int updateSummary(String summaryMessage) { update_in_DB(summaryMessage)...
I've made a website which is going into production soon. The website doesn't store any information about the user unless they create an account, in which case I save username, email and a password to a database, and a token in local-storage. Do I need any sort of notification when the user navigates to the site?
So if I have a class called Object, a class, bench, that derives from Object, and finally a class called Park that derives from Object that has-a bench - is this bad "practice", to have two objects that technically both is-a Object but still the one uses the other? The reason I ask is because I can seem funny to have t...
As far as I have been able to find, the first language to use ^ for exponentiation was BASIC, in 1964. Earlier languages, such as Fortran, used other symbols such as ** for exponentiation (although in Fortran's case this was likely influenced by its limited character set compared with later languages). My question is, ...
I see a lot of guidance in the DDD community around how to retrieve and use information from a remote bounded context (using an anticorruption layer, open host service, etc.), but hardly anything about how to handle storage of attributes that matter in the local bounded context for an entity that has its home in a remo...
So I have .eslint and .settings (VSCode) files that I would like to be consistent across projects. How would I do this? Currently, I am thinking that I should put them into a repository, which then I would instantiate as a submodule in new projects, which then I can symlink to.
Most of my redux actions are 'fetch some data from the database, here's the authentication token', and they for the most part look the same, like this: action creator export const fetchDashboard = jwt => async dispatch => { dispatch(fetchDashboardRequest()); try { const response = await axios.get( DASHB...
I have been working with a software strongly relying on the event sourcing and CQRS patterns for a few time and I'm trying to figure out how to properly model the domain events in relation to the needs of the read models. Let's try to describe the question I'm asking myself in a more formal way. In an event sourcing a...
I've the following project structure (simplified): domain dto view In domain model is kept. dto classes are used to pass data from domain to view. And in view I've a controller and a handful of *req, *res classes to pass the data via HTTP. So there are 3 classes (in model, dto and view) to express the same thing. Th...
In our project there are deep and lengthy if-else structures which can be significantly shortened by a simple rearrangement. To me the shorter version would be easier to understand also. As an example, this: if(a) { if(b) { doSomething1; } else { doSomething2; } } else { if(b) { ...
I've been out of C++ for years, last time I used it was back in gamedesign before C++11. I see all these new pointer types which seem great. But I'm unsure when and how to use them. In the old days I would create a buffer like this: uint bufferSize = 1024; unsigned char *buffer = (unsigned char*)malloc(bufferSize, si...
I am the senior developer at a company I work for and we have rapidly added many other developers and contractors. Our company is growing and that is great! Recently however, I have been tasked with code review (which is fine) but also with giving my opinion on how long certain projects most likely took for a particu...
If class is declared like this class Foo : IFoo From IFoo point of view, Foo is called implementation. If class is declared like this class Foo : Bar Then Foo derives from Bar. How do you call a Foo from Bar class point of view? Inheritor? Derivative?
We are floating around with the idea of breaking our monolithic application into microservices. The problem we are facing is there are parts of the application the business is not willing to accept the idea of eventual consistency. Our thought is to have a shared database, but each microservice would get its own schema...
I am building a CQRS-based application with Kafka Streams. For most entities in my application this entails event sourcing: capturing state mutations as events and transforming them into state which can be queried. The events are stored forever so they can be re-processed into state. However, one of my entities is freq...
We've built a custom CRM for one of our clients. Stack: asp.net MVC, SQL Server, Azure Some of the logic / features were hardcoded specifically for this one client. Now, more clients want to use our software but hosted separately because each client has their vision of the product and features that they want to impleme...
I have a system that is generating internal events for objects. I am extending their debugger to display a human-readable version of the events sent to the debugger. For instance, the system will generate "OnClick" for the "Blue Button" control, on a "a-guid-value-for-the-view" view. If the readable version of "a-guid-...
Modulizing software from my empirical experience seems to decrease performance, most of the overhead can be communication of modules, redundancy in computation, storage and depending on the application can be at a less or greater extend or can be optimized by a compiler. So I have been thinking of the benefits of e.g. ...
The equivalent of static { // Code here } does not exist in Python by default. The closest thing, while being "Pythonic", seems to be to create a decorator and do the initialization there such as: def static_initialization_decorator_for_myclass(cls): cls.initialize_static_stuff() return cls @static_initia...
I'm modeling a database, where I have a table called "appointments" (citas in spanish, but I would translate the tables's names for better understanding) where the user can create an appointment to visit a medic (taking values from the medic's table) or to visit an establishment (taking values from "establecimeintos" t...
We current have a very simple Multi Tenant monolith, with a SQL SERVER backend (Self hosted on EC2 on AWS), and multiple application services talking to one DB behind an Classic AWS ELB. Our database has grown to a point now that we are considering splitting it by tenants per region, due to growth in different regions...
I am designing a database system + application that deals with pipe objects who are part of a larger grid network. There are about 1000-5000 pipes for each network. Let's assume each pipe can have 2 states (clean, dirty). The application is able to change the pipe status after a maintenance job has been done at that pi...
Are there significant differences between, say, JDK 7 and JDK 11 (which latter I believe is the newest version of the JDK), where significance is defined by a change which might make someone who has learned an older version have Java lack knowledge or be only familiar with the old implementation of a feature? (Context:...
Is correct to represent setting options using use cases? For example the user can: - enable background updates - change map color - change interval updates From https://www.uml-diagrams.org/use-case.html A use case is a kind of behaviored classifier that specifies a [complete] unit of [useful] functionality perfor...
Say I have the following ER diagram: To implement the above ER diagram as a normalized database, I would create a School table, and a Student table, and a School_has_Student table (that only contains the school_id column and the student_id column): But let's say that I want to denormalize my database, this means that...
In his book 'Clean Architecture', Uncle Bob says that the Presenter should put the data that it receives into something he calls the 'View Model'. Is this the same thing as the 'ViewModel' from the Model-View-ViewModel (MVVM) design pattern or is it a simple Data Transfer Object (DTO)? If it is not a simple DTO, how d...
I'm quite newcomer to the programming. I've currently faced issue described in the title. When there's already app running on default port 8080, after my app installation ends I have to change this port in the app configuration file manually so I can access it. The whole app doesn't contain any GUI installer, and ther...
In the following database, School_has_Student is a denormalized table : Now if I decided to change the "paul" student name to "john" in the Student table, then the "paul" student name that exist twice in the School_has_Student table must be automatically changed to "john" to maintain data integrity. Likewise, if the "...
This is a concept related question. I'm writing a program polling for alerts on various devices, there are two different type of alerts i need to poll, reds and oranges. My approach is to create two threads, each polling their type of alerts independently. I thought about using threads because both polling functions ha...
I'm having a discussion in my company on how to structure a student enrollment application we are doing. We have an SOAP-Service for sending Emails. This Service is in charge of sending, and logging emails send from our different applications.(lets call it EmailService) Then we have a SOAP- service that handles all nee...
Assuming the following scenario: A web application that receives inputs from the user and process the inputs through an algorithm which takes between 5 to 25 minutes (depending on the inputs) and provide a differed result. By the differed results I mean, the user won't wait for the result behind the UI and he will be ...
I am learning ASP.NET MVC & Web API and trying to implement Onion Architecture with Repository Pattern for one of my Test projects as part of my learning. I have developed single MVC Projects before, but not using layered and onion. My idea is to give data to different clients (Web- MVC 5, Xamarin - Android) using a si...
Let's say an Entity is composed of multiple ValueObjects. For instance, a wanderer might leave a few footprints behind. Imagine I load Wanderer from a repository and delete all footsteps north of the Canadian border. Since Footstep is a value object without identity (ID), how would the repository know which ones need ...
I am modelling UserAggregate using DDD concepts. I know that two separate users should be independent, but when creating a new user, I need to validate, that there is no other user with the same username. How do I approach such a situation? One potential solution to this is for UserAggregate to depend on IUserRepositor...
I have a couple of functions, each function verifies a set of rules and updates a common object. The common object is just a container that holds a list of rules that passed or failed. I would like to implement this as async. Is there any downside to this approach? Are there any recommendations? The sample code I inte...
I'm often tasked with relatively complex flows that my employers will want to experiment with in regards to the amount of steps and their order. I'm a contractor and when my work is handed over to another developer, I'd like to ship something that is easy to understand quickly - and a flow with 10+ steps is quite the m...
Context: I am currently working on a small project in Python. I commonly structure my classes with some public methods that are documented but mainly deal with the high level concepts (what a user of the class should know and use), and a bunch of hidden (starting with underscore) methods which are in charge of the comp...
Why is it considered good style to do all imports in a python application at the beginning, even if what is imported is used only once? I have been programming only shorter pieces of software for a few month now, around a 1-2 thousand lines of code, and it would seem to me to lead to clearer code, if imports that are ...
In system testing, a software system is tested against requirements. In unit testing, a software module is tested against the internal requirements for this module which depend on the specific software design and are not visible to the users in general. I don't like the term internal requirement because a requirement i...
I'm new to programming and mongoDB and learning as I go, I'm attempting a mapreduce on a dataset using mongoDB. So far I've converted the csv to json and imported it into a mongoDB using compass. In compass the data now looks like this : _id :5bc4e11789f799178470be53 slug :"bitcoin" symbol :"BTC" n...
I am having a real difficult time writing some clean code with a simple user registration/login manager. I am trying to stay out of nesting/callback hell, and am also not seeing any benefit in using the supposedly cleaner async/await. Take for example my user registration code. It must perform 3 promises in sequence E...
What type of components could benefit from RPC over HTTP, vice-versa? Does there exist other information exchange mechanisms, what are their use? I've seen smart people use both, I'm sure for reasons I don't quiet understand. Thanks.
I am a beginner in C++. I'm currently experimenting with the Chromium source code and have noticed the following: For many of the cc files, there exist an h (header) file which is imported by the cc file. The content of the header file seems to be a set of abstract functions which is fully declared in the cc file. For...
Given a simple loop in C or C++ such as the following: for (int i=0, j=0; i<5; i=i*2){ j=j+i*1; } I would like to use a tool (gcc, clang or any other) to optimize the code without actually compiling it. I just want to see my own source code optimized. Is such a tool available?
I am new to PHP . I have primarily worked on java. I want to run the helloworld program for PHP. I got it how to do it through blog But I have got some basic questions :- Do I need to install both Apache and PHP separately or there is a way where Apache come bundled with PHP ? On google , I see to install LAMP but n...
If my function meets the two requirements listed below, I believe that the function Sum returns the summation of the items in a list, where item evaluates as true for a given condition. Doesn't this mean that the function can be classified as pure? Requirements For given set of i/p, the same o/p is returned irrespecti...
XSLT is a mature, widely accepted standard. It can be used in browsers (even in old IE) and on the server side (nginx has an XSLT module, which can be used from programming languages, of course). Its implementations are compiled and, therefore, should be much faster than Python or JS. The JS implementation Saxon JS can...
If I define a variable of a certain type (which, as far as I know, just allocates data for the content of the variable), how does it keep track of which type of variable it is?
Should the function that operates on the object return it? Shortened example: class Example1 { public function method($a, $b) { $result = new Result($a, $b); $this->multiplication($result, 2); return $result; } private function multiplication(Result $object, $value) { ...
Do I need to create a different use case diagram for my mobile app and for my web app? I have a mobile and a web app but mobile users cannot access the web application. Only the admins can do that.
I am designing a multi-tenant application which will use the same database schema for a separate DB instance per-tenant (i.e. every time I get a new customer, I create a new database for them). This approach is desirable for its simplicity in that I won't need to filter data per-tenant -> I can just select every User i...
In the context of domain-driven design, events usually describe something that has already happened (domain events, integration events). Commands on the other hand are directives that may or may not be executed in the future. This distinction is also given in another SO answer. However, in event sourcing, we have event...
When authoring OOP code, sometimes you have a file that only contains one class, and nothing else. PEP8 says that all modules and all classes should have docstrings outlining what they do. But in this case, the module is simply a container for the class. If you put a description of the class, then the information is du...
Consider unit tests for two (or more) consequent layers in web-application, backend, eg views (these are concerned with parsing form parameters, rendering the response) and actions (application logic). In the view, calls to actions are mocked. In the actions calls to underlying level are mocked. Tests are fast, but are...
I have a simple neural-network which can create new text out of words which are likely to come after a specific word. The code lacks of comma placement and punctuation. It also can't transform a sentence into a question. The code has the following steps: Read the training texts Create the network out the above explain...
I am trying to make my own programming language by making an interpreter for it in Java, but lately people have been telling me that an interpreter needs to be in the same language as the one it is interpreting. Is this true? Then what am I building?