instruction stringlengths 34 36.1k |
|---|
So, let's say I have a standard set up for application, that is:
- split into micro services
- and is running in a cluster (kubernetes or docker swarm, I guess specific implementation does not matter, just the main idea),
- there's a API gateway, that faces internet and authenticates all the incoming external requests.... |
I am trying to design the DB schema of my new project and I need some suggestions. I am thinking to have one extra column for some tables which is a UUID. I wanted mainly for tables which contain data which are accessible through REST, so I don't want to expose the primary key.
My concern is that when I want to update... |
I am trying to design the DB schema of my new project and I need some suggestions. I decided to create a lookup table in order to save the enumeration values. So I have a table Status with these columns
idstatus, statusName, statusCode.
My question is, do you think that is a good practice to follow this way?
Imagine ... |
I've been trying to figure out what this certain UML symbol means.
It is only used in design diagrams (as far as I know).
I've got UML distilled (3rd edition), but that too doesn't explain what this is.
Searching around the web gave me some meager results as well.
Does anyone know what this particular associatio... |
I need to collect user data every few seconds where each user is unique. I've done some research and concluded that I should consider my data as time series data because I'm looking at how user behaviour changes over time. I want to use DynamoDB and in its
best practices for time series doc, it describes creating a new... |
I have several but independent computer vision pipelines which were original planned to run by a user via a cmd (task1 -> script_1.py, task2 -> script_2.py and so on).
All pipelines share some code (e.g. resize an image) but otherwise the entire procedure inside the pipeline is different, for instance some problems are... |
Here's one example: My web application contains draggable elements. When dragging an element, the browser produces a "ghost image". I want to remove the "ghost image" when dragging and I write a test for this behaviour.
My problem is that I initially have no idea how to fix this bug and the only way I can write a test... |
You can create a data structure such as a Parsing Expression Grammar (PEG) that will be used to parse:
string -> object
You can then write a function that iterates through the object's properties and serializes back into a string, or will stringify it:
object -> string
I haven't seen any data structures for defining ... |
I’ve been interacting with a very early stage startup founder (no funding, just a simple site w/some visitors) and have offered to build out a microservice that helps automate some currently-manual tasks as a sort of proof of usefulness and general competence.
This is completed and working as promised (I control the d... |
I have developed a program to read through text in files and capture information, and write it into a CSV.
Each "field" is identified by an index, a label, and a value, like so:
.0 index
.0.label unicode "Area"
.0.value unicode "6WAY DB"
.1 index
.1.label unicode "SubStation"
.1.value unicode "E782DB257"
.... |
It is my impression that in software engineering, a connection can mean many things depending on context and the level of abstraction at which some system is considered. I'm surprised no one has asked this before, as I feel that a connection is such a fundamental concept, but also very easy to misunderstand. I want to... |
I have a piece of code that can be represented as:
public class ItemService {
public void DeleteItems(IEnumerable<Item> items)
{
// Save us from possible NullReferenceException below.
if(items == null)
return;
foreach(var item in items)
{
// For the purp... |
Eg: Assume a task has been estimated to take 8 hours working time, for 1 person to complete. Supposing that person takes a break of 15 mins every 2 hours. Obviously the task will take 1 hour extra and, assuming an 8-hour working day, will now be completed only the next day.
Therefore,
1. Should breaks also be entered i... |
In the following scenario:
A factory returns an object of a logic class:
ILogicClass object = factory.GetByRequirements(reqs);
I then want to invoke a method and get some results which are in the same shape for all concrete logic classes:
output = object.GetResults(...)
and then use the result.
Imagine the concrete i... |
This is a simplified version of a problem I'm facing in my current project.
Let's say we want to display shapes: rectangles, circles, etc. I'll have a Shape class which is subclassed by Rectangle, Circle and so on. I'll then have a World class which represents a 2d plane containing shapes at various coordinates. I'll a... |
What naming convention should use when I have a method with an out parameter. I want to do this using clean code principles. So is it a good practice to include the name of the out parameter in the method name?
I want to write a couple of methods like this in which I use one of them in another method. And I want to be... |
I faced the problem bellow when I designed our new app.
We are thinking to have one extra column for some tables which is a UUID for security purposes.
So, there are two different solutions.
First is to have an extra column (UUID) on top of primary key which is a serial. In that case you need some more calls just to... |
Languages with coercions (i.e. implicit type conversions) allows expressing things like that (irrespective of any syntax):
f : int32 → int32 = λx.x+x
a : int16 = 42
b : int64 = f(a)
Where type conversions are not explicitly indicated in the code. Type checking relies on: int16 <: int32 <: int64. Is there a programming... |
Most examples of auto use the = operator.
#include <iostream>
int main()
{
auto a = 1;
std::cout << a << '\n';
}
Why don't they use the uniform initializer like this?
#include <iostream>
int main()
{
auto a {1};
std::cout << a << '\n';
}
Is there any advantage or disadvantage of using one syntax ove... |
I'm working on a web application with constantly changing requirements. The relationships between entities in the database have mostly remained the same but the attributes of each entity type changes a lot.
I'm using Java, JPA, and Postgres. Postgres has a JSON type. Is it a good design to remove all non-key and foreig... |
lets say I have several objects Object A,Object B,Object C in different parts of my project. I have defined a Object X that is only used to store some specific values from the objects mentioned above plus some other context data, only getters and setters functions, and pass it on to another layer or service. What would... |
Knowing that BDD somehow avoids using the term "test", I am trying to understand the process as described in a book called The Journey to Enterprise Agility: Systems Thinking and Organizational Legacy.
They describe the BDD process like that:
Select a scenario from a feature
Write a failing scenario step
Write a faili... |
I am an Electrical Engineer now training and working as an embedded software developer, so I have little formal computer science and software design training. I have until a few months ago only worked in C and functional programming, but started recently working with C++ and OOP for Embedded Linux with a team whose dev... |
In university, at our algorithms courses, we learn how to precisely compute the complexity of various simple algorithms that are used in practice, such as hash tables or quick sort.
But now in a big software project, when we want to make it faster, all we do is look at individual pieces -a a few nested loops there that... |
I'm hesitating between algorithm and implementation as most of the questions here on how to prevent coupling between implementation and tests are about using spies/stubs or mocks.
The typical problem is that the tests are merely mirroring the SUT because tests are focusing validating behaviour instead of state.
The cou... |
I have a Product entity with a Category value object (contrived example).
There's an API endpoint /products?category=Keyboards,Mice
The classes at play here are the:
ListProductsController (interfaces layer)
ProductsRetriever (application layer)
ProductRepository (domain / infrastructure layer)
Product (entity / aggre... |
In our organization, we have several databases. Each of them has lots of schemas with tons of packages, procedure, functions and so on. Now, I wonder what approach is best in terms of organizing those objects in a git repository. Should I have repositories based on schemas or application they're used by? There are lots... |
I have a class that contains an object (set in this case). The set is modified by the standard function operators __add__ and __sub__, but I also want to explicitly expose a method of getting this set.
Should the @property decorator be used instead of a simple get() method, even if there is no intent to allow setting ... |
[Node.js / CommonJS]
I'm creating a single GitHub repo for my tool which has a Core, Control, Server, and Client library. It's unlikely that all of them will be used at the same time.
I'd like my fellow coworkers to require one entry point for all four libraries. So I made this questionable implementation: exporting th... |
I'm developing an application with Python. I want to have a Boolean variable that represent whether something is buy or sell but I'm not sure how I should name it. Here are my current ideas:
isBuy
isSell
buy_sell
sell_buy
buy1_sell0
actually I like the last one the most although it's somehow the ugliest because it te... |
In Typescript/Angular 6 (2+), is it considered a good practice to have a base abstract http service from which derives all the application services? for example:
//import the angular Http ...etc
export abstract class MyBaseService{
...
protected get<T>(url: string): Observable<T> {
return this.http.get(...)
... |
What is preferred and why?
void PrepMyInstantiatedObject(SomeComplexDTO someComplexDto){
someComplexDto.Name = SomeOtherClassHelper.DerivedName(someComplexDto.Name);
someComplexDto.Ids = SomeOtherClassHelper.Resolve(someComplexDto.RelatedIds);
someComplexDto.SingleId = SomeOtherClassHelper.FindId(som... |
Have read about "Repository pattern", before it, I have used pattern DAO (data-acess-object).
How should I implement table relations with this pattern? Should I create entity for links between tables?
Thank you!
|
Given the need to log only in debug mode the easiest way would be to use if conditions:
def test(x, debug=False):
if debug:
print(x)
# ...Some more code
if debug:
print("Something else")
# ...More conditional logging
return x * 2
This leads to the cluttering of the actual functi... |
This morning I had a presentation on PHPSPec which the official website describes as follows:
A php toolset to drive emergent design by specification.
As defined within an adjective context the word "emergent" is defined as follow:
the process of coming into being
On the other hand PHPUnit is said to focus on quick... |
I had been learning python and i know Java. if i were to write a simple program, can i write both programming language in one document or compiler?
I got into this problem because if i cannot merge both the programming language , what is the meaning there to learn them.
Another reason for this is that; I found some co... |
Do logging impact application performance?
First thing to know is , whether logs are written serially as processing takes place or are logged into file i a separate process?
In java world how should I improve performance of my application where I need to log a lot in that case?
Micro optimization is a side effect but... |
When testing RESTful JSON APIs with ATDD/BDD practices in mind is it good practice to test the structure of the response?
I'm thinking that it could too easily change, thus making for a brittle test. If this is true, then how should one approach testing REST API endpoints? Perhaps only test the status codes?
|
As always I came here to ask for some light in a design issue I am facing.
I have a system that issues some notifications :
PackageReceivedNotification
PackageSentNotification
DisccountAvailableNotification
More in the future
I want to store the text of them in the DB in multiple languages (imagine english and spani... |
Currently, we've been working on the architecture team on defining the database models. What has been troubling me is my superior's advice when it comes to working with audit fields.
He advocates for the updated_at and updated_by fields to be Nullable, reasoning that these should be initialized as NULL because the data... |
Let's say that I have a group of report types to be created and all of them inherit from base abstract class:
abstract class Report
{
public abstract void GenerateReport(IReportData data);
protected virtual string SaveReportFile(string filepath)
{
// common code to save the report file
}
}
Generate... |
I need to build a data store for transactions that meets the following requirements:
A 'transaction' is effectively a state machine which moves through a number of statuses during its lifecycle and the incoming data messages represent changes to a transaction's state (eg, transaction moves from 'Created' to 'Open' to ... |
I've seen trace tables listed under white-box testing in one part of my syllabus, and separately under dry-run testing in another part. Could anyone please clarify whether trace tables are generally considered to be part of one or both types of testing?
I have researched this thoroughly and found nothing that addresses... |
I don't think I completely understand what a component diagram should show. Let's say I have a 3-tier web application for a homestay booking system, similar to airbnb. The 3 main components are clear: client, webapp/Back-End, and DB. But when it comes to drawing the component diagram, I don't know how to name the inter... |
I want to develop a Factory of INotifications.
public interface INotification
{
string Text { get; }
string UserId { get; }
NotificationType NotificationType { get; }
}
The problem is, that the NotificationFactory has to be ready for getting multiple types of inputs , why? because there are multiple implem... |
I frequently come across this problem when developing games and simulations. As an example, I'm currently writing an implementation of chess. I'm using it as a vehicle to experiment with entity-component systems and responsibility chains, inspired by Brian Bucklew's talk on Roguelike architecture (https://www.youtube.c... |
According to Domain Driven Design and Development In Practice:
Spring Security (a sub-project in Spring Portfolio) provides a
fine-grained access control in both presentation (URL based) and
domain (Method Level) layers of the application. The framework uses
Spring's Bean Proxy to intercept method invocation and... |
I have read many articles explaining the overview of black- and white-box testing, including this Stack Overflow question: https://stackoverflow.com/questions/7258524/unit-testing-black-box-testing-and-white-box-testing
However I still have some confusion around black-box and white-box testing at a basic level.
In term... |
"Solicited output" means a user issues a command to a GUI and the GUI displays the corresponding output.
In this context, I include Web apps in the term "GUI".
However, often a GUI needs to display unsolicited output.
For example, the SE/SO websites often display an icon indicating the number of new email messages and ... |
Some user actions quite naturally lead to find-or-create situations. For example, user logs into a system by alternative method and find-or-create is called give email. Or, another example, User is created given Buyer's email. But of course, if there already is a user, that action causes find-or-create. Some databases ... |
Suppose I have a private project with 100 commits. I don't add a software license until the 101st commit. If I make the project open source, does that mean all first 100 commits are unbound by the software license in the 101st commit?
Should the project be rebased when a license is added?
|
While going through Decorator Pattern from Wikipedia 1 and reading pattern from Head First Book . One thing that struck me and is missing from both the sources or i may have missed it.
Why exactly do we need a Decorator Interface ?
Is it because we need to put all the Concrete Decorators under categorical umbrella.... |
I've got a project that is sort of a virtual operating system.
In this project, the Kernel class is responsible for creating Process classes. The process class consists of Thread classes and the Thread class will consist of a CPU class. The CPU class is actually a CPU emulator and the Thread is therefore an "emulated" ... |
I am currently working a data science team, and we write small utilities all the time to consolidate data, extract data, etc (an example is go through a folder of excel workbooks, convert all the sheets into csv files, and consolidate those sheets that have the same column headers, adding columns for the source locatio... |
If you run the statement:
System .out.println( (Integer.MIN_VALUE)-(Integer .MAX_VALUE ));
In java it returns 1 as the answer. Is this because Java just considers those values as 32bit integers without considering their sign?
Integer.MIN_VALUE = 10000000000000000000000000000000
Integer.MAX_VALUE = 111111111111111... |
My use case is that I have a real-time broadcast app where users get feed items based on a geolocation, i.e. a user will receive posts that were broadcasted from within a user-defined radius where (s)he currently resides.
As a backend implementation I want to use cqrs. The procedure is as follows:
Broadcasters uplo... |
Following SOLID first principle, the Class should be responsible for only a single part of the functionality provided by the software.
The same, I guess, goes with the Methods design principle. They should handle only a single "thing".
Let me give an example:
Suppose I have some program in which, at the end of some met... |
I want to share with you and know what your opinion/improvements are regarding a solution I was tasked with a technical interview I faced.
The exercise:
You need to create an API which will indicate based on a DNA if a person is male or female. This API must have two endpoints:
POST /genre:
It will receive a ... |
I'm looking for a way to quantify where my team should spend it's time addressing technical debt in our codebase. One idea for this is to measure file churn (edits over time). I got the idea from this video where Michael Feathers talks about escaping the technical debt cycle:
https://youtu.be/7hL6g1aTGvo?t=16m53s
What ... |
I manage co-curricular programs for the school I work at. Until now, they have signed up on a google form on a first-in best-dressed capacity, but there is lots of complaints about how some students get all of their preferences, while some get none.
As there is 1000+ students at this school and over 50 activities, it w... |
I have been reading a bit about code readibility and found conflicting information about the following: some say that flexibility (and-or extensibility) actually increase readability, while some others claim it decreases. Is there any generally accepted opinion about that?
|
We have Customer transaction table with many foreign key relationships.
We only want to see certain columns of the 3 tables joined in a web interface.
Eg just Date, PurchaseAmount, ProductName, and StatusDescription.
I hear repository should not select certain columns, it should select All columns. So we should not ... |
I have been tasked to increase code coverage of an existing Java project.
I noticed that the code coverage tool (EclEmma) has highlighted some methods that are never called from anywhere.
My initial reaction is not to write unit tests for these methods, but to highlight them to my line manager/team and ask why these fu... |
In doctrine (or any ORM in general), the easiest way to execute a delete/update operation is to select such entity, then remove entity or update single attribute in the code, ended by persist the changes to database.
This is the native way to execute delete/update operation in most of the ORM frameworks. It is very han... |
We're building two microservices that use CQRS and Event Sourcing: an Order Service and an Inventory Service. When an order is made, the inventory of that item must be decreased by the amount ordered. An order can also be canceled. In that case, the inventory must be increased again.
So in the Order Service we store an... |
I've got a .NET Core application that takes HTTP requests. I'm a little bored, so I decided to stress-test it using West Wind Web Surge, and putting an example request as the body.
My question is, since the request is exactly the same every time, am I seeing artificially high performance because the application has alr... |
I have some B2B services already exposed to customers who manufacture products and ships to end consumer.
These B2B services are implemented using asp.net web API and is performant enough to handle millions request per day.
Now I need to expose services to end consumer for there product activation and hence it is B2C i... |
I am trying to understand UML abstract syntax seen in the UML Specifications. This example below is hard to understand. For example, I don't understand:
the {subsets ownedElement},
the hybrid composition-association,
the /relatedElement (heading slash),
Is there any tutorial or course that explain these points?
I ha... |
I am trying to model an external system in Java and running in to some issues.
I have a handful of related types that I have mapped together through abstract (and sometimes concrete if it made sense) classes.
In a few cases some of the SubClasses turned out to be only implementing a caller method that just picked an ... |
I was having a discussion with few friends about inheritance and composition and what I learnt from that discussion is that the use of inheritance more or less condemned in industry nowadays and either replaced with composition or copy and paste.
Doing a quick Google search confirms this with many articles with titles ... |
I'm new to eventsourced apps and since the beginning I'm facing an issue that I'm unsure how to resolve.
I work in ecommerce and I always try to convey meaningful events to my aggregates like PriceIncreasedEvent, ProductDeactivatedEvent, OutOfStockEvent etc
But many times I just want to do a simple "CRUD" style with my... |
Say I have a program using Java or C, that will interface with a hardware device and either read streaming data or write it to a database before applying a few complex mathematical equations to this data for analysis.
Where would the equations be applied (ie the data layer, application layer)? Is
this possible in SQL,... |
I am currently learning about compiler construction and language design and I am thinking about what native datatypes I want to support in my language. Now there is a whole lot of languages that make a distinction between integer- and real numbers. However, I remember watching a talk by Douglas Crockford in which he sa... |
We are a recently formed team of 4 developers, some of them new to the company, some of them assembled from other, disbanded teams. I would like to know my team members better, how they "tick", how they want to learn, problem-solve, cooperate, communicate, how we see each other, etc. I would like to do that through som... |
Dependency injection (DI) is a well known and fashionable pattern. Most of engineers know its advantages, like:
Making isolation in unit testing possible/easy
Explicitly defining dependencies of a class
Facilitating good design (single responsibility principle (SRP) for example)
Enabling switching implementations quic... |
I am beginning with unit testing in c#.
Here is my converter:
public object Convert(object value, Type targetType, object parameter, CultureInfo culture)
{
int c = 0;
if (value != null)
{
var path = value.ToString();
for (int x = 0; x < path.Length; x++)
{
if (c == 2) { ... |
I'm new to coding and I don't know how what I'm trying to do is called, and I want to find out so I can do more research and not re-invent the wheel. I looked for things such as data consolidation/combine input but the results are either too vague or if I add the name of a language I get irrelevant libraries (eg javasc... |
I am new with the user story map approach, I started with to compose the stories to be implemented from user perspective, and it seems very promising.
However, I am not sure about the non-functional stories, how to place them within the story map. Especially when are talking from user perspective, that is not aware of ... |
I'm finding it tough to test my client-side code without testing implementation details.
For example, lets say you are testing a login form that displays client-side validation errors and does not submit unless the email and password are present and correctly formatted.
You could write a test independent of classnames,... |
Scenario
We have an application which has a session timeout of 20 minutes. However we have a requirement in which users must be able to access a certain page in the site for 8 hours after the original(20 minute) session was created. The page in question needs to use the session ID of the original session to pull saved ... |
The PHP framework Laravel allows to make an API and a website on the same application. As both of them will communicate with the same database, I was asking myself what is better between consuming my own API for my website and making a DAO proper to the website.
On one hand, consuming my own API would make a single ent... |
Is it, at least theoretically, possible to convert a Java application into native code that can be run by something else written in Java? One example of this could be a Minecraft Spigot server. You can code plugins and stick them in the plugins folder of the Spigot server. The server then runs and then runs the plugins... |
I have seen this question and do not believe this to be a duplicate What software models are appropriate for daily builds and continuous integration? .
I don't fully understand what advantage automatic daily complete builds may have over building on every commit in practice (continuous integration being the term I beli... |
I am developing a web-app, currently the application is being developed in both NodeJs and in ASP Net. We are structuring the application in micro-services. Lets say we have a service that calls some functions in a dll and we have the possibility to choose which dll to call the functions from, but the client wants to m... |
I recently reviewed code that read as follows:
if (!condition) {
do_something();
} else {
do_something_else();
}
In other words, in the if statement we checked that a condition was false, and ran one of two functions depending on its truth value.
I thought this was a confusing style, and recommended that the condi... |
I have Java microservice that exposes multiple APIs. Under each API there are many exceptions could be thrown. The last method that catches them all has big catch block ...
catch(exc1 e1 | exc2 e2 | exc3 e3 ..... | exc10 e10){ ...}
They are all of the same level. Now I thought of combining them all under one exception... |
I'm new to server-side programming and I'm building a small "test" web application in NodeJS. Each time the clients need to view data from the PostgreSQL database, NodeJS will execute a "SELECT" query and will give me the result in JSON (which I then add to a webpage and serve it to them). Instead of executing a "SELEC... |
During a code review, I suggested to my coworker that he had questionable parameters for one of his methods. In particular, the parameters revealed too much about the method's implementation details. My coworker argued that a method's inputs must reveal the method's implementation details, so, where does one draw the... |
I read in the book "Clean Code" from Robert C. Martin (at page 71) that the better way to handle try/catch block is to separate process (the "try" part) from the error handling (the "catch part"). Each part should have a dedicated function
Example from the book, illustrating a better way to handle try/catch :
public vo... |
I am developing an n-layer app.
One of the layer is the BusinessLayer and consumes a set of POCOs defined in the CoreLayer. Also I have a PresentationLayer (WinForms)
CoreLayer
POCOs (classes with properties)
Repository interfaces (use the POCOs as parameters types) For example :
public interfaces ICarRepository
{
IE... |
Sorry, maybe it's a well known design principle, but because I don't know a name for this kind of relation, I was not able to find any existing answer.
So, let's say we have a parent which may have many children, but only one child can have some property active (or set). Think about properties like "selected", "current... |
I asked this question on an IRC channel, sadly I am going around in circles.
I am aiming for a high level overview (but with some technical details if necessary) on how a function such as printf() from stdio.h "talks" to the Windows operating system.
I know a bit about MSVCRT.dll, bits of the Windows API such as how it... |
This may be a stupid question, and it would certainly take one Hell of a lexer, but do any extant programming languages allow you to do something like:
c# (1.2) {
// c# code
}
Perl (5) {
# perl code
c# (2.0) {
// some more c# code
}
}
To utilize multiple languages in individual source files? I... |
My example might be slightly contrived, because I've modified it so that the project isn't recognizable by my employer. I'm a newer developer at a very small company.
We have an object - Posts - that has a number of defined attributes (title, tags, content) and an unknown number of unknown attributes. These attributes ... |
I have the following tables:
Organization.
Articles
Templates
Organization is the parent of both articles and templates.
On the articles index page, I display (by default) all templates for the organization.
Here's my problem. How do I add the ability to customize which templates are shown for each article?
I could ... |
Also, if my argument and parameter are the same value can I just use the same identifier for both? Thanks
|
I am building an intranet web app with ASP.NET. We are using Windows authentication for granting access to different web pages. We grab your Windows login server side, then build web pages accordingly. I have a need for a group of tech users to be able to impersonate business users so that the tech users can see the ... |
Given three classes Apple, Fruit and Seed ;
Apple is a kind of Fruit and it has Seed in it. With the knowledge of Apple Class uses directly or indirectly the properties of Fruit and Seed. Can we say Apple is inherited from Fruit and Seed ?
|
I am project manager and I struggle with gaining the attention of the Reviewer of a pull request when the author has replied to a question from the Reviewer. In other words, the Reviewer initially put the PR in the "waiting for author" status because he had questions. The author has now replied with the answer to those... |
I am working on an application that will support working in multiple tabs at the same time. Currently, when a document is locked by a user, other users won't be able to acces the same document but the same user could, if he wanted, open that same document again in a new tab.
My problem at the moment is, when the user c... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.