instruction stringlengths 34 36.1k |
|---|
Situation:
A Client is requesting a resource from a Host multiple times, usually with minutes or hours between requests.
The Client has a signed, verifiable token, which we'll call a Receipt, that asserts that they should be allowed to access the resource. (The Receipt will eventually expire, say at the end of the m... |
I'm a long time Java developer, but with so little traffic on SE, I don't limit my viewing to any single tags. I've noticed that C# questions with async/await come up a lot, and as far as I've read it's the standard (but somewhat recent) asynchronous programming mechanism in C#, which would make it equivalent to Java's... |
I am working on a python project and I didn't use classes but created different modules and added functions in them.
Now I need to draw a diagram to describe the project/application for a paper. I already have a context level diagram and activity diagram. But now I need to describe the functional implementation of the... |
The CI flow for our Node.js app looks roughly like this:
Currently, this all takes place in a single TeamCity 'job' with three 'steps' (the Test step runs 4 concurrent child processes).
Problems with the current approach:
The whole job takes too long – 15 minutes. (The Test subprocesses run in parallel, but this o... |
Backstory (You can skip)
Awhile back I was developing a console toolkit for displaying debug messages and the like:
It gives me colour coding, blinking, underlines, bold, italic, etc.
While developing this library, I quickly learned that nesting with ANSI escape sequences was impossible, but assumed that good reasons ... |
My Java application uses Hibernate and H2.
It process music files within folders. Typically for a folder it would read the files in the folder and store each file as a Song class in database, then later on it would add additional data to those Song objects.
The application is multi-threaded so therefore multiple folder... |
Background:
we have 2 bounded context: Inventory and Sale
application context is Point-of-sale system
Scenario:
When a Checkout happen on Sale BC, we would like to decrease quantity in Inventory.
Problem:
We have 2 handlers in this problem that is interested in Checkout or PurchaseCreated event:
The handler from Inv... |
I have a SPA which at the beginning of application startup calls the backend API, sends a JWT and asks for the access permissions of the current user. SPA then caches the permissions in-memory and uses them to check what the user is permitted to do and clears the cache when user takes an action after which the cache mi... |
Consider the case where I have the following classes,
class A:
def __init__(self):
print("Class A")
class B(A):
def __init__(self):
print("Class B")
b = B()
The expected output with constructor inheritance is
Class A
Class B
However, the actual output is
Class B
Is this by design in python... |
I have a play application and want to take a common operation out from the application and make it as a library in order to use in other play applications.
This proposing library has a contract(interface) and several implementations of top of that.
I have 2 questions;
What if I use guice to bind contact and implementa... |
I have been having this dilemma from time to time whenever I have to design or start a new project from scratch.
I particularly like how Spring framework is organised in terms of classic software patterns like services, repositories, etc. By reading and going through community projects written in Spring and for example... |
I'm wondering what is a clean solution for representing an entity in many different format.
Let's suppose I have the following entity:
Person {
Long id;
String title;
String firstName;
String lastName;
Date birthDate;
List contacts;
Address address;
...
Date joinDate;
Date lastLo... |
I have a script that accesses my webcam and displays the captured video on the screen. I can also very easily draw a circle (a rectangle, it doesn't matter) over the video.
When I move the camera physically, the video also "moves". My webcam is attached to the top left corner of my monitor. So when I slide the camera a... |
Is a REST method which returns dynamically generated random data each time that it is accessed considered safe?
According to RFC 2616 (emphasis mine):
...
In particular, the convention has been established that the GET and HEAD methods SHOULD NOT have the significance of taking an action other than retrieval. These m... |
I'm taking over an Opencart solution for a client. This is for my capstone at College. I'm to create a simple CRM (Customer Relationship Management) software that will live as a single page application in the site.
Opencart is a free, open-source e-commerce platform based on the LAMP stack.
Currently, the client's site... |
And what is the recommended file structure?
The question is a bit similar to this one, but I'm looking for more explicit recommendations.
In theory I think it's a good concept to keep files short so you don't see other noise of nested classes where you're not interested in the implementation details at that point in t... |
I'm just learning DDD and a question raised in my mind about unique identifiers in an entity.
Consider this simple method that checks the uniqueness of an entity to prevent duplication:
private bool IsDuplicate(BoardGame boardGame)
{
//It's either this
if (Games.Any(x => x.Id == boardGame.Id)) r... |
I am creating a web application that is tiered in the following way:
Controller > Service > Repository
I have a ProductsController which has the following action:
[ValidateModel]
[HttpPost]
public async Task<IActionResult> CreateProduct([FromBody] CreateProductRequest request)
{
var result = _productService.CreateP... |
At what point does dependency injection make sense?
When I first learned about Guice I was really excited. I have a Concurrency module, which is basically just a singleton controlling concurrency. I was looking for a better solution than using a singleton when I remembered DI. I'd never used it before and there's some ... |
I have to expose some sensitive data containing a PII column that has a 25 digit number. Rest of the columns aren't PII data. This is done such that the data can be safely shared to the larger audience without the original PII column's data. but if required I need to check the original value, hence a look up file is ne... |
Let's say I have some project on php. One of its functions should be to check whether the latest version of php is used on the server. For example, for security reasons. There are no problems to use phpversion() and version_compare().
But how can I programmatically get the latest stable version of php? Maybe there is s... |
I am creating the REST API using codeigniter. I downloaded this library and installed in my application. It works great! https://github.com/chriskacerguis/codeigniter-restserver
But I have an doubt. As per this library. I have 4 functoins
GET
POST
PUT
DELETE
I understand the functionality of each POST method but what... |
That seems like a stupid question, but I can't find a proper name for "code that tests another code". The most of literature names that kind of code just "tests" but it's way to general in my understanding (obviously I am not an English native speaker so I might be wrong) - code might be tested by people, some external... |
Is it good practice to malloc in the caller function, and then free in the callee function?
Example:
int main() {
int *ptr = malloc(100);
foo(ptr);
return 0;
}
void foo(int *ptr) {
free(ptr);
}
|
Problem
BaseType has a field String jsonData that represents a JSON string.
The structure of the JSON string differs according to a field String dataType.
SubTypeA, SubTypeB, SubTypeC all extends BaseType, each having additional methods that parses super.getJsonData() appropriately.
A pseudo code of the intended usage ... |
Specifically worried that someone might be able to extract the API key in a way I am unaware of and make calls to my own Cognitive Services subscription outside of the context of my program.
|
When creating a new feature branch should I baseline from master branch or dev branch and why? I'm used to creating a branch from master as the baseline, making my changes and merging it back into dev but recently at my new organization it was suggested that I create the branch with dev as reference.
I both cases my pr... |
I was thinking about software development and writing unit tests. I got following idea:
Let's assume we have pairs of developers. Each pair is responsible for a part of the code. One from the pair implements a feature (writing code) and the second writes a unit tests for it. Tests are written after code. In my idea the... |
I'm developing a Electron/React app which uses Webpack and Asar technologies. It's designed to be a host app providing a common platform for some plugins. These plugins are downloaded and plugged into the host app by users at runtime. Each "plugin" may have code to run in the main process (i.e. full Node.js access) and... |
I'm new to software engineering and right now I'm focused on learning the best practices to consistently write robust code.
Recently I've been maintaining an application built by other people and/or my colleagues before my arrival at the company.
While writing my code, I make sure of what I'm dealing with and read the ... |
I have a C++ class that spawns a thread that contains an event loop of sorts and the class provides an API to query the list of events that have occurred since the last call, i.e something like std::vector<std::string> getEvents();.
In case some sort of fatal error occurs in the event loop, I shut it down and log an e... |
I'm working on a Django web application (with a mySQL back-end) that uses non-maintained tables(tables not modified by the web app). However, I have two copies of the data tables (one for production and one for development).
A problem occurs when I need to manually modify the non-maintained data in the development ver... |
I am writing a C library with routines I want to call from an external driver program using many OpenMP threads. The library will have a main container called lib_workspace, which will be used to do intermediate computations. Just wondering which of these is the better option:
Option 1:
In this case, I define multiple ... |
I'm building a console app (A), which depends on library B. Library B further depends on library C. I am building all 3 entities. Most of the development completed so far has been done using a functional design and so far this is working well, and is currently stateless, and no instantiations have been needed so far. I... |
I have a little app(PHP) that uses data from a third party. That data is processed constantly and saved into a database. And now i want to create a RESTful API to allow access to that data.
Should i keep my app on the same droplet as the API or should i separate them?
The API will mainly be called by a Python app(also ... |
Most of the express error handling documentation and tutorials I've read suggest using Express middleware to throw errors up to, and to handle the errors there.
eg. From the Express documentation:
app.get('/', function (req, res, next) {
fs.readFile('/file-does-not-exist', function (err, data) {
if (err) {
... |
We have a very small team: me, my 2 coworkers who are both my senior by over a decade, a web designer who usually works on marketing material but also does some graphical mock-ups or minor graphical fixes for our front end, and the manager/boss. The daily Scrum stand-up is me and my 2 coworkers. Due to the small scale ... |
I want to make GUI applications such that the non-GUI code is independent from the GUI one (let's say I'll use Java 8 and Swing for example). The goal is that I could hypothetically change the GUI API/library, or the kind of UI, for example shifting from a GUI to a console output, without modifying the non-GUI code (a... |
I have a class of (flat) objects that are going to be passed around between three different parties, each possibly running a different software stack.
my_object:
item: "string_a"
money:
amount: 99.9
currency: "EUR"
metadata: 5
origin: "https://www.example.com/path"
These objects will need to be signed... |
I am reading more about the differences between syntax and semantics, but I am still wondering about this one.
Let's assume that we have a language that only allows integers to be in the range of 0-255, so 8-bits, and the parser receives 256 or 257.
Should that be an error of syntax or semantics?
Resources I've checke... |
I'm building a web application, in which users have their own set of Topics. Since Topics are recorded for reporting purposes, it's important that Topics used previously are not deleted, so that they can be referenced by future reports.
In my relational database, Topics are associated to users through a user_id. My ide... |
I understand what oauth2 is and I've programmed it in one of our projects. The point was to pull user's data from an oauth2 provider (facebook, google, etc.) to our application (for example, the user's 10 most recent emails). It was very handy for that purpose.
Now I'm trying to think about why a web designer would wan... |
I'm building a shop system which works in three parts: a mobile app (Android/iOS) which is used by customers to make orders, view products and so on, a desktop application, used by the managers to manage orders and shop things and a web server with an API to which both mobile and desktop applications communicate.
The s... |
I working on a project requiring quite a lot handlers to handle requests.
In general, i'm comunicating with a communication card, receiving requests from any source (User Interface, Server it doesn't really matter to me), i need to process the request and send the appropriate data to the card.
The current hierarchy ... |
MongoDB recently announced their new field-level-encryption method for helping tackle DB breaches. (https://www.wired.com/story/field-level-encryption-databases-mongobd/)
In other articles it is covered in some more technical detail (https://www.csoonline.com/article/3403676/new-mongodb-field-level-encryption-can-help-... |
I'm trying to get my head around Python exceptions. I've read quite a bit on the topic but can't get clear answers to some questions. In particular, I'm still not sure whether to use exceptions or guard clauses for dealing with invalid arguments.
I know that this topic is, in general, a big debate with no clear answer... |
As I am maintaining and extend a software system in Java, I saw a colleague (who left due to retirement) implementing a table with a generic approach. This approach is unluckily bound to tables (ui-elements) with a key-value appearance.
For example:
Description | Value |
--------------|-------|
1 | 1 ... |
I have a few questions regarding the versioning in the microservices architecture:
Let's say there are three services - S1, S2, S3
S1 calls S2 and S3 to generate a response R1.
Service S2 generates response R2 and service S3 generates response R3.
Supported versions:
S1 - 1.0.0, 1.0.1
S2 - 1.0.0, 1.0.1
S3 - 1.0.0
In th... |
Forward
I've read a lot of things before asking this question, including many relevant
questions right here on SE:
(Software Engineering SE) Writing tests for code whose purpose I don't understand
(Software Engineering SE) Unit testing newbie team needs to unit test
(Software Engineering SE) Best practices for retrof... |
We use a Kanban process with the following steps:
(backlog)
specification
implementation
review
(completed)
The specification, implementation and review steps are divided in in progress and done phases.
The implementation step is done when the implementer thinks that the code matches our quality standards. The review... |
Say there are two microservices (example is simplified)
PickupRequestService: lists pick-up requests of passengers
DriverService: drivers use to accept pickup requests
On a completely decoupled communication method (via message queues), DriverService would make an async call to accept a pick-up request e.g., PickupRequ... |
In Big Bang Integration Testing, we combine all the modules we have together after unit testing immediately as one whole to see if there are errors.
In System Testing, we basically test the whole system. Whether the modules in the system are tested by integrating several at once or all at once is not important. The mai... |
In JavaScript (ES6), I can have optional function parameter with default value. So to add a new behavior to the existing code base, I could either introduce new method(s) or extend the existing method with an optional parameter.
Consider the following example:
Existing method:
doSomething(param) {
// code to do som... |
I often find myself creating classes that I suffix with 'Factory'. These classes tend to be solely in charge of the creation of a specific class or set of related classes. However I've always felt that this probably isn't best practice and that there's a better way of approaching this. One of the reasons that I believe... |
I'd like to build a rest service that will accept objects that has digital signature. This service has to support both xml and json data serialization formats. I'd like to use .Net core framework to build this service.
Controller has to check that digital signature is valid and dto properties were not modified.
This si... |
I am looking for some advice on the best way to manage my development worflow. I have been using git locally to track development and have recently uploaded a couple of private projects into Github.
One project is a Wordpress theme. Before using Github I would commit my changes and then use git archive to output my del... |
Let's assume the following architecture where
EventCreatorApp creates an Event which is logged to DB and sent to WorkerApp for processing
WorkerApp processes the event, handles failures, etc.
EventCreatorApp --> [ DB ]
|
---------> WorkerApp
Once WorkerApp is done, I want to update the event row in... |
Imagine a page with an autocomplete textbox on it, to get Customer.
I am wondering what sort of limit for record size makes sense in this day and age regarding whether all the customers should be pulled down on page load, vs. using ajax to dynamically query them as the user types.
For example, if it were every customer... |
I have a tree of Installations: Aggregate Installation has a property ParentInstallationId.
I also have a RemoveInstallationCommand --> repo.GetInstallation(x).Remove()
Now, I want to throw a domain error if I receive a RemoveInstallationCommand for an Installation that has children. But, the Installation aggregate do... |
What is the stand on initiating the class from its own static method? Are there any good practices about this?
I feel need of initiating a class from its static method while implementing a job scheduler as a backend of a GUI application. I can always make a util method instead of static method but realized i do not ha... |
I have been developing with Orleans actor implementation. Recently, I saw that we were scheduling a long running job on an actor, which was effectively blocking the actor since it couldn't process the next messages in its mailbox. Fortunately, Orleans provides a solution where a long running task can be scheduled on an... |
I am not sure how to explain my problem, but basically I have an input field which lets you enter member's name or select one from a dropdown list.
If the user has selected the person from the list then I would like to store in database the ID which would correspond to memberId from my table members. However, if the... |
Let's say your organization uses a blue-green deployment model. Simple question:
After Blue has gone live, do you rename it to Green, and the server(s) formerly known as Green now becomes Blue?
Or to put it another way:
Are "Blue" and "Green" the names of the physical environments? Or are they logical names, i.e. s... |
I just had a more than 2-week long vacation/business trip and I couldn't remember actually what was I working in my coding and where I stopped. Could someone recommend a best practice to solve this?
|
"What are some problems that can arise from using a HashMap with timestamp as keys"?
I, for one, do not see any major issues with this kind of "setup".
Is this "setup" a no-go/an anti-pattern/something that should not be done?
What are the things to look out for?
What problems does this setup have?
PS : it was in int... |
I have a few software architecture/design questions related to a technically quite simple problem. We already have all the functionality implemented properly, however from a design perspective it is super messy and unclear, which is why I'd like to refactor it using a nice structure - which is what this question is abo... |
The applications that I work with deal with Group level insurance. The insurance is mostly Life and Long Term Disability. We have a monolith library that all of our applications use at this time. We are thinking of moving more of our application to services and I'm trying to get some information on DDD practices to seg... |
For context, I am building an application with a server that is written in python, hosted on AWS, and uses DynamoDB for a database.
My question pertains to the following operation: When a user purchases an item, I want to update the count of soldItems in my database. To do this, I essentially do
updateItemsSold() {
s... |
Which one is better?
A
if ( complexDataCheck(...) ) {
doJob(...)
}
vs
B
doJob()
func doJob(...) {
if not(complextDataCheck(...)) return error;
...
}
In A, the function does one and only one thing which is good, but OTOH it may be called with invalid input.
In B, the function does multiple things (assuming t... |
BPMN is very popular notation for process modeling and it's theory is based on task sequences and work flows between actors. So it's seems that it's necessary condition to declare at least two lane (Actor) for model. But sometimes i find independent processes that only one actor has been engaged. Is it valid to draw su... |
Trying to implement the outbox pattern for an event driven system. The outbox pattern in a nutshell is a way to ensure system events are sent to the event log/queue/bus at least once (using the term event bus loosely here):
a separate process that periodically checks the contents of the Outbox and processes the messag... |
We are implementing an API and we want to follow best practices for naming the endpoints. However, during the design, we have found a challenge. We have some objects where the key to the objects is a combination of three keys: key1, key2, key3.
We have been following for other objects (e.g. orders) the pattern:
api/o... |
I was thinking that I could calmly Thread.sleep() on an interrupted thread. Sonar doesn't think so, of course.
In some circumstates we should waiting for conditions, even if an interrupt occured. Is there anything wrong, for example, with the code below? Is there any better solution?
private void waitFinish() {
boo... |
I believe that most of us have encountered this situation. What is the best approach when higher management or client is forcing the PO to include some new functionality in the middle of the sprint, something that is not planned and team did on commit on that?
|
I am trying to figure out a design pattern to use (if any exists) to a situation where I would be re-doing some functionality across a bunch of classes. Below is a (simplified) overview of the problem I am facing:
I have some Java code to CREATE, UPDATE, DELETE Student objects, Professor object, & Staff objects. And ev... |
For the last two months I've been working as a scrum master. I need your help on how to make the daily standup better for all the team members and how to encourage the team to embrace it?
This is the problem:
we follow scrum guidelines and limit the daily to 15 minutes, but sometimes we have these issues:
Some memb... |
I do not understand the macro concept well. What is a macro? I do not understand how is it different from function? Both function and macro contain a block of code. So how does macro and function differ?
|
In an event-driven microservices architecture, services typically need to update their domain state and publish an integration event to a service bus at the same time (Either both operations complete, or none).
Simple example:
The ordering microservice receives a REST API call to create an order. The microservice ne... |
I have a use case to make updates to a slightly complex JSON object and then return the list of changes made (not the updated data). The process of finding the list of changes is extremely similar to the process of making the changes and it would bring in some redundancy if I chose to separate the two methods. So I'm w... |
According to this article: Using Ids in Domain Models is not a good practice.
We should reference the entire domain model instead.
In this case, when we want to provide only Getters for our properties, we have no choice but to use the constructor parameters to pass all the data.
example :
class Car {
public Car(st... |
Sometimes, on an IT helpdesk, you have tickets with a few shared characteristics.
They're low priority--just minor annoyances to user
They're extremely hard to reproduce for testing
You've exhausted all troubleshooting possibilities you have at your disposal
You've spent hours on the ticket
This is fortunately a smal... |
I want to use a physics engine (like bullet or PhysX) in my program, however I want to hide the actual physics engine from it, so I can easily swap it out with another during run-time (e.g. switch between bullet and PhysX without requiring any changes to my main program).
To do so, I have created some abstract classes,... |
We are working on a transformation project
It has records in table entityA and entityB, which has a relation entityAB.
We need to delete records in table entityA and recreate them with some other parameters, lets say new records are rowA'. Now based on user input of matching between rowA and rowA', we need to update re... |
I work with a small team of software engineers. Each one of us handle different projects without much interaction. We all report to the same supervisor who more or less understands the requirement of all the projects each one of us are working on. He used to be the only person that would review our code.
Seeing that... |
I need to implement some system (using python pandas dataframe in my case) that parses raw data, then adds on calculated data, and then validates that calculated data (boolean output on some columns)
I couldn't make this problem simpler than what is below, so please bear with me.
Assumption: this is and always will be ... |
I have multiple projects in different programming languages that I will upload on online code hosting platforms as Open Source projects.
What file permissions and ownerships should I set on the files before uploading them? I work on Linux-platforms. It feels wrong uploading files with permission MYNAME:MYNAME as owner ... |
I need to validate a value with data from an external API.
The easiest way would be to add a validation rule in my model, call the external API and do my check.
But it feels very dirty to call an API within my model.
(Also a lot of specs would fail due to missing api call mock).
What other options do I have within the ... |
I’m building a web app using Rails API on server side. The goal is to make a planning manager. I want my users to be able to plan ‘daily’ events, which will display at some specific weekdays, with some specific member in charge.
Here’s a quick example about what data should look like :
event_name
- Monday with UserC
- ... |
We've stumbled at an inconvenient design in a game and wondering, whether there is nothing simpler. The background needs some explaining so I'm sorry for the wall of text.
The setting
We have a player class. The player knows how to walk around in the world. At certain occasions, we want to disable the player from being... |
I was writing some code and came across a scenario that I was thinking about doing a circular dependent class, which I have not done before. I then looked circular dependencies up and whether they are impermissible, and found that it is achievable but not desirable. But I have some dilemma regarding how to implement it... |
Background
I have a relational database an I want to have a table that contains flags. I want multiple tables in my database to have a many to many relationship with the flag table.
Options
I could go about this two ways (I think):
I could create a join table between the flag table and each table I want it to have a ... |
for (int i = lstReportCount - 1; i >= 0; i--){
if ( (input.ServiceTypes == "1" && lstReport[i].A == 0)
|| (input.ServiceTypes == "2" && lstReport[i].B == 0)
|| (input.ServiceTypes == "3" && lstReport[i].C == 0)
|| (input.ServiceTypes == "4" && lstReport[i].D == 0)
|| (input.ServiceTypes == "1,2" && ls... |
Two things you can do in Java:
Send a gzipped JSON body in response to an HTTP request
Send a StreamingOutput response to an HTTP request, where you begin sending a response before you know the entirety of the response (e.g. if reading entries from a database)
According to my testing, you can do both at the same time... |
the reader is expected to be an advanced Linux developer, having read ALP and having developed advanced GUI applications on Linux using GTK or Qt; notice that sadly I am not a native English speaker (but French).
I have difficulties in understanding the conceptual model of the copy/paste clipboard in recent HTML5 brows... |
I've been working on an open source project recently and have been checking out Core Infrastructure's best practices checklist.
One of the items pertaining the "Change Control" checklist is as follows:
To enable collaborative review, the project's source repository MUST include interim versions for review between rel... |
I have a design dilemma in deciding the response status code and architecture for a middleware we are designing.
So the Client Calls MiddleWare, And middleware calls the 3rd party service to get car-values for a particular car-reg.
If everything goes right and we get car-value, we are sending the status code as 200.
Bu... |
I have the following simple activity diagram:
My problem / question about is the last activity and its incoming object flows:
how to model proper UML here?
In UML-Spec 2.5.1 I find these quotes:
[15.2.3.1 Activities]
An object token is a container for a value that flows over ObjectFlow edges [...]. An object token ... |
I am writing an API (web-service) for my customers and there is an endpoint which allows to search for the documents in my storage (files, folders) by applyingg complex filters.
Initially, client need to send the following model to my API:
public class GetFactDocumentsTableWithFilterCommand :
IRequest<GetFactDocum... |
Let's assume I wrote an extension method in C# for byte arrays which encodes them into hex strings, as follows:
public static class Extensions
{
public static string ToHex(this byte[] binary)
{
const string chars = "0123456789abcdef";
var resultBuilder = new StringBuilder();
foreach(var... |
I am building a WebApp which has a list of Assets. I have a peculiar requirement and I am unsure of the best way to store the data in SQL.
Requirement:
My Asset Headers currently have a relation to a branch, and that branch to a multiple entities (see diagram).
However I need to be able to work out from a given date ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.