instruction
stringlengths
34
36.1k
I'm looking for patterns or best practices for maintaining different versions of an API contract. There's lots of information on the internet about how to version API's (URL's vs. headers etc), but this question is related to the mapping from one object model to different versions of the contract types (DTO's), and for...
I'm working on parsers that not only process delimited content, but also escape sequences within certain portions of that content. I'm contemplating the efficiency of several approaches to tokenization and would appreciate thoughts on the following. To use JSON as but one example, there's a few ways to process the foll...
I was coding some functions in C++ and wondered how different versions of those functions would affect generated assembly code. I put different versions into the Godbolt Compiler Explorer Tool and looked at the generated assembly. It was an interesting experience to see those differences and how some versions that seem...
I'm working on a little pet program in C where I have a game board that consists of a bunch of squares: typedef struct _square { bool checked; } Square; typedef struct _board { Square *squares; uint8_t width; uint8_t height; } Board; I don't want these structs to be visible to the public, so instead I...
I have a restful api router , where it connects with database and returns some rows. So is it Unit test or Integration test ? From my knowledge, unit test doesn't connect with external services likes database, files, ... . and how to write an actual unit test for restful api ?
I am currently in the process of trying to master C#, so I am reading Adaptive Code via C# by Gary McLean Hall. He writes about patterns and anti-patterns. In the implementations versus interfaces part he writes the following: Developers who are new to the concept of programming to interfaces often have difficulty let...
I am looking for a way for providing customers with hot-fixes and patches of my product. The patch could contain one or more hot-fixes, and customer should be able to check/uncheck any of hot-fix(es) from a list during the update installation. Every hot-fix may contain operations like: Add/Remove/Replace file Start/st...
Summary Our company runs two week sprints for our software development team. We have many projects our team shares with some being individual projects. We've noticed that when we end our sprint an hour or so before our sprint review meeting that we sometimes have problems demoing our software in the sprint review meeti...
Recently came across MDDA, I think the term was first coined by Salesforce (pg3) and others have followed it like Metadata Driven Architecture at benefitfocus.com (less dense and well written). The design sounds useful for enterprise products where the platform is flexible enough to help customers tailor (by end user ...
I have an ASP.NET web site on a shared server. The site is mainly used to house some WCF services that are used by a desktop application. We had a problem in that the server stopped responding, and the hosting company said that the application pool logs showed that we had hit our memory limit (500Mb), which caused the ...
We have a number of systems that are based on the competing consumers pattern. We currently monitor the delay between an item of work being queued and processing finishing, however, as throughput increases, this metric will only increase over the average when the system is already above its maximum capacity - the point...
Currently we are using a tag for every build on master which passes CI. This leads to a lot of tags (3-10 per day). The good side is, that those commits are easily human readable, show the version (v.X.Y.ZZZ) which is also shown in the .exe built and deployed of that very commit making it very easy to find the exact co...
Classical programs run a loop with prioritized ISRs. How do RTOS do this differently of better?
I am very new Java and have been messing around with a program that essentially prints a random line of characters based on random char values and array manipulation. I am having a lot of trouble understanding the object-class relationship as my only other programming experience comes from MATLAB. Therefore, I have be...
Problem I have a graphical console widget that receives output from an interpreter. Unfortunately the console is not fast enough to paint the output in real-time. So I had to implement a buffer(FIFO Thread Safe Queue) that delayed the writes to the console by 5ms. So when normally a loop of 1000 prints would be done in...
In many applications the 'UI thread' is special and framework UI updates must be dispatched from this thread. However, in order to avoid locking the UI slow tasks are executed in background threads and the results propagated back to the UI thread to be displayed. Different frameworks solve this in slightly different wa...
Our team is building an Android app using Kotlin (if that matters at all) by following the guidelines described by Uncle Bob (Robert Martin). The presentation pattern we use is MVI. We have presenters that communicate with Use Cases/Interactors and convert the resulting entity objects into ViewModels, suitable for rend...
I noticed something strange after compiling this code on my machine: #include <stdio.h> int main() { printf("Hello, World!\n"); int a,b,c,d; int e,f,g; long int h; printf("The addresses are:\n %0x \n %0x \n %0x \n %0x \n %0x \n %0x \n %0x \n %0x", &a,&b,&c,&d,&e,&f,&g,&h); return 0...
Suppose I have the following devices: Device A Device B Device C (...) Also, for each device, I have the following measurements: Measurement 1 Measurement 2 (...) Each measurement event includes a measurement id (int), a date (DateTime) and a value (double). What I'm trying to achieve is, in an event driven scenario, h...
I have an array that contains over 150,000+ object pointers of over 300+ different classes, but they all inherit from the same base class. Obviously that's very inefficient when we need to search for an object. I've thought about splitting this array per-object-type, which got some better performance, but not as much a...
I have to store many pdf/jpg/png file of max 10mb in a filesystem, and need to save their metadata on a database. The SFTP and the DB may be on different nodes. On WS, I've a local db where I can check the login and ask the address to the database and the filesystem. I was wondering: what happens if DB fails just befo...
Overview This question really becomes can I ask a software developer in Argentina or a software developer in Zimbabwe for a component in a standard way? Background Something that acts like I am thinking is how in the construction industry there are industry-specific classification codes, the Construction Specifications...
I keep thinking I have my head wrapped around the Liskov Substitution Principle, and then I realize I don't. Here's where I've gathered from StackExchange: Subclassing Square from Rectangle violates LSP because if you change the width of a Square the height changes too. Null Objects don't violate LSP. Those seem to c...
My company has one repository that contains five top-level projects, which are all different "services" (that being the flavor of the month). Even though they're all in a single repository, they're deployed separately and treated as different applications. We have some common code that we would like to share between al...
I have a list of steadily growing values like 19:57(12.259), 19:58(13.101) stored in mongodb. Now I want to find out if the value grew 50% within 30 minutes within the last 3 hours. My first naive approach was to take the value from 3 hours ago (a) and then look for the point in time when the value is greater than or e...
One of the most important rule in TDD is to write the simplest test to implement the simplest code in order to get closer to the end of a project. I'd like to implement the game of Briscola. It's a simple card game, with 40 cards, 2-5 players, and simple rules. To start, I thought the best thing to implement was the c...
I just debugged a problem which proved to be that "and" evaluated both arguments before checking whether either was false. That's fine, not all languages handle x = (will_return_true() || loop_forever()) ? "win" : "lose" in short circuit fashion. Is there prior art on a symmetric equivalent? Interpret x = (loop_forever...
I've read in a lot of forums, a lot of users agree C++ is faster than Java (even if it leads for a microsecond, it is important), so why are the majority of data mining software or software tools developed in java? Shouldn't there be a greater advantage by using C++??
In Python it is common to have "doctests" - simple tests inside the documentation of classes and methods. Their main advantage is that they can easily be executed while editing the code - when I change some code, I can run all tests with a single click, I do not have to open another file. In Java AFAIK there is no "do...
I have this method, which has multiple private calls: GetConfigStatuses(), ApplyFilters(), GetConfigListInfo(). Since these do not expose anything public I cannot test them like I would a public. And I am not changing access level, that would be a smell. So the only thing I can actually Verify and Assert in this meth...
Is it ok when I do rebase and force push in branch which is used only by me? And will I have a problem after merge this branch in master later? A few situations to illustrate this: We have master, I need to add some feature, so: git pull origin master git checkout -b new_feature make some changes inside my branch g...
I am interested in whether IDEs, compilers or linkers are considered SOUP in IEC62304. I found one website which claimed this is not the case. I think I agree based on my reading of the standard, however, I would like to double check.
I'm writing some pedagogic material and when I started explaining what an API is I realized I didn't know why we say "application programming interface" instead of just "programming interface". Does anyone know the history?
I am a self-taught programmer, and started my job as a PHP developer,in a small company. I then got some work to write python script. I didn't have any senior with proper Python experience. So I started learning on my own, and started with work. With time, it has happened that, I have written about 90-100 scripts, all ...
I want to have functions that convert numeric values into strings in English words, to pluralize nouns, to inflect, break by words and so on. I will use these throughout a big project. Normally I would put them as pure static methods in a StringHelper class with nothing but static methods. But it there a better way to ...
I'm very new at writing Cucumber tests. I'm writing Ruby helper functions to assist Cucumber step definitions. Should there be a separate set of tests to test my helper functions i.e. unit tests? The step definitions are using the helper functions but there's nothing really testing that the helper functions are working...
I am not sure why there are so many header file for the C standard library (stdio.h, stdlib.h, math.h). How do these header files point to the same library? I guess I am a little bit confused about what actually is a library. Where does it exist? Isn't a library linked to the program through a header file?
Early on in my career I was advised to add additional spacing between source code and an inline comment, like so: de_cologne = (i == 4711 # 1 and j == 1799) # 2 Note the two spaces. Supposedly, the reason for doing this is to distinguish operators that we use to delimit comments from other operators. P...
Here's the representation of commonly seen Spiral Model: From what it has been written in book and articles that I have read that in every iteration, the four steps are carried out in a loop: Determine objectives/ Plan Risk Analysis Development / Code Evaluation for next phase But what are the sub-steps in each spir...
According to this article, nginx has a master process and a number of worker processes. I'm trying to understand how a request is handled by the nginx worker processes. nginx uses an event driven architecture with multiple listen sockets and connection sockets. Typically with an HTTP web server you'd have a single pro...
I've read about NEAT/Evolutionary Artificial Neural Networks/Genetic Algorithms. I understand the concept of choosing the fittest neural networks and breeding them to produce another one, but how exactly does this work? Do you simply choose at random, weights from the parents, for the child network? Do you cross over t...
I'm a software intern and I am assigned bugs to fix as well as features to add to the software. When I add features, everything works well. My problem is more with fixing bugs. I'm working on an extremely large codebase (span of millions of lines) with poor documentation (There are no comments, tons of magic numbers...
I have written two small programs in which I declare a very small array. Then I try to access values out of bounds. The interesting thing I noticed that when I try to decrement the index I can decrement this very very further away. If I try to increment it the program crashes much faster. This is my two codes and the r...
Let's say I have an entity class ListOfItems with many related entities Item. These items are processed in a ItemsProcessor class that encapsulates the behavior. This class has several control lists and variable, for example, a processed_items list. Every time an item is done processing, it is added to that list: class...
TL/DR: When requiring another script in Node.js and defining it as a const should the variable name still be in camelCase like it was usual with var or should it instead be in SCREAMING_SNAKE_CASE as is more usual for a const? const someVariable = require('...js'); vs const SOME_VARIABLE = require('...js'); Longer v...
Entscheidungsproblem placed a challenge in 1926, Can we write an algorithm that checks to see if a proof can be solved without actually doing the proof? Alan Turing reduced his Halting problem to this problem, by saying in his paper: "Corresponding to each computing machine 'it' we construct a formula 'Un(it)' and we...
I have an API being used in an app which has URIs like these : /API_Name_1/v1/param1/param2 /API_Name_2/v1/param1 /API_Name_3/v1/param1/param2/param3 /API_Name_4/v1/param1/param2 etc. Now only one of my API [eg. API_Name_2] need to change while others need to remain the same. Should I just upgrade this particular one...
Assume I have a class that represents a complex domain object with dozens of properties, such as a pension policy. The GUI lists all pensions in a summary table that only contains a small subset of those properties. The application uses an ORM such as .NET's entity framework. When querying the db to populate the summar...
I have a solution with an onion architecture using an asp.net MVC project. I also access Active Directory, and was wondering if one needs to loosely couple Active Directory access? Say I have : Entity Framework POCOs Repository Service MVC The way I currently do it is by adding Active Directory operations classes dir...
When debugging object oriented (Java) code, sometimes some field of some object is null while it should not be. I often spend what I feel is way too much time trying to figure out where it should have been set (at which point it's often quickly clear what went wrong). If it had been a function argument, I'd be easy to ...
Each time an iOS app is installed a new device token is generated. When the app asks the user for permission to push notifications one can get the new device token value. How can I know that this device token is from the same device (e.g., the user has deleted and reinstalled the app) and not from another device used b...
I am running an ecommerce website built in Java using Spring and Hibernate. If I have to briefly describe current architecture then it is like this: I am having two projects by name - store front and admin Storefront project holds DAO, model, service, controller and views for showing the storefront view of website and...
At my company we have multiple C# programs that use Dictionaries in a config class to keep track of the configuration and state of the program. For example, bool isFoo = config.GetBool("Foo"); This seems clunky to me for a number of reasons. For one, there is no easy way of knowing what is in the Dictionary at any gi...
I'm working on a hardware product that contains an embedded Linux system. The majority of what we execute on that system is a set of Python code which currently has its own Git repository and is version controlled like a normal standalone software project. I'm stuck on how to manage and version control the OS configura...
I have an Enum in Python that looks something like this: import enum class Color(enum.Enum): red = 'red' blue = 'blue' yellow = 'yellow' puce = 'puce' chartreuse = 'chartreuse' And I want to have something like: primary_colors = (Color.red, Color.blue, Color.yellow) But naturally if I try and sti...
The following explanation is rather detailed, but I think if I simplified the problem at hand no proper answer could be given. I'm working on a scripting system for a game (for end users rather than internal developer usage). The game has both singleplayer and multiplayer modes. There is a base Script class, inherited ...
For reasons lost in the mists of time, your project has a code coverage standard. Unfortunately, some new code has gone in which takes the coverage below this figure. John Doe is duly assigned to write more tests (since Jane Doe is off snowboarding). John is unfamiliar with the code and drags the coverage over the line...
I got asked a question today that was so basic I was unsure how to answer it. I had added some logging statements to our integration testing package, to find out what part of it was taking so long (many hours) to finish. These tests are huge, so I've been going through them adding logging to different parts as time pe...
I always wanted to create software but was not really into websites.I see that popular programs(such as skype) don't make as much money as popular websites(such as facebook,twitter etc.). Is this because monetizing websites is easier than programs? If so, why is that? And what are some popular methods to monetize free ...
I've developed an SDK (link) for a RESTful API in PHP, and my automated tests (example) are actually live calls against the API, which is bad for multiple reasons, mainly: it takes a long time (about 3 hours) for the tests to complete it's impossible to do concurrent tests because they'll interfere with each other I ...
I'm developing a new service in a micro-services environment. This is a REST service. For simplicity, let's say that the path is: /historyBooks And the POST method for this path creates a new history book. Let's assume that a history book covers one or more eras in history. For brevity, let's assume we have only the fo...
Assume we have the following class: class Foo { public: void func() { _func1(); _func2(); } private: virtual void _func1(); virtual void _func2(); }; This class, from one side, specifies the interface (foo method), and, from the other side, it defines the implementation (first we call _func...
I couldn't come up with better title. I will try to explain what the problem is. Currently I am trying to build dynamically created report structure. I define needed report in config file. When user wants to a report I simply parse from config and create. The struggle I have is about how I can implement a general struc...
Is it a good style to place curly brackets around logical parts of sequential code to structure it? An advantage would be, that you can collapse these blocks in an editor like vim and get a better overview of your code. I talk about code, which does not belong in a separate function, due to parameter passing overhead, ...
I have a repository, which at the moment, reads from the database every time it is called. However, the data is only updated once a day, and to improve performance, I'd like the repository to store the data in memory. When the data is updated, by another application (but same solution), I would like to notify the repos...
Docker is amazing. You can use it to replicate production and all its quirks on your local machine. Then you can deploy that instance straight through all the staging workflows super-quick. Ie your software stack becomes an immutable repeatable widget in a CD pipeline. The challenge is that the understanding the docke...
Why is Iterative software development better than Waterfall software development? In the Iterative method it take more time because of iterations and start with minimum small planning which is not good because with minimum planning which can easily lead us to wrong path. Instead if we use waterfall method first we wil...
For various reasons we are looking to move from TFS source control to Git. We're hoping to keep our current workflow but struggling to understand how this translates to Git. In TFS we typically have two branches: Main (day to day dev in here) Release (production, we deploy from here) Typically, developers will check-...
I should preface this by saying that although I've been programming for a while, this is the first time I'm doing it for work and am relatively new to PHP. I have been asked to create a PHP app that, on the face of it, is quite simple - although it has some complicated business logic. Basically, it shows the user a num...
Current setup We currently have one Jenkins server that automates deployments for about 15 different Java web applications. Each application has three deployment environments on separate Linux boxes. Development Test Production In Jenkins every application has it's own "view". Inside every view there is a job for ev...
The are two operators '<>' and '!=' used in programming languages with the same general meaning. '<>' can be used in PHP, SQL, and Pascal. '!=' seems to be more commonly used. What is the original reason for both of these operators to co-exist, when they seem to be so similar in purpose? What was the first language to ...
I'd like to better understand Iterator/Range design decisions (focusing on InputIterators). Basically, this is the java model: while (iter.hasNext()) { Object o = iter.next(); // do something with o } But, here is a quote from James Kanze: Not that Java's iterators are perfect, either. The merge access and ...
I am curious on if this design is considered good or bad practice. I have a dispatcher and a service class. Dispatcher I have the following: public void doBeforeUpdate(Map<Id,sObject> oldMap, Map<Id,sObject> newMap, List<sObject> triggerOld, List<sObject> triggerNew) { Boolean myBool = service.myCheck(triggerOld...
I recently started reading theory behind algorithms. I then started thinking about "what if we abstract problems and algorithms, so you would be able to implement a generic system that can solve most problems.". Unfortunately I was not able to find information on this topic. Logic Programming comes pretty close I guess...
I have been researching oauth2 as of recent and trying to draft an implementation plan. However I seem to be missing something, or something hasn't quite clicked yet. I plan on creating an api and having certain endpoints be protected, requiring authorization. This api will be accessed via my 1rst party web applicatio...
Suppose that I want to build a notification system in which users can configure what time during the week they will receive notification. So I might want to get notifications on Monday 10 am - 2 pm and Thursday 8 pm - Friday 8 am something like that. But would the object be like? I am thinking class TimePeriod { D...
I'm creating a site for commercial needs, for myself or for sales. In them, I'll use the Laravel framework. Laravel is licensed under the MIT license. The MIT license tells to me: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. What is the...
How exactly do stack machines (both real and virtual stack machines) store global variables? I know that C(++) just compile it to the .data segment of a program's memory segmentation. Then there's Java's JVM which uses a stack-heap system (both data-stack and heap are stacks that grow towards one another) and stores st...
Scenario: I am designing a system where user uploads a structured data file ~0-5GB in size. I need to let user analyze this file and perform some transformations on the file which essentially means running functions that extract information from this file and/or change structure/data in the file. User can perform these...
I'm reading Code Complete (2nd Edition) and in Chapter 21 the author mentions the terms system code and application code in the context of formal inspections, saying that system code has to be handled at a slower pace than application code in order to be productive. I've tried searching the web for a distinction betwee...
I'm looking for pseudocode suggestions for sorting my mp3 files in a way that avoids title and artist repetition. I listen to crooners - Frank Sinatra, Tony Bennett, Ella Fitzgerald etc. singing old standards. Each artist records many of the same songs - Fly Me To The Moon, The Way You Look Tonight, Stardust etc. My go...
Python (Flask) web application has a big portion of email/SMS messages generated by templates, translated by Flask-Babel. To my eye, having literal constants for the message in views, among other view logic and calls to the other layers, is not elegant: Views are there to render the html or serve ajax calls, not render...
In the book Compilers: Principles, Techniques, and Tools (2nd Edition), Appendix A, the authors offer a implementation of a compiler front-end that generates three-address code for a very simple language. Like many other languages, the language in the book has scopes denoted by opening and closing curly braces. To avoi...
On my team I'm working as a frontend developer in a React codebase. We're building an application and do everything in React. Before this I was actually always a backend developer. Now I have the feeling that in most "backend" frameworks it's quicker to just generate a view with a template engine instead of connecting ...
I'm the co-founder (there's two of us) of a software development company, doing mostly webdevelopment. Recently we hired our first employee and soon enough we find ourselves in the need of a standard (and preferably enforced) coding style. We do however not enforce a certain IDE. I for example use Atom while the curren...
I'm looking for some advice on testing strategies for service to service communication. I have one service (service A) that makes a call to another service (B) - which is a rest API. Both services are owned by me. I have some unit tests around the service calls and I simply mock the HTTP library so no requests are actu...
I have recently tried to to implement unit tests on a Java Web Application my project is built on MVC design architecture and uses Spring & JPA Hibernate and JSF here is a package tree -src -entity -dao -impl -service -impl -rest -impl -web -utils -config -common -enums -exceptions...
I'm in need of some advice before going foward. I want to build several large scale projects, like a marketplace product, and a few domain-specific products and libraries. The products may or may not be related but may share libraries. Each product may very well be their own companies [e.g. the marketplace]). I'm for u...
For small command line applications I can get away with simple command line input. ./test input.png output.png But for larger applications that requires a lot of input, simply using command line becomes messy very fast. ./test cam1.png cam1_focal cam1_principle_x cam1_principle_y cam1_k1 cam1_k2 cam2.png cam2_foca...
I'm working on a application which is implemented using microservice architecture. There is an authentication service (A) which uses jwt standard, and there are other services in the application like S1, S2, S3 and so on. Now for example S1 receives a request, it should validate the token to see if the user is authoriz...
There is REST endpoint in my application which handles POST request and then makes a HTTP post to another external application and when the resource is creating in the external resource then I create a record in my database with the externally created resource ID. For example if a user requests to save a new Car then t...
I am noticing a weird mentality, when it comes to refactoring code, and I am not too sure about how I am perceiving it. Overview of the current project: A web application used as an extension to an existing 3rd party web application. The 3rd party application maintains schedules between customers and vendors. The exten...
We are developing a REST application based on an MVC architecture. The service layer is returning Optional<T> where T could be any class. So on the controller layer there is a conditional statement which tests if the result is Optional.empty, and then return a custom response with data []; else, return the actual data ...
Below are the relevant types(in java) for annotation processing, In addition to Field & Method types, Package type is also used in context of annotations with reflection, because these types implement AnnotatedElement interface. This contract allows to access(in runtime) the instances of those types to get their meta...
I may be misusing "scheduling" in this context, but here it goes: I'm trying to build a simple calendar scheduling algorithm/routine, the purpose of which is to determine if a particular Time-Span is long enough to execute a number of scheduled events, each of which having a pre-determined duration. I.e. Task A, Durat...
I currently have a web server running apache with multiple sites on it using virtual hosts. I want to add a service to my server that is using nodejs but I want it to be accessible under the same domain as a sub-domain. This is, I believe, impossible with my current setup since nodejs and apache can't both listen on po...
Currently looking into Event Sourcing in a Microservices architecture and I've found this article. It describes a possible implementation of CQRS and event sourcing. If the logic dealing with updating the read model and creating the events are both implemented in the same (scalable) service, how does this architecture ...
I have heard from a former colleague that not all bugs need to be fixed, because as you go down the priority list of bugs, the use case which causes that bug becomes more obscure, or the customer satisfaction gained gets lower. But you still have to spend considerable time on fixing that bug. In an effort to convince ...
When trying to turn a class with mutable state into an immutable one I am regularly having a hard time choosing between two alternatives: I can 1) either extract the state into another (immutable) state object and pass this state to the class with every method call (and return the new state) or 2) make the state part o...
I am trying to break down a large application so that multiple teams can work on it. I have created a number of Bounded Contexts for the domain layer. Each bounded context is contained in its own solution with an Infrastructure layer and a Service Layer. There is one repository per aggregate root. How do you deal wi...