instruction
stringlengths
34
36.1k
I have a Foo service that, among other things, retrieves data from a table called Widget. This table has about 50 columns. This service is called by a request from a browser. Now, I have another service, Bar, that wants to call Foo. This is a Windows Service that we can trust because there is no end user. Bar also need...
In a php project that I maintain I have a database structure without migrations, hence no way to reproduce it or make on the fly a test database. And the queries used to be performed on them are rather complex ones. The pattern in code used with them is (I try to show a generelized preview of the problem): public funct...
Consider something like.... (Pseudocode Javascript like) var capitalizeWord: function(word){ word.toAllCaps(); } What if now I need to do multiple words, but still sometimes only do one still. Is it better to do... var capitalizeWords: function(words){ _.forEach(words, function(word){ capitalizeWord(w...
I'm a great fan of refactoring but I've been wondering about the issues raised by refactoring. Fowler advises refactoring to make code readable to all users to make the code structure more sensible, e.g. methods in the class most affected by them to make the overall project more OO - and hence more easily maintained ...
I wanted to know what fellow developers follow while designing rest API error responses. For all the not-found get resources, do you also send the some sort of body indicating that resource was not found or some more detailed level error messages or only error code with null or blank response?
I have an external data model framework with frequent updates to the names of fields. Say for an iteration I implement on - EnterpriseModelObject -- EnterpriseDomainContentList --- EnterpriseDomainContent -- ContentDeliveryResult --- ErrorList ---- Error --- WarningList ---- Warning Another iteration this will become ...
Curious how containers are portable across development/testing/cloud environments with no worry needed about the underlying infrastructure. Does the Docker Engine essentially standardize operating systems to the point where the engine is able to launch the same container from the different operating systems? Or does a ...
I'm starting a project to build an instant messaging application for mobile devices. Although not the complete list of components these are the main data flows I'm concerned about: Mobile app conencted to WebSocket -*for message analysis (abusive language / etc) and persistence. Mobile app connected to MQTT broker -*...
Gang of Four’s Flyweight design pattern introduces the concept of intrinsic and extrinsic states: The key concept here is the distinction between intrinsic and extrinsic state. Intrinsic state is stored in the flyweight; it consists of information that’s independent of the flyweight’s context, thereby making it sharab...
I am making a full-stack web application for a professor. At his request, the passwords and usernames are generated programmatically, and they cannot be changed or reset by the students. (If you forget your password, you ask the professor, who can look it up.) Does this tightly-controlled system eliminate the need to d...
I have googled enough for days but i cant find a clear intuitive document about this embedding technique. In their paper they say : We present StarSpace, a general-purpose neural embedding model that can solve a wide variety of problems. But they don't explain how. Thanks in advance.
Tennis is played as singles or doubles. I considered making my tennis scoring model logic refer to "teams" throughout its naming since "player" wouldn't take into account doubles. However, seeing teamOne and teamTwo throughout the code to accommodate both modes seems awkward since a team of one person doesn't make sens...
I'm working with a project that uses ASP.NET Core 2.2. The main solution contains different projects, including APIs for a mobile application, APIs to integrate the system with third parties, a web application, etc. Mobile API - For internal application Public API - To integrate our system with others Web - Website...
I have queue of MoveableItems in a class BackgroundTaskQueue (based on example from Microsoft here). Clients call BackgroundTaskQueue.QueueBackgroundWorkItem to add a MoveableItem to the queue. An instance of BackgroundTaskQueue is passed to a class QueuedHostedService (which is also based on this). QueuedHostedService...
public class B { } public class C { } public class D { } public class E { } public class A : IRetrievable<B, C>, IRetrievable<D, E> { public TValue Retrieve<TKey, TValue>(TKey input) { throw new NotImplementedException(); } } What is the reason I can't do this? Visual Studio is telling me ...
I'm building an API endpoint for a UI grid to search, filter, and display a list of domain objects, let's call them "widgets." In the past, I would have built this with a list of named query string parameters, like this: GET /api/v1/widgets?type=2&name=what&from=2019-12-31&to=2020-01-03&pagesize=25&page=2&sort=name,-cr...
I’ve been trying to get a firm understanding of the MVC design pattern so that I can write my own framework for implementing the back-end of a forum web application using Slim 3. In particular, after reading this, and asking this and this question myself I’m now at a point where I think I understand how the model shoul...
I am trying to draw diagrams that show the difference between system virtual machines and Java virtual machines. The first two images looks correct to me. But I don't know how to draw the third. Image 1: Image 2: Image 3: As you see, both red blocks and gray frames have the same captions: "JVM". I don't think it is ...
My questions are regarding the use of mysqli::rollback. If not used in a declared transaction but used in a try...catch will rollback do anything at all? (autocommit on) If it does work without a transaction being declared is rollback necessary for single query statements? See example below... try{ $sql = "DELETE F...
A site I'm working on tracks users before they sign up or log in to determine things like which pages drive the most users to sign up for the service, etc. Currently we make use of a browser fingerprinting library. We fingerprint the browser, save the result in a cookie, and use this cookie to uniquely determine users....
We currently have a requirement to build a multi-tenant application that has cross-tenant users. That is the business data is separated by tenant but users can belong to multiple tenants and should have access to all of the data for each of their tenants. My question is does this even make sense? And if so, how can we ...
How can I discover and master the technical system of an ERP and/or a framework published by the company that has just hired me? For example: is it useful to draw UML diagrams on paper (and if so, which ones?)? What notes on paper to take?
Consider the following Activity Diagram : First of all the activity a22 is confusing me through this configuration .If we need to list all the possible activity sequences that can take place in this activity diagram. My answer is as follows : Sequence one : a11 ; parallel combination of a22 , a33 and a44 ;a77. Sequen...
I usually do Javascript and I like putting console.assert liberally in my application. It throws an error if the first argument is falsey. E.g.: console.assert(price > 0, 'Price isn\'t above 0') It's easy to automatically remove this for production builds. When developing, I often accidentally break an assertion. I thi...
Probably the answer is you can't. However, I would like to have a work-around to solve my problem. Objective I am trying to create a program in which I try to avoid nulls as much as possible. Problem I am using the empty object pattern in places where null could have been returned. Like this: public User GetByEmail(st...
im trying to create a sequence diagram for login , but i dont know if its true or not , maybe the community can help me check , because i see many way to create sequence diagram and its not the same at all .. Thank you for the help and explanations
Linux Onlyoffice Docker scripts are available for download. Are docker containers tied to a particular CPU architecture (IA64 vs ARM)? I would like to run Onlyoffice on an ARM platform (Raspbery Pi 4 or similar SBC computer).
What do you think about using interfaces just for the sake of enforcing certain naming and patterns across your team? Other than that, it doesn't hold any practical value programmatically. I'm on the fence on this one because I tend to minimize abstraction whenever possible, but this seems a bit unnecessary. However, ...
We have a set of micro-services that are functionally dependent and have intertwined validation logic. e.g. consider 'Credit-Card' service and 'Loan' service. When user has a credit card then loan shouldn't be given and vice versa. Hence when processing a request we validate across these services using API calls and co...
https://docs.microsoft.com/en-us/dotnet/core/tutorials/publishing-with-visual-studio In Create a Hello World application with .NET Core in Visual Studio, you built a Hello World console application. In Debug your Hello World application with Visual Studio, you tested it using the Visual Studio debugger. Now that y...
I am creating a small project that implements an interface in Java. I am not allowed to modify the interface, which means I can't change the functions in my class that implements the interface. However, one of the methods in the class (from the interface) requires a different behaviour in some cases. How do I implement...
Assume the flow graph of a function is below (sorry I have forgotten the code of the function): And when I try to calculate the cyclomatic complexity: When I use the edge and node to calculate it, V(G)= 9 - 8 + 2 = 3; when I use the branch node to calculate it, V(G) = 3 + 1 = 4. However, when I try to find the independ...
We know that the primary actor is the one that initiates a use case and a secondary actor is the one that helps completion of the use case through his specific support. The Primary actor is usually placed at the left side to the boundary of the system and the secondary actor is placed to the right of the boundary of th...
I have a Customer which can have sereval address. Sereval customers can possibily live at the same address. So in my relational database a classic many to many relationship. As : An address can not change (a customer can change address); It does not involve any logic with side effect. And the equility between two a...
I am confused because in quite a few places I've already read that the so-called 'boneheaded' exceptions (ones that result from bugs in code) are not supposed to be caught. Instead, they must be allowed to crash the application: Vexing exceptions, by Eric Lippert A comment under Eliding Async and Await, by Stephen Cle...
Here is part of an ASP.NET MVC program, from https://docs.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/controller-methods-views?view=aspnetcore-3.1 : A model class Movie: public class Movie { public int Id { get; set; } public string Title { get; set; } [Display(Name = "Release Date")] [Dat...
I am quite confused about the responsibility-driven design concept. Mainly because of ever so slightly changing definitions depending on the source. Quoting BlueJ (the book I am learning that teaches Java): Responsibility-driven design expresses the idea that each class should be responsible for handling its own data....
List is implemented in C# exactly as Stack, see: https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.stack-1.push?view=netframework-4.8#remarks https://docs.microsoft.com/en-us/dotnet/api/system.collections.generic.list-1?view=netframework-4.8#remarks Given that: Why should developers choose, List ...
to summarize a bit my current situation: I am building a backend based on microservices using spring boot. These are aggregated behind an api-gateway. My intention is to consume these api's from both a mobile app and a webapp. However, I'm constantly wondering what kind of technology I should use to build my webapp fro...
In MVC, does the view component deliver a new view to the user directly or indirectly via the controller component? says The first thing to realize is that Server-side Web MVC (e.g. ASP.NET MVC & similar where controllers handle requests and views render to HTML) is not the same as client-side/desktop MVC/MVP UI patte...
I am letting users change their password after a reset, by following a link containing hashes of the password and user name (e-mail address). The link can look like this: www.example.domain/login?h1=8tGecrXvKJBOhtzvyDmJNjpLF5RF3Ed+QSkimxlJaFo=&h2=Bv2WmO4uzgrDIRj9scKtMz0Ek0KpyJ3M00wJrMU7oeA= Note the presence of a "+"...
What's the difference between reactive programming and event driven architecture? Is reactive programming a way of implementing event driven programming?
You have a video game in which upon killing final boss you get coins that get distributed based on whether you are: Person(individual) Group(consists of individuals or groups) If reward for killing monster is 100. And the Fighters that killed monster together are: var joe = new Person("Joe");//Person var jake = n...
I am currently developing a wrapper API for a translation service that should provide multiple methods for translating strings, Task<string> ITranslator.TranslateAsync(string phrase, Language from, Language to) an ICollection<string>, Task<ICollection<string>> ITranslator.TranslateAsync(ICollection<string> phrases, La...
As the title implies I am trying to understand the difference between boundary, controller and logical class types, which are used in the MVC pattern. I will do so using an example. Please consider the following Class Diagram : I have to add the needed analyse classes of type boundary and controller to account for t...
Why are FLASH memories considered to be EEPROMS? EEPROM has "Read Only" in its name, so by definition you cannot rewrite it, yet FLASH memories are used for USBs and many other technologies which are constantly rewritten. I understand that EEPROMS are "Erasable" which means I can modify their contents by erasing and r...
The usual workflow for my team looks something like this: features are planned by product management and then collectively broken down to business requirements. Then the developers start working separately through those requirements one by one until the next feature comes around. One issue I noticed is since the storie...
How does one service get the data from another service? I will give few examples: 1) Let's say we have two services which need to share the data: User Service and Order Service. Order Service pretty much will want to get some data User Service's database has like address, bonus points to cut the price, but all Order S...
GitHub and NuGet Do you use connection strings to instantiate your adapter services or just always configure it through IoC? I think that connection strings could provide a way more flexibility, especially while being combined with IoC container. Here are my two helper classes which I defined to handle URI based connec...
So, recently I have been doing a lot of programming in Python. I have noticed that my programs can be somewhat hard to read. I usually have one main class which does everything, sort of like this: class main: def __init__(self, *args, **kwargs): # Make baseline variables here self.foo = "bar" ...
I've got 2 near-identical functions (NodeJS). One of them queries DB for shop information by its phone number, while the other one queries by its id. I'd like to know if there's a clean way to merge these 2 together. async getShopInfo (phone) { try { let shopInfo = await shopConfigModel.getShopInfo(phone) ...
I have a eCommerce like system which produces 5000 user events (of different kind like product search/product view/profile view) per second Now for reporting business users would like to view the different dimensions like 1. Find user session(say of 30 mins) in any given x days.. 2. Find number of searches/product/p...
We are using Entity Framework with SqlServer Database. Business program needs to create many columns which are not in the Database, due to storage, high querying cost etc. Currently, the team is Copying the whole DB Entity Layer (from scaffolding), and Creating whole another layer adding computed members in new entitie...
We have a set of microservices and would like to expose endpoints from a subset of these for third parties to use. To this end, we will build an API Gateway that acts as the access control mechanism for all our services. In terms of how access is controlled, I've thought about the following but I'm unable to decide on ...
I'm making an app which is a Django backend and a React frontend (being developed by someone else). The plan currently is to fully decouple the two and have them communicate over API. However, I would like to make use of Django's Authentication features. My understanding is that Django Authentication makes use of Djang...
My model classes (business layer/library of ASP .NET core solution) uses a number of services (IOrmService, IEmailService, IFileService, IHtmlToPdfConverter etc.). Different models requires different combinations of the services for CRUD operations. It prevents me to use base class to max extent and forces to repeat co...
I want to create a program for the Linux OS in Haskell with multiple .hs files. I don't need help with the code or compiling it, what I don't know how to do is create an application that can be called from the terminal (like how python or ghci is). So: Where should the files go? What do I need to do to allow it to be ...
In my limited understanding of microservices they seem to focus on quite limited pools of information, leaving it up to the application to bring all the data together in ways which were perhaps not anticipated. I am working through a simple project in an attempt to get up-to-speed with a number of new concepts for me....
I have very little experience in this area, so sorry if I use any incorrect terminology or if this is a stupid/simplistic question in general. But from what I understand, when a developer wants to push out an update for an app, it has to be approved by Apple/Google which can take up to 2 days. And apparently it even us...
I have a design question and am hoping for some validation. I want to create a 'serverless' web app which will parse a csv file and return an XML file. I will have a single page react app hosted in AWS S3, where a user can drag and drop a file, and it will be parsed and the contents of the csv file will be sent to a l...
Android uses the modified version of JVM known as Android Runtime to execute android apps. How do games (with Unity 3d) and Apps (Xamarin) written in C# (which require dot Net's Mono framework) run on Android? The official website of mono says The Mono runtime has been ported to the Android OS. What exactly does tha...
An example of my API is mydomain.com/v1/update-profile So the user is authenticated and wants to update some stuff in their profile. Should we design the API to expect a POST or a PUT HTTP Method? From my internet search it seems PUT is idempotent, but at the same time it's usually used for updating a particular resou...
I'm ingesting 150 objects that each require an user capabilities check, the function isUserAdmin tells me whether or not an user is an admin or not. Inside this function, there's a lot of deeper checks and so on. It'd be really, really nice if I could cache this stuff so I don't have to check for 150 objects. I'd like ...
I am trying to create a season schedule for our Knowledge Bowl league (middle school trivia). I am NOT very mathematical nor a "techie". Here are my constraints: There are seven schools participating; each school has three teams. Example: Tenino Black, Tenino Red, and Tenino White This means there will be 21 team...
I am designing an application where there will be one column that stores a large amount of text. I'm debating whether the text should be stored in the database itself, or whether the database should store a reference to an object store such as Google Cloud Storage or Amazon S3, and have the application use that referen...
I have different types of posts a user can create: TextPost ImagePost VideoPost The frontend client needs to retrieve the last 10 posts from a user. I am wondering how to model this structure correctly in a relational database and the data structure for sending the data to the frontend. My proposed solution: A post t...
Imagine that we have a storage of objects O (can be in SQL, NoSQL, doesn't matter) where the object contains some property P_1 to P_n. Some of these properties are stored in storage S1, some in storage S2, etc. In general, imagine that the full definition of the a single object can only be done by invoking some kind of...
Here's a simple scenario: a REST API of which you launch multiple, load-balanced replicas of the same service with Gunicorn. Unit and integration tests are run in single-instance cases, but how can you run integration tests that include all instances so you check that they have a single source of truth? I can think of ...
For modelling software implemented with the imperative or procedural programming paradigm we have Flowcharts, process diagrams, etc. For object oriented we have UML class diagrams, object diagrams, state diagrams, etc. Is there an UML diagram suitable designing software implemented with functional programming?
I have a complex PostgreSQL database structure that is consisted with views, materialized views and foreign wrappers. The database schema is manually updated without any sort of migration script, hence I want to introduce a database migration schemes. One approach is to generate an initial SINGLE migration that will r...
I know that a RESTful would have unified API and it treats everything as a resource (a noun, example a book, a product,...) and it can be applied with CRUD operations using HTTP Verbs (GET, PUT, POST, PATCH, DELETE,...) I am aware of the fact of nouns & verbs. Now, I am building a Web API that is managing the books and...
I am trying to review our current architecture. These are the current layers, trying to analyze them, and see if the following three ideas are good practice. DatabaseSQLStorage ---> Entity Framework Class Layer ----> Generic Repository ---> Entity Framework Copy Model Layer ----> Application Service ---> DTO Layer -...
I have a class called D2Array which represents a fixed-size 2D array. It's meant to be generic and it comes with quite its lot of methods: getting an element, setting an element, extract a whole row, column, etc. Now I want to write MyClass, which contains a D2Array, and in order to use MyClass properly I'll need to ...
Currently I am working on a school project written in C#. Some teammates just started in C# and some are already familiar with C#. Today I had a discussion on whether to use syntactic sugar like this in our code: private _someClass; public SomeClass SomeClass { set => _someClass = value; } // Equivalent to: priva...
What is exactly meant when software-engineers talk about "behaviour" in contrast to "state" (Definition of "state")?
I'm developing an application that has a backend (Java, Spring) and a frontend (TypeScript, Angular). The backend application provides with an OpenAPI-compatible API and performs certain operations with different 3rd-party services (Kubernetes cluster, GitLab server and other ones). The backend service has controllers,...
I am still quite new on here so I hope I am posting in right forum. I am currently writing a small library where I realized I could use some kind of design pattern which lets one pass constructor arguments to initialization or allocation functions, and these can be further specialized in inherited classes. Something li...
I am trying to decide between a NoSQL (MongoDB) or a SQL (Oracle) database for my project. This database will be used to store output files from a set of parameters. I can model this as a MongoDB document, so that the parameters and their values are stored as a key:value pair. Afterwards, I would query those documents ...
I am investigating a good maintainable architecture for GraphQL. In particular we want to migrate a REST app to GraphQL. Specifically I am using .NET. I am following the tutorial here: https://fullstackmark.com/post/17/building-a-graphql-api-with-aspnet-core-2-and-entity-framework-core which is very similar to most t...
So, I was wondering about how Haskell's lists are implemented. I looked it up, and found this: data [] a = [] | a : [a] So I get that you can write lists like this if you want to: a:b:c:[] -- instead of [a, b, c] But my question is: How is the list syntax that is usually used (the [a, b, c] syntax) implemented? Edit:...
Clarification question on saving entities best practice. What is the purpose of returning an entity that you might have just saved in a repository? I see the benefit of returning it's Id once it's been created but not the whole entity. Can someone please explain the purpose or benefit in returning the entity.
I understand "the works" of event driven systems and I've built simple ones. However I find that I am struggling a bit in efficiently designing one. E.g., Formulating all the events upfront seems not easy, I find that I'm removing/renaming some events I initially determined later down the road. Another thing is determ...
We're implementing a service that exposes data related to a particular part of a business. It will pull data in from different sources, do some ETL, and store it in Redis. It will expose this data via ReST endpoints (and possibly GraphQL). For scalability, Redis will be replicated from London to US. The service t...
I have a issue that keeps coming up as a developer using any .NET (C# mostly) and SQL. I personally feel it is bad practice to build SQL statements in code. There are too many case scenarios that may appear that you may not be aware of. If you ever done a SQL audit, it becomes infuriating creating unit tests for every ...
I'm writing an education app and my current Firebase structure looks like: Course ∟ Lesson ∟ Modules (Includes video, audio, text and quiz modules in one collection) Where "Course", "Lessons" and "Modules" are each collections. I also have a type field inside the module document that tells me what I should d...
I've read some articles about CI/CD and find that a typical CI pipeline often includes Build, Test and Deploy. We also add Code Quality Scan stage to our pipeline. The question is that, what is the proper order of them? Should Test goes before Build or after? Is there any best practice?
In one of my projects, I have this following use case - I have a variable, that I need to pass around in many methods. Business logic and object creation in those methods are dependent on that variable. It can be the case I have object creation inside a constructor of another class. For those, I am also propagating th...
I have got an argument with my colleagues about this. IMO It's common practice that you don't need to check if an id exists or not before rendering it. So here's an example. This is what my colleagues implicitly saying its proper to do. let hotels; getHotel().then(res=>{ hotels = res.hotels.filter(hotel=> hotel.i...
Let's say for a Net Core library that I will deliver to the customer The library define a Interface like IGetData and also a default GetData class. The library also define a ICacher interface with a default Cacher class It's the client's responsibility to register the Interface and the default Classes to their DI conta...
Are use case classes (application services on DDD or a.k.a. Facades) stable? Should controllers and listeners be coupled with interfaces at all?
I started creating an application which uses strings as key, in order to have readably, non-guessable API values: GET https://myApi.com/docs/obuxn6xhzg GET https://myApi.com/docs/qxfj1g40xf PUT https://myApi.com/docs/jgtw2vsqqh (--> to update the item, for example) as opposed to having https://myApi.com/docs/1 .. http...
I am attempting to partition a decision node based on environment attributes. The process I am modeling is slightly different depending if a variable scope is public or private. I am trying to associate the related Map Variables action in the Pipeline partition but cannot determine the best way to model this. Should I...
I have been playing around making amortization schedules in PHP. My php.ini currently has the precision set to 14. I understand going into this that there will be rounding errors however I am hoping to minimize these errors. My current way of doing this is only rounding my payment amounts and then leaving all other va...
So I'm currently trying to write a project using Clean Architecture. Its a Unity Engine project which doesn't make the task any easier. The Issue I'm running into however is much more basic and has to do with the fact that all examples for Clean Architecture use cases I have seen appear to be rather simple mostly CRUD ...
How can I determine the monetary cost of a user story point in a given team? I was asked this question recently since the business is interested in determining how much a given project could cost them. Now I know a user story point is a subjective measure of estimation, e.g. The team assigns T-shirt sizes to the storie...
From what I understand, the visitor pattern is supposed to solve the expression problem (described here), where a program needs to support performing multiple operations on multiple types, ideally allowing adding new operations and new types without touching existing code. OOP languages can define a method for each op...
Considering that: when using the repository pattern you deal with entities - those are the atomic units you persist (regardless of Hibernate or "manually") when changing an entity you save it as a whole (there's no set or increment field) multiple application instances might be running the same entity might be fetched...
This is for unity I tried another way of stopping player after he dies and it worked fine but now it does not work with sounds That was my way the only thing that I changed is the state Ben's was if (state == state.Alive) { Update() } Mine was if (state == state.Dying) { return; } They look the same but the prob...
I am trying to follow the Onion Architecture to design my application where I have the following layers - Domain Layer: is the inner-most layer and defines repository interfaces Infrastructure Layer: forms the outer-most layer peered with the Web/UI layer and implements the repository interfaces Service Layer: is ...
My team is building a solution where a mobile app communicates with a backend. I need to describe functionality where the communication between the app and the backend is optimized according to some rules that work for both the client (mobile app) and the server (backend). This optimization will be mostly developed on ...