instruction stringlengths 34 36.1k |
|---|
I don't have a formal education regarding application architecture, what I know I mostly "absorbed" on the job from enterprise architectures of the companies I worked for and/or from senior colleagues.
One principle I absorbed from a huge company is that each server-side enterprise application should only have access t... |
The following are some examples that you may see in an intro to programming course:
Print the elements of an nxn array...
Spiraling in from the outside
Spiraling out from the center
Zig zagging from the top left corner
Going right, then left, then right, then left(like a printer)
Etc.
These are fairly standard to whi... |
I have a Desktop application that was saving some data to %AppData%\MyApp\old.txt (roughly 1KB).
I have decided to rename the file that I write to to new.txt.
If I push out this change, customer machines will now have a redundant old.txt on their systems that won't be used for anything.
Is it good practice to add logic... |
Is there a de facto standard algorithm for finding good places to put line breaks in a paragraph of text rendered in a monospace font (e.g. to a text console)?
The algorithm should aim to output lines of an equal length (which is given as an argument), inserting a variable number of spaces between each pair of adjacent... |
please let me know if this StackExchange isn't the place for this and I will move the question.
I'm trying to write a mobile app that will have a 'notification' aspect. I have web development experience so my references will include that :)
A "post" gets into my backend API/database for which there will be subscribers ... |
How would you treat an interface where you cannot supply its dependencies before runtime ?
IDelta looks like this;
void Create();
void Update();
void Delete();
Consider this constructor on a type - DeltaCalculator - which inherits from the IDelta.
public DeltaCalculator(IEnumerable..., IEnumerable...){}
The construc... |
Let me explain what I mean.
I have made a complex, highly polished over years PHP framework/library for my own use. I very aggressively log the smallest notice and immediately deal with it as soon as it pops ups, always trying to predict potential errors in my code as to never have them occur even in rare situations, b... |
Intro
My question is I personally spent last 2 years working on a Django project for a factory, it uses the standard MVC pattern. The app uses the factory IP for authentication for terminals in the factory. It was my first web project and I have learnt a lot from it, and hence re-written many aspects of it.
3 Problems ... |
I am trying to figure out how to build most scalable and maintainable architecture for my app.
The app is just about choosing some shape and then editing it.
More precisely, choosing some existing shape from the list(square, rectangle, circle, oval, pentagon, N-gon, "house", some custom shape) and then after choosing i... |
We have test code like:
clickElement(a);
clickElement(b);
clickElement(c);
that's repeated in many places, where clickElement is called 1 to 5 times in a row.
Should we make a helper function to consolidate these, e.g.:
clickElements([a, b, c]);
I've heard arguments against creating the helper function, that it makes... |
I am currently building a small application which used a public API to get some information. The API doesn't support auto-login in any way (don't know if something like this even exists with APIs), but I don't want the user to have to login every time he uses the app. How can I achieve auto-login, when I need the usern... |
I have a calculation program which uses a number of different vertex types. Currently I have euclidean and geo, and I have decided to create an interface. Now I am wondering if that is a good idea.
interface Vertex: Comparable<Vertex> {
var id: Int
/** returns then distance to another vertex. Vertex is expecte... |
I've got an extremely oniony(deep) folder structure which contains Appx 1,000,000 text-based files on a network share. Using windows search is extremely slow and unreliable. I've created some text files which lists of all the files and have searched that text file to speed up searching, but it's time to mature this and... |
Possibly my problem already has a solution, but I couldn't find it as I don't know the correct terminology.
Essentially I have a class called 'Item'. Usually this item is grouped into Groups (N:1 relationship), which are in turn grouped into SuperGroups. It's also possible for Items to be associated directly with their... |
We have an input flag in our API which indicates whether we should keep the mid level resources involved in fulfilling current request or not. I've decided to use some context managers at interface level instead of passing the some store flag around the code.
For example, we should decide whether to store requests imag... |
My team is working on an analytics system for the web app. The web app has a service-oriented architecture, and all events are gathered in one centralized analytics service. The system is sending events from the front-end and back-end; these are requirements of the product team. However, the engineering team has stuck ... |
The resources on the web I have seen so far suggest that the 'sub' claim in a JWT identifies the principal.
According to this question, at least for some identity provider implementations, one cannot transfer sub values from one identity provider to another should the need arise.
This would suggest that it is better fo... |
I'm designing an editor as a desktop application that opens, saves and saves as documents from files, something very common in fact.
I already have Bounded Contexts for my business rules.
Naively, I want to put the paths of the files used to re-hydrate entities as their identities and implement the repositories with fi... |
If I got it right, the Dependency Inversion principle says that high level modules should use interfaces to the low level modules and low level modules should implement these interfaces. The purpose is to reduce the coupling between low-level modules and high-level modules and make the low-level modules easier to repla... |
Summary:
I want to transfer a file which changes over time, probably faster than the available connection allows a successful transfer.
Setup:
A remote device with bad network reliability and speed most of the time, but with "windows" of decent connection (able to scp ~>100 mb overnight).
The device could spend anywhe... |
I'm having trouble defining this problem space (example below), where to look, what to search etc. and would appreciate any help with suggestions of algorithms or libraries that I should look into. I've spent some time looking into constraint programming & OR-Tools but most problems seem to be scalar and I haven't yet ... |
I am creating a small data-driven desktop application using .NET 5 with WPF, ReactiveUI, Dynamic Data, and EF Core 5. The app uses a local SQLite database to store all persisted state, and relies heavily on dependency injection.
I would like to share state across my app by exposing observables of my EF entities in sing... |
Recently I hit something like the following setup in our codebase, and I'm wondering if there's a preferred way to do it, to achieve the cleanest separation.
public class FileLoader
{
public object LoadFile(filename);
{
return loadSomethingFromSomewhere(filename)
}
// new functionality
... |
Lets say we have a class Cat:
class Cat{
public eat(String food){
if (food.contains("cat")){
burp();
}
}
private burp(){
System.out.println("burp!!");
}
}
And we have the following code to test it (using Mockito and TestNG):
@DataProvider
public Object[][] dataProvi... |
My aim is to create a language specific to the scientific field (which would be used mainly in the field of machine learning and physics) which would be based on the functional paradigm, a paradigm which seems to me to be perfect for data analysis and processing.
Ideally and in theory, this would imply that there would... |
As we may know, there are two main high availability patterns: fail-over and replication.
In active-active failover, both servers are managing traffic.
In master-master replication, both masters serve reads and writes and coordinate with each other on writes. If either master goes down, the system can continue to opera... |
The Background
I have a friend (no, really!). This friend works in the layer between IT and end users. Something like a business analyst or consultant. This friend does not have a technical or IT background. They have gained a high level understanding of software and systems, but, for example, are not able to read/writ... |
The disadvantages of 1-indexing are well-known. However, our hand is sometimes forced by our choice of language and we have to convert algorithms that were intended for a 0-indexed language to being 1-indexed. When my hand is forced in this way, I find that I struggle immensely. My intuition tells me that I should be a... |
I'm working on an algorithm visualizer for sorting algorithms. Give it a (user-submitted) sorting algorithm, hit run, it'll generate a random list of integers and show you what the algorithm looks like. But then you pause to think about this for more than 2 seconds and realize that this is easier said than done. You ne... |
In my existing code, I have an interface like so:
public interface IStudentService
{
T GetStudent(int userId);
}
This interface is called in many places, and the concrete implementation, let's call it StudentServiceDb, reads the student from the database.
Then I have a new requirement, which is to get the student ... |
The motivating concept here is that the fewer tests you have, the faster your test suite runs. This kinda feels like I'm basically describing smoke tests, but I think smoke tests and other tests are commonly treated as entirely separate test suites: separate steps in a pipeline. Broadly speaking, we may have smoke, int... |
I have the following class
export class Agent {
constructor(modelName: string) {
this.shape = app.gallery.getModel(modelName);
...
}
randomMethod() {
... // using app for other stuff....
}
}
Which I find is very bad software design. My reasoning is as follows:
Access of a static var ins... |
There was a question asking what the "O" stands for in "Big O", the answer to which seems to be "Ordnung von"/"order of".
I wonder what's the origin of the names "Omega" and "Theta" in the "Big Omega" and "Big Theta". Or are they somewhat randomly chosen without an inherent meaning.
|
I have a web application where a user can customize one or more sandwiches to order.
Once the user has set up his sandwich, the sandwich is added to an unsubmitted order.
The user can add to the order has many different sandwiches has he or she likes.
When the user is satisfied he can submit the order for further proce... |
I'm trying to implement a system that allows a user to upload files over HTTP, saves the file to object storage as well as any metadata surrounding the file that already exists to a NoSQL database (i.e. the groups who have access to it, it's name, size, etc.). At that point it will be sent to a document parser will wil... |
I'm developing a java project that I'd eventually like to publish and make open source.
To make a executable jar file I use the maven-assembly-plugin. This includes my dependencies in the jar, which makes it easy to deploy as the user (currently only me) doesn't have to add the dependency jars in a different lib/ folde... |
I recently refactored a program for code feasibility and maintainability; however, I am totally unaware of what software principle I did implement. I just followed my feeling.
The purpose for this post is that I want to know what software principle I did implement so that I'm capable of referencing books or websites.
B... |
As mentioned in title, I don't understand how I supposed to cover by tests code which is just wrap http api.
I guess I can write only unit tests, because wrapped service is paid. Integration tests in my opinion isn't required because goal is just provide strict structure of input and return raw output.
Am I right in my... |
In many projects, software requirements change, sometimes meaning we software engineers have to throw out our work and start over. Heck, we have entire methodologies built around the assumption that requirements will change.
So, why are requirements changes allowed to happen in cases where the software engineers then h... |
I have two tightly coupled classes Basket and Discount.
Basket is responsible for keeping track of the items in a shopping basket, keeping track of any discount codes applied, and calculating the final bill.
Discount is an interface that has many implementing classes such as BuyOneGetOneFreeDiscount, FlatDiscount, Meal... |
As I understand, every programming language is either statically type checked or dynamically type checked (and there are cases where these two approaches are mixed, but for simplicity I won't mention it further), and every programming language can be implemented either in a compiler or in an interpreter.
From this I co... |
I've been looking at this for a long time: https://news-web.php.net/
Almost every single mailing list has the last messages sent to them in the year 2000-2003. That's 17-20 years ago!
It would be an understatement to say that I was shocked by this. I find it seriously creepy.
Even the most "active" PHP mailing list on ... |
I'm on a project which often follows the trends, so whatever works for big cool companies, will surely work for us, regardless the contexts and specifics. If that sounds like a little rant, then it is.
This way, one of my team members jumped on implementing Event sourcing, calling it commit log. Which might be good, be... |
For my recent project I decided to leverage Authentication-as-a-Service, in particular I am using Auth0 but I do not think this particularly matters. I've got my React client set up correctly and I am capable of signing in, I can also make authorized, restricted calls to my backend API (written in ASP.NET Core.)
The ex... |
I had some engaging conversation with my co-worker and we've discussed the "proper way" of Decorator Pattern usage. Unfortunately I couldn't find any confirmation of my assumptions and it's the reason of how my question have begotten.
Let see:
If we have HandlerInterface and also HandlerImpl and DecoratorImpl which bo... |
I'm currently working on a React Application with Firebase that involves a ton of data manipulation and reading. One specific feature is the ability to autofill a form based on a very large CSV file (about 500 MB).
I am wondering what would be the best option to go about this using React to read the CSV file? I doubt j... |
I'm working on a Kafka platform development project, the team is keeping all the code in master with no branches, next moving to QA, Stg, Prod. If in between these stages if they don't need any changes to move to next stage, they then revert all the unwanted changes and deploy the code and then put the unwanted changes... |
I have to implement a LazyLoading on the properties of my Entites Class. I can't use any framework and external dll (nugets package are forbiden, I can't use Entity Framework or Castle Dynamic Proxy Interceptors).
My actual solution is to use decorators that override the properties and do the lazy loading.
public class... |
I am writing a unit-test framework (for Matlab/Octave, but that does not matter) which also supports property based testing. Thus, I need some functions which generate random data which are tailored for the functions under test (At the same time I am writing a scientific program which I test using my unit-test framewor... |
I know this may fall under "opinion," but I'm also genuinely looking for advice on how to proceed here.
Our product owner recently left our team of 3 developers for another role. We don't work on a single product, but do lots of projects and support multiple applications for other business units.
I was previously a lea... |
I need to vary the object creation at (*).
public class Parser { // Problem code
public List<FileOption> methodA() {
// Does something ...
fileOptions.add(new FileOptionImpl(line)); <--- (*)
return fileOptions;
}
}
One way is to apply the abstract factory ... |
Consider a bitbucket project with 3 separate repos, A, B, C. These form the components of a microservices application, APP. We'd like to safely try out a monorepo pattern and see if it streamlines the codereview/deployment process. Ideally these would be replaced by a single repository APP that has subrepos (or modu... |
The more that I'm reading, the less I know about this one.
I'm actually working on a new website using Symfony.
In Symfony, you have the concept of Entity. An entity represent basically an object and discribe how this object should be stored into the database.
So my question is I've been reading that I should program o... |
I'm trying to represent some entity.
LineProduct A line holding a quantity of product and a Product entity
LineProductBlank A line holding a quantity of product and a ProductBlank entity
Product Entity is a real life product
ProductBlank Entity is some product that a user want to create which contain ONLY a name
... |
What is the intended usage of the ImmutableDictionary<TKey,TValue>.ValueComparer property?
Why is it useful being able to compare dictionary values by using a specified equality semantic?
I totally understand the necessity of being able to compare dictionary keys by using a specified equality semantic, but I can't get... |
This question is asking about a generally applicable engineering principle. It is using T-SQL as a specific example, but the question is about the engineering principles behind major SQL dialects in general. It is also asked in the same spirit as this earlier question:
What advantage was gained by implementing LINQ i... |
Users have the ability to enter and save text in a rich text editor which is eventually stored in a database and then rendered on a site.
Is it better to convert the RTF to HTML when it's stored to the database because there will be more reads than writes and converting it once will be more efficient?
Or would it be be... |
Supposing I live in a country where every car brand has a different tax rate, and I have a base class called Car
public class Car{
public string CarType { get; set;}
public int Year {get; set;}
public abstract double calculateSalesTax();
}
Would it be OK to add an abstract method to calculate the sales tax... |
My English skill is poor because I'm not a native English speaker.
Please understand.
I wonder that there is a error handling algorithm easy and useful in LR parser.
LR Parser is bottom up based so it make difficult on error handling.
For example let's assume there is a grammar like below.
Here, If user is typed "whil... |
I have searched for this question but could not find a good answer for my case.
Suppose I have a SuperClass for a bank loan with properties Amount and InterestRate.
public class BankLoan{
public double Amount {get; set;}
public double InterestRate {get; set;}
}
Then I create a derived class called SmallLoan, whi... |
My requirement is simple, I want to be able to count the number of bits in a number. With a little bit of research, I found that MSVC has __popcnt, GCC has __builtin_popcount and so on.
At this stage, it's one function. Later on here are some that would also be very useful in my program, but are again compiler-specifi... |
What do people mean when they say 'Logical' in terms like Logical separation, Logical partition, Logical grouping etc. in software ? I know what 'Virtual' means, it means something that does not actually exist, a non existent 'thing' mapped to something that actually/physically exists. Does 'Logical' also mean the same... |
The responses I've received thus far have helped me formulate this TLDR:
Currently the Observer Pattern is implemented to get information from the sensor-actuator modules to the individual Bluetooth services and LwM2M objects. The actuators should also be controllable from Bluetooth/LwM2M. This can be solved by just ha... |
I have boolean variables for the population of many towns. And I want to create an application where a user can type in a percentage corresponding to the variable's true value, and I want to get the biggest possible population that satisfies that proportion
Let's say for example in Town 11 I have
Town population (popu... |
I am new to the world of open source and just set up my Github account. I was wondering if there any naming conventions/styling guides to follow when naming things such a repositories. For example, in Python, there is snake_case. How should I name my repos?
Thanks!
|
A well-written program will be configurable. It will have a configuration file or database which specifies where to look for files, which network ports to open etc.
An Operating System lets many programs run together at the same time. It can place each program in a separate directory, no problem there.
So why is Doc... |
I am implementing a system where in the front-end, the user needs to select if option A or option B should be active. Depending on the option, a conversion module converts other input data for use with a low-level calculation-core.
If option A is active, operations [a, b] need to be performed by the conversion module. ... |
I'm making a git extension. It's in its own git repo. To run tests, I have created several test repos which are used by my project. Currently they are submodules of the main repo.
I am dissatisfied with this. Firstly they themselves need to be cloned (in case the original cloner didn't use --recursive) as part of the t... |
Consider 2 roads merging into one(This map is supposed to remain fixed). The program will not generate this map. The program will read this map and plot positions on it on its own.
The python program will control the position of the object. The program is supposed to "highlight" or "fill" a box when the object is at t... |
I hope this is the right site for this question...
I tutor in my spare time, and recently I downloaded a past GCSE exam paper and was attempting to edit the pdf- to select just a few pages to send to my student. Unfortunately, I could not do so because the pdf is password protected for editing.
Perhaps this is a silly ... |
I have code that checks if the scanned qr code exist in the database and if it exist it will insert data into another table but I did it in the HTTP GET request, is this alright to do it this way or there are other ways to do it correctly?
|
I've got the following flow:
HTTP API is exposing data from 2 database tables that are combined into one JSON structure. We're implementing this using CQRS - splitting the reads from multiple tables into different queries to run in parallel. Since the language we're using is PHP and it doesn't currently support multip... |
I have an object that contains several dozens of properties. A portion of property values come from Service A, others from Service B, and the remaining from Service C. This object is a flat model that is used to be serialized as a request REST call to another external service.
If I define the service APIs to accept the... |
We have a few 100's lines of code, that according to some complex logic decides if certain columns of certain entities should be updated from some legacy system.
Those columns don't necessarily get different values, if the requirements are met, they are assigned with the new values, regardless of the old ones.
Now we'v... |
How does one go about debugging concurrent protocols/concurrent algorithms in general?
I typically uses the built-in debugger from Intellij/Pycharm, but I find that it fails spectacularly when it comes to debugging concurrent apps.
What's the general recommended workflow for debugging and understanding how concurrent p... |
For a monolithic desktop application with two projects - a frontend and a backend, both in C#, what would be the best practice for communication between them?
The frontend needs to make calls to the back and get progress report back. If service references are added for both projects, a circular service reference will o... |
When making a decision to version an API. If you are making a change to an entity but are only making changes to the one of the HTTP Methods.
For example POST /api/v1/customers accepts a list of customers instead of only a single entity.
Should I grandfather the other endpoints to v2 or do separate the versions at the ... |
Edited Question based on the comments and great feedback (thanks)
I have a REST controller exposing two GET endpoints.
GetById - taking a single id (string)
GetById - taking multiple id's (a collection of type string)
The only thing the controller does is call the service/domain layer which also exposes the GetById m... |
I'm looking for advice on my specific problem, how to break up a class, Basket, that has too many responsibilities.
Currently, it does three things:
Keeps track of the products in the basket: addProduct(), removeProduct(), getProductQuantity()
Keeps track of the total price of the basket: getTotalBill()
Applies discou... |
I'm fetching data from Clockify, flattening the JSON response, and storing it in the database where each property on the API response should have its own table's field.
I have read this article about how can I achieve what I'm trying to do, however in my JSON response I have tagsIds which looks like an array, and I'm l... |
Reading a little bit about Functional core & imperative shell pattern, I am wondering if the DI principle can be improved.
What happen if instead of having an Infrastructure layer depending on concrete domain objects, e.g.: IUserRepository.Save(User obj), we create a Core layer just with abstractions like: IAggregateRo... |
Part of the Aggregate + Event Sourcing (A+ES) methodology feels
uncomfortable.
Why does it feel uncomfortable? (As I've read from other questions and the book itself, it's a new-ish way of thinking, and the literature may not be great.)
I think part of it is the separation between state ownership, and
state transition ... |
I see a lot of reasons to use binary over text-based formats.
With binary, I find it a lot easier. I can use fread(data, sizeof(struct DataStruct), 1, fileptr) to read, or fwrite to write data. I find that a lot easier than finding and using someone else's bloated library to parse and encode data in JSON or XML.
Since... |
I am getting started with software testing in Java and was wondering if test-driven dev and white-box testing could be combined directly... If not, what ways can we extend TDD to combine white box testing?
|
I'm using semantic-release to auto find out the next version based on the git commit. It's working fine with creating new version, upload to npm and create new git tag. And semantic-release is executed whenever code is merged to master.
However, in Node.js or front-end project, usually we have a file named package.json... |
Premise
A web application that has a frontend / backend separation. The frontend can be the JS framework of the month, which talks to a REST API in the backend.
The backend part of the system accepts commands, which are delegated via application services to a Rich Domain Model created by applying Domain Driven Design p... |
I have a React App (created via create-react-app) secured with OAUTH2. Currently all dynamic content is via REST APIs, secured with the same OAUTH2 token issued at login. It is hosted on AWS.
I want to implement a picture library and here are two React components that i'm considering:
https://www.npmjs.com/package/rea... |
While I am reading The Pragmatic Programmer e2, I came across Tip 38: Crash Early. Basically, the author, at least to my understanding, advises to avoid catching exceptions and let the program crash. He goes on saying:
One of the benefits of detecting problems as soon as you can is that
you can crash earlier, and cras... |
If my foo.py is merely foo_var = 1 and bar.py is merely import foo, I know I can write baz.py that says from bar import foo_var, but should I? (Or should I instead do from foo import foo_var?)
Is there any reason why chaining imports like this would be bad?
|
I saw a lot of examples of decoupling domain models from Identity models. For my knowledge, currently IIdentity is included in standard .NET library, so is this actual now and should I follow this approach?
Thanks in advance!
|
I've been using Graphviz a little and just found out about PlantUML which is quite similar.
I make diagrams but later the processes or systems depicted by the diagrams might change so I need to make changes to the diagrams, hence it is important that code used to generate the diagrams is maintainable.
I was wondering i... |
I recently joined a team who are using github Pull Request feature as the single code review tool.
In previous teams, I was used to reviews done on a fully checked-out code base, done using IDE tools, code coverage and static code analysis tools, etc.
Compared to these reviews what I get today through github is abysmal... |
Today, we learnt about sign extension to solve the problem where adding positive number to another positive one gives a negative.
But my professor didn't mention at all when we should use it and how much extension should I do?
How may I know when to stop?
|
I don't want to spam you with a ton of code, but please have a quick look at this boiler-plate method:
In this scenario let's say I have a ProcessingText.py file (class) that I finished its unit testing, including the methods setTextToClean(text) and getCleanedText().
And I have another file, UI.py (a class also), that... |
I am wondering about this. This is a sort of follow-up to my last question here:
In the MVC pattern, what has the responsibility for creating the view?
because now I've run into the question of how to deal with multi-threading in this application. For readers who have not read that, the application is a desktop applica... |
In a bit of a quandary. I am using Cloud Run on GCP for backend services, and it will auto-scale based on HTTP load, potentially scaling down to 0 if there is no traffic for awhile.
I have a product with 3 backend restful services running on Cloud Run, and the backend services need to communicate with each other. They ... |
def create() -> socket.socket:
...
return sock
def create_(func: callable)-> None:
...
func(sock)
return
What are the names of those two interfaces between* a socket creator and code using that socket?
Perhaps touch on situations in which one is considerably more appropriate.
* - sockets are just ... |
I'm Java developer and I'm now learning Javascript creating a personal project.
I don't know how to handle different errors in Javascript in a clean way and I can't find a good solution on the web.
I'm consuming some external APIs using axios. The external resource use a pagination system, so when I get back a 204 stat... |
Let's assume I use Kafka as an event store and put there all the lifecycle events of an order. Now I need to get the current state of this order in my system in during some business process. What's the best way to get the state of this order? Some random ideas coming to my mind:
Before putting an event in the event st... |
Assuming that we have a project called: "WizardProject".
The WizardProject, which currently stands at version 1.x.x, has a mostly Java based stack and active development has been discontinued on it.
Now, we want to bring the WizardProject back to life. Everything is new, but the same idea behind it, as well as the same... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.