instruction
stringlengths
34
36.1k
What are the generally accepted means of running tests that pass on the dev machine on the build server where they'll consistently fail due to missing dependencies? (In this case, a configuration file that is managed by another completely external application.) My app is reading an INI file containing various key/value...
In my previous question, it was highlight that implementations of C++ such as GCC must store a vtable pointer in every copy of a class for each parent class which has a virtual function. So a class which implements say 5 "interfaces" (i.e. pure abstract classes) must be at least 5 pointers in size before even it's own...
I have a simple project where the controller calls the service, and the service calls the repository in order to get the needed data. Assuming that we have these domain models: // this model has a RepositoryA built for it Class A { public string Name { get; set; } public int B_Id { get; set; } } // this model ha...
I have a service (S) that receives an object of type 's', this service will be called by several classes (maybe 6) and each class has their own object a,b,c, etc. with the information necessary to fill object 's'. There is no big logic when setting the values of 's', just some s.setPhone(a.getPhone()) calls. Would it ...
I have a serious problem with application which i working on. It has a lot of procedural code and now it needs to refactoring now.. The problem: we have two different application in general, but they're use the same "module", concrete functions from this module. It looks like this: (pseudocode) // general application c...
I am looking for the best approach to design the following system : I have a class of object, called Compilers (C, Go..Etc) I have another class of object, called Protocols (HTTP, RPC, WEBSOCKET..Etc) I have another class of object, called Serialization (BINARY, JSON..Etc) Now each compiler has to be matched with the...
Background I have an application which stores a lot of entities in a classical relational database (Microsoft SQL Server) and I use an ORM (Entity Framework) to query data from it. This database has one schema any only a "global view" to this data exists. The data is made available to users via an OData API. For simpl...
Is it possible to create an algorithm that will execute at the same rate and speed on faster and slow computers. What i mean is, i have a year 2000 desktop that can run a certain computational algorithm. a hundred years latter, quantum computers have arrived in their full capacity and i want to run the same algorithm. ...
I have an endpoint "import" that is supposed to accept an entity. This entity can contain several sub-entities with yet again some sub-entities. Since this is an "import" endpoint, some of the entites or sub-entities may exist from previous imports some may not, some are required and some are not. Some have special rul...
Today my manager said: 'Amir, don't mix the business logic with data in database'. I surprisingly shocked! I said 'Where?'. According to wikipedia business logic is: In computer software, business logic or domain logic is the part of the program that encodes the real-world business rules that determine how data ca...
Myself and my colleague were having a discussion about MVVM and how lists and selected items should be stored in view / viewmodel. I think the viewmodel should only offer up the data and allow the view to interpret it how it likes. It could display it as a list with a selected item or it could show it completely differ...
What are the best ways to unit test code that outputs random sequences satisfying specific conditions, such as Markov chains? Let's be specific. There are two natural things to test: That the initial state returned in each chain follows the user-specified probabilities, such that chain[0] == i with probability p_initi...
A flat state machine has one active state. In a hierarchical state machine (HSM), if the HSM is in a child state, it's also in it's parent state. So, an active state configuration of an HSM consists of multiple states which form a tree. If the HSM doesn't have orthogonal regions, the tree simplifies to a list. Is th...
Some sites, like theater ticket reservations, place a limited-time hold on the item , while the order is being processed. As soon as you select the seat and proceed to pay, Seat is reserved say for 10 minutes. I see here a big risk where a hacker/automated script(bot)/manual user can lock all inventory and does not act...
I'm currently developing a controller for an industrial application which takes data inputs from various sensors and interfaces (ethernet, serial, etc.), does some minimal processing, and adjusts outputs to interfaces and mechanical systems as needed. The device, a B&R X20 automation controller, uses a simple RTOS oper...
Auto-completion :- When we start typing, does system suggest the product from cache or hit the DB every time or hit the DB only when no result found in cache ? Search:- When enter any product, does system straight away hit the DB or tries to fetch it from cache first ? Orders :- I believe here order must be straight a...
I'm trying to write a very high scale IRC logger that can handle like 1k messages per second. My Database of choice is cassandra and maybe later I might look into scylladb. My Question is how do I write the software part to be distributed. How do I best horizontally scale this. The obvious way would be to have multiple...
our startup is working on an integration for various customers. All of the customers are required to provide their data in one unified way = we chose XML files because of legacy compatibility and ease to validate the files with XSD schemas. The scenario should be that the customer provides their XML file which we will ...
I have an interface IMyService in a class library. I have an implementation of this interface MyService in a separate class library. MyService may raise a custom exception CustomException. Should CustomException live in the interface class library, or the implementation class library?
The problem is simple on paper... but a bit harder when it comes to write the algorithm to solve it. Let's use the following graph: First part This graph has an entry point A and two possible exits B and J. I'm looking for a way to find the minimum and maximum number of nodes needed to go from entry to an exit (the pl...
As a personal project to learn key technologies, I am trying to build a spreadsheet on the cloud (something like Google Sheets). How would you design the storage backend to power something like this? Does it make more sense to use a relational DB, something like a No-SQL-DB or a different kind of storage technology? An...
Although things have come a long way in recent times, in my workplace we're still talking about DLLs, containers, configs, substitutions, pipelines - all complexities when it comes to shipping code. We deploy many of our .NET applications like so: Containerise everything with Docker Build everything and run all tests ...
Reading books on REST architecture(especially O'Reilly) many times I came across the idea that one should attach data's description into link http header. Link: <http://example.com/contactmanagement/profile>; rel="profile" Date: Fri, 21 Dec 2017 06:47:25 GMT Content-Length: ?? { "contactId":1, ...
Lets say that I have a shelf on which I can put items that are shelfable (not sure if that is actually a word but you can understand my point). So I have the following: class Shelf { /** @var ShelfableItemInterface[] **/ private $items = []; // addItem, getItems... } interface ShelfableItemInterface { } ...
The database schema of an application is rarely fixed, due to new development the schema has to change. This also applies to a schema-less solution like MongoDB. There is documentation on how to handle schema changes, i.e. if a property has been removed / renamed etc. My problem is how to query data after such a schema...
I was just reviewing some code and realised it is going to introduce the possibility for a situation where the numbers our staff use on a daily basis could be slightly out of line with the numbers we get in our monthly reports. Fixing this would be difficult and ultimately is of no benefit. I see this as a small quirk ...
RFC 2606 standard reserves the domain names example.org, example.net and example.com for the purpose of being used as examples in documentation. What is an equivalent for a phone number (including country code) that can be used as an example, e.g. for giving users an example in what format to input phone numbers? In th...
I have a graph service where I use if/then/else statements. class GraphService { function getGraphData(array $products) { foreach ($products as $products) { $gotPumpGraph = false; $model = $product['model']; $item = $product['model']; if ($model ...
We're building a search engine at a client's place. To evaluate the results, the client is comparing top N results of our search engine to top N results of a competitor. And they want me to get at least some "X" percent common results with competitor. And that's the only metric they're using to decide success of the pr...
For example, suppose I have a ZipCode class: public class ZipCode{ public value String value; public boolean validateFormat(){ ... } public otherMethod1(){ ... } } I found many classes uses ZipCode instances, but validateFormat() is used in one place only : register page: public ...
I have a business, selling online. Now I'm updating my software portal. My developer suggests using stripe instead of a bank account. He knows it is better but he cannot explain why. Some more details on my situation My situation is - as always, when I sell stuff on internet I need to make clipping and pay my agents. ...
I came across this Enum and Struct declarations in a project supposedly done by an expert. The declarations / definitions are little different than what im used to so far. enum EnumKeys { KEY_MENU , KEY_EXIT , KEY_DOWN , KEY_UP , KEY_RIGHT , . . . }; But nowhere in the code the actual Enum had been defined...
I want to create an app where a user will go through a series of steps every day. All the subsequent step will depend on the previous ones, that is, 2 users can have different experiences depending on the choices they make every day in my app. Something like if .... then .... => ..... if ... then => ...
I'm currently learning about TDD techniques, one of the suggestion is to test only public methods and skip the private ones. I have also been reading about Mocking. If I want to mock a certain method, then it needs to come from an interface or be marked as virtual. When I start developing my application I don't know wh...
We have one microservice that will be deployed on two different environments(A and B). There are some common fields and also some are specific to the environment. Example: SomeEntity for environment A have only name and age and their validation. SomeEntity for environment B have only dept and experience and their valid...
My main goal is described here. How can Microsoft Word or Wordpad or other word editing software render fonts when these fonts seems to not follow the same rules? How do they render characters glyph based on adjacent(or sometimes even further neighboring) characters? For example look at this font(it is free). opening ...
I am trying to extract some core functionality out of my main application code, that doesn't change very often (e.g. logging, utils etc.). Our current Situation: A dev branch with all code in it. A lot of release branches, that were branched from the dev branch So what I though about: Create a new Core-branch for m...
Today we are using SQL server with multiple indexed views. Whenever we update the source tables for the view there is too long delay. I have no experience with Spark, so the question is: Can we input the data from the source tables, create the "data view" in spark and then only select the data we need from it? but stil...
I'm migrating from Java to JS and I would like to know what is the best way to do it in the field of JS ecosystem. After reading all the You Don't Know JS series by Kyle Simpson, I would like to learn: npm, grunt,gulp,lint, transpilers (babel), webpack and so on. I don't have any experience in any of them and to be tr...
I work for a company that is building a web application with ASP.NET & MVC, which was last worked on a few months ago. I am part of the team working on the project and have encountered values (such as place names) being hard-coded in the project's web.config file. In my opinion this is bad practice as multiple develope...
I am studying Onion Architeture but i got some doubts: All the samples (github) I found over internet are too simple, or are implemented under DDD (which I have not studied at the moment) so I can not get a clear concept. About Domain.Services I have some doubts: It has to define implementations? For all Services int...
I have a personal photo album application where I upload my photos. However, I'd now like to extend it with videos as well, and I'm unsure how to properly perform this extension. The current design consists of 2 tables - Albums table that contains info about the albums (name, dateCreated, etc.) and Photos table, where ...
lets say we have a "door api" and I want to create a resource to close the door. I could do this in 3 ways: traditional way using PUT with payload {id: XX, color: YY, closed: true} advantages: simple and follows standard disadvantages: client needs to edit the door instance by editing closed property and send the va...
I have been working with Jira within an Agile scrum like methodology for a while now. What happens quite often is a ticket is estimated and started on. By the end of the sprint 95% of the work is done. What usually ends up happening is that this ticket is dragged over to the next release iteration to complete the 5%. M...
The scenario is: client makes request to server A Server A makes potentially multiple requests to server B. Edit to clarify, server A makes the requests concurrently using Futures. Server A blocks until all results return Server A collates responses into single response and returns to client So currently the approa...
Say i have a Rest API that has a POST and GET method. If i want to overwrite a resource in the API i can call the GET method to get the original item and then call the POST method to replace that resource after i am done modifying it. Should i add the update functionality to the client class like in the first approach ...
I am part of a team that has recently moved from an SVN repository to a Git repository, and have started using GitFlow. As I understand it, this means that in a perfect world, the minimum number of Git branches can be as few as two: master and develop. In practice, there'll be more, accounting for release and topic bra...
I do understand this is a wild question and totally open-ended but just wanted to know that I am barking up the right tree. I've inherited a large code base of many solutions and services, and whilst I'm learning to program in C#, ASP MVC and javascript have noticed a load of issues with the existing code. I'm being e...
I return to this question every couple of years, so now i decided to solve it once and for all, by asking here. So, the sequence: I'm writing a simple application that parses Json file (configuration to 3rd party app, further named as config) and allows user to do some editing with it. I've picked a platform, made som...
To learn Javascript I am building a simple Single-Page Application. It is a basic slideshow app that needs only to process some basic settings and execute some behaviors. The basic structure of my code is thus: var settings = { ... }; function initStartPage() { ... }; function initSlideshow() { ... }; function setting...
I have a web app whose server creates a Client for each websocket connection. A Client acts as an intermediary between the websocket connection and a single instance of a Hub. The Hub maintains a set of registered clients and broadcasts messages to the clients. This works pretty well but the problem is that a client mi...
I'm working on a C compiler for Linux for the purpose of personal curiosity/fun. How can I test the generated assembly before the compiler is complete enough to do anything useful? For example, if I have the following program: int a = 1; and it compiles to a: .long 1 How can I be sure that this output is actually...
I'm wondering if there is a name for the pattern of defining a generic class with one type argument where the type inherits the defining class. For example public class A<T> where T : A<T> { } I'm not sure if there even is a name for this. Any help would be much appreciated, thanks.
I am doing a collaborative note editing app which uses a NoSQL database (Firebase) in server side. Each user can sign up using their phone number or email. Currently, the user object has only four values: user_id, user_name, user_email, user_phone. Any user can create a note by including people from his contacts even i...
I have a scraper service that looks for media online. For every source type, there are two tables. A common source table and a source_type_media table that are related by source.id to source_type_media.source_id, this service will store raw information. The scraper service will scrape at some frequency via a cron job...
I am writing a driver for an IMU sensor using test driven development approach. Communication protocol of choice is SPI. Using CubeMX and STM32F415 processor, SPI interface is implemented in stm32f4xx_hal_spi.h file, which contains many and more function declarations. Note this SPI interface is processor-specific and I...
I am trying to resolve a circular dependency between two components in my system. The Messenger component is responsible for sending and receiving messages on a web socket. The Controller component requires use of the Messenger component to be able to send messages to connected clients because the Messenger component k...
We are developing an angular 5 application that must run in different environments (dev, qa, int, uat, prod), and connect to different APIs depending on the environment. We have traditionally have only 4 environments and we have a environment file for each with environment variables. But now with the introduction of t...
Let's say you have two microservices (contrived example): Customers service Dashboard service In the customers service, you manage all aspects related to customers (address, preferences, whatever). In the dashboard application, there's a map you want to display showing all of the names of customers and their location...
For example, it is common to see games with game loop and states: stateChanged(){ switch(state){ STATE.PLAYER_SELECT_CHARACTER: this.currentController=new PlayerSelectCharacterController(); break; STATE.CHARACTER_MOVE: this.currentController=new CharacterMoveController(); break; } ...
Refactoring an old API into a new one, because of several tools using it (admin and some mainteinance scripts) and compatibility with older versions reasons the database structure must remain the same. I have a table user and another table user_optionals related 1:1. The user_optionals are just a bunch of fields with s...
Our system was initially created around the client's ordering logic which is received by an API. This was allowed by the previous I.T. dept. However over time (after growth) many different clients with differing systems send their order's to our API which have to be cleaned and changed into our working version, example...
Or simply asked WHY ? It simply does not seems logical ... if ( null.asInstanceOf[String] == null ) println ("null.asIstanceOf[String] is null") println ("BUT !!!") if ( null.asInstanceOf[Double] == 0.0 ) println ( "null.AsInstanceOf[Double] is 0 !!" )
Some years ago, the w3c documented a proposal for a method called QUERY, where query information may be passed in as the request body rather than on the request line in query parameters. You can see this here: https://www.w3.org/2012/ldp/wiki/Proposal_for_HTTP_QUERY_Verb My Question I realize you can send any made up v...
This is the most popular way (it seems to me) of checking if a value is in an array: for (int x : array) { if (x == value) return true; } return false; However, in a book I’ve read many years ago by, probably, Wirth or Dijkstra, it was said that this style is better (when compared to a while-loop w...
I took over 5 hours in sprint planning for a week long sprint. That seems like too much. We discuss things in detail in sprint planning, as most of team members are not senior. If we don't it will lead to mistakes during implementation and redesign during sprint. How do we deal with this? How much detail should I discu...
I am currently using Postman, Newman and Jenkins to automate the process of testing API end points. The API is being written in Node.js and Express.js. Currently the tests I write with Postman are being saved to a git repo, being fetched by Jenkins and run with Newman. I now want to stream-line the process of creatin...
I'm currently working on a project/product which consists of ~60 REST APIs and one client (Web app) I find many downsides on this design, and not so many benefits, and I'd like to know if this is clearly a bad practice from an architectural standpoint or just bad execution. (And if it can be improved without changing t...
Let's say we've got 3 entities here, User, Tag, Track and a single associative entity called Tagged. I need to count a tag frequency of a track and the common way is to count the record of tagged, but what if I just store the tag's frequency as an integer attribute on Tag entity, and maintain the value every time ther...
I have two screens: A screen with a list of items, where every item in the list has "Show Details" and "Update buttons" An item details screen. The "Show Details" button navigates to item details screen. When clicking the "Update" button, it needs to take a decision based on item state and then navigate to either t...
We know about using service workers in modern web sites. Consider a scenario back-end as node.js and SQL Server. Data is loaded from central database to local customer web app (DB is about 700 MB) and maybe each days update about 2 MB. Can this situation handle via Service Worker or Browser Cache? Which is the best...
right now application is storing a file data in database and we are considering instead to store a link (http, ftp, etc) to the file and its checksum. We will only provide a service and the service consumer is supposed to provide the URI and its checksum. As we do not want to store the file, we won't be able to calcula...
Where exactly to put business logic. While everyone said put it in the aggregate. Yes, But what if business logic need datas of multiples aggregate? Or if business logic need to update multiple aggregates. Does it acceptable to be in command handlers or need to be in saga? And Why? My first approach Room ID Capacity...
I am working on an Android app, and trying to figure out which version I should target. The current version is 28, so I figure that targeting any version of that minus 3 (ie >= 25) seems reasonable, but I'm wondering if there is any industry accepted guideline on this. When the most recent version of Android is X, shou...
In multi threaded java program, I initiate four concurrent threads with below details 1. Thread 1 writing file F1 2. Thread 2 writing file F2 3. Thread 3 reading file F3 4. Thread 4 reading file F4 Its an octa core processor, My question can four threads parallely read or write on hard disk or it will be sequent...
I'm developing a node.js web server which will have built source code of server and client part at once. I mean, my web server is on the isomorphic level. this means editing source code of client part eventually give some effects on server-side code. so when I've finished to develop (fixing bugs, etc.) my web server ap...
Number of times this question comes to my and my team mind, should we persist or cache the data. I understand some time there is functional requirement that we need to persist in DB. But in my case there is not any. But here I mainly talking in context of scalability/performancewhich design is better. Lets take an exam...
I use C++ on ESP-32. When registering a timer I have to do this: timer_args.callback = reinterpret_cast<esp_timer_cb_t>(&SoundMixer::soundCallback); timer_args.arg = this; Here the timer calls soundCallback. And the same thing when registering a task: xTaskCreate(reinterpret_cast<TaskFunction_t>(&SoundProviderTask::ta...
I have a windows service and a remote IIS server that need to communicate without any user interaction. As I can’t guarantee the two machines will be on the same network; the service will connect to the server’s public facing IP over the internet (so security is critical) and transmit encrypted binary back and forth. I...
I have been a staunch advocate of never blocking on async code. I felt it was always better to use a synchronous API than to run the less efficient state machine generated by the compiler even if there is no chance of deadlock. But in the specific case of System.Net.HttpClient with code that cannot go async all the way...
I'm designing a system in which a key component acts like a "journal", in the sense that it stores a list of sequential events that can change the state of the entire system. Upon request, any other component in the system can ask this component for the full list of events that happened since event XXX. One can think ...
I'm currently working on a script (in PHP, but I'm not sure if that's relevant here) which allows users to set up a simple file-sharing system on their server. I'm stuck when trying to figure out how to deal with file downloads. I see two possible approaches here: 1. Direct link to files on the server Such as https://...
My understanding of Micro-frontends is that the key problem they solve is in helping enterprises have multiple, possible disparate teams, work on individual components/small-apps that will be used to compose a large web application. Here the key problem being solved is the ability of multiple teams to work independentl...
The security of a TLS connection relies on trusting the CA's certificate, which in turn, is usually actually a proof of DNS entry ownership. Even though the server operator may request a certificate on its behalf, when server operator and domain owner distrust each other, domain owner wins. SSL and TLS are usually asso...
Good day everybody, My capstone project partners are stumped with a logic question that has to do with JWT, MVC & web services. We have already built a web app with a signup/signin feature using a MVC framework, but for our capstone we need to securely access data from a web service (we have not builded yet). We consid...
Let's say you want to center the text here: <div class="wrapper"> <div class="content"> <p class="body"> GUCCI GANG, GUCCI GANG, GUCCI GANG, GUCCI GANG, GUCCI GANG, GUCCI GANG </p> </div> </div> It doesn't make a difference whether you put text-align: center; on wrapper, content, or...
In my workplace I am seeing an issue which I feel is wrong, but I am open to the idea that maybe the way I do it is wrong. A minor example would be a class accepting configuration //pull config from config file, then pass in to class public class SomeClass() { public SomeClass(string connectionString, string someOth...
Say I have a following class: public class A { public void execute() { if (something) ThirdPartyApi.method(); } } Now, I would like to test in particular the execute() method. I want to assure that all paths are covered and work as expected. However, the issue I would run into here, is not being abl...
I need to build a few (2-3) different systems (frontends), they will have different uses and users, however the data for all those systems is in 1 DB. example: 1st system is a customer facing site 2nd system is a customer facing mobile app (android and ios) (similar to the site but can have different views/data) 3rd s...
Our software has two services - one which provides rest api used by client and one for computations. The computation is quite expansive and can take few hours or days in some cases. There is only one instance of rest-api service and one instance of computation service. Rest-api service communicates directly with comput...
We want to figured out, whats are the pros and cons, when you use a REST api vs querying directly to a database, if you have different client platforms (Web-Application, Android, iOS). Edit: I know that this question is very general and every developer has different opinions, but we only wan't to here some pros and co...
Our frontend JavaScript / Vue code makes uses of a number of "internal" REST endpoints, which are implemented in Java using Jersey/jax-rs. We have an "informal" specification that lists the different REST operations, and describes the "beans" that are passed in/out. On the java side, we have different bean classes, an...
I'm looking at putting up a fan site for an author using code released under the AGPL. Under the AGPL, as I understand it, I would need to publish my code modifications. This is entirely fine. However, the website is in django. I will probably be deploying with Docker, and forking the project to do so. If I want to aut...
I'm working in a OOP language called Fantom, similar to Java, to create a workflow engine. My code sends emails to users, and it awaits for users to click a button within the email. In my current working code, I send the email, then I suspend the thread with something like Thread.sleep(1000), and check every few second...
I am reviewing best practice with if statements. Below in example A I include the entire code to be run and ensure it remains within the if statement. While for example B the code to be executed resides outside the if statement. From my understanding of Best practice on if/return, example A appears to be best practice....
In my understanding, a singleton design pattern is where we have only one instance of an object in a system. I am not sure on this part of the definition, but I believe in an OS there is only one running kernel at the supervisor mode. Thus, is it correct to say that an OS kernel is an example of a singleton?
My service has long running processes. For example - user can signup, but if email not verified after 7 days, we send a reminder email. I need my system test to cover this scenario as well. Currently, I manipulate the data in the DB so the system thinks the user signed up a week ago. But this makes my tests tightly...
Please note that this is about a thread-safe LRU cache (not simply a LRU cache as specified in https://leetcode.com/problems/lru-cache/description/). It isn't a duplicate of LRU cache design question as there are some tricky aspects of Locking Hashtable/Linkedlist(LL) that aren't addressed in other multithreaded LRU de...
I have a system in which user creates an entity. Now this entity has attributes which are dependent on many external systems. We have all those pipelines in backend which updates these entities when there is any change coming from external systems. Now I want to inform user about these updates even when they are not l...
I have some user defined custom fields corresponding to a ticket (A ticket is an entity which has subject, status and custom fields). I need to search tickets based on its custom field values. A field can be a Decimal, String, Date or Boolean. Example - A ticket has subject, status and custom fields - product...