instruction stringlengths 34 36.1k |
|---|
I'm working at a startup, as a solo mobile application developer as a contractor. This has been for around 5 months now. I work part time. I have 3+ years of experience as a developer.
We have a strong user feedback loop, which also means frequent and fast changing requirements.
With so many frequent changes, I miss ou... |
In Part 5 of Wizards and Warriors, the blog proposes the concept of a "Rule" and rulebook to address the issues with solutions in the previous parts.
One of the issues was the need for double dispatch using a Visitor pattern:
Player player = new Wizard();
Monster monster = new Vampire();
player.Attack(monster);
Playe... |
I'm creating a very simple compiler PoC that only has
Procedures
Calls to procedures.
The syntax of the language is really simple:
Main
{
Call("Proc1");
}
Proc1
{
// Empty
}
I want to create an algorithm to get THIS STRUCTURE (that is, in fact, a directed graph)
Script
{
Procedures:
[#1] (Procedur... |
So we work in a structure with three week sprints, and we want to give testers time to test.
Currently our process is, write functionality > write unit tests > code review > deploy to testing environment.
What I thought of is that when we have functional code, why are we not deploying it to give testers more time to te... |
For some more type safety I wanted to introduce a PageId type in my application. However, I am not totally sure what the best option to do so is.
I want the IDs to be GUIDs, so I thought I just create a PageId class which inherits from the Guid class. Unfortunately the Guid is a struct, which does not support inheritan... |
As a learning project I started looking into how to mimic some basic features of a no-code platform. I usually code in Java/Python, have good knowledge over Javascript/HTML, but wanted to use this to pick up React or Vue frameworks. I am more of a backend dev than front end.
I understand the mechanics of the drag and d... |
I am challenging my OO design skills and started an ambitious project that is supposed to be highly reusable and extensible. It is supposed to be kind of a framework for evolutionary algorithms. Maybe there is somthing out there on GitHub, but my research didn't come up with anything I'm looking for and anyway, I'd lik... |
Would anyone here recommend using debug statements such as the following in production quality code?
I think these are personally one of the easiest to include or exclude, but they make the code hard to read so alternatives would be better
#ifdef DEBUG
perror("open");
exit(1);
#endif
// Otherwise here we just ... |
I have moderate Golang experience and lots of experience in other programming languages such as Java, Python, Rust, Scala, and others. I'm comfortable with building REST services and most of the other related topics, so the concept in general isn't new to me.
Background
I'm building a REST API in Golang using gorilla/m... |
I need some code from some deprecated libraries, one small class (150 lines) and two functions (24 lines). The libraries are part of larger set that we use a couple of but both are being deprecated. The packages are still up on the registry but they are removed from the GitHub and not going to worked on or included in ... |
In short, "functional core, imperative shell" can be summarized as:
functional core implements logic; you unit test it. Your tests call real functions just like in production real functions are called; ie compared to mocking / faking, you don't run a risk that mocks / fakes mildly mismatch behavior of the real depende... |
I am working in Python so attribute privacy isn't enforced. I have a Library class that stores a list of library Items related to that library. I want to be able to access the library Items through the Library class. Right now I accomplish that by returning the "private" items attribute. However, any class would then b... |
A good auth system contains access and refresh tokens. I know what access-tokens are for and I know what refresh tokens DO - but I don't understand their meaning.
For example:
If I authenticate myself successfully to an API, then I get an access token and a refresh token. If a bad guy steals my access code, he can acce... |
If you haven't heard of Kent Beck's TCR, it can be summarized with this: any time your tests go green, you commit; anytime your tests go red, you git reset --hard.
This post is about how to practice TCR correctly. It ISN'T about the merits or deficiencies of TCR (although that would be an interesting topic for another ... |
We are building a system that runs on our cloud and that needs information from our clients network that must not be exposed openly. We have concluded that the only way this could work, is if our clients can install an agent in their network, that would gather the required information and push it to our system through ... |
My friends' company is using the incremental method to update/deploy a new version of their app to the customer site. But what kind of surprises me is their update/deployment is on granularity of files, not the services.
For example, suppose the finally built app in version 1 consists of two files A and B:
web_app (ver... |
When doing TDD "by the book" we should only -- as far as I understand -- write failing tests. This means tests for unimplemented functionality.
I often find myself wanting to add tests for edge cases that expect to work with the current implementation. This means the test does not drive the implementation, it is merely... |
How does phone number based authentication work, and what are its best practices?
I've noticed there are apps with streamlined sign-up/log-in processes where only a phone number is required, simply the phone number and then a verification code sent to the user via SMS. A good example is the dating app Hinge.
I don't re... |
Okay, first of all I understand the concept of IoC container! It's used to implement automatic dependency injection so you won't have to manually inject dependencies to class. It can automatically detect that if a class requires, let say for example IEmail dependency, inject Gmail class into it.
I noticed that, IoC con... |
I have a large collection of (C#) objects and these objects have a large number of properties, mostly strings and numbers. This collection is stored in a database. When a new object is about to be added to the database I need to check if similar objects already exist in a database.
One way of doing this would be to enu... |
As I got to know there are 256 possible combinations to get for 1 byte. If I understand it correctly, it should mean that you can display any number out of numbers 0-255 and this very number would use only 1 byte of your storage on your computer. Displaying a number out of the numbers from 256 to 65535 would however co... |
I have an eternal discussion in my work about why "error first" is "worng".
In order to ensure what I try to tell with error first is the following code pattern:
if condition:
raise Error()
code
Instead of if-else approach
if condition:
code
else:
raise Error()
I think that the first one (error first) is... |
Background
I've taught myself Python over the past year-and-a-bit, and would consider myself an intermediate Python user at this point, but never studied computing at school/university. As such, my knowledge of theory is a little weak. Python is the only language I know.
I'm trying to wrap my head around the Liskov Sub... |
Suppose I'm building a web application using Django. Some of the views need to touch multiple database tables or rows, and there is some kind of state consistency that I need to ensure among the records.
Here is a simple example, albeit a bit stupid. Suppose we're talking about an application for the management of clas... |
Consumer software often has interpreter dependencies. How should a situation where the required interpreter is not by default installed on the targeted system be handled for consumer software, soft for non-technical people?
Bellow, I give an example with Node.js and macOS, but my question applies equally to other platf... |
I need to create some commands that share the method Execute() and a property that gets the result of such execution: List<IResponse>. I have the following interface:
public interface Command
{
public IEnumerable<IResponse> Responses;
void Execute();
}
Each class that implements command needs different inputs ... |
We have function DoStuff. It can return Stuff or Error. What is the cleanest way to do this in C#? I know that it's best to throw in error case, but it has its own downsides. Also consider case where there are 2 logically different results, which are not errors. what then?
Important for me is that code is readable and ... |
I've been running into a common pattern when requesting data from multiple sources:
Have a list of objects from one source (e.g. a list of Cars) with an id property and a few other properties populated (e.g. make, model, year).
Call some service (second source) with the list of Car ids to get data for a few other Car... |
Frequently in applications we encounter situations that could throw a NullReferenceException; for example, assuming the following method's argument is a user defined reference type, accessing the reference without first checking if it is null, can result in a NullReferenceException:
public void ProcessObject(MyObject o... |
Our software product is not complete, but it is functional enough that one of our clients is using it.
We produce release notes with every sprint. The notes are divided into sections such as "New Feature", "Improvements", "Fixes" and "Known Issues".
Frequently we get a change that would never appear in the release note... |
I wrote a Java web service using Spring that handles REST calls from
the Internet.
The web service uses a Postgres database underneath to store, modify and read data.
The Postgres database is used exclusively by
this web service, no other program accesses the database.
The web service uses a database user th... |
Today, I updated ZBateson\MailMimeParser the PHP e-mail parser library from 1.x to 2.x.
Soon enough, my PHP error log started filling up with errors.
Noting where it happened, I found out that it had to do with their ::parse(...) function: https://mail-mime-parser.org/upgrade-2.0
An additional parameter needs to be pa... |
I have various types of financial securities. Each one of these securities shares a common set of methods. For instance, they all pay some amount of cash interest between two dates. Each security has a different way to calculate that amount, however, that can require totally different inputs. Think of this as trying to... |
I have been assigned a ticket to update all node packages and dependencies in a react project to the latest possible version without breaking the application monolith as it is now; no further meaningful development of features is planned for this application.
Although I plan to finish the task without much questioning,... |
I’m struggling a bit to design the following class:
It’s a service class with multiple methods. It depends on a http client interface which must be created in the factory method and can’t be passed externally.
If property1 is set to ON, it is expected that the url property is set.
Then it’s required that it calls the e... |
I am writing functional tests for my application that scrapes some data online then sends the results in an SMS text (on a weekly basis). My understanding is that functional tests are meant to test the functionality from the users' point of view. So, how do I "test" that the user receives a text? I am using Twilio API.... |
Right now I'm working on a project that's basically a marketplace. The project separates backend (Django + DRF) and frontend where frontend can hit different endpoints based on user interactions with web interface.
The project has two distinct but related entities:
buyer;
supplier.
So original engineers decided to co... |
I recently joined another team part time where I kinda know several of the people, and they know me for my design work mostly, but I'll be doing design and some development with them. There's a lot of things I've noticed in the space of the first week that are just not done right, but I don't want to bring up a huge li... |
In a golang project, I have mocked external services. But in order to check that mocked services has the same behaviour as real services, I have done some common testing on the interface with both mock and real, so with real credentials.
Let's say that I have :
repositories/serviceA/mock/mock.go
repositories/serviceA/m... |
I have the following code and I am not sure if the builder factory is the best approach to solve this code duplication.
createA(a, b, c, e: {e1, e2}){
return{
a
b
c
e
}
}
createB(a, b, e: {e1, e2, e3}){
return{
a
b
e
}
}
createC(a, e: {e1, {ee1, ee2}, e3}){
return{
... |
Consider the following approach to validation of an API class (POJO or what have you, I mean a class which just acts as a container for some properties), we make all constructors private to the API scope (and actually let us insist there only be one constructor), and the constructor does validation of its inputs, throw... |
I am working on an application for awarding organizations by the CEO based on a somewhat complex criteria of multiple dimensions. The process consists of 3 nested workflows:
Award workflow (opened → closed → endorsed → approved → published)
Nomination workflow (submitted → reviewed)
Nomination Review workflow (started ... |
Say I have an application/service A. This application will continuously take in some input X, process it and store it in some database T. This process is quite resource intensive.
Now you also wish, as a user, to have access to the data in T so you need endpoints for retrieving and updating this data from the database.... |
What is the "best way" to implement something like this:
I have a list of steps that will be iterated and ran for an IContext instance. But, some steps will only apply to a specific instance derived from IContext, while other steps can apply to any instance implementing IContext.
I could create an abstract class Contex... |
I am reading “Building Event Driven Microservices”.
It states a requirement of the event broker is:
Infinite retention: Event streams must be able to retain events for an infinite period of time. This property is foundational for maintaining state in an event stream.
However this does not seem to be standardly availa... |
I am working on an application right now, which is fully paginated. The application basically providers the client (a browser SPA) with a list of all data items other users added, and it does that in chunks of 50. So when entering the page, the user gets to see 50 items, and once scrolled to the bottom, 50 more items a... |
For a school project, I need to make a DFD for an educational game, where both students and teachers need to be able to view the game's leaderboard.
Currently in my diagram, "Student" and "Teacher" are seperate external entities, "View leaderboard" is a process, and the leaderboard data is stored in a data store called... |
I am looking for a way to show duplicate data-stores in data-flow diagrams (DFD). With "duplicate" I mean multiple occurrences of the same symbol to avoid too many crossing flows.
In Gane & Sarson's DFD notation, duplicate data-stores are indicated by adding an extra vertical line to the left of the open ended data-st... |
Suppose we need to ensure that a sequence of database operations - currently implemented as A followed by B followed by C - executes either all together, or not at all. We can achieve this using a database transaction - but how can we write an automated test to verify that this atomicity property is satisfied, which is... |
Imagine we have microservice A and B. A has and endpoint in its rest API that will execute some CPU-bound operations and will formulate the return afterwards based on the actual state of some objects. This operation is actually requested for a bunch of other microservices. I can't see how I could decouple microservice ... |
We currently have a hotel and a restaurant management software (named Top-Sys and Pointex CHR), and they are working completely without server software.
These are designed to be installed locally but their databases are located in shared folders, currently installed on a Synology NAS and shared over smb. Now, I'm devel... |
I have an application made of several microservices with independent databases
So let's consider 2 microservices
Users and Documents
The users microservice manages the users and handles everything related to them and the documents microservice contains the document info, properties, file ....
Now each document belongs ... |
I have a class which aggregates some temporal data from a database and provides a bunch of methods to query said data. It looks like this:
public class InfoProvider
{
public IEnumerable<Contract> GetContracts() => GetContracts(DateTime.Today);
public IEnumerable<Contract> GetContracts(DateTime at) => GetContrac... |
I want to understand the difference between Kruchten's Logical and Development view when using a microservice architecture.
Krutchen describes the software architecture model 4+1 model with four different views.
Logical
The logical architecture primarily supports the functional
requirements — what the system should p... |
I have an application with an external configuration. Basically, there are a few basic environment variables, then the rest of the application's configuration gets pulled from AWS S3, is checked for validity, and then cached locally.
Given this is a PHP app, I can easily pass a query parameter to a page (ie. ?refresh_c... |
What is a good way to mix non-dev content, like FAQ text or internationalization text, into a development pipeline?
For example, suppose you have an app that is being coded by software engineers, but it provides a lot of text to the user and that text is authored by non-engineers. The text could be a FAQ that is writte... |
I've inherited some research code where there's already a fair amount of code duplication: on several occasions, the original author duplicated a file and changed minor things to calculate a variation of the original problem. I'm tasked with making modifications to calculate a different variation. Following the style t... |
Java source code is compiled into bytecode for the JVM. But, how does JVM convert bytecode into machine code? Does it re-compile bytecode into machine code and then run it? Or does it simply just run the bytecode, directly?
|
I've read the Fielding's thesis that defines the REST architectural style and noticed that the defined style appears to significantly conflicts with the so called "archetype controller", that a definition can be found in many places, like here.
The first thing to highlight here is that the "resources archetypes" is not... |
Situation:
VB.NET WinForms application, using the WinForms as a presentation layer project. Another class library project containing the business layer, in the form of CQS and Service classes, plus a data access layer.
Summary:
I'm attempting to follow CQS for new features being added to the legacy application. Conside... |
In (the most widely used) programming languages there is a distinction between "statements" (function or loops bodies, assignments... basically "the stuff that ends with a ';'") and "expression" (simple calculations, function / method invocation ... "the stuff you can assign to a variable"),
so far so good.
When I use ... |
I am trying to assess which of Apache Kafka, RabbitMQ, and Apache Pulsar will meet my throughput requirements for a system with multiple producers and multiple consumers for a single topic.
How can throughput even be compared if systems can be scaled to whatever throughput is needed? In benchmark tests I saw that Rabbi... |
i have as a mechanical engineering student in my practice semester to create a database that includes about 100k+ paths to images in our network. Every, lets say week, i have to synchronize all changes in the network with my DB. So i have to delete Data from the DB if someone deleted a Image in the network or i have to... |
I am building an application with ASP.NET Core 5.0 following DDD and the CQRS pattern. I internationalize on the presentational layer but when I send emails I send them in the application layer via an email sender service. This service doesnt know anything about internationalization because I have that capsuled on the ... |
The "VDA Automotive SPICE Guidelines" (excerpts: https://vda-qmc.de/fileadmin/redakteur/Software/Automotive_SPICE/Veroeffentlichungen/VDA_Guideline_Rules_and_Recommendations_2017.xlsx) tells to lower the score "If the verification results (…) contain only a pure passed/failed information without a supporting verificati... |
I'm honestly not even sure how to go about how to ask what I'm looking for/need. lol.
I'm currently using Sql Server for my database and the 'new' .net 5. There are multiple pricing tables that each have their own purpose for pricing lineitems on an order. These pricings get updated quite often, ranging from either mon... |
There are plenty of articles about parsing full Markdown/CommonMark/etc, but I'm interested only in a specific limited subset, so I'm wondering if a better approach is available to me, and would much appreciate any tips or advice.
I only need to support:
*italic* / _italic_
**bold** / **bold**
[link text](url)
`inline... |
Checkout this HTML using the attribute action, method and target from <form></form> tag:
<form action="/action_page.php" method="get" target="_blank">
<label for="fname">First name:</label>
<input type="text" id="fname" name="fname"><br><br>
<button type="submit"></button>
</form>
Is a good practice using form t... |
In the past I've mainly worked with monorepos, specifically a Vue.js app that was served by a rails backend.
Setting up E2E/integration tests in the CI was simple, because all the required parts were kept in one place anyway and the testing tools provided by rails did most of the heavy lifting. Now I'm working on a pol... |
My group in school is tasked with creating an application of our own choosing which follows good object oriented design principles. The group has chosen to make a tower defense game with help of libGDX (a Java game framework) and we are currently debating whether the update loop of the game (code that is executed each ... |
I'm developing an intranet application and I'm trying to use some concepts from Domain Driven Design (DDD) and Command and Query Responsibility Segregation (CQRS) in .NET Core, with EFCore.
But, to avoid weird exceptions from the API, on every Command and on every Query I'm first checking if the database is online (usi... |
I couldn't decide if the question belongs on Stack Overflow, but I went with SE Stack Exchange for the higher quality, broader answers. Bare with me.
Examples are in Node but I guess applies to a multitude of languages
I'm big on writing pure code without side effects. It's easy to reason about and to test. Yet, the fo... |
I have an application that is receiving a live stream of files, I am using active MQ for listening to the file arrival in s3. As soon as the file arrives in s3 my application downloads the file and starts processing for it.
Now, I require to pause the processing for certain types of files (*Xyz*.txt, pause window is 8 ... |
Context
In many GUI frameworks, it is very common that widgets are placed in a container to arrange them visually in a window. For example, in Gtkmm, a window with a label and a button (side by side) will look like this:
int main(int argc, char *argv[])
{
auto app = Gtk::Application::create(argc, argv, "no.abstract... |
I am building a database, and have implemented a transaction log system to ensure that writes are atomic, idempotent & consistent.
When a transaction is 'committed' it is appended to a log file before it is considered 'committed'. The log file is eventually persisted to the disk file, once it is marked as "full" during... |
Let's use https://github.com/dotnet-architecture/eShopOnContainers as an example. There are CatalogService, BasketService and there is ApiGateway. In api gateway in BasketController there is AddItemToBasket handler (https://github.com/dotnet-architecture/eShopOnContainers/blob/dev/src/ApiGateways/Web.Bff.Shopping/aggre... |
I am developing a desktop application that utilises Tensorflow. The aim of the application is to let users easily train a given model and use it for inference within the app. I want to support training and inference via the GPU, if available on the end-user's machine.
The primary issue appears to be setting up Nvidia d... |
I'm working on a microservice application and I need to describe the complete execution graph of a specific event being published, where each node in the graph is a specific microservice subscription to this first event.
This diagram should be able to describe new events that are eventually published in response of thi... |
I have an app written using MVVM and RxSwift.
For navigation I'm using coordinator
What is the best way to store user's credentials and pass them to Network Layer.
I don't want to sore them in DB or keychain. I want them to persist in memory while app is running. Also wanted to omit having singleton with Credentials.
|
We have been in the process of scaling up my companies infrastructure, we have graduated from single servers and moved everything off to scalable AWS Ec2 servers that auto scale, there is one little item that has not scaled well though
Before, we had the server OS firing off a script that sent out emails via a cron tas... |
I've seen this problem in a few different contexts now but I'm not sure what it's called or how to think about it.
Suppose I have a service, AccountService, that serves accounts from a database, e.g.
account.id
account.fname
account.lname
account.email
account.business_address
account.tax_id
account.invoiced
...and so... |
We are a wholesale marketplace and we have three main products in our startup. The products are:
1- the marketplace app that allows customers to view products and purchase online.
2- the seller app that allows the sellers to list their products and see review incoming orders.
3- the courier app that allows drivers to r... |
In the announcement of Linux 5.15-rc1 Linus said:
At only just over 10k non-merge commits, this is in fact the smallest rc1 we have had in the 5.x series.
What is a non-merge commit? What's the opposite of a non-merge commit?
|
These are my class designs:
I also have Controllers where I can create table, create users add users to table, deal hands simulate user bets using PostMan (Above classes are game engine classes, I did not share controllers in spring boot. It is all API)
Somehow, I am not able to stitch them all together as a complete ... |
I am designing a workflow, and am trying to avoid parallel deployments of the same service. Thus I am looking to have one service that handles both interactive and batch traffic. My main concern is how to ensure that my service can horizontally scale fast enough, with large batch runs, and not interfere with the inte... |
Here's an analogy of our concrete problem to demonstrate the issue at hand.
We need to manufacture cars, with either petrol or diesel related parts (the parts can be the engine and the exhaust - e.g. different requirements for exhaust for diesel engines).
Engine
+ engineCapacity: Integer
DieselEngine: Engine
PetrolEn... |
I'm deploying a serverless/lambda-based HTTP API via AWS API Gateway. My goal is to minimize latency in handling requests. I am considering two architectures, and I'm wondering which best meets this goal. Here are the options:
Deploy one edge-optimized API Gateway application. AWS will then create a CloudFront distrib... |
"Designing Google Docs" is a popular system design interview question, and there are plenty of articles on it on the web. However, those mostly touch on merging changes, but don't explain how to swiftly notify a user of a change made by another user in the same document. Supposedly, for collaborative editing getting no... |
Its not exactly my use case (would take too long too explain), but imagine a task management application where tasks for employees are displayed in a list along with some information about that task. These are some of the Task types.
Simple Note like "take out the trash" or "refill fridge"
Customer Support Ticket for ... |
In our ASP.NET Core application, we have many APIs which are calling public method from the service class. Service class is implementing an Interface. Each service method (depending upon complexity and requirement) may call any number of internal or private or helper methods. While each of these internal/private/or hel... |
I am unsure where/how to specify the behavior of a mock in a test scenario when using the Given-When-Then syntax.
It seems to me both Given and When could be correct.
Consider the following example:
I want to test the control panel for a car.
This panel has a start button for the engine and a LED that shows the engine... |
Understanding that it is less load on the server to not have to parse HTML, when does it work the other way, as far as server performance.
The majority of my Web sites are database-driven - often the same cosmetic structure with entirely different information. Separating the HTML, which is minimal compared to the PHP i... |
I have an event pubblished in a bus(rabbit) and two application that are subscribed to this Event.
public class CreationEvent
{
public int CreationEventID {get; set; }
... other properties
}
Application A and Application B are subscribed to this event, and listen from a rabbit queue.
Application A save the pr... |
Note: I am not sure of the correct terminology for what I am describing, so if you have suggestions for a better title please feel free to edit it.
"Favor composition over inheritance" is generally a good rule to follow, but there are some cases where inheritance is a must, like in the following case:
Node a = ...
Node... |
about those objects and arraylists inside the classes, derived from one-to-many relationships, using the ORM techniques, what's the best way to deal with them at the time of setters and validation methods? for instance: for me to save PurchaseItem inside Purchase, how and when do I chech that PurchaseItem is valid? wha... |
At the moment, the application I work on relies on an ISettingsService which is injected via the constructor; classic dependency injection. As time goes and the application's capabilities (understand complexities) build-up, the quantity and diversity of the settings exposed by the service have grown.
Some classes requi... |
According to my experience, there are two types of problems:
For some problems I have been able to use some quick/dirty workarounds. Users are happy. Since the outcome quality has been acceptable for them.
For some problems, no matter what I did with quick/dirty workarounds, I couldn't reach an acceptable quality.
A... |
I work as a Website developer. We use a framework for building the backend of our sites.
This framework recently released a new major version with lots of breaking changes. We have some sites using the old and many sites using the new major version.
I am currently tasked with writing a module that needs to work with bo... |
As we know HTTP codes are used in HTTP response. Usually with this code we can have an idea about what happened. For example if I make a get request and I obtain a 404 I can figure out that the resource that I requested doesn't exist on the server side.
Suppose that I want to encode the status of an object in the DB. F... |
As I am creating different database connections on the basis of database credentials (i.e. JSON or POJO with all the credentials required to create a DB connection).
e.g.
Imagine a Map containing these (UUID and Connection)
{
(UUID1, connection1)
(UUID2, connection2)
(UUID3, connection3)
(UUID4, connection4)
}
For... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.