instruction stringlengths 34 36.1k |
|---|
Sorry for the long-winded question. I hope the question and its potential answers can serve as a useful example to developers who are wondering where to set the bar regarding testing fairly simple combinations of already tested functions.
Consider the following simple model for an order (definition of auxilliary types... |
I know that there are some differences between GET and POST, like descriped in this post on StackOverflow. But what I cannot figure out is, are they interchangable, assuming that you change your code accordingly?
For instance, could you use POST to request HTML-content and display it in the browser? I am not concerned ... |
I am going to log some events happening in my program. My program is working on a database that I cannot change (add table). These events can be stored in a single table with no relations.
I would think, that since there are no relations, an SQL database would be a poor choice, but I am not familiar with other types. T... |
I was re-learning about state diagrams this weekend, and realized that I may have been using them for years without realizing it.
Suppose i have an order record, with a bunch of fields including status, start date, end date, customer name, address, name, etc.
The status field has different states, and needs a transiti... |
We're having a bounded context dealing with payments.
I'm trying to model case, where Merchant can create another merchant and inherit some of its properties in this case: users that are needed for authentication to another bounded context (payment processor) that acts as open host service with anti-corruption layer o... |
How should an open source project with a public repository best handle pull requests (PRs) that address securely reported but not yet publicly disclosed security vulnerabilities?
I'm involved in an open source project with several hundred contributors. We publish security notices and vulnerabilities several times a yea... |
Our database has an Attribute table and a WorkItem table that are in a many to many relationship using a WorkItemAttribute table. The WorkItemAttribute table contains the foreign keys for each and a value column specifying the value of the associated attribute.
I wrote a simple CRUD web api and tests dealing with the W... |
I'm getting into microservices architecture and there are some issues which are badgering me. The main advantage of microservices is scalability. Let's say that I have service and I'm running 1-n instances of there services.
In case of spring boot application, we have cool easy to implement cache mechanism, but our in... |
For example, I find myself using software X.
Software X has a github repository. I find that I can make a lot of serious refactoring changes that are not small, and reconfigure the entire repository to use a different software methodology. i.e. software X is written using procedural style non-object-oriented coding. ... |
I am designing a web application with Django as the backend. Overview of the system is as follows
Data is collected from user related to different entities. Example : Plant, Project, Machine, Test, etc.
Configuration Blocks (consolidated, fully self contained, dated & versioned JSON files) are created by user by selec... |
I want to design a REST API given the following data model :
Accounts
UserId | Balance
user1 | 500
user2 | 200
And given the following Ui that must use the REST service for it's operation for a transfer of funds.
What would be the best way of designing the api for this data model that must also support the t... |
I have a web application written in Java, Oracle, and AngularJS. I want to save log in database when user changes, creates or updates something.
There are two way of implementing this:
1. Auditing tables via Triggers
Cons: On database level I don't have user information who makes changes, so I have to save userName in... |
We are implementing CI/CD in our company and we have a regulatory project which takes a long time to test. There is no way to break it down since the project contains around 300 rules, each of which needs to be tested every time. Other projects have a much smaller time of testing and they checkin with the mainline much... |
How do I understand Hilbert's map in this answer? The author of the answer has mapped the hash value (integer) of some strings to a 2D image. I understand that Hilbert's curve is a technique for 1D <=> 2D transformation which preserves locality of the points.
My question is, what can I infer from this 2D image about t... |
With WebSockets, when clients should be notified that data changed, I've seen two approaches:
the server pushes the data modifications directly within the push;
or the server pushes no data, and the client, on receipt, triggers an API call to get the updated data.
Which one would you use, and in which case?
In my cas... |
I'm building a web application, which involves (currently) a REST backend and a frontend SPA. The backend is hosting massive geo-enabled data, and the frontend is displaying it on a mapbox map. I'm hitting performance issues, because of the stack I set up. Here's the stack, when it comes to displaying a map.
Mapbox... |
After some consideration I ended up seeing that Service Fabric Actors is probably the best way to start. Now, I'm wondering if I'm approaching this the right way.
The structure
Below, is the structure i came up with.
Summary
I have a Stateless Service (DeviceCalculatorManager) which is responsible for mapping the rece... |
I am running into an interesting scenario that I just haven't been able to get answers on. I would like to see if there are elegant solutions for this. Here are some use cases:
I want to pass the identity/user principal of the user that called an API Action in a Controller to Services and Repository layers. There are ... |
I'm trying to solve a problem that exists for a sport. The sport is fragmented into many federations, and each federation is completely isolated from other federations. The sport is the same for each federation. The problem I'm trying to solve is to aggregate all of the data from each of the federations (about 10 of th... |
I'm thinking about implementation of command/query pattern and I have following solution:
Interface for queries:
public interface IQuery<TResult, TArg>
where TResult: class
where TArg: class
{
TResult Execute(TArg query);
}
Implementation:
public class TreesTransQuery : IQuery<List<Trans>, GetTree>
... |
On an entry level for a codebase you are not familiar with, how do you introduce testing, an at what levels ?
When introduced to codebases with no tests at all and at the same time being tangled together, it's difficult to measure where it's best to put in the energy.
I often pick a smaller corner to start from but in... |
I use a third party API on my webapp that is accessed when the user requests a particular ressource. I'm worried that the successive API calls happening upon user's request might cause the user to wait a very long time and slow down my system (since the thread processing the initial request is also waiting on these API... |
I am having a dilema on a html/js application I have been requestyed to handle drag'n'drop events in order to display a dropped image in a div if is not from images that are already displayed in my app then upload them as well.
My problem is how I will know if is an in-app image or not?
A sample code that describes th... |
The situation: Our team of developers and testers is transitioning from ClearCase to git, in some pioneering fashion. While experience with git is limited there is some familiarity with Linux, cygwin and msys; nobody is afraid of the command line, and people were generally not very happy with ClearCase (although, of co... |
Let's say you are working under Scrum and you have a story which very clearly describes, most likely in BDD, what is required as a new feature in the application.
Let's also say that, as a developer you have enough clarity to begin writing your server side code.
Also, you do not know the language, platform, APIs or per... |
I'm trying to model the security of my project using DDD but I ended up in a dead end.
I have the User, UserA, and UserB classes that were modeled as follows. What changes in practice is that UserA objects have an access policy different from UserB and for this I thought about using the STRATEGY pattern as a good optio... |
The following question is from Introduction to Software Testing by Paul Ammann and Jeff Offutt.
Consider the simple path [3, 2, 4, 5, 6] and test path [1, 2, 3, 2, 4,
6, 1, 2, 4, 5, 6, 1, 7]. Does the test path tour the simple path
directly? With a side trip? If so, write down the side trip.
Can someone explain t... |
When doing test setup, is it better to use low-level APIs to get my system in the right state, or use the same abstractions that my application would use? I'm specifically interested in what promotes long-term maintainability in large codebases.
Example (in Ruby, but my question is language-agnostic):
A User can buy an... |
I just started my first job as a software developer over a month ago. Everything I have learned about OOP, SOLID, DRY, YAGNI, design patterns, SRP, etc. can be thrown out the window.
They use C# .NET Webforms and do almost everything within the Code Behind with very few external Classes, definitely not called objects. ... |
I have list boxes and model relationships in the database. I'm doing the following migrations to maintain lists, rename items, and add items:
def up
Fund.create min: 0, max: 1_000_000
add_column :sectors, :order, :integer, default: 0
Sector.create name: 'Agriculture', order: 1
Sector.create name: 'Con... |
I had a quick question and I was hoping someone could help me figure this out. I'm new to Java and I'm trying to learn about classes and objects and I see you can call parameters in the constructor of the class. Such as:
public class PairOfDice {
public int[] dice = new int[2]; //Create an array of length 2 to ... |
I am requesting information about a Users address and as is good practice when collecting information, I validate the input and respond accordingly where appropriate.
Assuming valid input is received, the format of the input (particularly character casing) could be a bit funky.
For example; given the input 34b bAker ST... |
i have a static IP from my ISP(for eg-> 123.202.21.45).
i have configured my router with that Static IP, and my laptop is connected with that router and its ip is 123.202.21.45. works great!!
but now i connected my phone and iPad to same network and getting same IP (123.202.21.45) on all those devices and internet stil... |
I am working on a legacy C++ code with two libraries.
Library1 is the main and Library2 uses classes from Library1 (so there are some #includes "HeaderFromLibrary1" in Library2).
Deep in the code of Library1, there is some work done and when something happens I need to set a boolean variable. Library2 has to be able to... |
I have a class which checks for differences. I could call this
class ViolationDiffer
public IEnumerable<ViolationChange> Diff(
IEnumerable<Violation> old,
IEnumerable<Violation> new
);
Or
class ViolationDifferentiator
public IEnumerable<ViolationChange> Differentiate(
IEnumerable<V... |
I have a simple "Index" object defined as follows:
{
"position": 4,
"value": 345
}
And I'm trying to figure out the best way to store this object in a mongo database, assuming that:
The "position" of each Index is not necessarily unique and does not depend on other Index objects
Each user can have a huge number o... |
I have customized a free downloaded web template as my simple, static website. It contains HTML, CSS, and JavaScript/jQuery.
I want to make it live, and am confused from where to host it. The hosting providers say that as my site contains JavaScript/jQuery it will have to be hosted on a VPS, which is very costly. I don... |
I plan to have server which consumes all data sent from clients. I want to use messaging system (RabbitMQ) to avoid all troubles with discovering services, recoveries and so on. Client just publish the message whenever the message broker is available (whenever the connection is available). So, my server is sink here an... |
Please refer the following two forms of the same code
First:
<?php if(some_condition){
?>
<li><a target="_blank" href="example.com/channel1/" class="xyz">If content</a></li>
<?php
}else{
?>
<li><a target="_blank" href="example.com/channel2/" class="xyz">Else Content</a></li>
<?php?>
}?>
Second :
<?php
... |
I know they can be more natural to write, but I'm finding it conceptually hard to 'read' fluent API method chains. There's so much going on in a couple of lines.
As an example from the Nest ElasticSearch API:
var result = Client.Search<AutoSuggestItem>(s => s
.Source(sf => sf
.Includes(f => f
.... |
Having built a couple of moderately complex API's - both in Laravel - I appreciate the value of transforming data before sending it in a response.
What I am struggling with is how this data should be handled when it comes back, so for create and especially update methods. Should it be transformed (but in reverse)?
For ... |
I have encountered this problem a number of times. Let's say you have a large object that you want to store in the database. Perhaps it's a dating profile for a user, and it has 100 fields. All of these 100 fields should have a value, once the profile is complete.
However, you want to avoid forcing the user to enter... |
I have a requirement for a reporting tool in which the user will be selecting the "class" that has some associated column and "filter" option in the view.
Each class is associated with a list of columns in the table and each filter condition will add some filter criteria to the "select" queries. We have a script in pla... |
I am talking about single thread general purpose memory allocation/deallocation from a global 'heap' as e.g. every C programmer knows in the form of malloc()/free().
I can't recite the actual title of a paper about a much-better-but-alas-somewhat-restricted-in-usecase allocator, but I think I read the same judgement on... |
I am designing a REST API that allows users to register and authenticate with an email address and a password. Before being able to authenticate, I want to ensure that the user owns the email address they are using, so I send them a verification email with a token. My issue is that the token can expire, so I need a way... |
Our team is growing, and with it, discontent with common coding standards being imposed on developers with alternate (strong, bordering on religious) views on what constitutes a good coding style.
Examples of points of major contention:
Spaces vs tabs
Placement of braces (K&R, GNU, Linux kernel, Stroustrup etc)
The li... |
I am looking for a "test" to determinate which IDE is more productive.
I imagine this is a project in the desired language (my case would be javascript react, or Ruby) and I need to follow instructions like:
Refactor class A and rename it to B
Write a short function that does "this little job".
Search for a method ca... |
Pretty much almost all frameworks I use in programming uses the height and width when identifying a flat dimension (without Z axis), but when in math, a 2 axis object is always measured by length and width. What is the history behind this naming convention?
|
I have 2 classes that have dependencies.
public class AuditManager
{
//set of methods
public static AuditManager Singleton= new AuditManager();
public int AuditEvent(int x){
Event event=new Event(x);
event.SaveToDB();
}
}
Also I have a class:
public class Event
{
in... |
Our product is released every month. I'm looking at popular git flows like the ones in the official git site or Atlassian's. On a high level it is recommended to:
Develop in develop branch
Create a release branch
Test and prepare
Pull request to master
While I understand the need for the release prep step, I'm worrie... |
After some google search, I feel still in the mud.
I am wondering whether what is the best approach for writing wrappers mapping two similar APIs that offer similar semantics but perhaps in different models, syntax or styles.
For example: map Cairo (a graphics library) into Java2D (another graphics library, with a fair... |
I try to build an app using the following layers
Controllers <-> Application Services <-> Domain Services
<-> Infrastructure
Some validation might happen in the Domain Services and I am trying to find o a way of getting such information to the Application Service which will send i... |
I am working on a project, for which I want to create my own file format to store large amounts of data. I am trying to decide how that file format should be built to be as efficient as possible.
The data I want to store is basically a big data structure.
The idea I am currently examining, is storing the data in a way ... |
I'm reading about "Factory method" design pattern from "Head First Design Patterns". So, there is a class
public class PizzaStore {
SimplePizzaFactory factory;
public PizzaStore(SimplePizzaFactory factory) {
this.factory = factory;
}
public Pizza orderPizza(String type) {
Pizza pizza... |
I am writing a Spring boot app with Thymeleaf, which should support two languages (or more). I have set up the locale resolver and messages.properties so now my app can translate static messages on locale change.
The problem is, because there is some data in my MySQL database that have text in it (for example, descript... |
I have a scientific model that is typically run by providing it a complex text-based input file. I would like to provide a service endpoint to allow users to instantiate the underlying model. The simplest thing I could do would be to create a RESTful service that lets a user POST the text-based input file to the serv... |
I need some real time estimation samples from big companies like google, facebook and apple etc.
I need the task description, time estimation for task, team members count and after all, the real time consumed for design, develop, test and deployment of result.
Is there any real data available? All documents about time ... |
My project has a UI layer, a Service Layer and a Repository layer. The latter has Entity objects as part of the ORM (.net Entity Framework).
The service later returns a Dto to the UI layer.
My question is what object should the service layer work with? Should I return the Entities to my service layer methods for perfor... |
I am writing a web app. I want users to be able to go to a URL and start a new "session" of my app. They can Slack their friends/colleagues the URL and then everybody is in a socket-connected scenario where the originator can pose questions to the group, who can answer anonymously.
Right now, I initialize the user typ... |
As today most of the development is towards the lightweight service and RESTful architecture, is WSDL still needed to describe these services? In today's world -- where cloud computing, mobile computing, and Internet of Things are dominating -- is WSDL and UDDI still used by industry or practitioners?
|
I have a UI and a .NET C# backend server that communicates with each other. I have a route /getBigFile that the UI calls on a button click, which the C# backend can take up to 60 seconds to create and return so the user can download it. (The file size can be anywhere between 1 kB to 600 MB.)
This would mean that the UI... |
What's a correct format of a geographical address/location which is a good fit for any address on the Earth?
At the moment I have:
country
city
street
number
text data (for simplicity)
zip
lat/lng
But I believe I can improve it: there might be a state/region of a country or something like area. Or no area/region/stat... |
I am working with multiple commands that are executed in order (and possibly have sub commands as well) which can be desribed like this:
interface ICommand
{
void Execute();
}
abstract class AbstractCommand : ICommand
{
protected List<ICommand> ChildCommands { get; }
public virtual void Execute()
{
... |
I am trying to understand the factory design pattern and how it can be implemented in Javascript. So far what I understood is factory design pattern helps to create an instance of more specific class that inherits from a general abstract class.
So I was reading this article. I stumbled upon second point of drawbacks o... |
This may be easiest to explain with an example use case.
Let's say I have an e-commerce site where users can add items to their shopping cart. When adding items to the cart, users can type in the quantity that they want to add, and then click an Add button. Clicking Add will send a request to the server. The server ... |
I am trying to find a robust and correct solution for syncing data from different sources to my local relational database.
I have different sources of data for eg: CSV, REST API and probably network shared file system. These sources at any point of time gives the snapshot of the system and there is a script which runs ... |
Consider a super class Animal, inherited by multiple subclasses(Dog / Bird). On their instantiation, objects have their local state & behavior:
wiki says:
The strategy pattern
defines a family of algorithms,
encapsulates each algorithm, and
makes the algorithms interchangeable within that family.
If a requiremen... |
I am working on creating a set of microservices in Docker (using .net core and AWS RDS as the backbone, but that is not relevant).
As part of the deployment, the old container and new container co-exist for a short period of time (under 30 seconds usually) to ensure there is no downtime.
However, this means that if my ... |
With two existing implementations, UFOEnemyShip & RocketEnemyShip,
To introduce every new implementation implementing EnemyShip interface, shown below,
changes are needed in factory class EnemyShipFactory, with an extra else if, shown below,
public class EnemyShipFactory {
public EnemyShip makeEnemyShip(String sh... |
I've been teaching Python to someone that was new to programming; and so far, so good. Now, I'm about to teach Classes and Objects. However, I still think it's too soon for the whole OOP concept, plus we don't have much time left. My idea is to give her some basic, but useful introduction on Classes and Objects without... |
According to Pycharm (and thus assume according by PEP) i should state all instance attributes directly inside __init__. In my case it does not seem suitable to me. I have something like:
class Handler(object):
def __init__(self):
self.start_index = # parse
# Do stuff
def parse(self):
p... |
There is a project on github which is GPL-3 licensed. I want to use this code for my commercial project, but I don't want to open my codes. So, I contacted with the developer to check if she can change the license to BSD. She allowed me to use the code under BSD license. So what should be the next? Should developer upl... |
I'm spending some time lately reading and thinking about alternative ways to build web applications. One of the approaches I'm experimenting with is heavily based on OO, using TypeScript. The general idea is to divide the application into ever-smaller components, similar to the way Angular (and so many others) does it.... |
About a year ago we started on the journey of slowly breaking apart our legacy E-commerce platform and replacing it with smaller rewritten services. We now have several teams each focusing on separate areas of the website e.g. Checkout, Cart, Search etc etc
Each of these teams looks after a number of services that deli... |
I would like to use garbage collection several times after calling some external dlls. And I wonder how often can I do this, without causing problems to my application.
I'm using the following codes
// Force garbage collection.
GC.Collect();
// Wait for all finalizers to complete before continuing.
GC.WaitForPendingF... |
Example
I will explain the paradigm below but I am specifically talking about Liferay's Service Builder code for anyone who knows that platform.
Basically in Liferay you can definite a model and it's properties in an xml file. Let's say that we have a Student entity with the following properties: studentId, name, age,... |
Short format of question
Is it within best practices of DDD and OOP to inject services on entity method calls?
Long format example
Let's say we have the classic Order-LineItems case in DDD, where we have a Domain Entity called an Order, which also acts as the Aggregate Root, and that Entity is comprised not only of it'... |
I'm trying to find some opinions on best practice for returning different types of data for the "same" endpoint. Surprisingly, I can't find much on this subject.
Basically, I am building an API for our website, which is a single-page app. The client uses caching to store data across pages and this data is updated as ... |
It doesn't seem to me that a railway semaphore describes a semaphore better than any other generic signalling object, like a flag or a stoplight. Even something like a keyring (people take keys off the ring to access locked resources, then return them when they're finished) is more descriptive. So why is a semaphore ca... |
I have a big doubt about dynamic allocation. Suppose you have a class like this:
class MyClass {
public:
MyClass() {}
~MyClass() {}
private:
std::vector<MyOtherClass> others;
};
If I create an instance of MyClass using new MyClass, the inner vector wil be allocated in heap or on stack?
|
Our current Redux state tree is this:
{
"dog": {
"name": "Barkley",
"age": 6,
"hungry": false,
"location": "Living Room",
"height": "36 in."
},
"cat": {
"name": "Sir Eatsalot",
"age": 10,
"hungry": false,
"location": "Living Room",
... |
We are using Abstract Factory design pattern in our project, as the project became complex, most of the time the concrete class functionality need to separate to multiple class.
As the following code snippet, the render are supported by Renderer and Canvas, so there need static_cast in the concrete implementation as fo... |
Lately i have been taking an course at brilliant.org, i was exploring a lesson on QuickSort algorithm, found a question.
Which of the following would provide the optimal pivot selection at each step of quicksort?
A. The element in the first position
B. The element with the smallest value
C. A randomly selected ele... |
In Automotive SPICE 3, there seems to be an overlap in "Software Requirements" and "Software Architecture" about where are software interfaces defined. Can someone clarify this with a practical example?
See the overlap:
Section "4.4.1. SWE.1 Software Requirements Analysis" of this ASPICE 3 reads:
As a result of succ... |
Simplified a little, I have this code:
public class TaskProcessCases{
private Assessment assessment ;
public void execute() { // the actual name
for (Case case : cases) {
assessment = new Assessment();
// some more code (which a.o. sets 'id')
retrieveData(id); // th... |
For some payment methods users fill out paper forms with a 9-digit reference ID. Numerical IDs have the flaw that users can make transcription errors (lost digits, duplicated digits, switched digits). You can trivially detect those errors by adding a checksum (e.g. modulo-based from the ISO 7064 standard). But how can ... |
Imagine an API to identify whether a person has selected their spirit animal. They can only have zero or one spirit animals.
Currently:
/person/{id}/selectedSpiritAnimal
when they have selected an animal returns http 200 and {selectedAnimal:mole}
but when they have no selection it returns http 404.
This makes my spirit... |
I'm developing an app suite that uses an OpenID Connect provider. But I guess my question works in all situations where there is a separate user info provider.
I persist which users create a given object in my db and I want to show to other users what the user name is. At the moment, I store the user name at this momen... |
I'm really struggling with creating robust tests for my frontend because of the coupling in data schema between my backend and frontend.
To clarify, I have a Django rest API and I have a front end that queries serialized forms of my Django API backend models. When I want to generate test data for my backend, I use a f... |
I have been trying to understand how one would scale an application utilizing tcp/ip sockets for client server communication. For example in the simple diagram below:
+------------+
| Server |
+------------+
| |
| |
|tcp/ip|
|socket|
... |
The goal is to publish the attachments of received e-mails as soon as possible on an FTP server. These e-mails are sent at night, manual work is impossible. The mail server these e-mails are received on is Microsoft Exchange with complex login procedure.
Not-so-great solutions found so far:
Computer in house
Leave a c... |
The team i'm in is moving to use couchbase rather than elasticsearch DB. Now this is only an example but my question is more general. In elasticsearch you have the notion of parent-child relationships . When we move to a standard key value store we don't have these. My Question:
Assuming I do want to enforce relatio... |
I was tonight thinking what it tells about design and architecture of classes with many injected objects. I am taking into consideration setter and constructor injection specifically.
Setter injection proponents always use an argument of constructor injection complexity in opposition to setter simplicity especially in ... |
I've read this post Name of data structure that's tree-like with multiple root nodes. What I'm asking for is not a forest.
I would give you a simple example that easily depicts my case.
You have a usual power source from EB and an inverter (alternate power source) in your house. Consider these as the root nodes. And t... |
Why are "bit masks" called like this?
I know that they are mainly used for bitwise operations and the usage of bit masks is more efficient than the usage of separate variables.
However my question is why and when were bit masks invented? Were they used since early computing? Are there any other type of "masks" besides ... |
Using C# I've modeled a JSON message this way:
public class MessageBase<T>
{
public MessageBase() { this.message = new List<T>(); }
public string type { get; set; }
public string id { get; set; }
public List<T> message { get; set; }
}
public class LogonRequest
{
public string userName { get; set; }... |
We have a content authoring tool that creates interactive learning activities (imagine a multiple choice quiz) packaged as self contained zip files that contain an index.html css / js / media assets (inc video).
We then create customised courses (an aggregation of these learning activities) and serve them to users.
My... |
I'm currently developing a Website that requires direct access to the client computer. Therefore I decided to split this project in this three main parts.
There are some requirements that have to apply
The Website has to use SSL everywhere because sensitive user data is exchanged with the API
The connection between t... |
What does "continuous" mean in "continuous deployment", "continuous delivery" and "continuous integration"?
What is it opposed to?
Does "continuous" make "deployment", "delivery" and "integration" do more things than without "continuous"?
|
It seems that there has been a gradual shift in thinking about the use of pointers in programming languages such that it became generally accepted that pointers were considered risky (if not outright "evil" or similar aggrandizement).
What were the historical developments were for this shift in thinking? Were there spe... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.