instruction
stringlengths
34
36.1k
I have a scenario where I can take a student Id as input via a part variable and return some data back as JSON objects where JavaScript handles the response as a part of AJAX call. Suppose the method is called like: /student/{studentId} where studentId is a path variable in Spring MVC web service declaration. Now for...
Context: I'm working on an open source project to solve a problem that comes up in ad-tech and social media data mining: indexing boolean expression trees, and matching them against incoming documents. The expression trees that come in from the user need to go through some transformations before they can be inserted in...
I have an application that is modifying some XML files. Two of the files have a similar structure, with similar business logic needed to be implemented on them. I've realized that there are some identical - or near identical - files in their domains aggregate roots. The files aren't value types. I don't see them chang...
I have a legacy class XMLReaderWriter which I think I should break into two classes so that it doesn't break the SRP. Unfortunately the class is already in production and I have to maintain backwards compatibility. What would be the best way to go about this? Any relevant design patterns that I should use?
How do you pass a integer between two process. I'm new to IPC and using pipes I know how to transfer the string between two process. But how can I pass a numbers like that?. I can do this with the string. But is there better way to do this? And how real world product do these things?For Example, chrome browser
I'm working my way through Practical Foundations for Programming Languages but am finding some of the notation difficult to follow. In section 3.3 (page 46 of linked PDF) the author introduces a vertical bar notation that I imagine comes from somewhere in formal logic and I'm not sure how to interpret it. Generic deri...
Say we have a load balancer that also does rate limiting. Rate limiting seems pretty straightforward for logged-in users - just look at the JWT and maybe use an in-memory data-store to see how many requests in the last 10 seconds for that user. However, what about non-logged in (unauthenticated) users? We don't know fo...
Does there exist a Turing complete programming language such that for a fixed alphabet (say, ASCII), every possible permutation of those characters is a semantically valid program capable of being executed? We consider infinite loops to also be semantically valid. I know some data formats, such as Markdown, possess uni...
As a fan of regular types and value semantics, I'm keen on classes becoming more regular and being non-polymorphic. As a fan of non-throwing operations, I'm keen on operations being noexcept. I also appreciate confirmation of what special member functions are actually being generated by the compiler. And I'd like to tr...
I have the following requirement. Read data from a messaging Queue and process each message to enrich the message and then finally send the enriched message to a different system. The enrichment logic is in DB and it is based on message type and each logic can be of different language. Each message will have some type ...
While developing my own logging library, I studied the source code of the standard logging module of CPython. One of its features is that handlers are thread-safe. One can write logs to a file from multiple threads without the risk that the lines are corrupted. I digged into the sources of the logging module and I figu...
Please see the code below; it tests to see if a person with Gender of female is eligible for offer1: [Fact] public void ReturnsFalseWhenGivenAPersonWithAGenderOfFemale() { var personId = Guid.NewGuid(); var gender = "F"; var person = new Person(personId, gender); var id = Guid.NewGuid(); var offer1...
I'm curious what's considered the (best) correct way to pass data to a service layer in ASP.net Core. Say I have a Person entity that has a relation to a Image (profile picture) entity and another relation to a Address entity. Should the signature of the service method look like this: public Person CreateCustomer(Perso...
Keyword-only arguments are arguments that can only be supplied to a function by keyword. In Python they are defined by a single asterisk in a function's signature. For example: >>> def foo(bar, *, baz): print(bar, baz) >>> foo(1, baz=2) 1 2 >>> foo(1, 2) TypeError: foo() takes 1 positional argument but 2 ...
Consider I have a list. I want to iterate over it and map it's elements -- but the mapping might also require to change others than the element I'm currently iterating over. Let's say I have a switch (has a field of list of light id's it controls, and bool field if its switched on) and light (has an id field, and a boo...
I was struggled to find a real-life example of using curry function and get the benefit of using curry. When I google curry function I often see the example like let add = x => y => x + y; let add10 = add(10); console.log(add10(20)); I have to say I really don't see the value of using curry in this example. After read...
I have a service that runs queries on a database and gets (potentially) large number of rows. I also have services that can export a given set of rows to csv, xlsx or pdf etc. I have separate export services to leverage language capabilities, for example, java has a better xlsx exporting library. What is the best archi...
I had a question for separating my python project files. What is a difference between "resource" and "source" in programming? When I should use "resource" separation and When I must use "source"?
When optimising for speed, profiling first can help focus the effort on the parts of the code that bring most benefit. Since speed can be measured objectively, the benefit can also be measured objectively by profiling before and after making a change. Is there any analogous approach when optimising for readability? I'm...
Say we have an imaginary system managing purchases made by customers, and there are the following business rules: You can only buy a product if you have enough money on your pre-paid account You can deposit any value to your pre-paid account If you buy a particular product for the first time, you get 50% discount Fir...
We recently started using agile methodologies at my company. Because I am quite new to agile, I wonder if our way of implementing it is correct according to the basic principles of agile. Previously, we had roles such as business analyst, QA tester and software developer. But now management has decided that these roles...
We are working with the design of the software. It is piece already working developed from scratch again. My managers are telling me to draw the business processes. I doubt in this due the fact that I know this piece already and I can start the design and prototype development immediately. Do you see business process ...
I'm a hobbyist developer of 16 years and would like to start contributing to the ChromiumOS project. I have extensive experience in developing for mobile and embedded devices, so my skill set is mostly limited to interpreted languages, with only enough low-level coding experience (C++/Obj-C, not C) to have gotten me th...
I am looking for a git branch management model that would be used easily and would allow for Continuous Integration/Delivery. Imagine I have 3 environments: prod, uat and dev. The code repository includes source code as well as infrastructure as code files (in this case serverless.yml) I would like to use semantic vers...
On public clouds like AWS and Azure, each account/subscription can create a certain amount of public IPs. I wonder if I can use up all IPv4 IP addresses by creating a huge amount of accounts/subscriptions, given that I do pay for that.
I have a UNIQUE TEXT column (“name”) in SQLite for one of my tables (let’s call it “table A”) and i’m considering using that column as the key for the table The reason i can see for continue using a standard “rowid column” (integer with autoincrement) is that the name could change and in these cases i will have to upda...
I'm working in C++14 and trying to figure out a way to put two classes (with the same name) inside the same header file. In this scenario one class would always be ignored as a result of something happening in main.cpp during runtime. Here's an example of this header file: // First class: class foo { public: foo();...
We have a microservices architecture very similar to the architecture described here Obviously, it's a simplified diagram of a real system. In our case, we have a requirement to perform background operations in a service in addition to exposing APIs. e.g. In the Catalog service, if a certain product's count goes bel...
I read through documentation and searched on google, but couldn't find a specific answer. Currently, I have an object that subscribes to a click event. I am trying to understand how a view that receives a mouse event with an (x,y), determines if it's within that object with the mouse event. To be specific, a view recei...
Lets say I design a generic read only repository IReadOnlyRepository. public interface IReadOnlyRepository { ... TEntity Find<TEntity>(object id) where TEntity : IEntity; IEnumerable<TEntity> Filter<TEntity>(Expression<Func<TEntity, bool>> filter) where TEntity : IEntity; int Count<TEntity>(Express...
I am creating a library to interact with third party api.This library will be wrapper around that third party library and i want to expose my wrapper methods to client(webapi,winform,console,mvc etc..). Below are the methods that i want to expose to my clients to perform operations using third party apis but i dont wan...
I'm working on an overlay/HUD for a Java game, where the user should be able to enable or disable certain components and choose configuration options. One such example is a health bar, which the user can choose to either enable or disable and choose its size and color. What would be a good design to handle this kind o...
Few months ago I started working in a team that develops software using Node.js. Quite often we encounter the problem that has been already solved by someone else and the solution is already available in npm registry. Some examples of these problems include: writing deep merge function, writing single value to JSON fil...
As far as I understand in trunk-based development there are no long lived feature branches, one could even argue that there are no branches because at the end everything will be merged back to trunk very quickly and the only valid version is trunk, thus one can't use previous branches as a reference point. Usually wh...
I am using Scala for my example but I believe this probably could apply anywhere. Say I am using a class somewhere in my project that reads in data from a live stream of events which monitors where a player is in a 2D game at any given moment. case class Player(player_id: String, time: Long, age: Int, color: String, po...
I'm working on a project where an increasing number of small mini apps all share nearly the same tooling - makefiles, dockerfiles, jenkinsfiles and webpack configs, along with a couple of scripts, are all rigged for each project to give a standard set of dev tools for each project. This is becoming increasingly difficu...
I have an arbitrary number of derived classes all inheriting from the same base class. These derived classes all have the same static variables and static methods, although the implementations may vary from class to class. I'm using pointers to the base class in order to interface with all these derived classes. Ex: ba...
I'm building a Spark-based, text analysis package using both Java and Scala. I have a series of transform functions, which take in one dataframe and spit out another, and that can be chained together to perform various analyses. Each transform and all the methods that it calls are thoroughly unit tested. These tests ru...
How can we capture the response from REST API. Here is what I am doing: React JS page which contains the button for login. As soon as you click login it will redirect to Ping Identity Login page. On login page user need to authenticate himself. In case he is valid user Ping will redirect to REST API which is post inte...
I have a user feature. user feature also has other subfeatures user application details and user contact information. Usually, because application details and contact information are part of user feature, we are dealing with one-to-one relation, I would put application details and contact information within user folder...
I am wondering if I wrote a little simple documentation and provided the JavaDoc, would it be enough documentation for a application GUI manager library for java?
According to the AWS feature page for SQS: FIFO queues support up to 300 messages per second Standard queues support a nearly unlimited number of transactions per second (TPS) per API action. I'm trying to build a system that will add notifications to a queue that will then be sent to a customers device using push no...
I'm working on a project that requires using multiple programming languages. I'm confused about what term to use to specify the interfaces available to bind two languages, e.g JNI, ctypes, jpype, etc. I don't want to limit the meaning to say that the binding exists only between high level and low level languages(java-c...
HATEOAS is an acronym for "Hypermedia As The Engine Of Application State". What is the "Engine of Application State" referring to, and particularly - how is "hypermedia" the engine of it? As far as I have been able to understand, HATEOAS, and associated standards like HAL, address the "discoverability" part of REST. Th...
I'm a high school student interested in topics of computer programming. Recently I became interested in file compression, and in my head I tried to combine this with a completely different part of programming I heard about a while ago, hash values. From my understanding the hash value of a file is created by an algori...
I am developing a library management software in javafx and I am using sqlite as a database for that. I have to store data of almost 50000 books. And all those books would have a barcode. Obviously, the barcode is a going to be an Integer(PS. Correct me if I am wrong) and it would contain many digits. So I am not under...
What is the benefit of having multiple implementations just for doing one thing? Are there any other languages that use this concept?
Can someone explain concretely why it is not desirable for ViewModels to communicate directly with other view models? It seems to me that for virtually any UX application there will be a “root” view (with its ViewModel) and any further views will be somehow initiated from from this view/ViewModel, or a sub view/viewMod...
Sorry for this naive question. Reading some existing JavaScript I see a function with code like ... async function _load() { await ensureDir(path); return await readFile(filename); } ... why not use readFileSync instead, what's the difference? When you call await (e.g. in Node.js) does other code become runnable, ...
I want to ensure that my program code is correctly inserting, removing, and modifying data in my database. Full integration testing can be slow, and I have concerns about keeping mock objects and data current because my database is evolving rapidly. Is it ever proper to test database interaction by setting a database r...
Here is the original question from MIT lecture notes : Write a Spy procedure that takes two positive integers as input and returns True if the first is greater than the second. Use only the primitive functions = and + and recursion. I haven't figure out anyway to compare two number with these requirements. Spy is jus...
So I am just starting to use a linter and I like the no-magic-numbers rule in generally. But in unit test files it is giving me 1000 warnings. Here is what they look like: it('getWeekNumber', function() { expect(getWeekNumber(1538918924615)).to.deep.equal([40, 2018]) expect(getWeekNumber(1536918924615)).to.deep...
I was just thinking about implementing a binary tree with its root pointing to the parent folder and then the children pointing to subdirs nested within to store a directory structure in a binary tree. I am not sure how to cater this problem with binary trees or if its possible? M-way trees seems like the correct way o...
I was once asked a system design question during an interview. I don't remember the details, but it was a fairly typical web app, so I described what I thought was a pretty common architecture (users making REST-style requests to the server, servers talking to the database, the database is partitioned and replicated fo...
The following code causes a memory leak: #include <iostream> #include <memory> #include <vector> using namespace std; class base { void virtual initialize_vector() = 0; }; class derived : public base { private: vector<int> vec; public: derived() { initialize_vector(); } void initial...
I am a hobbyist programmer, working on a much more complex Python project than I've attempted before, which is in the form of a Python library. I find that I'm often passing **kwargs around (as described in this question), but I'm also realising it's bad for readability and maintainability. The answer to the previous q...
I tested out a few different compiler optimizations on GNU GCC, in the CodeBlocks IDE. With each different optimization I ran the same test: I let my program try to build as big of a tree as it could in 1 second. The nodes of the tree were objects of a class I created. Results: [-O1]: 78,235 nodes generated. [-O2]: 78...
I'm an academic rather than a programmer, and I have many years' experience writing Python programs for my own use, to support my research. My latest project is likely to be useful to many others as well as me, and I'm thinking of releasing it as an open-source Python library. However, there seem to be quite some hurd...
So lets say you want to outsource your database to a third party and be able to query on it on their server but you want to "encode" the salary column of the users on their server, aka hide the real value from that third party, in a way that you can still query it on that and decode the result for example one approach ...
I just started reading more about OOP and its design patterns and is confused with this conceptual question. I am too new that I am having second thought that the proper title should be, "when is it okay to have the constructor function in the interface?" If interface defines the blueprint/API of your object, how do yo...
I'm building a home project using EWS and SQLite. I have a bunch of really similar (and not so similar) Mails (that hava the usual subject sender body etc fields). These mails contain similar information and i would like to collect them into a sqlite db. Also i want to separete the collection logic from the main code ...
Here's the Scrum situation: A certain task (implement a back end populated data table) is a frequent story The tables frequently have similar but custom functionality Each table takes about a week to implement (8 story points) Eventually the team invests 4 weeks to create a reusable component Now creating a new table ...
If a file foo.cpp already includes foo.h, and foo.cpp requires some types from (for example, string.h), which is better, to include string.h in foo.cpp, or in foo.h ? For example, Guideline#9 in this tutorial recommends to include it in the cpp, if possible, but I don't understand exactly why.
I'm designing an API for a Python library. The user will create objects with several parameters. In most cases, the user will either leave these at their default values or will set them globally, for all objects. However, it should be possible also to set them individually on a per-object basis. The most obvious way to...
In Chapter 10 of Clean Architecture, Martin gives an example for the Interface Segregation Principle. I have some trouble understanding that example and his explanations. In this example we have three separate Users (Classes) that use a Class called OPS. OPS has three methods, op1, op2, and op3. Each of these is only u...
I've made an engine that plays Connect Four using the standard search algorithms (minimax, alpha-beta pruning, iterative deepening, etc). I've implemented a transposition table so that the engine can immediately evaluate a same position reached via a different move order, and also to allow for move-ordering. The probl...
I am using Kafka. I am developing a simple e-commerce solution. I have a non-scalable catalog admin portal where products, categories, attributes, variants of products, channels, etc are updated. For each update, an event is fired which is sent to Kafka. There can be multiple consumers deployed on different machines a...
I am trying to get my head around "event driven" microservices. I understood, there are several techniques and patterns, like event notification, event sourcing, CQRS, etc that can help us to achive that. Very simply said, it boils down to some kind of a command has been sent, which leads to a change of the systems sta...
When specifying a period is there ever a case where passing the number of the month as integer is preferred over passing two datetimes? For example GetTotalSumByMonth(int month) vs GetTotalSum(DateTime begin, DateTime end). It seems to me that the second option has clear advantages since it is more generic and less amb...
In my understanding of Uncle's Bob Clean Architecture, a Use Case (Interactor) is responsible for orchestrating the Entities. At the same time, it represents Application-specific rules. The business rules live in Entities. I have a need to orchestrate the Entities to achieve a Business-specific rule. What is the best a...
I am trying to do the architecture of a new application we are building. We wanted something quite modular. Considering we are open source and we want other people to be able to easily add new features, we opted for a component based architecture. We have a back end that is made in Java, and a front end that will be m...
I´m looking for some kind of better compilation of principles which takes the old basic concepts (DRY, KISS, etc...) and applies them to OOP related concepts like abstract clasess, interfaces etc... Some reasoning behind this quest: I find some interpretations of the SOLID principles very compelling, but I've found so...
A lot of tutorials on DDD I studied are mostly covering theory. They all have rudimentary code examples (Pluralsight and similar). On the web there are also attempts by a few people to create tutorials covering DDD with EF. If you begin studying them just briefly - you quickly notice they differ a lot from one another....
While setting up a nodejs server with a mariadb database, I found this: While the recommended method is to use the question mark placeholder, you can alternatively allow named placeholders by setting this query option. Values given in the query must contain keys corresponding to the placeholder names. This seems odd ...
I have recently graduated from university and started work as a programmer. I don't find it that hard to solve "technical" issues or do debugging with things that I would say have 1 solution. But there seems to be a class of problems that don't have one obvious solution -- things like software architecture. These thin...
This is a very broad question, but maybe someone has a worthwhile response. There is a general synchronization issue that often has to be solved, but always seems to be difficult. Here's an example: I was working on a remote system and had an ssh-connection and a remote desktop open at the same time for some reason. I ...
I was hired to program a basic, plain text site for a local business that amongst other things, provides basic pricing quotes through a Javascript Applet. For obvious reasons, it seemed unnecessary to me to in anyway encrypt the traffic to and from the site. However, the person who hired me strongly requested that I se...
A water user can submit an Application for a water right with the hope of getting a Permit to use water, which might later become a BonaFideWaterRight. The right holder may apply to Transfer any of the above items (or others not listed for brevity) by changing ownership, moving it to new ground, splitting it in half an...
My question is that is there any reason for Thread class to implement Runnable interface by itself. Are there any specific use cases where overriding Thread makes more sense than implementing Runnable by design
New to DDD I have a simple case a I would like to model using DDD approach 2 entities Student and Course Relevant property for Student are StudentId and Budget Relevant property for Course are CourseId and Price Student and Course are entities that can exists on its own and have their own life cycle Business requiremen...
Can I draw mutual dependencies between two artifacts in a deployment diagram as a dashed line with two arrow heads? Or is this a no-go in UML?
As the code below, class Foo1 implements interface IFoo, which has a property of IData. public interface IFoo { public IData Data { get; set; } } public interface IData { ... } public class DataA : IData {...} public class DataB : IData {...} public class Foo1 : IFoo { private DataB _data; public IData D...
I am trying to figure out the best way to decorate html. What I mean is replacing specific syntax string with the actual content. Kind of like, razor syntax in Asp.net MVC using <%= %>. Currently, I have an HTML page with design and I just need to replace tags (for ex: <%HISTORICTABLE%>) with actual content. I have 5-...
Emacs loads into memory as: An editor that has m functions with n inputs. An elisp interpreter that can be used to change the behavior without restart. Why do programs need such an extension that is an interpreter all by itself? What feature does it provide so that I consider adding it to my own project? What I under...
I have a main window and I amgetting data from http client service while form load. public class MainWindow: Window { private IClientService service; public MainWindow(IClientService service) { this.service = service; GetClient(); } public asy...
I was given a more or less complex task. The goal is to interpret a SQL Check Constraint inside my C# .NET libary. In our case we have a simple UI that displays what is inside the database. We do not want out UI-Components to allow any values that wouldnt even be possible because there is a check constraint. Since ever...
I have a class Person. Person { String firstName; String lastName; String Date dob; String email; String mobileNumber; String address; } To add a person, I have following REST APIs: POST /person { "firstName":"Donald", "lastName":"Trump", "dob":"01/01/1990" } PUT /person/{id}/addContact { "email":"donald.trump...
I am writing a potentially large web application using Angular 7, where I came across a design problem. My angular applications until now have been relatively small, so there was no problem keeping whole code in one project (divided in modules with lazy loading). However now that an application can grow in size I find ...
Currently, my thoughts are that GET requests would be feasible by using the concept of screen scraping combined with a cron job that runs at a set interval to scrape data from the GUI and sync to my own database. However, I'm not quite sure how I would handle actions that seek to mutate the database that sits behind th...
In laymen's terms, what is the difference between opcodes and operands in assembly language programs? I understand that one involves where to get the data and one involves what is to be performed on the data, but is there a way to understand it in more detail?
Yay or nay? I have several related but separate services that are to be run in different processes. They execute a particular task unique to the service. Their call signature is similar, but the name of the service changes. For example. Service 1: :5000/Invoice/<id> :5000/Customer/<id> Service 2: :5001/Invoice/<id> :5...
Let's pretend I have an 'Book' entity, that can contain many 'Chapter' entities, having both their own unique IDs. A chapter must belong to a book, it cannot exists on its own (ie: there is a required foreign key in the chapter's table). There is a screen where the chapter's content can be edited. So far, we considered...
I am in search of information on how I to manage code in git flow and methodology to test and work with it : I have an API in place to build and manage a product catalog and it was designed around the business needs of my first client project (let's call this the master branch) For a second project with another client...
I have just created a function which checks whether a ipv4 is public or not. I have not heavily tested it yet since it is kind of practically impossible to do so (because I do not know where to start). My algorithm is based on an article from this website. Public IP addresses will be issued by an Internet Service Prov...
Can anyone tell me what does "machine" means in Compiler Theory? Does it mean computer in general or operating system? Actually, the problem is I understand the definition of machine language as "the language understand by the computer". But does machine here refers to anything specific other than computer. I was readi...
I'm not sure what the correct procedure is, when you have a question based off an answer you read but it is a seperate question that arose because of the answer provided. the answer in question Which HTTP verb should I use to trigger an action in a REST web service? Walkthrough of my method, where this is relevant [Ht...
I have a base type of Entity, and multiple implementations, Enemy, Bunker, Projectile I have separated these entities into their own containers so I can pass them to different classes to perform different actions on them. However it is becoming clear now this may not have been the best approach. I am currently writing ...
I currently have two derived classes, A and B, that both have a field in common and I'm trying to determine if it should go up into the base class. It is never referenced from the base class, and say if at some point down the road another class is derived, C, that doesn't have a _field1, then wouldn't the principal of ...
In my application, I have a finite number of question types, but the order in which they're asked and whether they're asked at all is not known up-front. An example analogy is a hotel booking process, during the process you may be asked a number of questions, like whether you want late check-out, rent-a-car, breakfast-...
I know the sites are not geared for recommendations so I am hoping to pose this question in a way that doesn't ask for recommendations. Questions comments are welcome. I am just getting involved in wanting to create a .net Core API for one of the projects we are working on. I have read a little on the topic and what ...