instruction
stringlengths
34
36.1k
There is this article that says: A Composition Root is a (preferably) unique location in an application where modules are composed together. Only applications should have Composition Roots. Libraries and frameworks shouldn't. A DI Container should only be referenced from the Composition Root. All other modules s...
I am currently developing the backend for a news application, which fetches news from various aggregators (e.g. Feedly). I thought this qualified as a good use case for the adapter design pattern, so here’s what I did: I created a configuration file that houses all the relevant information about each aggregator, includ...
Once written, a protobuf specification can be compiled using protoc to a variety of implementations in different languages (e.g. python, c++, go). That's great. But to compile that generated code, you need a protobuf development library and, if I am not mistaken, a runtime is required as well. Is there a way to generat...
I have a product which is a combination of mobile apps and webapi . I am working web API. The webapi part created earlier and it build with layered model. Even thought this does not have a business layer (API and Data access), each one created as seperate project in the solution. Now I just optimized the code some leve...
When an android device enters sleep mode it is know that cpu sleeps. That means that, services, threads are paused and everything sleeps. Is that true? In case it is, what happens after the device is awaken? Threads continue from where they left off? E.x if a thread reads from a database and device enters sleep mode(s...
I started reading the book Clean Code by Robert C. Martin and at the start I found this idea of his interesting, "Leave the code cleaner than you found it" adapted from the "Leave the campground cleaner than you found it". Now at my work in our code database I have this getter function in a class that gets a boolean va...
I have a ratings web app where I want to output the average of all the ratings. How I'm currently doing it is recalculating the average every time a new review is posted and storing that in a database table, and every time someone lands on that page, I retrieve the value from that table. Is there a better way of doing ...
This question is not specific to images, but this is the current issue im having so im using this as an example. So basically, I have some kind of a pipeline that some data(in this case, an image), has to go through before It can be used in my app(in this case, a web app). If we split the pipeline into functions it wou...
I have two paths: /students /students/{id}/addresses ...with the following behavior: POST to /students - 201 Created (if successfully created the Student) POST to /students/{id}/addresses - 201 Created (if successfully created the Address under the requested user) Now, imagine a situation where the client POST to /st...
The Scrum guide defines the Sprint Goal as: an objective that will be met within the Sprint through the implementation of the Product Backlog, and it provides guidance to the Development Team on why it is building the Increment. However, I am a bit confused about the proper understanding of what is the Sprint Goa...
I am confused about the two following statements and how do they both influence on which items be included into the Sprint backlog: The Sprint Goal and Sprint plan is produced by the collaborative work of the entire Scrum Team. The Product Owner builds the order of items in the Product backlog in order to best achieve...
When writing tests I usually ignored logging statements, but now I wonder if it was right. The logs are often important tools when diagnosing production issues, moreover there can even be requirements for logs, like "log every interaction with external system, including request and response on highest detail level" or ...
I am tracking the position of characters on a 2D grid (this is a computer game). At every step each character can attempt to move (stationary, up, down, left, or right). There are some rules that govern what moves are allowed. Example: Characters cannot move outside the confines of the grid. Characters cannot pass thr...
When building a standard web Apis in Java world there is two ways I could do nowadays Use SpringMVC (Not Reactive) Use SpringWebFlux (Reactive) There are few benefits of using Reactive that I can think of It uses less memory resources as there is less thread running (maybe better for a container based deployment) It...
In scrum, do you reserve any extra story points for tasks that weren't part of the original estimate, but my come in between the sprint like any technical dependencies?
I have a developer who is developing an ASP.NET Web application for me and I've been publishing it so far on my server, example1.com, so far without any problems. It is managed with a single Git repository on Bitbucket without any hassles so far, when he adds new features, I can easily fetch & pull the changes, and the...
I'm developing an application which has a 3D room. Each room is a 3d model and can contain media boards. each media board contains image(s) as slides or video. I have created following Data Models : class Room { string id; string room3dmodellink; List<Mediaboards> mediaboards; } class Mediaboard{ string id; strin...
The Nexus Guide states that: A Nexus Sprint Backlog is the composite of Product Backlog items from the Sprint Backlogs of the individual Scrum Teams. However, trying to build an analogy between the regular Sprint Backlog and the Nexus Sprint Backlog, I got confused about the following aspects of this artifact: Does...
I am working on a machine learning pipeline where we have to compute certain measures on streaming data. Every day, new raw data enters our pipeline. To update our features, we have to run an ETL that loads the entire raw data and recomputes features. I'm looking for a framework to think about how we can incrementally...
When a user is able to perform an action only once a day, for example getting a free ticket for a competition, there are two possibilities I came across in my experience. 1) 24 Hours Reset If he performs the action on day 1 on 11:45 PM, he can only perform the action again on day 2 on or after 11:45. He won't be able ...
In the Clean Architecture, Uncle Bob defines Entities as enterprise-wide business rules and Interactors (Use Cases) as application-specific business rules. Also, he describes that Interactors are responsible for the "dance of the entities", and in the diagrams the Interactor -> Entity relation is shown as direct, witho...
I'm working on a Java reverse engineering project, where I am analyzing bytecode and trying to identify classes, methods and fields using the ASM framework. After identifying these I transform some classes to implement my custom interfaces with, e.g., getter methods. For identifying classes, I have created an abstract ...
Based on the project structure below i will have some questions Domain Layer 1) MyApp.Domain.Entities (DLL) Product.cs PagedResult.cs Referentes No References 2) MyApp.Domain.Interfaces (DLL) IUnitOfWork.cs IProductRepository.cs Referentes MyApp.Domain.Entities 3) MyApp.Domain.Common.Interfaces (DLL) IClock.cs ICrypt...
I am thinking about using Entity Framework Core in a new project. The project has a many to many relationship. Entity framework Core does not allow shadow state entities as described here: https://github.com/aspnet/EntityFrameworkCore/issues/1368 There are two options for the design: 1) Create a CLR type for the junc...
I need help understanding the following text from section 4.2 on this paper: Implementing Fault-Tolerant Services Using the State Machine Approach: A Tutorial Dependent-Failures Output Optimization. If a client and a state machine replica run on the same processor, then even when Byzantine failures are possible...
I have a case where a bug takes more than an hour to manifest in debug mode (and still 20+ min in release mode). Does one know a debugging strategy which can help to reduce the waiting time until a breakpoint is reached in the area of the code which is suspected to contain the cause? I have tried logging and prompting ...
I like to build a component connector view / UML diagram for the given problem but I realized it's way too slow if you try to do it exactly as it's given in the following text. My question is what could be optimized? Knowing this I would create the entire diagram myself. We have 2 teams playing against each other and ...
I think this question can span multiple languages, but in C# specifically there is a clear distinction between a field (ex: private int a;) and a property (ex: private int b { get; set; }). While there is often good reason to choose one or the other, in many cases they can be used interchangeably and they serve the sam...
The application I'm working on has a need to create a counter representing the number of times each piece of content has been viewed. There are two goals here: Update the counter in real time Minimize load on MySQL Currently what we do, is make a cache key in Redis for each piece of content that contains the view cou...
I'm doing an internship into a small company which is working on part of a systems which runs on a base already written by another company (many company are working on the same project) which is basically a 1:1 translation from an old COBOL system into .NET technology. Since they have not been given enough time, they'r...
If there are n variables each with m possible values. (For integer, m is 2 billion something.) First, map every possible value to an integer from 0 to m-1 in order. And define the mapping functions. index(v): value to integer value(i): integer to value Second, loop the n variables and count how many times every value...
I have a use case where my team owns a web UI to aggregate data from 10+ service teams and present it to the customer in order to collect more information . This data (which is in json format) is very dynamic (changes every other day) and is used for building multiple html form pages where customer inputs information e...
In android there are many different implementations for MVP. Most of them favor to use the Activity or Fragment as the view, a few would make them presenters, and even less, would separate the Activity or Fragment from the MVP, and have the classes related to Model, View, and Presenter reside inside the Activity or Fra...
I need to use DispatchQueue within controller and pass it as dependency. This is what I have tried so far and worked out two solutions. Need to ask what is better and in common use by other developers: protocol DispatchQueuerable: class { func perform(withDelay delay: Double, block: @escaping () -> Void) func p...
I was checking this example of Observer Pattern. https://www.tutorialspoint.com/design_pattern/observer_pattern.htm It seems that there is a circular reference when Observer Pattern is used. import java.util.ArrayList; import java.util.List; public class Subject { private List<Observer> observers = new ArrayList<...
i am having a simple app example here: say i have this piece of code which handles requests from user to get a list of books stored in a database. from .handlers import all_books from flask import jsonify @apps.route('/show/all', methods=['GET']) @jwt_required def show_books(): user_name = get_jwt_identity()['user...
I am referring to Robert C. Martins book "Clean Architecture" on the top of page 318. There he states: In the ports and adapters approach, the OrdersService and Orders interfaces have inbound dependencies from other packages, so they need to be made public. Again, the implementation classes can be made package p...
I am working on a Rails application which employs a classic MVC as its fundamental structure. In that structure the controller is supposed to be responsible for "which view to render when". Now after reading a design pattern book I learned about design patterns and, inspired, started looking for ways to use them to imp...
I've taken on a Visual Studio C# project where my previous colleague used a lot of Extension Methods in static classes over multiple files depending on the uses. In my previous experience I would be more selective when using Extension methods but instead use a public static method in a static class. It got me thinking...
I'm developing this Achievement System and it must have a CRUD, that admins access to create new achievements and it's rules. I need some help with the Achievement CRUD data structure. Rules sample Medal one: must complete 5 any courses with a score of at least 90 Medal two: must complete two specific courses with a sc...
I have Java application. I try to realize multiplayer chat with TCP protocol, but I have an issue. I cannot output all messages I get on client tier (server tier works perfectly), because I give an input to user and create a thread to read messages from TCP client, so <Scanner object>.nextLine(); Is blocking an o...
I have an Android application that communicates with the server using REST. During the flow, the client(Android) usually send 3 separate requests to the server with different data. Some of the data sent during the 1st request are also used during the 3rd request. Of course, we don't want to ask the user to enter the s...
I currently use the Google trends API and I implemented a class to integrate with its services. As you probably know, Google trends tracks statistics which will change over time. So, when I write a test now, after some time, it is very likely that my test will break because the statistics will change. How can I writ...
I want to build a web application in Java on Tomcat server (I am open to change the type of server if needed) The requirement for me is for the user to be able to login and download sensitive data (think bank app and downloading of statement). These should be done through RESTful communication. So obviously security is...
I have asked this question on Stack Overflow and I got a suggestion of posting it here for better suitability. So here is my question : I am new to DevOps, and i have a solution with Umbraco as CMS, Mobile App as front-end for the content added in CMS and .Net MVC web API to connect CMS with the Mobile App. I also hav...
Recently, I tried to deploy a web project to a virtual machine. I used the Ubuntu server as my OS, but while following along some tutorials I came to the fact which was very confusing for the beginner like me. I had to install the Nginx server on top of a server (Ubuntu server). I don't understand why I have to install...
Currently i am handling placing my services by their action type like App Services Storage Payments Providers Gateways IpnHandler But i felt like whenever our payment providers are growing i have to check Gateways / IpnHandler. And i felt like payment gateway should only care about payment and its result. ...
I'm already posting this question on StackOverflow, but thought that asking it in different communities might give me different insight. So here's the repost of the question: Hello, I'm having a financial related service that enable our users to topup their balance in our system, and then disburse the money. They'll be...
I want to make an android app that allows you to write scripts to draw stuff. Like text, buttons, images... using opengl. Now, if i have a function that draws an image like this: drawImage( imageSource, x, y, width, height ); What kind of unit of measurement should i use for x, y, width and height? I could use pixels...
I have a method in API handler which does API validation, performs business logic and then makes a call to db. Is it a good idea to move the business logic to utility class or service class? IMO the business logic should be moved to service as utility class are supposed to have methods which can be shared across appli...
I'm in the planning phases of trying to build a distributed file processing system in Java and I'm looking for feedback and advice: Problem : There are a large number of files continuously posted on an FTP server that we need to grab, process and pass on. Solution Idea: A master node will look for new files on an FTP s...
I have created a rest api. It supports multipart/form-data request type. My API clients used to attach content of files in their system to POST request body. It works fine. But recently there is need for very large input files. I think it will not be a good idead to attach very large file in request itself. How do I ...
I'm trying to figure out a technique to optimize bytecode for the following virtual machine: Bytecode is a flat list of instructions, with execution starting from the first instruction. Stack bytecode: instructions like i++, a+b, method calls f(a, b, c), etc. occur on the top 1, 2, N values on an operand stack, and le...
Im confuesd about the usage of std::move in class constructors. I want to pass a value to a class and check in the constructor if a valid value is passed. If not an exception is thrown. Before i used to pass the value by const reference: #include <string> class Foo { public: Foo(const std::string& value) :...
So i want to understand how DBMS implementation works To give an example : MySQL implements each tables with its own pages, which are 16KB so each table is a file, and is a multiple of 16KB, considering how large is it and therefore how many pages it needs Now i read somewhere that these pages don't get fragmented, so ...
I'm writing a small library to open an xml. If reading top level xml element fails, the library throws an exception. However, if reading one of the minor, lower level xml elemetns fail, I currently throw the exception to stop the constructor, but then catch it and do nothing with it, since the error may not be critical...
My team has developed a new service layer in our application. They created a bunch of services that implement their interfaces (E.g., ICustomerService, IUserService, etc). That's pretty good so far. Here is where things get a bit strange: We have a class called "CoreService", which looks like this: // ICoreService inte...
Onion Architecture talks about separating the UI, Service, and Data Layers. All the samples usually given for this involve a single deployment model of the application. For example in .net most of the samples are Web - MVC app Core/Domain - Simple class library Data - Entity Framework What happens if my application ...
I often encouter the following pattern: A bug is resolved/closed as duplicate of another still open/unfixed bug. I have trouble understanding the reasoning behind this strategy. From my naive point of view, there is at least one major downside: there is no easy way to verify that this is really a duplicate. Normally, ...
I have a time-critical function that needs to be executed multiple times sequentially. void task(state_t *state); It uses a relatively large amount of memory, so I figured that allocating it once at the beginning, and freeing it at the end would speed up the task sequence. state_t *state = alloc_state(); task(state...
Apologies if this isn't the right place for this question, please direct me elsewhere if that is the case :) I was having a discussion with my boss who has experience (but not official education) in software engineering about a member-field in an object that indicates whether the object is active. The objects in questi...
Sometimes, I use the call stack as a data structure. I use local variables as elements on the stack and use the data member of a class to store the top element. When I use this pattern, I feel like I'm doing something a little naughty! Here's an example of the pattern. The pattern ensures that break and continue statem...
Suppose there is a reasonably sized programming task(500 lines of code). Which is better? 1/Code the whole task from start to finish without running the code and debug later. 2/Code some small features, then test and debug, then repeat until the whole task is done. Personally from my experience, sometimes the first app...
I have this two use cases in a user registration process : Case 1 : the user register an account online and the system should send him an email notification in order to confirm that his account has been created and validate his email at the same time. Case 2 : the user account is created with an agent, in an sale off...
I have a module with the class Foo. Foo has three methods: The constructor(__init__()) An error handling method (_error_handler()) The method that actually does something. (run()) Then, I have a bunch of helper methods which are actually called by run(). These methods, at the time of this writing, are declared as "pr...
Because the reaction of @DanCornilescu I understood that my question was not clear. That is why I edited the question heavily. I was brought in on a project where there was only one developer. All development was just done on trunk. But they want to change things: They want to work with different developers from al...
I have a mathematical model with two main "stages" 1. data loading (only a few KB of data) and 2. running a model on the data. I want to implement some tests and checks to ensure the data being fed into the model are valid (correct types, correct values etc.) to ensure the model output is correct. At what stage in the ...
I have been interested in parallel computing lately, and I just wanted to check if there's some sort of standard or workflow for designing a parallel architecture. In particular, I am interested in the answer to the following question: If you need to write a code that you know will be parallelized, would it be best to...
I am currently working on a software library that will be used to develop Class Libraries. These class libraries can be run by our application running on the user's machine The application uses the same dlls that the customer uses to develop their library. The user code expects objects of certain types that are pr...
I am trying to analyze blue green deployment strategy to provide zero downtime upgrades for our customers. We have an enterprise java based monolithic web application that uses Oracle as the data store. There are a few challenges that I would like to get expert inputs With every database object types (procedures, tabl...
There are a number of functions of a kind; returning a boolean, and the name always starts with the "Is" prefix. e.g. IsAlive(), IsDead(), IsKeyPressed(), IsKeyReleased(), etc. How do we categorize these kind of functions? Is there a vocabulary for that?
I'm creating a set of Microservices following Event-Driven Architecture using Event-Carried State Transfer to move state from one service to another. Given the following services; Order service Shipping service The Shipping service will subscribe to OrderStarted, ProductAddedToOrder OrderAccepted events and use those...
I have a class that only holds data, specifically Collections of data, it is called *BezierSplineData: class BezierSplineData { public List<BezierSplineControlPoint> ControlPoints; // ControlPoints that can change the shape of the spline. public List<BezierSplinePoint> Points; // Actual points in the 3D world t...
I am a beginner in Ruby and I am trying to wrap my head around symbols. Would you say that my current understanding, summarized in the following (oversimplified) definition, is true for most purposes? "A symbol is a string constant with its name also being its content." And if this is true, why don't we just use string...
I have a scenario where I can take a student Id as input via a part variable and return some data back as JSON objects where JavaScript handles the response as a part of AJAX call. Suppose the method is called like: /student/{studentId} where studentId is a path variable in Spring MVC web service declaration. Now for...
Context: I'm working on an open source project to solve a problem that comes up in ad-tech and social media data mining: indexing boolean expression trees, and matching them against incoming documents. The expression trees that come in from the user need to go through some transformations before they can be inserted in...
I have an application that is modifying some XML files. Two of the files have a similar structure, with similar business logic needed to be implemented on them. I've realized that there are some identical - or near identical - files in their domains aggregate roots. The files aren't value types. I don't see them chang...
I have a legacy class XMLReaderWriter which I think I should break into two classes so that it doesn't break the SRP. Unfortunately the class is already in production and I have to maintain backwards compatibility. What would be the best way to go about this? Any relevant design patterns that I should use?
How do you pass a integer between two process. I'm new to IPC and using pipes I know how to transfer the string between two process. But how can I pass a numbers like that?. I can do this with the string. But is there better way to do this? And how real world product do these things?For Example, chrome browser
I'm working my way through Practical Foundations for Programming Languages but am finding some of the notation difficult to follow. In section 3.3 (page 46 of linked PDF) the author introduces a vertical bar notation that I imagine comes from somewhere in formal logic and I'm not sure how to interpret it. Generic deri...
Say we have a load balancer that also does rate limiting. Rate limiting seems pretty straightforward for logged-in users - just look at the JWT and maybe use an in-memory data-store to see how many requests in the last 10 seconds for that user. However, what about non-logged in (unauthenticated) users? We don't know fo...
Does there exist a Turing complete programming language such that for a fixed alphabet (say, ASCII), every possible permutation of those characters is a semantically valid program capable of being executed? We consider infinite loops to also be semantically valid. I know some data formats, such as Markdown, possess uni...
As a fan of regular types and value semantics, I'm keen on classes becoming more regular and being non-polymorphic. As a fan of non-throwing operations, I'm keen on operations being noexcept. I also appreciate confirmation of what special member functions are actually being generated by the compiler. And I'd like to tr...
I have the following requirement. Read data from a messaging Queue and process each message to enrich the message and then finally send the enriched message to a different system. The enrichment logic is in DB and it is based on message type and each logic can be of different language. Each message will have some type ...
While developing my own logging library, I studied the source code of the standard logging module of CPython. One of its features is that handlers are thread-safe. One can write logs to a file from multiple threads without the risk that the lines are corrupted. I digged into the sources of the logging module and I figu...
Please see the code below; it tests to see if a person with Gender of female is eligible for offer1: [Fact] public void ReturnsFalseWhenGivenAPersonWithAGenderOfFemale() { var personId = Guid.NewGuid(); var gender = "F"; var person = new Person(personId, gender); var id = Guid.NewGuid(); var offer1...
I'm curious what's considered the (best) correct way to pass data to a service layer in ASP.net Core. Say I have a Person entity that has a relation to a Image (profile picture) entity and another relation to a Address entity. Should the signature of the service method look like this: public Person CreateCustomer(Perso...
Keyword-only arguments are arguments that can only be supplied to a function by keyword. In Python they are defined by a single asterisk in a function's signature. For example: >>> def foo(bar, *, baz): print(bar, baz) >>> foo(1, baz=2) 1 2 >>> foo(1, 2) TypeError: foo() takes 1 positional argument but 2 ...
Consider I have a list. I want to iterate over it and map it's elements -- but the mapping might also require to change others than the element I'm currently iterating over. Let's say I have a switch (has a field of list of light id's it controls, and bool field if its switched on) and light (has an id field, and a boo...
I was struggled to find a real-life example of using curry function and get the benefit of using curry. When I google curry function I often see the example like let add = x => y => x + y; let add10 = add(10); console.log(add10(20)); I have to say I really don't see the value of using curry in this example. After read...
I have a service that runs queries on a database and gets (potentially) large number of rows. I also have services that can export a given set of rows to csv, xlsx or pdf etc. I have separate export services to leverage language capabilities, for example, java has a better xlsx exporting library. What is the best archi...
I had a question for separating my python project files. What is a difference between "resource" and "source" in programming? When I should use "resource" separation and When I must use "source"?
When optimising for speed, profiling first can help focus the effort on the parts of the code that bring most benefit. Since speed can be measured objectively, the benefit can also be measured objectively by profiling before and after making a change. Is there any analogous approach when optimising for readability? I'm...
Say we have an imaginary system managing purchases made by customers, and there are the following business rules: You can only buy a product if you have enough money on your pre-paid account You can deposit any value to your pre-paid account If you buy a particular product for the first time, you get 50% discount Fir...
We recently started using agile methodologies at my company. Because I am quite new to agile, I wonder if our way of implementing it is correct according to the basic principles of agile. Previously, we had roles such as business analyst, QA tester and software developer. But now management has decided that these roles...
We are working with the design of the software. It is piece already working developed from scratch again. My managers are telling me to draw the business processes. I doubt in this due the fact that I know this piece already and I can start the design and prototype development immediately. Do you see business process ...
I'm a hobbyist developer of 16 years and would like to start contributing to the ChromiumOS project. I have extensive experience in developing for mobile and embedded devices, so my skill set is mostly limited to interpreted languages, with only enough low-level coding experience (C++/Obj-C, not C) to have gotten me th...
I am looking for a git branch management model that would be used easily and would allow for Continuous Integration/Delivery. Imagine I have 3 environments: prod, uat and dev. The code repository includes source code as well as infrastructure as code files (in this case serverless.yml) I would like to use semantic vers...
On public clouds like AWS and Azure, each account/subscription can create a certain amount of public IPs. I wonder if I can use up all IPv4 IP addresses by creating a huge amount of accounts/subscriptions, given that I do pay for that.
I have a UNIQUE TEXT column (“name”) in SQLite for one of my tables (let’s call it “table A”) and i’m considering using that column as the key for the table The reason i can see for continue using a standard “rowid column” (integer with autoincrement) is that the name could change and in these cases i will have to upda...