instruction stringlengths 34 36.1k |
|---|
I have a Python library that performs a kind of calculation given a parameter-object. A requirement of the parameter object is that it be both hashable and serializable. It's a long calculation, so it memoizes itself. Let's say this is implemented something like this:
# Notes: params *must* be serializable and hashable... |
Suppose I'm creating a game played on a 2D coordinate grid. The game has 3 types of enemies which all move in different ways:
Drunkard: moves using type 1 movement.
Mummy: moves using type 1 movement, except when it's near the main character, in which case it will use type 2 movement.
Ninja: moves using type 3 movemen... |
As it is said in ARLOW, J., AND NEUSTADT, I. UML 2 and the Unified Process, 2nd ed book, there are 7 types of relationship between different objects.
Dependency
Association
Aggregation
Composition
Containment
Generalization
Realization
But I have read in somewhere else that if a relationship has one of the followin... |
I need to check my understanding regarding the spiral process model as it is confusing me.
According to my understanding, the spiral model is similar to the waterfall model with the activities as follows:
Requirements analysis
design
implementation
testing
But in each phase we do the following: Firstly we just do... |
I've been reading Unicode's core specification (see https://www.unicode.org/versions/latest/). I mostly understood what the text was explaining in section 2.1 Architectural Context until it started talking about layout behaviors. It feels like there's no preface or explanation of the phrase 'layout behavior of characte... |
I have a C header that is generated from a CSV file and a Python script. The C header mainly contains a list of #define constants.
I want to be able to detect manual changes to this header during compilation (which tends to happen frequently in this early phase of development), and have the compiler display a warning t... |
UPDATE I totally get why this question could/should get dinged ... but hey, if you feel inclined to vote down this question, can you also provide some feedback on where a better forum could be for me to take this question?
I am at the start of a new effort to create an internal product for my company. So, right off th... |
I am new to neo4j and the graph I'm shaping will be used by third party applications for some fixed (cypher) queries - we can think about the classical "Who is friend of Alice?" question.
I'd like these queries to be easily requested from the other applications - that can be developed in different languages - while not... |
I want to create a multi-layered backend architecture with a REST layer and GraphQL layer later on.
So let's say you would start with the basic layers controller, service, repository would it make sense to create request/response interfaces for each layer?
When creating a user you might come up with
create-user DTO =... |
The spiral model is a risk-driven SDLC model. There are many diagrams that describe this SDLC model. Here is one of them:
As we can see there are many iterations (one for concept of operation, requirements and so on), every iteration has its own prototype.
For example, there is a prototype associated with the requirem... |
I am a CIS student and want to do the best industry standard for organizing projects. I find my desktop and dev folder cluttered with different projects and would like some advice on how to better organize like a professional. Thanks
|
I am trying to plan a system which validates the compability of different components by comparing their semantic versioning number, especially the major release number (since it indicates API changes and backwards compability). I came across the following scenario where I could not find an exact answer:
Let's say the c... |
After some extensive research I still don't know how to properly implement the following case. I think this question answers something similar, but I'm not 100% sure (Should client have access to 3rd party API access token?).
Let's say I have my resource server (my-api.com), my identity provider and authorization serve... |
Let's say you have a wireless network that acts as a bridge/wireless repeater. How would both factor into a class diagram? In my mind it makes senses to have a parent object that can exist on its own. Then the child object that is both dependent on the parent, but also creates an instance of the parent. The child can a... |
Coupling is defined as the knowledge one object has about another one, which describes how dependent they are. The more dependent, the worse, since changes in one would impact in the second. High coupling is bad, low coupling good. There are different coupling types.
Let's assume we talk about call coupling.
In Java, w... |
We were discussing how to design a API response, for simplicity, think of having to give information of all the different types of facilities available in a city:
{
"city": {
"cityName": "Gotham",
"population": "8620000",
"facilities": {
"airport": {
"name": "Batm... |
We're reviewing the popular Gitflow as our git branching model and I've liked it so far. One case I'm not sure about is the production rollback. Say we've there's a new feature that we're planning to publish in the upcoming release. The feature is tested and finally merged to master. Either automatically or manually th... |
Currently, I have a rest API service which serves to many different consumers. One of the endpoints of API is for retrieving an order. Inside a single application, I am making 5 different service calls to other external API's to generate and return the response to the caller.
Half of my API's consumers do not need the ... |
(Almost) all numbers in my program are parsed and treated as complex numbers. There is one corner cases, that specifically needs an integer. Unfortunately my programming languages does not allow to compare integers to complex numbers so I needed to come up with the following code:
function_name(Complex c)
if c has ... |
I have a python class that has methods to perform the CRUD operations via REST api:
class my_class():
def get_obj(self,...) -> requests.Response:
res = requests.get(...);
return res;
def create_obj(self, ...) -> requests.Response:
res = requests.post(...);
return res;
def... |
Help me settle an internal question.
We have an endpoint which we all agree should be a GET, because all it's doing is calling a stored proc and returning a set of data. However, there is a set of filters that we need to pass to the endpoint. Below is an example of what the filers might look like if all of the filter... |
I am developing small lottery games where the participant can win one of many gifts, each having various quantities. (The code is in PHP)
Simple scenario:
I have 5 types of gifts, 1000 in total, and am expecting 1000 participations.
What algorithm can I use to ensure that these 1000 gifts are distributed somewhat evenl... |
I am trying to develop an Instant messenger using WebSocket.
I have multiple instances of my servers running (say server1 , server2). Two users(say userA , userB) who wants to chat with each other. But connected to different servers.
UserA to Server1 and UserB to server2
Need some suggestion on how to implement
... |
I am making an SNMP agent. In order to pass information to this SNMP agent, I need to periodically extract data from two different sources (and there may be more sources in future.) I am trying to design the interface for these periodic data extractors.
However, both of these extractors return different sets of informa... |
In the most abstract, platform agnostic way possible, can someone explain what actually determines the end of input/output a socket? Is this something the programming language itself typically handles and indicates by a special return value (for example, -1 bytes read)?
I am exposed with an IO API that will throw EOF w... |
By first, i mean i have read articles which puts project planning as the first phase of the sdlc.
In my opinion it should come after the requirement analysis and specification, because if you dont know the reqirements of a project, how can you plan about it?
it does not make any sense to me.
you're planning for a proje... |
Forgive my jargon , as I'm not very familiar with Constraint Satisfaction Problem(s) or Linear Programming procedures (For eg: Presolve)
I have very trivial constraint set from variables of continuous domains. However, the problem may have to be solved at scale. All constraints are equality constraints. I'll give a sma... |
i have some back end service that is in charge of sending notifications to my end users via mapping between some identifier to their real web sockets.
currently the service works in a sync way, meaning every loop iteration it checks if i got some new messages in my queue and if so i am polling the message from the queu... |
I have a new website product which I'm beginning to demo. I have the opportunity to demo to a relatively large potential client. I've found out (from the individual) that they already have a similar product that they previously tried to monetize but would like to look at mine and are interested in switching over to my ... |
SETUP:
Local Windows 10 machine. It runs a VM (Ubuntu Server, NAT, Virtualbox)
QUESTION:
I want to make a VNC connection from my Local machine to the VM. Since VNC is not a secure protocol, it is recommended to make the connection through an SSH tunnel. However, since the VM is running on the same machine, I wonder if ... |
I have a project at work that was written entirely by a scientist who was learning programming while writing it. It is almost 200,000 lines of C++, and almost every variable is a global variable (over 2,000 global variables). I think he found out about local variables about half way through writing the project. The few... |
I have a scenario in our Web Application.
GUI invokes a REST web wervice and further web service calls a procedure. However, the procedure returns data properly for most of the scenarios. In some scenarios it takes more than 5 minutes and a session timeout happens. Now client suggested that in this case if any procedur... |
I was talking to a colleague recently about hashCode and equals being methods in class Object in Java (among other languages). I am from a more theoretical background while my colleague is more of a pragmatic person.
In my opinion it does not make any sense of having the hashCode and equals methods being defined in cla... |
I am confused, from what i have read the design phase has nothing to do with how the software looks like and its about how it should be build in the next phase which is the developement phase?
My Understanding of Design phase:
how to the software should be build, like its a blueprint of its mechanism i guess?
I want t... |
I have the resource OrderRequest which I guess can be qualified as process. The OrderRequest can be create of update. The create should be idempotent, because creating the same order request 2 times is undesired. At the same time the POST is not idempotent and it does not always return the same result. I use a combinat... |
We're looking to split up a monolith. In order to do so, we've identified some business areas that look like good candidates for subdomains, and we're trying to figure out how to split the functionality across those subdomains.
The domain is sports league management software.
We've tentatively identified a few subdom... |
My coworker and I are debating the correct design for an API. Say we have a function void deleteBlogPost(int postId). What should this function do if the blog post indexed with postId does not exist?
I believe it would be appropriate to throw an exception, because the function should be designed to do one thing. When t... |
I have always written my if statements like this when I want the negative condition to enter me into the if block.
Example 1
if(condition == false){}
However, we just hired a new senior on the team that insists we should refactor to
Example 2
if(!condition){}
and use that moving forward.
I find example #1 to be ea... |
I'm developing a FOSS library which I am pretty fond of. More specific details probably don't matter.
I've already "finished" a feature set sufficient for an initial release IMHO. However - some of the features I introduced in there were added for completeness of the API; I didn't use them in my own applicative coding ... |
Premise: This is for learning purpose.
I'm trying to adapt my Console Application code to be served through a WPF Application GUI that I would like to create.
One problem is struggling me.
Actually I'm using something like a procedural approach, even if it's async in some path, how I could decouple my code to be the se... |
I'm looking to build a graph that's tied to any caching system that I can interact with. Its only goal is when an item is deleted, based on its "linked items", to also delete these. A partial rebuild of the cache, if you will.
For example, in an action-driven system, my object would be listening for the action post_upd... |
So I was watching Jimmy Bogard giving a talk on Effective Microservice Communications (Power Point available on his GitHub). One thing he mentions is that the messages between the services should be small, something like this (example from the presentation):
POST /dress
{
"order": "/order/23"
}
To my understanding... |
I have a monolith application in .net core 3.0 with entity framework core 3.0. using:
a table with ~3 million records. Its structure is BusinessUnitId | ProfileId | Amount(it has more fields, but these are important ones);
another table that looks like this: ProfileId | Price.
When I need to generate report for all... |
I'm doing a bit of refactoring work for a software that use hardware, specifically cameras, to gather images and process them in different ways. A few different cameras are supported, and there will likely be different ones in the future, and therefore I thought it would be a good idea to hide the implementation of tho... |
I'm new to AWS serverless applications and am looking for something like ocelot request aggregation on the AWS serverless stack.
Assume I have two AWS lambdas that return data needed by a SPA: A and B. They each take 1 second to run to load data from different sources. When the browser makes a call to the API I wish to... |
Here's an example of my question in python. Notice there's only a very subtle difference: changing an if to an elif. There's no difference in behavior; if the first if statement is executed, the second will never be reached. Is it better practice to use an if or an elif in this situation? (Which is better: Option 1 or ... |
General overview
We recently had lots of problems with automated tests in our team. Part of it was that the people designated to writing them had little experience. After this failed, we incorporated a different approach where the product owner and the developers are much more engaged in the overall process of automate... |
I have two data sets. The first data set has approx. 50.000 movie and song titles and the second one have 20.000 blacklist strings. I am looking for the best algorithm to detect movie/song title which contains blacklisted word(s).
Example:
Dataset #1
The Lord Of The Rings
E.T.
Star Wars
...
(50k items)
Blacklist Data ... |
I'm currently in the process of transforming a monolithic application to a microservices based architecture. The monolith is dependent on third party services (as in other departments) for its data. Most of these third party services are accessible via SOAP while some of them use REST.
Some of these third party service... |
I'm working in a rest API for a turned based game from scratch, and I'm having some troubles figuring out the best architecture to do it.
I need to explain how the game works and what is my architecture so you can help me out.
The game is a turned based board game with up to 4 characters that can interact with eachothe... |
We have several microservices and are now in a position where we need a GET request with a list of ID's in a querystring.
I'm reluctant to use a POST for the purposes of a GET request because of the general principal of using HTTP verbs as intended.
However, there are plenty of drawbacks to serializing our array of ID'... |
I have a Java background and am studying Python's data model. Specifically, I am curious about how and when special methods (e.g. __add__) get called.
It seems like the Python interpreter may execute these special methods when it encounters certain built-in functions. To take an example from the book "Fluent Python", ... |
I have the following dataset:
[234,565,678,90,66,7,8,44,5]
[275,23,54,34,5]
[4745,23,54,4,556,65,89,5,4,569,87,412]
[75,273,59,5,4,567,412]
[44,34,556,69,5,4,569,812]
Each array represents a web session. Each element in the array represents an activity that the user did during the session.
What's shown above is only ... |
This is a general question but I work in the .NET world so I'd like to know if there any specific quirks about the .NET Framework / Core platforms that I should be concerned about here.
I think it's safe to say that as a general rule, breaking long-running jobs in to threads could be slightly faster than breaking jobs ... |
I've read a lot about Domain Driven Design including books from Eric Evans and Vaughn Vernon. So I am familiar with the concepts Aggregate Root, Entity, and Value Object.
But while I was modeling some domain model using Domain Driven Design approach a question arose which I never had before. I realized that I could mod... |
I am trying to design a HashTable from scratch. I am starting with an initial bucket size of 11 and trying to maintain a load factor 0.75.
Java documentation mentions that whenever the number of items reaches the load factor the HashTable increases the size of buckets by double.
My question is if I am starting with ini... |
I was designing an email service in .net standard 2.0 using mailkit library. I proposed the following design
This design was not accepted stating the following reasons:
This design have to many components. Basically it adds more LoC.
It proposes interface for models.
If anyone want to implement Imap, then its increas... |
We are setting up a pattern library.
It's use is on the one hand to document and display our UI elements in a web view. On the other hand, it should also be the place where components are built. The actual web application should then consume the components (markup, CSS and JavaScript) from the pattern library and only ... |
Currently working on designing a process which demands me to send alerts like email notifications to the users which meet a business criteria(we can also call business rules).
I want to make this process more dynamic so any rule can be deleted, modified added on demand(because there are no predefined set of rules and... |
I am currently in a process of maintaining a data warehouse for a quickly growing start up company. There is a lot of reporting demands from the clients, and this is usually handled by a data warehouse we set up. However, unlike bigger more established companies I worked for in the past, this company has a rapidly gr... |
I've been thinking on how to import a project B into a project A, which both are GitHub repositories.
Project B is a library I reuse over many projects, I do add stuff in it, directly from project X, Y or Z.
Project B is simple, it's a directory with C# files and an assembly definition, i.e. a Unity class library. It's... |
I assumed that the purpose of pull requests within a team is to get a second set of eyes and basically proofread the code. But lately I am noticing that they can serve an additional function of preventing knowledge silos. The logic is that if every piece of code you write goes through a PR, then we preclude the danger ... |
I have been working on a project and Im hoping to get a gauge on possible performance issues before I put it in any production environment. Currently on my local machine Chrome's task manager says I average about 60000-70000 K for my memory footprint while the JavaScript Memory varies from about 5000-12000 K with 3000-... |
Say that I am developing a web application that has the following structure:
An SPA web frontend (angular in my case)
Postgresql database with:
A bunch of initial data in CSV's and JSON's that need to be loaded.
A bunch of cron-job scripts which periodically fetch data from external sources and feeds it into the da... |
Traditionally web applications has been build by one singel page served to the client for every functionality (/settings, /users …). So every time you need a new Gui, you would have to navigate to a new page/new request.
For example: suppose we have an app. the user want to change some settings (for example which users... |
We had an application break in production during a deployment because a load-balancer package in our top-level Dockerfile had pulled its latest version, which happened to have a new API. Our app broke during a time when most of our developers were out of the office, so I and another dev had to scramble into the night t... |
I'm not a low-level programmer, I mainly program in C# which is a managed language. Still, every now and then I read articles, news and patch notes about the most varied software talking about memory unsafety fixes, including a video (if I remember correctly about Rust and it's memory safety) in which the host says tha... |
Say I am wanting to include a third party HTML component in my site...
I know that I can simply include a <script> tag to pull in the component on the client's side; however because I do not trust this component to load in a speedily manner, or to load at all, I am wanting to have it server side render for users so th... |
I'm trying to unit test some repositories and have no idea what I'm doing if someone could point in the right direction that would be good, currently, I'm testing behaviour of creating a new user
[Fact]
public void Create_New_User_Test()
{
var userRepository = new Mock<IUserRepository>();
va... |
We develop a web app which consists of a frontend and a backend project. The frontend is consuming an API that is provided by the backend.
Frontend and backend are developed separately by different teams but in the end, we deliver one application to our customer.
Both applications getting build separately by gitlab-ci ... |
I'm trying to simulate the hiring process of a record label. Formally, I decided that the steps to do it are these:
The artist send its new album to the record label, which will review it and decide if approve it or not.
If the record label approves it, they will prepare an interview in order to decide if hire the ar... |
Imagine I am creating a command called UpdatePhoneNumberCommand. Imagine also that in my application a business rule dictates that no-one may update anyone else's phone number - it is always you updating your own Phone Number.
The number itself obviously needs to go onto the Command as a property (UpdatePhoneNumberComm... |
This question is highly related to this over question. I'm asking another question between I still am a bit confused on the topic.
The Issue I Ran Into
I currently have a Django web application where users can have a list of their hobbies and can increment a counter each time they do one of their hobbies. My issue is, ... |
We currently handle a well separated monolithic service which handles various 'contexts' to help with the separation. I haven't had any issues so far when dealing with problems that require the creation of a new context since it was simple enough.
Now I'm dealing with a group of entities (3, to be exact) that relate to... |
Say that A is working on a branch based off master and B merges changes into the master branch, which introduces merge conflicts between A's branch and master.
Whose responsibility is it to fix merge conflicts? I am not intending to be petty, so in other words - is it more productive in general if A fixes these conflic... |
Our company is trying to find a good generic way to have Many-to-One data for an entity. For example, a user might have 1 primary email, but many other emails also attached to their account.
So we have a users table (1 row maps to 1 user):
| id | handle | primary_email | is_verified | first_name | last_name |
|--... |
By way of background, I recently coded a small app that detects the number of boxes in an image. The app defines some types, for example:
class Box(val x1: Int, val y1: Int, val x2: Int, val y2: Int)
This app is Kotlin, but the principles should apply to any strongly-typed language. The definition of Box above is how ... |
I am using a 3rd party library that must be initialized with Lib::init() before any of its other functions may be called and that must be uninitialized with Lib::destroy() before the application ends. My classes that use the library just assume that it is initialized. This is not a problem in my application - I am call... |
Let's say you have a username value object which has formatting rules e.g.,
class Username
{
private $username;
public function __construct(string $username)
{
// thrown an exception if invalid regex ^[a-zA-Z0-9]+$
// ...
$this->username = $username;
}
}
Like above, usually ... |
Title pretty much says it. I ran into trouble getting condition coverage of a logical statement and found that the order in which the statement is written (rather than order of operations) results in different condition coverage. The equivalent statements are the following. I'm using google test.
if (A && (B || C))
{
... |
In our current architecture, a user has multiple ways they can change an address (as an example). They can do it through an online portal, through our core processor directly, or via a number of apps that talk to the core processor. I want to design a solution that has one place for all of those users to funnel to, a... |
I asked this question originally on StackOverflow, and was advised to post it here instead. My question is concerning the best practices for continuous deployment and continuous integration especially with small teams.
Within our project we have a situation, where we would have to have a server running code (optimally... |
What type of programming is C. It is not object oriented, but what oriented is it? I googled it, and got no good answers.
|
I am implementing an ECS system with a data-oriented design, and with a TDD methodology using Catch 2. I have the following class declaration snippet for an EntityManager:
using Entity = std::uint16_t;
using Signature = std::bitset<MAX_NUM_COMPONENTS>;
const std::uint16_t MAX_NUM_ENTITIES = 10000;
class EntityManager... |
So I was reading https://hackernoon.com/objects-vs-data-structures-e380b962c1d2
and I stumbled upon this quote :
"A Person data structure has a first name, last name, and phone number. A Person object walks, runs, jumps, and speaks. A Person object does things."
As I understand, the Person data structure would be like ... |
I have been given a task to take on a legacy application (which has a very poor API in terms of user experience, is undocumented largely, and performs slowly) and build a new API and SDK to improve the user experience. I have access to the source code of this legacy application and I can see only one endpoint which doe... |
Let's say we have a abstract super class A with abstract method m1 and m2. B inherits from A, overrides m1 and m2 and defines a new public method m3. Since to access m3 we have to cast B and this requires the usage ofinstanceof` operator:
A a = new B();
if(a instanceof B) {
B b = (B) a;
b.m3();
}
Does this mean th... |
What is the differences between the Class and Actor in UML. Can I use an actor in use case diagram which is used as a class in a class diagram?
|
Situation: I am designing a REST API that needs one or more, potentially large objects to do it's work
I am facing a decision to either
Pass the large object by reference and have the API retrieve it
Pass in the large object as a parameter
Approach 1:
@PostMapping("/api/{id}")
String getSomeObj(int id){
//make ... |
Why in C# it is not important to know when the generation 1 was collected by GC while implementing the GCNotification?
While reading the CLR via C# book I met the following excerpt:
The GCNotification class shown below raises an event whenever a generation 0 or generation 2 collection occurs. With these events, you co... |
In TypeScript, the following is called a union type:
number | string
and this is called an intersection type:
number & string
However, is the resulting type of the | not actually an intersection, and that of & a union?
From the docs:
For example, Person & Serializable & Loggable is a Person and Serializable and Log... |
I have a website which offers pages in the format of https://www.example.com/X where X is a sequential, unique number increasing by one every time a page is created by the users and never reused even if the user deletes their page. Since the site doesn't offer a quick and painless way to know which one of those pages i... |
I know majority of databases uses B-Trees, and I can see how using a balanced binary tree will give fast sort times, for ordering by ID or whatever else the primary key is; but how are databases able to ORDER_BY different fields like Name or Age, does it just perform an efficient sorting algorithm like merge sort or qu... |
As I understand it, RESTful URL is more like a resource locator than a command. For example, to get user 1234, you wouldn't use this:
//Not restful
https://server/GetUser?UserID=1234
You would use this:
//Restful
https://server/users/1234
This makes sense for resources that take a single identifier.
But what if I wan... |
In another question on this site, asking to clarify the open closed principle, @Kate Gregory answered this.
I'm interested in this part specifically:
Imagine you wrote an Invoice class that works perfectly and has no bugs. It makes a PDF of an invoice.
Then someone says they want an HTML invoice with links in it. Yo... |
Let's assume a SimpleFactory that creates a group of objects:
public SimpleFactory {
public Bycicle createBycicle(String type) {
if(type.equals("ONE")) return new OneWheelBycicle();
if(type.equals("TWO")) return new TwoWheelBycicle();
if(type.equals("THREE")) return new ThreeWheelBycicle();
}
}
Th... |
Was wondering if someone could give a practical understanding of what it means for an algorithm to perform in (log a / log b) time?
In other words, practically speaking for an algorithm to perform in nlogn time it would need to split a max of log n times and perform n amount of work at each level. For log n performance... |
I need some guidance that how to capture the face when we blink the eyes. I have seen the core Image framework, but it detects only after capturing the image. But I need it to be live capture.
|
My setting is the following (Please assume that this points are entirely rock solid unchangeable, some for good reasons some: "just because"):
In a super scalable microservice environment i receive messages
These message have a logical order (a timestamp that they bring with them)
The messages are fed into a messaging... |
I have gone through Elastic working and understands how inverted index(faster look up) and index(
storing actual document disk in ES). My understanding is that inverted index has most of the required stuff when search query is executed.
For example : word to document id mapping/location/TF-IDF/boost score etc
Say If I ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.