instruction
stringlengths
34
36.1k
Say I have this reasonable contrived situation: public class Toast { public bool Toasted { get; set; } public int MinutesToHeat { get; set;} } public class Toaster { private Heating _heating; public Toaster(Heating heating) { _heating = heating; ...
When we determine names for the variables, there are two important issues that the people mention: The variable names must be explanatory. For the sake of this, their names can be long.` The variable names summarize main purpose briefly; they cannot be long. Long names decreases understandability.` Which one of these...
I'm trying to decide which is the best architecture for a turn-based multiplayer game where the players can be either humans or AI and the UI is optional, for instance because the game can just be used to make the AIs fight against each other. Let's take the simplest possible game out there, tic-tac-toe, and I used a c...
ls and objects functions are both from the base package and are exactly the same as discussed here. I've seen other examples of duplicated functions (in the tidyverse and base if I remember correctly). To me, having this type of functions juste make the code less clear by introducing more and more functions. I don't se...
Reading the final chapter 6 of the paper "The Many Faces of Publish/Subscribe" I stumbled across: Decoupling is a desirable property because it enforces scalability at the abstraction level, by allowing participants to operate independently of one another. At the implementation level however, scalability remains a sen...
We are creating several websites, the main content will be the same across each of them but there will be some differences (e.g. extra button, extra texts, different styling) what is the best way to manage this in git. there will end up being around 30 sites and we want a way to be able to easily change something acros...
Here's my setup: Entity Framework Backend Large WPF project that has a main window with 3-4 user controls on it, each of which has 3-4 user controls on it (and so on, in some cases) What I currently have: public class MySettings { public string Property1 { get; set; } public string Property2 { get; set; } pu...
I've been using git for a while, but still do not understand how to deal with feature branches. When you develop in a feature branch in a strictly local manner everything makes sense. You commit, merge upstream, rebase on master and finally push everything. Things change with feature branch being pushed to a remote ear...
Do we have pattern, which is opposite to Template Method? I mean, in base class we define parts of algorithm and abstract method which implements algorithm. Then in derived class, in that abstract method, we can mix those parts as we want.
I'm adding admin dashboard to a website that doesn't use HTTPS. For now only that (admin) section requires user authentication. If I use encrypted + salted password and check the client IP address to allow only couple of IP-s to be logged in, will it be not secure enough? Can the attackers imitate the client IP addres...
I have two Microservices A and B. B Microservice has a large set of an entity called User. A Microservice stores the User entity in its own DB if User is configured by an agent. There is no flag available in Microservice B's DB to find if the User is configured. I want to find all the list of all unconfigured user ...
I have an Angular application with a table, and I'm considering having the console application take the name of C# programs that the user can run. I was thinking of passing the name or code of the console application to a ASP.NET WebAPI controller that will run the console application. However, I'm not sure if it's...
Generally in procedural/imperative languages, it's best practice to place variable declarations as close to usage as possible. This seems a little hazy in lisp, considering more code is used if there are separate lets. Given an example function using two lets: (defun draw-box (new-image corners) (let ((h-len (- (alas...
My question is in the header. I would like to know is there architectural solution that enables to perform nested transactions on the business model. Let me to explain - the standard flow for web service is validate input data process request persist results write response However, there are cases when i Can not vali...
In Laravel (for the record I'm using v5.6) there is an option to queue emails for background processing. I have a scheduled job to send out daily email alerts to users. Currently the job drops the emails (mailables) in the Laravel database queue and I use the Mailgun driver for sending out emails. My question is Mailgu...
Is it better for an API when it provides additional methods that check if something exists before adding? For example: if (!userManager.HasPermission(user, "somePermission") userManager.AddPermission(user, "somePermission"); versus userManager.AddPermisionIfDoesntExist(user, "somePermission"); If you use this HasP...
I'm trying to redesign a provisioning application that administrates other application through their REST API. The application is quite simple, we have groups, we have users and roles and we have a list of software to provision. We are giving access to some software to groups and we are applying different strategies to...
I am currently working on a project where I need to manipulate a tree-like data structure, which I implemented with a composite pattern. I want to be able to do different actions on this data structure, so I implemented a visitor pattern. I was starting to see some code duplication in between my visitors, so I decide...
I want to implement two methods: AddPlayers and AddPlayer. Is it better when AddPlayers calls AddPlayer or AddPlayer calls AddPlayers with a single item array? Is there a significant difference in performance and IL output? // AddPlayers contains the logic void AddPlayer(Player player) { return AddPlayers(new [] { ...
Many systems that store data in a structured manner (although this is marked language agnostic, the origin of this question is an MS SQL database) struggle with duplicates. Taking a physical person/user of a system as an example, I'm trying to figure out how to develop a strategy to reliably identify new data entry as ...
When you have a method that is doing stuff and changes occur in the parameters, should you always return the changed object like this: public SomeModel DoSomething(SomeModel someModel) { [something made changes to the model in here] return someModel; } This way when someone reads the occurring line when the method w...
I inherited some projects in which secrets were in source control in App.config and similar files. Fortunately it's not a public repository so the risk isn't as serious as it could have been. I'm looking into better ways to manage this, such as Azure KeyVault. (But I don't intend this question to be specific to that so...
My team and I are integrating with a 3rd party company and using their API to perform different CRUD operations. Their API isn't always reliable though. Maybe 0.1% of the time an API call just fails with a 500 error, and then when you try again, it works fine. Occasionally, they will have times where the API call fails...
The company i'm working for it's rewriting a legacy web application and we are evaluating the better architecture to get the job done. The business domain is quite simple: there are few entities, few relationships and simple business rules. We expect a low number of concurrent writes, but a huge number of reads: the e...
We have an Accounts table in a Postgres DB that has a unique index on user_id and product. Users can have many accounts, there's no product table. Occasionally users will create an account accidentally, and we will need to add that account back to their original User record, after they've collected some information on ...
i’m working on a project where i’m using SQLite and where i have a few relation tables looking similar to this one: CREATE TABLE tag_entry_relation ( id INTEGER PRIMARY KEY, tag_id INTEGER REFERENCES tag(id), entry_id INTEGER REFERENCES entry(id) ); I know that the two “referencing” columns will together be unique (so...
My registration system normally asks for 4 things: The user's full name, their email, their preferred username, and a password. I want to add four oauth2 registration services to make it easier and faster for users to create an account. I can see three methods for doing this, or maybe there is something more elegant I...
I work on applications that have user documentation but it is not organized or updated to the current release. Is it worth my time to create my own documentation with screenshots and notes on all the current business operations that can be performed with the product? I feel like this is useful in that it formalizes the...
I know there's a proposal for params IEnumerable<T>. When designing an API, when should we choose params T[] (params array) over IEnumerable<T>. Or should both be implemented for better end-user experience? Example: void MyCoolMethod(params string[] strings) void MyCoolMethod(IEnumerable<string> strings) When using pa...
I am trying out F# for the first time with little prior theoretical functional programming knowledge. I have written a small function so calculate simple moving average on a list. Here it is: let rec sma n data = let length = List.length data if length < n then data else (sma n data.[..length-2]) @ [List.average...
I am trying to understand the architecture of the system described in this patent about aggregating and analyzing confidential data: https://patents.justia.com/patent/20180089196. The general schema shows three different backends in this system: Confidential data backend, Backend queue and ETL backend: Why are ther...
I know that integration tests test parts of project that interaction with each other somehow. And I need to test this interaction. And there is the question: 1)Should these tests use real database data? I mean I'll have to connect to a real database? 2)I suppose I cannot use common database, I should use my private da...
There is what we call feature branch in git. Imagine for example I am making a game and I need to add a Power-up feature. How I see my commits names with feature branches: Branch name: Adding Power-up. First commit name: Added prefab. Second commit name: Implemented graphics. Third commit name: Added collision detecti...
I am working on an app that will run queries and return results to UI. However, these queries can take a long time to finish so I should not wait for the result. As far as I know, people use task queues in this case. My question is when task queue returns the result, how do I send the result to UI since the http reque...
I'm working with ASP.NET core web API project, where I have 8 controllers, multiple DTOs being used for request and response and mappers to map models(also used in the web app) with DTOs. Recently, we have started with versioning, for that, we're referring to the best practices: API-Version-Conventions. Here is the pr...
I usually define my repository interfaces at Domain Layer with DDD. Given that the UI needs to display some paged data I thought that adding params such as currentPage, pageSize, and define a model PagingResult at my domain layer have not to do with domain itself. This is the method signature: PagingResult<Customer> Ge...
What time complexity would you classify the following as having? int n = 100; for(int x = 0; x < n; x++) for(int y = 0; y < n; y++) for(int z = 0; z < n; z++) DoWork(x,y,z); I don't think anyone would argue that it's O(n^3) Now consider a scenario where the bounds for each dimension are provide...
I have two ideas on how to proceed with an availability class but I'm not sure which one is better. public class TimeRange { private Timestamp startTime; private Timestamp endTime; public TimeRange() { //set defaults } // appropriate getters //setters public void setStartTime(Timestamp startTime) { this.startT...
When creating a web application from scratch with ASP.NET MVC Core (using Visual Studio 2017) and using Vue.js, is the MVC Core part of the application solely for the API? What other function would it have other than allowing Visual Studio to use the Task Runner? Update: When I create an application with Vue using Vi...
I tried this way to define custom defined property but I wonder how to handle if any of the dependent properties have null value. public class ObtainedMarksDetail { private decimal? _percentage; public decimal? TheoryTotal { get; set; } public decimal? PracticalTotal { get; set; } ...
Say I have this structure: project/ node_modules/ xxx/ asset.js index.html app.js and in app.js I have: const express = require('express'); const app = express(); app.use('/docs', (req,res) => { res.render(require.resolve('./node_modules/xxx/index.html')); }); app.listen(3000);...
So I noticed it's possible to avoid putting private functions in headers by doing something like this: // In file pred_list.h: class PredicateList { int somePrivateField; friend class PredicateList_HelperFunctions; public: bool match(); } // In file pred_list.cpp: class Pre...
When I call paid() on my aggregate it sets all the properties internally that need to be changed based on this action. But at this time the change has not been saved to the DB, so I can't reliably trigger the Invoice.paid event yet. Do I get this right that I need to use another object, like a domain service to manipul...
The goal is to provide a scaleable system implementing multiple data processing tasks which can be seen as a graph. Data objects will travel that graph. Most object will visit the same nodes in the same order, but depending on the data object properties, the order as well as the included set of processing taks can vary...
I'm experimenting with Clean Architecture for my turn-based strategy game project. I have use cases that form hierarchies and need to be coordinated with each other. I would like some advice on how to design these interactions. Example My entry point to the game is the TurnUseCase. It gives information about the curren...
I have an web app to which external applications can be connected to send their data. This is for telemetry purposes. The web app is not controlling what kind of telemetry data is sent to it - it can be anything in a form of a Dictionary<string, object>. I intend to store each key of this key value pair as a separate r...
In our team, we separate the UI logic from the Activity or fragment by creating a new class for the view and let the Activity/Fragment manage the Life Cycle only is this good practice or not? public abstract class BaseView implements ViewInterface { protected View rootView; protected Context contextInterface;...
This question continues on a previous question asked here about continuous integration for scientific software. Like the poster of that question, I am developing software for numerical simulations and I am in the process of applying continuous integration (CI). My main problem is that I have tests that are used for ver...
I am using the Azure AD authentication provider for the asp.net web application and I wish to add extra role claims (based on custom application logic, those cannot be provided from Azure AD). Something like described here: https://joonasw.net/view/adding-custom-claims-aspnet-core-2 I am using the following code in the...
I need to make a sponsorship system with complex business requirements. Basically, after a user makes a payment, the system should get triggered. There are many different types of sponsoring, so I found abstractions to make my life simpler now and in the future. To use polymorphism, I first created an abstract class th...
Here's what I mean: class MyClass { int arr1[100]; int arr2[100]; int len = 100; void add(int* x1, int* x2, int size) { for (int i = 0; i < size; i++) { x1[i] += x2[i]; } } }; int main() { MyClass myInstance; // Fill the arrays... myInstance.add(myInstance...
To automate tasks, I have only heard of people using scripting languages. Why don't people use compiled languages to automate tasks? What can scripting languages do for automating tasks that compiled languages can't? EDIT: Let me be clear with these phrases: By a "scripting language", I mean a programming language such...
I am writing an article about traditional REST vs GraphQL. However, after doing some research about REST (not just a specific implementation of REST), I started to see that GraphQL actually abides to the same rules as REST, with 1 minor exception. IMPORTANT: I am talking about the actual REST specification. I am not ju...
What architecture design is used to create a virtual queue? A virtual queue, virtual waiting room, or virtual line can be described as: An online queue system that redirects excess end-users to a virtual waiting room environment and passes the end-users back to the website or app in a first-come, first-served order. U...
I was told most modern computers follow the same floating point standard, does this mean they will all get the same float answer for a given math operation if the inputs are the same? I ask because i am researching into making an RTS game on a network, and syncing hundreds of unit's positions sounds like a bad way to g...
I'm a self-taught Engineer, a beginner in Java and I am trying to create a Dungeons and Dragons character creation module for a bigger game to solidify my understanding of core concepts while learning best practices for given scenarios. I have an implementation outline below, but I believe that there are better design ...
REST principles are described here: https://www.ics.uci.edu/~fielding/pubs/dissertation/rest_arch_style.htm#sec_5_2 https://en.wikipedia.org/wiki/Representational_state_transfer#Architectural_constraints https://ninenines.eu/docs/en/cowboy/2.0/guide/rest_principles/ An aspect of REST I am confused about separating RE...
Our call center collects requests from customer, which are processed by back office. Much of the requests are passed in spreadsheets by type of request. In view of automating some work of back office, I want to model the current situation. How do I proceed? Do I model the call center as an actor, and the describe spre...
Is this a code smell? I have a repository which connects to a SQL server. This repository uses Dapper to map the results to an object. I have a method in this repository that checks a result, then passes a bool back on whether the result passed a test. Since I don't want to use the results of the SQL query outside of t...
An increasing amount of effort is being put in keeping company code "boilerplate" header up-to-date according to classifications and templates from an external application, leading to "source code changes" and retesting because of updating tens-of-thousands of files' copyright. And now and then the license template cha...
I am building a website and along the way I have come across a lot of things I didn't know about and was hoping to get some help in understanding some of them. I started building a website using Flask and the Jinja templating language. This was very intuitive and easy to understand: client makes a request, server check...
How do I have to design my classes and their methods, so that it is clear, that certain method calls have to be made before others are useful/valid? Stage1 firstStage = StageProcessor( userOriginal ) Stage2 secondStage = firstStage.ApplyRequiredTransformationBeforeSecondStage() UserResult result = StageProcessor( fi...
I have recently looked at some Web APIs provided by well known companies' e.g. this one by HSBC: https://developer.hsbc.com/swagger-index.html#!/Products_Commercial_Credit_Cards/get_open_banking_v2_1_commercial_credit_cards/v2.1 I notice there is domain logic contained in the JSON returned by the web api. For example;...
In Elements of Reusable Object Oriented software by Erich Gamma, the intent for Command design pattern says: Encapsulate a request as an object, thereby letting you parameterize clients with different requests, queue or log requests, and support undoable operations. What does the author mean by undoable operations? H...
I have this web API project which handle all database access via entity framework. I have another web client reside in DMZ to call those APIs (via ajax or c#) in the web API project. When I make API call via c#, models passing between web client and web API are the same. For web API, the model is generate by entity fr...
I have a MySQL database and I am working with Core PHP. What is the best practice in terms of accessing the database? Should I create functions in MySQL and access them in my PHP-code OR write inline queries from code directly? Let me know if you need any additional info
I have a python CLI tool that my department uses to process some excel file aided by a yaml. I tried to diagram a basic work flow here: Step 1: User downloads a xlsx, puts it in a file, runs tool --preprocess which takes some inputs A, B, C, and the file name. This step doesn't do anything, see my question below. St...
Currently we are designing a system where a user can comment on multiple subjects. Subjects can be a picture, a post, etc. A comment should be editable and deletable. It would just contain text (for now). A comment can only be placed if the subject allows it. On the first hand, I would model it as follows: | Comment (...
Consider these 2 types of implementation: public int add(int x, int y) { return mysteriousAdd(x, y); } public int add(int x, int y) { int output = mysteriousAdd(x, y); return output; } A colleague of mine says that second implementation is better because during debugging we get to see the variable that m...
I have real-world materials that are defined by various properties, some common, some not, that I would like to map to objects in C#. For example, Concrete has properties A, B, C, and Metal has properties A, B, D, E. This looks like a textbook case for class inheritance: class Material { public double A { get; set;...
I am tasked with an animated graph based on a timeline, and I am having trouble finding a suitable data structure and/or algorithm that's reasonably efficient. I have a working system suffering from performance issues the larger my data set becomes. Let's say I have a set of people in an array [Bob, Jane, Kevin, Alice,...
I have an event handler that creates objects for which it needs data from both before and after an event. The event handler itself implements Selenium's WebDriverEventListener interface and gets registered accordingly. That is, I have no control over how the class is being invoked. In order to create the objects, I use...
When it comes to organizational structure in an agile context, many people claim that feature teams are generally a better choice than component teams. This at least is what I find when discussing with colleagues, both in my current as well as in my previous position. Also, Larman and Vodde argue vehemently against c...
I do not how to ask the question, but I am confused by how to manage sessions when the server is at local host. Accessing the database direct Without a middleware (REST), sessions are created as soon as you connect to the database. Even 2 connections from same computer gets 2 separate sessions. Accessing via REST and ...
It is a Design Problem which I am listing out here. I have multiple event sources in my app, each one produces events with the different set of data (but each source is producing only one type of event). On the other side, I've got multiple actions, that can be triggered by sources. Sources and actions may be extended ...
I found an inheritance tree in our (rather large) code base that goes something like this: public class NamedEntity { public int Id { get; set; } public string Name { get; set; } } public class OrderDateInfo : NamedEntity { } From what I could gather, this is primarily used to bind stuff on front-end. For me,...
I'm writing up this website running under IIS with .NET Core. I developed most of the site with minimal use of JS so that the server will be doing most of the work (and thankfully so because of the issue I'm having). One of my functions calls the Javascript .includes() which is not supported on IE11. There are workarou...
I'm confused as to how to properly interact with my Postgres database throughout the typical user experience on my web app. I'm seeking clarification on the most efficient method of communicating with the database, without over-communicating (spamming). Currently I use org.apache.commons.dbcp.BasicDataSource to connect...
I have reading about mutation testing and even though its inner functioning or how to do it is clear to me; I am having some troubles to understanding the relationship between a program that wants to be tested and mutation testing. I have been reading material about this subject, but still is not so clear for me. For e...
I am writing a piece of code which takes the difference between two numbers, finds that location in memory, and then sets the location to true. Currently my method of performing this is as follows. Note the function i_jlocation just does the comparison. #pragma omp parallel for collapse(2) for(int particleRow...
What is the Agile philosophy around the criteria for a groomed story and Tech team responsibility? (I deliberately phrased the explanation as antagonistic for the sake clarifying the opposing viewpoints.) The user-experience designer (UXD) develops wire frames for an epic (say, filling out a form). UXD considers all as...
I'm working on a React/Redux application. I receive a data object from the api resembling this: const dataObj = [ { id: 1, name: "Filo", activity: 9, info: { statusCode: 4 } }, { id: 2, name: "Spot", activity: 8, info: { statusCode: 2 } } ]; I have to run the ...
I'm the technical lead for a small company (6 developers). We currently use SVN and we're slowly porting over to Git, after everyone gets their training. Currently our clients are the ones who "pull the trigger" on branch integration. Meaning that some module or feature is built and then, that feature sits in a branch ...
I found information that the best way to update ranges of array values is using difference array. It works but I can't figure out why it works. Can anyone could explain it for me?
I build and run many Electron apps on Windows. I noticed that all of them have the same common api files / libraries to run. They all take about 30mb of space. I'm thinking of installing these files in the system, maybe moving them to system32 folder or the GAC, and then removing them from all my electron apps. I would...
How could you determine if a collection is implemented as an array or as a linked structure without access to the source code (assuming you can run the code)?
I have two classes, let's call them Foo and Bar. They both extend different classes (Foo extends X, Bar extends Y), which have some common ancestor "way up" the inheritance tree, something like this: Both Foo and Bar have some common class members (and some more members which they don't share), and I would like to imp...
I have a program which perform different actions depending on the plugins that are passed. For example, python main.py -m foo -m bar will perform the actions of foo and bar. The structure of the directory is: ├── Dockerfile ├── README.md ├── docker-compose.yml ├── entrypoint.sh ├── modules │ └── foo.py │ └── bar.py...
Usually method overloads delegate their parameters to the more detailed overloads with default values. here is an example A(x) => A(x, null); A(x, y) => A(x, y, null); A(x, y, z) => ...; What should I do if i want to override this method and do a little modification before calling the base method? If I override only ...
Currently we manage our source code in a Microsoft Team Foundation Server project. We have the following branches: Development Feature 1 Feature 2 Etc. Test The process is that development is either done in the Development or a separate feature branch. As features and fixes are completed they are merged to the Tes...
How would I go about prompting user-input, while at the same time running timers, to periodically execute automatic functions. Pseudo-code to illustrate: while true { if input() OR timer(10) { if input() != Nill { execute input.value } else { ex...
We are migrating a desktop application into web based Spring Boot micro services application with a client imposed mandate of using their existing MySQL database, so all micro services share a common database. Since its a SQL database we chose Spring JPA (Hibernate). During project setup, our architecture team generat...
Basically we should depend on abstractions instead of concrete classes, that's the Dependency Inversion main principle. interface ITest { void DoSomething(); } class TestImpl : ITest { public void DoSomething() {} } class UseTest { private ITest _test = null; public UseTest(ITest test) { ...
we started a new project in which back end consists of several layers (each in different project). For simplifaction I'll define a few: Project.Data -data layer with access to db Project.Repository - repos Project.Repository.Interfaces - only repos interfaces Project.WebApi - API Our team leader proposed we should b...
When I read about sets in Python, it is always mentioned that they return items in an arbitrary/random order. What exactly causes this "randomness"?
At work, we are creating an android app. We have a business logic module for talking to an API for CRUD operations. The app I'm working on, the UI module, speaks to the business logic module to create, update, delete and get entities. These entities can be in various states (not started, awaiting, started, ended as wel...
I was in #Qt irc channel, and I showed a small snippet of my code in a style that I heavily rely upon. It looks like this: /* Get Reply from Server */ QPointer<QNetworkReply> reply; { QEventLoop waitForFile; // A QObject connect(&m_NetworkAccessManager, &QNetworkAccessManager::finished, &waitForFile, &QEventL...
I'm looking to improve the processes in our team. We currently are pretty informal: "I've finished feature X. Can you review my code?". This is not scaling up well now that we're busier - it's hard to remember whether a feature has been reviewed or not. I'm familiar with using pull requests for code reviews when peo...
I am reading Refactoring by Martin Fowler, and working in the patterns suggested into my coding. This has caused me to put up two code reviews for my service which are significantly lengthy, which are just refactoring code reviews. It is challenging for my reviewers to know what I am doing even though I have littered t...
I'm a newbie with respect to git, but not to version control in general — I've been using CVS and Subversion for years. I've read both the Progit and O'Reilly (Version Control with Git) books, and I think I've got a good grasp of the general concepts. I'm trying to set up git for an existing project, and I'm running in...