instruction
stringlengths
34
36.1k
I have this URL: /api/pallets/list Which returns a JSON array that looks like this: [{ palletId: 333, code: 'J050000081', grower: { growerId: 35, name: 'Grower Of Blueberries Inc' }, species: { speciesId: 1, name: 'Blueberries' }, caliber: { ...
I'm embedded engineer, and one of my field of work is building embedded systems based on STM32 microcontrollers. ST provides its own HAL with names of functions like HAL_Delay(), HAL_UART_Receive() etc. They use two-space indentation, all brackets on new line and other ST-specific codestyle features. Also, it is very ...
The absence of a datum in XML can be expressed either by omitting the element (minOccurs="0" in schema) or by setting it to xsi:nil="true" (nillable=true in schema). Using minOccurs=0 seem altogether cleaner and more consistent, and it doesn't require the XML to reference the XSD namespace. So what is the benefit of n...
I am working in a project we we use DDD and now we want to implement localisation for some fields. Example: <?php class Product { private $id; private $name; public function __construct($id, $name) { $this->id = $id; $this->name = $name; } } I have a service to create this pro...
Is it considered an anti pattern to hardcode SQL into an application like this: public List<int> getPersonIDs() { List<int> listPersonIDs = new List<int>(); using (SqlConnection connection = new SqlConnection( ConfigurationManager.ConnectionStrings["Connection"].ConnectionString)) using (SqlComm...
In Object Oriented Programming, since we use classes and methods in these classes, when we are going to implement a certain functionality we must decide where it belongs, in other words, on which class it belongs. This raises questions like: "should I create a new class and add this there" or "should I add this to one ...
What is the curve below called (if it has a name)? What can you generally infer from such a curve? The line with negative slope is the number of remaining test cases and the line with positive slope is the number of bugs.
I'm working on a project in which we are incrementally replacing an existing application. By incrementally I mean some features will be developed and shipped in the new application, and those features will be "deprecated" in the old application, but still available. The deprecated features will then be removed from the...
Context: I'm going to use the board game Sorry as an example, but this question could apply to other board games. In Sorry, each player has four pawns. Based on drawn cards, a player moves their pawns around the board. These moves can impact other players' pawns, like bumping another player's pawn back to Start. For a...
I am trying to write documentation for a project and I have trouble finding information about list of documents that need to be written. I know there are Vision and Scope, User Requirements, Functional Requirements etc., but I haven't been able to find concrete description about which documents should be written and in...
I need to call third party APIs where the payload size has a maximum size limit, say, 4 MB. That means I cannot call the API with a payload more than 4MB in size. How can I solve this in an algorithmic way? Because a simple solution could be like every time I generate a payload, I check the size, and if it exceeds, I c...
I worry that I'm too concerned with code smells. I've spent the last two days procrastinating over implementation details and how I would actively refuse using the approach suggested. We have a scenario where we "pull" orders and each order can be "deleted", "re-created" or "ignored" Tech lead suggested having one data...
In a question on stackoverflow the answer I received was basically "It happens if you replace a .dll file in an already built application". That seems very dirty to me. I understand the need for marketing changes like renaming the executable and things like that, but here we are talking about changing the functionality...
I have a collection of Python objects, lets call them fruits. Some of these fruits might be faulty. To check for these faults, I have a number of functions that performs different checks, and returns a list of fruits that did not pass the check: def not_delicious(fruits, limit): return fruit for fruit in fruits if ...
We are trying get our CI/CD up and running and I was after some feedback on it. We are using VSTS and building c# api + JavaScript applications. We want to use VSTS build and Release management. The release management uses the idea of 'promotion' of the same build through the various environments. Our process We tend...
Is it a good idea to use the same naming nomenclature (e.g. camelCase) for both front end (eg. Javascipt) and backend (eg. php) ?
Recently, we have learned about UML class diagrams in university and I began applying that knowledge to my work projects. However, I am still unsure how or where I am supposed to describe the functionality that a method of a class offers. In code, I would simply put a docblock above a method in which I describe that m...
For junit tests where I am just testing if something works correctly, should I use assert(true)? Since it is legacy code, it is difficult to get a good assert statement.
Github uses the convention "/user" (singular) to interact with the logged-in user's info. They still have the full "/users" suite of paths to support getting info based on IDs (or usernames in their case), but the singular resource took me by surprise. Is this common/accepted/desired across the web, or is this just a ...
I’m a little unclear on some questions relating to the "intent" part of concurrent collaboration algorithms (operational transformation and conflict-free replicated data types). Please help! Strings are a frequently used example in OT explanations. Usually, you see something like "abd" * ins('c', 2) * del(1) ≠ "abd" *...
In our software, we have a windows service that performs all our background processing from sending scheduled SMS to performing backups, (maybe 10 different functions). I am questioning as to what other people's experiences are in regards to windows services, is it better to have a single service for a single function...
We are working with a performance metric that all API requests should respond within 50ms when running locally. I am taking this from the average response time of Githubs API. I have an object called Foo. A single Foo might contain 6KB of text when serialized as json. Foo has a sub object which makes up about 3KB call...
In android, some codes, such as updating UI buttons, needs to be called in UI thread, however, before UI update, some task, such as getting response from internet, need to be done on another thread, here is the most common form of response callback I see: public void httpResponseCallback(String responseString){ MyF...
I have to do a program to school in Assembler but we did just a few basic things. Is it possible to write code in Java and convert it to Assembler?
I am in the process of refactoring a large application originally written in .NET 2.0, running on an old version of Microsoft's Compact Framework. The idea is to refactor and rewrite the code so that it in the future will run on Windows 10 IoT. So far this is going pretty well. However, the program should also ideally ...
I have released API 1.0.0 in the master branch (default branch). Since then I have separately branched to branches api2/foo and api2/bar, both containing backwards-incompatible changes. The API version is declared in the source code. Should I bump the version to 2.0.0 in both api2/* branches, or in the master branch? I...
Context: We're having a ton of super heated debates around the office. I'm just a neutral observer, as this is my first month at my current employer. Previously I haven't ventured outside of the Bootstrap waters... but it has got me thinking. Is doing this weird/bad/a code smell/etc... Currently we seem to have a lot o...
My team is currently trying to design an authorization system that can be used in any language (Think authorization as a service). One thing i'm trying to figure out is if there is a good way to write authorization checks without littering them all over my code. Is there any way to actual do this in practice? For examp...
I read in this article about microservice architecture by M. Fowler: Another consequence of using services as components is a more explicit component interface. Most languages do not have a good mechanism for defining an explicit Published Interface. Often it's only documentation and discipline that prevents cli...
I am learning software design by building a CRUD web application (ASP.NET MVC with Entity Framework). I split it into two projects: first is Core library, that contains business logic, second is Web GUI. I got an idea, that separated Core library can be used elsewhere (for example desktop application) or GUI can be com...
Say I have a Service Layer method like this: public void TestMethod() { DomainObject domainObject = new DomainObject(); domainObject.TestMethod(); } TestMethod looks like this in the Domain Layer: public void TestMethod() { TestMethod1(); TestMethod2(); TestMethod3(); } Is it bad practice to Unit Test ...
We are planning on using OAuth2 / OpenID-connect for Authentication & Authorization and I'm looking at what services would be required. So far I've identified that I need at a minimum: An OpenID-connect authorization service, e.g. implemented using Identity Server Service(s) for registering and managing users Service(...
I have the following interface in my business layer public interface IUserService { void CreateUser(User user); List<User> FindUsersByName(string searchedString); User GetUserById(int userId); User GetUserByCredentials(string login, string password); void UpdateUser(User...
A lot of ISAs including x86, x64, ARM, Itanium, have a pop instruction that requires an operand which is usually a register (or, in ARM's case, a register list). In fact, I can't think of an ISA off the top of my head where the pop instruction doesn't require an operand (other than stack-machines for bytecode like the...
I'm designing a C# bot using the Microsoft Bot Framework. I'd like the bot to be easily extensible, allowing developers to add dialogs/responses while making code changes in as few places as possible. From my own experiments and looking at the examples in Microsoft's BotBuilder repo, it seems like adding a new dialog/r...
With the creation of Temporal Tables in SQL Server 2016 (or similar technologies in other databases), would you consider Event Sourcing unnecessary? Both are audit techniques, very similar (one deals with entities, the other with specialized DTOs), but Temporal tables are far easier to implement as they are ready right...
There is an application that processes TCP/IP requests according to some logic, and pretty always it connects to DB. Architecture is very common: one client -> one processing thread -> one DB connection -> one DB thread to process a query(DB thread exists inside DBMS application and mentioned here to show how insuffici...
How to calculate C(n, r) modulo m, m is of the form p^a, where p is prime. Here C(n, r) means n choose r. The range of n and r is large (of the order of 10^18) so it cannot be solved by calculating the power of primes. Also m is less than 10^6. I tried reading the generalization of Lucas Theorem, but could not underst...
I would like to make a semi-automatic OCR software for offline handwritten documents, where the OCR tries to recognize the words and the user has the ability to correct the fails of the recognizer by defining the misrecognized characters. I found a similar issue but doesn't really answered my question: https://stackove...
Problem: 3000 business objects, each with some regular data (~20-30 shallow fields, JSON) and its own unique small behavior (often just a one-line javascript function). Possible solutions on my mind: Solution 0: business_objects.js (~1 MB) data and functions on same object. Solution 1: data.json (~800KB) + only_behavi...
Academic task… First we were told to generate a set of static .html files showing election results in various administrative divisions. Then we were told to "modernize" this by using Django templates. Fair enough, I can see the benefits of such approach. But then we were told to further "mordernize" this by making the ...
What is the best way to provide a web application in multiple languages? The focus of my question is not what to think about, but indeed how to do it. The text in the web application: text in the popup of spatial features text in the sidebar containing the feature's description text elements of the website components:...
Recently lots of people adopted DI in their projects (I am working with aspnet core). The problem I have is that DI turns my code towards procedural paradigm. For example in OOP way I would do: class Something { Something(Other object, Dependency dep); // created manually or by factory obj DoStuff(); } Howeve...
What is a good way of setting up a "shared index" of file metadata, when there can be no shared process such as a database server? I'll explain the scenario: A server contains M (say 10000) large files (say e.g. image files). each file is in a unique subdirectory with guid name. The root directory is shared as windows ...
Are there best practices for method summaries? I'm a bit confused as to what belongs in the parameter and returns description when both are objects. Here is an example of a method I am summarizing: public class DocumentRequestObject { public List<UserIds> UserIds { get; set; } // User Ids being searched for do...
I'll preface this with a few classes that shows what I'm trying to do interface IDataField { /* ... */ } class DataFieldImplementationA : IDataField { /* ... */ } class DataFieldImplementationB : IDataField { /* ... */ } interface IData { IDataField Field { get; } } class DataImplementationA : IData { publi...
Example 1 (used at the moment) If (BodyPart["Right Leg"].BodyStatusEffects["Active"].Active) { BodyPart["Right Leg"].BodyStatusImpacts["Poisoned"].Active = false; BodyPart["Torso"].BodyStatusImpacts["Poisoned"] = BodyPart["Right Leg"].BodyStatusImpacts["Poisoned"]; BodyPart["Right Foot"].BodyStat...
This is a question regarding how Multiple Dispatch works. Suppose that we have a type hierarchy like this: Drawable -> Shape -> Polygon -> Rectangle And there are three functions (This is a pseudo-code): void func(Rectangle*, Drawable*, Drawable*) ... void func(Rectangle*, Rectangle*, Drawable*) ... void func(Polygon...
I have a Data Access Layer that uses a json API. If the structure of the program looks like: Controller | Data Access Layer Is it best to convert the response strings into objects in the Data Access Layer and return them as types to the Controller OR Should I be returning strings back to the Controller, ...
Disclaimer: I am asking this question with regard to a school project. The purpose of the project is hands-on learning and simulation of a real-world software development project. I am fully aware that I don't properly understand what I am doing; and I am not putting anyone at risk in the case of designing a very flawe...
I have a class similar to ServletFilter which has multiple validation on the input request class TokenHandler implements SomeHandler{ Response handle(Request request){ if(paramXMissing(request)){ return new Response(); // empty response } if(paramYGreaterThan100(Request request)){ return new...
I have the following situation. I'm writing a c++ program where I have a function that checks a custom equivalence of two json objects. If the check fails, I don't want the entire program to stop (its a QT gui program), and I have a branch that executes upon receiving an exception. This exception is then passed up t...
I am learning unit testing on the job, at a new job. The testing team is small, (1 other), and all of the tests are written in the following fashion. class TestClass(unittest.TestCase): def testFunction(self): #Test - 1 #Assign #Act #Assert #Test - 2 #Assign ...
Our Web API app is C#/MS-SQL and our DBAs want us to use two databases, one Writable, one Read-only. The database for writes will replicate to the read-only copy. This question may apply to other languages as well. The reason for this (from the DBAs) was so performance would not be impacted if/when tables are locked d...
I'm attempting to develop an open-source Python module for modeling task networks for discrete event simulation. The most fundamental component is the task object, which includes various data such as a distribution of possible task duration times, a release condition (criteria for initiating the task), a beginning effe...
With all the github services available nowadays, it has become quite easy to have automated unit tests for e.g. C++ or Python coding projects. Together with colleagues I have written a basic install script for Arch Linux in Python that I would like to test automatically instead of manually creating a VM, letting the in...
I develop mobile apps, now im working on a very big project building a tool for the employees to be heavily used. Now the app is on development mode, and testing with few users, but will need to be scalable and have a fast response. So the question is about the way the thing is being constructed, how it updates the inf...
I'm working on a project for my College and I'm stuck on this problem in my design. Right now I have something like: public abstract class AbstractClass { protected SomeClass attributeOne; protected SomeClass2 attributeTwo; public SomeClass getAttributeOne() { // code } public SomeClass2 getAttributeTw...
I am not sure which stackexchange website is correct website to post this question. I haven't worked on payment process before - and I need help with payment process using Stripe - we are developing a website in which we will be selling items from different businesses. Now the flow of the Application is like this: C...
I'm starting to learn about reactive web applications, and I pretty much get the hang of the whole components, virtual DOM, states and more. First of all, I usually don't name a technology, but for the sake of simplicity I'll use ReactJS as the example, but I'm sure the concepts also applies for other libraries/framewo...
I am on a fairly new team that is also new to TDD and Agile/Scrum. Currently we are developing a project that consists of web API and a native iOS and Android application, with a small team of devs working on each one. We were having a discussion about how to solve issues in developing concurrently and all had differin...
Suppose that I have 3 classes; class A, B which inherits from A, and C which also inherits from A. And I have a mixed list of B and C instances contained under a list of A. What is the best way to identify the inherited class when iterating over the list of A? 1) Store a 'type' enum property in the inherited classes a...
Being portable C++ code, our project has an abstraction layer over threads. This layer has unit tests. This includes tests like that Thread::sleep(100) wakes up in 130 ms, that CondVar::notify() wakes up the other thread in 50 ms and similar. Obviously this occasionally fails, especially when the computer is also doing...
I have a page that displays a set of records. The page has filter section to search records. currently the logical operator AND is applied between all the filter conditions. Now the requirement for including the OR operation has arisen. The user suggested to add a dropdown with AND,OR options next to Value dropdown. B...
Imagine a standard shop system were users buy stuff and products are being stored and presented. The platform saves and manages a lot of data. Now there are managers who want to be able to see this data e.g. via excel sheets, but in generic ways, some want to see all users with their names, some without, some want to s...
First is I'm starting to build a standard XML format/structure for our users. The objectives are: XML that can be used for multiple organisations XML that can be used to map external system data to our system data XML structure should be in best practices XML should be adaptable to change The above are the objectives...
I'm a bit trapped in my own design. I have to extend it far beyond initial expectations. I'll first show how things are now and what behaviours I want to add but don't know how. Currently, the following code works fine. Some things may be discussed (like the builders class, which exists for the sake of Single Responsib...
I have a proxy server that talks to a bunch of services and I want to have a way to prove to servers behind the proxy they are actually receiving a request from the proxy server and not from something else. I thought about letting clients register themselves dynamically with a key/secret pair thing and sign requests wi...
Let's say I have IRepository interface implemented by Repository class(uses database context to implement IRepository methods). And IUnitOfWork interface implemented by UnitOfWork class using IRepository. My questions are: 1) Should I unit test Repository on it's own?(have no idea how, because it uses database context...
Description of the environment: I am implementing a (hobbyist) modern engine for (an old) PlayStation 1 video game Graphical data is represented as packets where it can represent either a polygon or a sprite, (and they are transformed differently to end up as pixels on screen) All those differents type of packets (18...
So I have a Google Cloud AppEngine server which has 2 main jobs. Every Day at 00:00, download lots of data (Firebase/Async), process it, and send out notifications via HTTP, interact with GoogleStorage, etc.. Listen to different types of requests and send out Notifications via HTTP when received. So for testing purpo...
I like to know what the advantages to putting the logic in separate classes rather than putting all the logic in the RuleManager class. For example Separate the classes for each responsibility class RuleManager { public function create(string $name) { return (new CreateRuleCommand($name)); } ...
In the Java course I'm currently doing at university, a lot of emphasis is placed on using JML constructs like @require and @ensure clauses in Javadoc comments. I understand that this is implementing the design by contract paradigm and that certain tools exist that are capable of mathematical verification of software u...
I'm working with a team on an ASP.NET MVC C# EF application that needs extensive Help materials. The Help materials will be stored on a helpdesk site (FreshDesk) so they can be accessed as a Knowledge Base and so we don't have to duplicate the Help materials both there and inside the app. In a proof of concept test,...
My team has to take over a project from an external company. They've provided the last state of trunk to us as a zip file and are trying to convince us, to accept this as a complete delivery of their development. I strongly object this, as I consider source code as the following: code = history of single commits + proj...
I work for a company which has developed a test automation solution and willing to release the same under GPL. I need to know where all do the company need to register and what is the overall process?
I am a full stack developer in a very small company. It has a custom built ERP software using PHP 4 (no framework). Currently, it works fine from the business point of view except for some bugs here and there. Presently, about 4-5 people use it. The company's plan is to offer it as a product to clients with some modif...
I am a beginner in ELisp, but have programmed in C++ and a number of other programming languages before. My rule of thumb (and I think it is a common one) that a function should fit on the screen. However, it should preferably be even smaller (20 lines is on the long side). However, I notice that Emacs has functions th...
I'm trying to retrieve some personal data from an application that has completely disappeared from Google Play, and its author has answered none of my emails. (I'm namely trying to retrieve a private key. I make the assumption it is stored in a keystore) The problem is that I cannot succeed to find the files related to...
Up until now, I have been initializing most of my variables as such: const QString foo("bar"); Which from my newfound understanding, is known as direct initialization. (http://en.cppreference.com/w/cpp/language/direct_initialization) I was looking at someone's code, and in a namespace, they were initializing their vari...
I have a login page, where user logs in via his mobile number, He gets an OTP send via backend server, once he enters a One-Time Passcode (OTP), we hit an API like this: https://backend.com/api/login?mobile=9123123123&otp=1234 My question is this good enough from security point of view or should I encrypt both mobile ...
As part of a program I am developing for practice purposes, I've created a namespace Core designed to contain the core code resources for the program to use. This namespace is in a Class Library project. Two of the sub-namespaces in Core are Core.Files and Core.Errors. In Core.Files there is a TxtFile class that is res...
I am working on a project that manages employee payrolls using php (no frameworks). This application consists of clients (with their own databases). Each database consists of the client's employees and their payrolls. The relevant features are: An administrator can process a payslip twice a month for all employees in ...
There seems to be significant amount of deep information on the lesser time complexities: linear, polynomial, logarithmic; But there isn't a good source of deep information on how to easily determine if an algorithm is either exponential or factorial time complexity. Usually resources have information on the time compl...
For a class like this: class Foo { public: virtual int GetA(); virtual int GetB(); }; Where should I declare a non-virtual function GetSumOfAB()? 1 - Make it an instance method? class Foo { public: virtual int GetA(); virtual int GetB(); int GetSumOfAB() { return GetA() + GetB(); }...
I originally posted this on StackOverflow, but got the message that this was the correct forum for such a question. https://stackoverflow.com/questions/44077183/wpf-arrangable-row-of-rectangles. I am in the process of creating a small application which has the task of visualizing sorting algorithms. I am using the MVVM...
if field is blank or in form print "enter again" else if no credit and debit < 1000 print "less amount" else print "accessed" end if end if I'm very confused in calculating the cyclomatic complexity. For the above program, I get the answer as 3, as there are two conditions and V(G)=P+1=2+1=3. But the answer ...
For any successful programming language, making a breaking change to the language is extremely difficult. This is the case even for those changes where the legacy code could be reliably and automatically fixed with a simple tool (effectively, a trivial transpiler from the old version to the new). Among such changes mig...
We are a product based website company. We deal with online sell/purchase of automobiles. We have an already-established product with daily 100k visitors on our website. Current scrum team - six full stack developers and one Tester. Full stack developers deal with C#, JavaScript, SQL. Average experience of developers ...
I need to present the conceptual architecture of my site in a couple of days. It is an extremely simple web-site: it is made using HTML, CSS, JavaScript, XML and XAMPP for PHP, MySQL and Apache Server which resides locally on my laptop. Basically what can you do on the site is reading some news after you login or r...
I am beginning the process of moving my django stack to docker containers. Most examples I have seen put the Dockerfile and docker-compose.yml files in the same repository as the application source code. I have been using ansible for deployment so far, it's served me well, and I intend to keep it while gradually packag...
For example I have a relationship like this: user (0..*) buys product (0..*) Which results in an association class, called sale, which has the userID and productID. Just for the question's sake, imagine this sale class has NO other attributes, except for these IDs. My question is, should I show this sale class in my c...
Posts may be smaller than they appear! Skip the bulleted list. Lemme Just Say... I know that this is going to be largely (entirely...) opinion-based. Everyone has their own approach, and their own best-practices ideology, but I'm hoping to glean some thoughts from those who have worked on successful web-apps previously...
I was reading Memoization with recursion which tells how for a recursively defined function fun we can do memoization by: -- Memoization memoize f = (map f [0 ..] !!) -- Base cases g f 0 = 0 g f 1 = 1 -- Recursive Definition g f n = f (n-1) + f (n-2) -- Memoized Function gMemo = fix (memoize . g) So I think it is some...
The Kano model of customer satisfaction defines different classes of product features. Among them are Must-be qualities: If these are not implemented the customer will not accept the product. Attractive qualities (delighters): Features that the customer often doesn't even expect in the first place but cause excitement...
For example, should I test like this: // it shouldn't even compile since I'm using a static type-checking expect(addTen('string')).toThrowError() when it is already type-checked like this: function addTen(n: number): number { return n + 10; }
I was in my CS class when my instructor presented me the following classes: public class UninstantiableTest { private static Uninstantiable uninstantiable; public static void setUninstantiable(Uninstantiable used) { uninstantiable = used; } public static void main(String[] args) { Uni...
The use case I am trying to solve is, assigning millions of users to their groups/segments. I have thousands of different criteria from which buckets of users are created. E.g. bucket criteria: All married males in NY or LA assign to Bucket/Segment 1; Currently at the end of day, I query users from a TB scale table i...
I'm working on rearchitecting a game engine in which multiple concurrent scripts run in parallel threads, which unfortunately occasionally gives rise to race conditions. I'm trying to set it up so that all the game logic will run in the same thread, and any blocking call will run as async. Rendering needs to absolutel...
I am working on a very large ASP.NET Web Forms project. Our team wants to rewrite this project with ASP.NET MVC and domain driven design. Is it a good idea to combine Web Forms with MVC? With this idea we can develop every page and use newly developed page in current project. Old pages work with Web Forms and new pages...