instruction
stringlengths
34
36.1k
I have REST API for my SPA application. My domain model has Order entity, it has Commission property which calculated on backend, it is number value For get Order entity SPA calls this endpoint, this endpoint returns saved order GET /api/orders/{id} This endpoint returns basicly filled model for new Order GET /api/ord...
I have some values and methods to define in a scala object. I do not know in which order I should define them. Is there a "good way" to do it? Such as private methods first then public methods? Only alphabetically ordered?
I got confused with the role of the Messenger in MVVM. I see contradictory articles about it. This Article by MSDN by: Communicating from the View-Model to the View Observant readers will notice that Figure 1 has one arrow missing: in this figure, there is no way for the View-Model to communicate with the view. ...
TL;DR: what do I call a section of code that is used to assemble a Graph object? I have a fairly large section of code that is duplicated in a few areas. I wish to extract it into its own class. What do I call this class is my question. The section contains code like this: /* * First Graph */ $flow_...
An application I'm currently working on in our front end we currently use React, Redux and some singleton services (wrappers around some 3rd party libraries). We started discussing a new feature which we need to develop which involves non-changing data (as far as we can see) as it is set when the app is initialised, va...
I have a server which is exposing API through REST. I need to implement a simple Heartbeat service to monitor this server status and availability of API. The interval of Heartbeat check will be every few seconds, like every 3 seconds. Is it good enough to just define a REST end-point (say ping) which will return the st...
I was going through the traditional quick sort algorithm. I had a look on the partition algorithm in a couple of places and the implementation difference was very subtle. Here are the 2 approaches: Approach 1: Pivot is last element partition (arr[], low, high) { // pivot (Element to be placed at right position) ...
Can't figure out how. 1) Resource identification. How do I identify the resource? Something like this? /latest_news/<id> That doesn't seem right. 2) Now suppose you have a URL for the resource latest news. Now each request for the same URL may give you a different representation. Does it violet any constraint of REST...
I'm implementing the onion architecture with webapi, service layer, repository, unit of work and the domain classes. I use also DI, using simple injector. But my issue, is how can I implement a specific use case. The webapi should have the ability to receive a batch of files from the ui. After they are received they ...
This might be a bit of a wide question but I want to understand if it's the correct way to do it. Assume I have a couple of classes all doing operations on an object. First class takes the object, does some operations on it; after this seconds class takes it and does it's own operations and so on. Each of these classes...
Changeability is a quality attribute of requirements that is emphasized in some classic literature. To get changeability of requirements, they must not be redundant. However, when dealing with requirements in Scrum, some practices will inevitably lead to redundant user stories. For example, if a software shall have a n...
We have been thinking about comparing product size/effort at least roughly and this is what some suggested: There are multiple products, each with one scrum team All the scrum teams estimate their stories relative to a common reference story. Therefore, e.g. in Project A, they look at their story and estimate it as re...
Based on this question about the correct usage of nUnit's TestCaseAttribute, I was wondering whether to specify the test case directly on the implementation or create test methods (as when using explicit Assert.AreEqual etc.). In the following, I specified examples for both approaches and also listed potential argument...
I'm working as a support engineer, having access to the source code, and I'd like to use this opportunity to document the source code, but I stumble on a first question: how do I even start? For single-threaded applications, this is simple: using a tree structure (main() function calls some subfunctions, calling subsub...
I have joined a team working on a large and mature responsive website (using a javascript MVC framework), and one thing I frequently see in the codebase is branching code in controllers or components checking whether we are in Desktop mode or mobile mode before doing some action. In some ways it feels like two separate...
Is there anyone who can explain the relationship between customer, users, and the company ? As far as I understand, the product is used by the users, and before that product is designed, the users list their requests for that product. This is called user requirements. The customer is responsible for constructing a nego...
I am working for a company which has an abundance of Word and Excel files festering away in the depths of their file server, probably like most other companies. The problem is that each of these files contains nuggets of information that at the very least would give some valuable insight into past performance. There is...
I've been developing several front-end web-applications recently that bind against a database using a RESTful CRUD api. I've noticed a massive amount of boilerplate code going into defining the API. For example, on the back-end I define a db-schema, controller, api endpoint, and view-model. On the front-end, I expose...
I am trying to understand how I can make the code for this easy to understand and debug too. The reason I'm asking is that it feels like the kind of scenario which has probably been tackled before plenty of times. And if that is the case I would like to use that as a solid starting point which will allow this to be e...
It is generally understood in software engineering that global state is bad. However, OpenGL has been designed very much embracing the concept of global state. many of the things you modify will affect everything in your program (active shading program, uniforms, active buffer, glDepthTest...) Because of this, I ended ...
I'm trying to make an abstract board game. In the game, a player can choose to make multiple actions within one turn such as placing, moving, or rotating a piece. I'm not sure if whether or not my implementation is bad. I was told by my professor that using instanceof and if statements like this is a sign of code smell...
for example, sometimes I need to define a hardcoded string with some variable parts, I often have trouble to choose the style: style 1 : reuse every characters when possible showMessage(num){ let strArr=['Mon','Tues','Wednes','Thurs','Fri','Satur','Sun']; alert('Today is '+strArr[num]+'day'); } style 2: Keep the v...
For example, I have multiple projects which shares some common libraries: ProjectA CommonLib1 CommonLib2 ProjectB CommonLib1 CommonLib2 At the moment, they are all in one big repository: ProjectA ProjectB CommonLib1 CommonLib2 However, I think it is better to have one repository for ProjectA and ProjectB. But...
I have a situation on the front end where a user clicks on “Download” button and the query behind the scenes is going to take over a day. I have a Spring boot web app running as far as web services are concerned. What I want: When the download button is clicked on the front end, I would like to put this process in som...
When I think of software configuration, I think of a file that is read by runtime - said file would contain things like the port a server might use, whether to use encryption, and paths of various resources. When I first came across "Software Configuration Management", I thought it meant the management of configuration...
I'm trying to implement authentication and session management for a microservice. In order to do the process RESTfully, I understand that I'll need to use some kind of token-based authentication to avoid tracking client session data on the server. The following quote from this answer on the Information Security Stack E...
I am evaluating an open source CMS called Piranha (http://piranhacms.org/) for use in one of my projects. I found the following code interesting and a bit confusing, at least to me. Can some help me understand why the class is inheriting from a base of same type? public abstract class BasePage<T> : Page<T> where T : Ba...
Trying to figure out which structure is cleaner between using a specialized function or using parameters to accomplish the same thing (see code example below). Essentially, I can reduce the number of abstract methods in my interface by adding parameters (as in the BufferParameter case). If the methods themselves got to...
Our previous developer set his name in the license of our open source project. Thats how license header looks: Copyright (c) 2018 (his name), Stichting (our company name) <(his email)> Can we change that to our company name?
I'm writing a project for school - Tinder-like app. I thought of implementing database entirely in RDBMS (PostgreSQL). But now I think it's a good opportunity to get to know NoSQL systems a bit. I'm closest to using Redis (seems fast and friendly), but I'm also thinking about: MongoDB (very popular) ElasticSearch (see...
I recently joined a company where I was tasked with building a system for one of their clients. The work I've done is so far working well, but the most senior developer on the team who's been with the company for many years is having trouble understanding my code. He says it's hard to follow. I tried conducting a train...
Let assume that we have a system in which the users can chat with each other and we are working on the backend. We can name the service which fetches the chats in one of the following ways: ChatsService UserChatsService If we use the second version, is it a bad practice or it is ok in your opinion ? The idea is that s...
I am working on a little framework where I have this directory tree: project/ |--- ... (directories unrelated to the question) |--- public/ | |--- index.php .htaccess The .htaccess sends every request to project/public/index.php but I have to add specific rules for assets (stylesheets, js, images, ...). Searching ...
I'm designing a database that holds the information for users of three diferentes apps that share the access to the data trough an API. For every user i'm storing credentials, profile and roles. What I'm looking forward to have should accomplish the following requirement: Some users need to have access to more than one...
This might be a bit of a wide question. I have a couple of classes in Java that take input a String which is a mathematical expression and evaluates it. I want to implement a desktop GUI for this. The user inputs the equation in a textfield and a couple of rectangles should be displayed under the textfield if the equa...
I Have a REST API endpoint where the caller can supply some optional filters for the results. GET api/inventory For example, an object member of a GET request may look like the following { "books" : [ { "id" : 1, "description": "this is book 1" } ] , "pencils" : [ { ...
for example, suppose I need to play different sounds according to "grade": file list: fairSound.mp3 goodSound.mp3 excellentSound.mp3 code: showResult(grade){ if(grade==0 || grade==1){ SoundUtility.play(fairSound); }else if(grade==2 || grade==3){ SoundUtility.play(goodSound); }else if(grade==4){ Sound...
I would like to be able to implement immutable data in C++. In short, given a C++ object in which I would like to modify a member variable, instead of modifying that member in place I would like to get a new copy the object with the member being modified. To address this, I wrote a small template class to represent the...
My boss asked me to develop for him a price quotes desktop software (he doesn't want a website), he wants to give the price list and the users of this software would write the prices according to the boss prices, all the bosses prices would be stored on local DB. I thought about the following idea: to develop two deskt...
I work with a feature branch model where the branches get merged into master when they are ready. Before a larger test (specific to my field of work, involving a lot of heavy hardware), several feature branches (individually tested using simulations) are merged into one "test" branch. Before the actual test, the "test...
Let's say I'm requesting a list of IDs for which I'd like to receive relevant DB entities (e.g., my-restaurant-api.com?restaurants=1,2,3). In this example, let's say ID 3 has been deleted and should not be returned. Should the API response: return a 404 return a 200 and include the entities that exist return a 404 and...
I practice TDD and refactor aggressively. Recently some colleagues have complained that the resulting pull requests are difficult to review, or would require a lot of regression testing. When I refactor, I'm disciplined about using safe, behavior preserving refactorings, mostly around changing names and extracting meth...
As you know, epics consist of user stories. The user stories are short descriptions which specify the requests of the user. They can be perfect instance of the questions listed below: Who, What, why One of the customers told me that he wants a main page for anonymous users of that application, and this page must provid...
I just started leaning about algorithm design and I am now having trouble identifying the additional space used in an algorithm. For dynamic program, as far as the examples I've learnt, such as knapsack problem, interval scheduling, sequence alignment, we all explicitly create a data structure to store results of sub-p...
This may be an obvious question but I really don't understand this so if someone can help me that'd be great. Basically, I am in the middle of developing an e-commerce app for my database management class and I downloaded a free trial of the web design app Sketch. After playing around with it for a bit (having no clue...
I have a requirement to create a console application that will read in data from a file. This data will be used to create new users in a database and assign them roles. The input file will specify usernames to be used and the roles to which these new users will be assigned (7 potential different roles where it is possi...
I have a simple concept like in the image below. Basically there is an Item which can be 1 of 3 types and a character that can be 1 out of 2 types. All generalizations are disjoint. What I'm trying to do is to somehow depict with UML notation that a Character can at any given time carry only one item but Monk can carr...
I am a bit confused by the nesting that occurs in Media types (also known as their former name 'MIME types'): The top level types are called application, text, image video, audio, message, model and a couple of others. However, it is not clear to me why certain subtypes are nested under one of these, while other subtyp...
Lets say I want to store songs in my database. Instead of having just one Song table, I have ten tables. The Song table also has a foreign key to the Artist table. When an artist is added to the database, we check exactly how many songs are there in each of the Song tables, and we assign the table with the smallest num...
Not using UncheckedIOException, NullPointerException possible public void callerMethod() { Object result = ioMethod(); // call instance method of result } public Object ioMethod() { try { // IO Stuff return new Object(); } catch (IOException e) { e.printStackTrace(); }...
While reading on the design for autosuggest implementation on large scale systems (like google), I'm able to understand the usage of trie and how top "n" terms are stored at each node to quickly retrieve the list. However, I'm not able to get my head around the logic of efficient way of "sharding" the trie in a distrib...
I am facing trouble in creating a unique, customer facing Booking Id. It's a simple thing to do at backend where we can create a UUID and maintain uniqueness. But the UUID looks ugly from a Frontend Customer perspective. I wouldn't want to keep quoting or using this 36 character string everywhere. I do understand to ac...
Here i am basically looking for performance improvement. I need to match names in a SWIFT message (Let's say MT 103) against sanctions lists (sanctions lists by UN, by OFAC, some custom lists) and below is what i have developed Since there are various lists and total number of names are more than 50 thousand so i loa...
I have a website for admin and a mobile app for normal user. Both of them share a same database which is now on the cloud(The website for admin is already deployed with the database on the server). The way I use to connect to our local database for our mobile app is through PHP scripts which contains the necessary para...
Background: I am working on a service where the domain logic exists as a library, and then the actual executable is built on a web framework as a wrapper around the domain logic library. There is no guarantee two customers run the same version of this service. Task: I was asked to create a way to print the schema for r...
In Elements of Reusable Object Oriented software by Erich Gamma and friends, the intent for Abstract Factory Pattern says: Provide an interface for creating families of related or dependent objects without specifying their concrete classes. Can anyone explain in clearer terms what does author mean by related or depen...
I am trying to start with a geo search project that will find all landmarks in the 10 km/miles (not important for this story) of a particular landmark. So for example, lets say I have a database of a 1,000,000 landmarks. In order to find all landmarks in 10 miles range of a landmark with certain coordinates, I would ha...
We are currently in the process of building a service (a REST API) which is called on by our primary application. The primary application contains a users/permissions/roles set up which is used to verify if the user is able to complete tasks on the application. The user-roles relationship is one-to-many. The third part...
Can someone explain to me why one is necessarily better than the other? int M() { int y; LocalFunction(); return y; void LocalFunction() => y = 0; } Versus int M() { return LocalFunction(); } int LocalFunction() { return 0; } I'm not getting the point of using the lambda expression vs just m...
I have part of the system that looks like this: Basically, the client decides which API call to invoke on the server based on the flag that is previously provided. It knows in advance which type of response to expect as well. So the code would look something like this: if (flagOn) { Response1 = ApiCall1(); Proce...
I have an application say x which uses another Java library(say Y) as a JAR file . So y basically needs to download a file and load it into memory before any of it's methods are called at runtime by X. How do I make sure that files are downloaded and loaded before any of the methods of y are called ? Also, Y is being u...
I'm developing or maintaining a free software project Foo which uses CMake for a build system, as well as source control (e.g. Mercurial or Git), with the repository being available online. Now, this project depends on another project, Bar - say, it uses include files that this other project provides. Bar exists indepe...
Why is the method in Global.asax called Application_Start() and not ApplicationStart()? According to MSDN method names should be in Pascal case.
Let's say i've got the following absurd viewmodel in a MVC application. public class Absurd { public string WelcomeMessage {get; set;} public string PlainTextAdminPassword {get; set;} } And this is the entirety of my view <div>@Model.WelcomeMessage</div> Let's assume that both my WelcomeMessage and PlainTextAdmin...
My project structure (Spring / maven): src / main / resources / application.yml src / test / resources / application.yml This is working well (when I launch test, it takes the test application.yml). But often, I see posts where the application.yml is postfix to take the active profile: i.e.: application-test.yml for t...
My web application at the moment accepts REST requests and handled via some controllers, which calls corresponding services to perform the logic. Now I want to add in some security logic before calling the services. This includes checking if a service can be accessed ALSO amend the request body if necessary. I am havin...
I'm a web developer of a small, local SaaS web application. It currently has about a half-dozen clients. As I continue to design the application, it's become increasingly harder for me to convince myself to commit any time to the project, which has happened in the beginning phase. Having grown attached to the project a...
I am struggling with some web application which is quite big and messy. There are several Domains that land on the server. domains can have a "channel" and every channel should use different templates for customized look and feel. The decision which channel to use takes place in different parts of the code and is chaot...
There's this sample repository, which showcases different Android testing practices. One of the apps is android-testing/unit/BasicSample, which is very simple and, among other things, checks the email field and for that purpose adds a listener like this: mEmailText.addTextChangedListener(mEmailValidator); https://gith...
So I started a month ago at relatively small company (12 people in the building) as a junior developer without professional experience apart from my own (7 years) and no degree. We're building a JEE app that's been going on for 15 years, and for the next version it was decided we would rebuild the frontend, removing fr...
Just read this article: https://microservices.io/patterns/data/database-per-service.html We are designing 2 microservices - both have tables in a shared db. What I'm wondering is if I build an API that provides access to these sets of tables... where should this (HTTP REST) API be installed? on a separate application...
Logically how can I prevent a client from making changes to a domain model entity if a service is not used? For example: Let's say I have an Account class that contains Transactions to compute a balance. A service is used to coordinate the interaction of these entities. However, I only want a client to be able to use s...
I'm having trouble finding resources for this implementation I'm trying to figure out. I want to save nodes in a binary search tree (self balancing) containing an ID and value struct Score { int id; int score; }; If I want to delete (id=2, score=7), how can I delete this node without deleting id=6 or id=5? ...
I am loading a large amount of data (2,000 files with about 30,000 rows, 30 columns) for use in a Django application. The files are based on 40 different templates. The column names are consistent within the templates but not between templates. We've manually mapped the columns to canonical names for the fields we are ...
I am trying to figure out how to translate the onion architecture into an ASP.NET Core WebAPI solution, this is what I ended up with: Let's say I have an application that takes a file path / uri into input whether via a Console application or a WebAPI application, read each line and if some business rules are met chang...
Admittedly it's probably mostly in traditional BASICs (which require line numbers) that I've seen this. Take these examples (cribbed from Wikipedia): 10 PRINT "Hello, World!" 20 END and 10 INPUT "What is your name: "; U$ 20 PRINT "Hello "; U$ 30 INPUT "How many stars do you want: "; N 40 S$ = "" 50 FOR I = 1 TO N 60 ...
In my program, I have a long-running function from which I would like to interact with the user for various reasons: Giving status updates ("Downloading file /foo/bar.png") Displaying warnings ("File upload failed; will retry later") Asking for input ("Please enter your google drive password") The problem is, of cour...
This is really a question about "best" or "practical" practices, and would be interested if anyone else has had a similar need as myself, and how they handled it. I have a REST(ish) API that we have developed to "bolt onto" the front of an existing legacy system. I use this "REST" API to enable both third party, and ou...
I recently learned about Flyweight Pattern from this link. It is written there: It’s very important that the flyweight objects are immutable: any operation on the state must be performed by the factory. I did not understand this well. Any opinion will be appreciated.
Say you have a HomepageController that' suppose to show all the blogs, users, gallery, and some members-only info (for logged-in users) Normally, it looks like this: <?php class HomepageController { public function index() { $blogService = new BlogService(); $data['blogs'] = $blogService...
I am willing to refactor some code that acts like a controller class executing work embedded in other classes. On one side it looks good as the controller is generic and what changes has been well encapsulated, but on the other side the solution implies lots of downcastings. I have proposed a generics based refactorin...
There exist lots of discussions on variable naming. However, I would like to address a specific aspect. I am a data scientist and deal with dozens of features/variables/columns — however you may call them. My work benefits from names that: contain information about the variable's ontological background; this means tha...
When writing a lexer/parser, why/when would an advised developer chose to define the tokens' types through an enumeration field/type hierarchy? The closest question I've found here so far was Lexing: One token per operator, or one universal operator token? by Jeroen Bollen, but it seems to be more about the ideal dee...
The Spotify model has become a popular example for the right way of doing development. If a product has a single, main, code repository, like most products have, how do you make squads autonomous and independent? There is common code that different squads will work on during the same period and if a squad adds a bug, d...
In one of the projects I work for, we have just added karma to run unit tests. When reviewing the MR of a coworker, I noticed the karma.conf.js (the configuration file) has 120 lines, which seems to be a lot for me. While reading each configuration, I noticed many of those configurations are the already default values....
I'm implementing an API with pagination which has max_results that can be specified by the client. The server will have a hardcoded limit, for example 100 results per page. In the situation when the client specify max_results >100 which is more expected behaviour and why do you think so: return just 100 raise an erro...
My question comes from using the agile template in Azure DevOps though its more of a general question about dealing with bug work items. When a bug work item has been investigated and the issue has been identified, prior to any tasks being created to resolve the bug, where/how is this usually documented? Looking at th...
As a Ruby/Rails person, I often deal with method delegation. It's often convenient to delegate a method to a composed object or a constant. Ruby even has a def_delegator helper method to easily build delegators and Rails' ActiveSupport improves the builtin's interface with delegate. Yet when I looked at Python, I found...
Suppose I have a kind of UML activity diagram with 1-n forks and joins. The assignment of the individual nodes relative to each other is defined by an XML relationship table via UUIDs where each sourceand target attribute's UUID represents such an individual node. The following, highlighted example should clarify this:...
Say there is a single database table containing information about two different types of animals: land animals and sea animals. I want to create two lists of animals, one list for each type of animal. Is it better practice to query all animals from the database, iterate over the returned list of animals, and place them...
I am modeling our existing database in transition to a graph database. Currently here is how I can interpret the database a graph relationships group -have-> groups group -have-> participants participant -is-> user user -has-> profile user -has-> user-accounts user-account -composed of-> social-logins user-account -com...
I've been thinking a lot lately about safe code. Thread-safe. Memory-safe. Not-going-to-explode-in-your-face-with-a-segfault safe. But for the sake of clarity in the question, let's use Rust's safety model as our going definition. Often, ensuring safety is a bit of a how-big-is-the-net problem, because, as proven by Ru...
If I display user_id that represents each unique user in the db as an atrribute in an HTML element, is that good practice? Because I need the reference to the user if I want to perform an action on that particular user such as adding him to be my friend. Example in HTML: <div data-user-id='12' onclick=addFriend(12)> ...
On my e-store I wish to allow customers to buy store credit, which could later be used to purchase items from the store. The vision is that the customer would send some actual money to my account via e.g. PayPal/Credit Card/Whatever and that amount would then appear on their profile. E.g. if a customer carries out a cr...
Very beginner. Need to compute route from A to B for a robot. i would like to know how to store area map and compute the route. I can compute shortest path etc using algorithms e.g. dijkstra. What format of maps are used for efficiency. Edit: 0. Unable to find anything useful using search 1. could not find a relevant...
I am currently working on a game engine for work and have hit a wall on my idea. I have multiple objects (called prefabs) that have very common properties such as Position, Rotation, and Scale. There are more, but let's just focus on those for this particular issue. The idea was to create a base class called RenderObje...
I am quite new to DDD, but I am currently working on a system which has a payroll element to it. I have a requirement to send payslips to an external system when they are created. Currently the payslip process is all in the existing legacy code, but I was thinking that it might be a good chance to move some code into a...
My situation is this: I am contributing to a Symfony/PHP project. I had to completely reskin one page in the application. The controller logic is almost totally unchanged. I only had to change the template file (named index.html.twig). But the changes are completely different. If I make a pull request with these change...
I have a series of classes that represent widgets in a layout system. The base class for all of these concrete widget types is Widget. If I have a Button and a Text Box, these both derive from Widget. The layout is structured as a tree. Each widget can have only 1 parent and zero or more children, which are also of typ...
My understanding is that separate data store per service is a best practice in microservices architecture. This Nginx article mentions that, but it goes on to advocate a Master Data Management system for ensuring consistency of data across disparate data stores. How can both coexist peacefully? It seems to me that e...