instruction stringlengths 34 36.1k |
|---|
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... |
I am redesigning a CRM tool, of sorts, from the ground up. We are creating the application and the database from scratch. In order for developers to stay out of each others' way, each developer has a local copy of the application's database rather than sharing a single dev database. This avoids the case of developer 1 ... |
http://gitversion.readthedocs.io/en/latest/why/ and https://github.com/GitTools/GitVersion explain the advantage of GitVersion over "Version.txt/Version in build script" and "Build Server versioning"
Before being able to understand the differences between the three approaches, what kind of problem do the three try to... |
I'm not even sure how to ask this, but here goes:
Let's say I have a Web application that incorporates Teachers, Courses and Students in such a way that I can do things like this (pseudocode):
teacherQuery = new TeacherQuery;
teacher = teacherQuery.getById(teacherId); // teacher is a Teacher object
foreach (course in... |
http://gitversion.readthedocs.io/en/latest/why/ and https://github.com/GitTools/GitVersion explain the advantage of GitVersion over "Version.txt/Version in build script" and "Build Server versioning".
Before being able to understand that, I was wondering what the two other methods
"Version.txt/Version in build scri... |
It is generally a good idea to restrict access to your variables as much as reasonably possible. For example make things private instead of publicand make variables final if they aren't supposed to change. I believe the same applies to method parameters, but I find actual practice of this to be extremely rare.
For exam... |
So I'm working on a growing C program in a Linux / POSIX environment, and I've run into an area where I'm not quite sure how to proceed.
Basically, I'm using a module pattern to develop my code for use with different external hardware and I/O operations (for example: a file module, a camera module, a Serial module, etc... |
So we have a code base that gradle builds into 3 different targets for 3 different clients that are from a business perspective completely separate.
To simplify our release workflow, we have opted to keep the same versioning for all targets as less than 5% of changes are client-specific and we'd much rather keep track ... |
It's a good idea to have a Singleton implementation with dependency injection?
I have some classes that performs some heavy tasks on instantiation (related to database loading).
I would like to use them always as new instances but is problematic due to performance.
The code I am working with is from a legacy app, so i... |
Today I had a discussion with our architect about writing using statements in WorkUnits.
Lets assume we have a PersonWorkUnit with methods:
public class PersonWorkUnit
{
private IContextFactory contextFactory;
private IRepositoryFactory repositoryFactory;
public PersonWorkUnit(IContextFactory contextF... |
Problem Statement: Write a program to build a house, house can be of the following types: Apartment, Individual House, Bungalow.
Kitchen is customizable: ItalianKitchen, ModularKitchen, StandardKitchen;
No of Bedrooms is customizable: OneBedroom, TwoBedroom, ThreeBedroom;
Drawingroom is customizable: StandardDrawingRoo... |
Playing with some 3d game stuff in my spare time in C++.
C++ doesn't really lend itself well to fast, simple functional programming, and games where there is a lot of necessarily shared state don't always either.
However some functional ideas still seem useful. For example my renderer is implemented as a single "pure" ... |
If you have an enum with values only (no methods as one could do in Java), and this enum is part of the business definition of the system, should one write unit tests for it?
I was thinking that they should be written, even if they could seem simple and redundant I consider that what concerns the business specification... |
This is a WPF application using MVVM design that connects to Services (Business logic layer) which manage Models, with an exception that some property set of the model is bound to some views directly. This means the model properties are updated without involving ViewModel in some cases and this view scheme cannot be ch... |
I know they can for addition and subtraction, but I'm not quite sure if they can for multiplication.
|
why do we need priority queue when a set always keeps its object sorted, I think we can always remove the first/last element of a set and it would work as priority queue because priority queue offers the element with max priority(last or first positioned element in sorted collection), apart from the fact that set does... |
I am working on a graph problem which is special in the sense that the nodes are computed only when required. This is because the graph is so huge that the entire graph won't fit in memory.
So, in my code I only have a node class and a computeChildren() method which gets called only when needed. I also have certain glo... |
I like to try out stuff in projects I am in.
When something doesn't seem right to me, I like to implement a new thing, see if it fits or not for a while, and then, slowly implement it to the rest of the cases.
For example -
Lets say that in the UI, I want to try out unidirectional flow.
So I take one page, and make... |
I got a headscratcher: someone submitted code to test whether all of some checkboxes were unchecked, and it indicated True when an even number were checked. The code looked something like:
if (box1.checked == box2.checked == box3.checked == box4.checked == box5.checked == false) ...
and I read it naively as: if each o... |
I know CC is counted at the code level to determine a set of basis paths (i.e. independent paths), the elements of which then can be combined to create any possible execution paths.
In software testing, CC therefore determines the minimal number of test cases to exercise those paths and cover all edges and all nodes.
A... |
In my very small C# application, I handle the SQL queries directly from the code using basic ADO.NET. I do not want to use an ORM, such as Entity Framework.
Now, I have a repository for CRUD operations. But I find I need flexibility for more complex queries.
For example, here is the (naive and simplified) process of lo... |
The biggest difficulty I am having is finding responsibilities of each object identified by me in the system or so called problem space. I am positing a very simplified description of a book reader.
This time I thought like which actions can be performed on an object and that action became the method on that object, la... |
I have a C++ project, cloned from GitHub, which I'd like to build with a Docker image (a customized Debian stable). The image contains the usual tools for compiling C++ apps plus all the dependencies required by the project.
My ideal workflow would be:
cd into the project dir;
invoke Docker and let the container confi... |
I'm confused how to name software functional requirements, and I have searched some examples and found names like F-01 (for functional requirement number 1) and found other examples like SIMT-01 (the name of the system followed by the number of the functional requirement).
Does someone know a standard/journal that says... |
Current Setup
We have a staging environment which used NFV (be precious NSX)
to configure the network (Software load balancer and software
firewall)
The Production environment has used the traditional
networking techniques (hardware load balancer and hardware firewall)
Both environments have the same application serv... |
I am working on a project where the input is a map of key-value pairs. Different users can provide different key-value pairs in the input. But the keys are pre-defined and maybe even an Enum.
Based on the presence of a key, I need to execute some logic.
For example, if the map contains key A, then I need to execute log... |
I am developing two libraries in .Net
Firs one it's a library with core functionality (named it Library.Core.dll)
Let's focus in User class
public class User
{
//set of constructors and methods
public void LogOff()
{
//does not know the functionality
}
}
In the other library I am implementing... |
I'm very new to this,so please correct if I'm wrong.
I've understood that with Amazon RDS one can create read replicas and use those for all read-only operations. This helps scaling the application a lot.
Unfortunately, I have a PHP application that does not support separate read-write and read-only connections.
Is th... |
I often end up with methods with long number of arguments (up to 5 arguments). for ex -
public void doSomething(obj1, obj2, obj3, obj4, obj5)
obj1 to obj5 are unrelated to each other
I thought of creating a Bigger Object obj containing obj1 to obj5 then pass only obj object that is -
public void doSomething(obj)
Bu... |
I've been questioning the size of the user stories that i'm currently working on. The feature that i am implementing is a Datepicker component. The business value of the component is to allow users to quickly choose a date range. The component will be used on multiple pages of the web application.
Currently, there are ... |
I'll describe an example:
I start making an API for a baking shop. The API will allow people to search their catalogus for baking products, such as home-made minty chocolate chip cookies using api.examplebakery.com/search?q=......
Someone uses this to look for a product named pineapple-banana flavoured cookies and will... |
We have a graph that shows bandwidth usage over time. The bandwidth is returned from the server in bytes.
We need to decide which units to show in the graph in case there are several different bandwidth points.
The data is received from the server like that:
[10000,200,3150,150,25900,193] // In bytes
The client shows ... |
I am new writing good test cases, so please bear with me. Writing a test case for private methods
public Stock getStock(String stockTicker) {
Stock company = new Stock();
String url = getEndpointURL(stockTicker);
htmlDocument = fetchHTMLDocument(url); // private method
c... |
We're working on a reporting system which has a clear write and a read path. For example writes will only happen after consuming events from a queue and reads will only happen when serving requests from an API. The responsibilities won't likely mix, i.e. the service writing to the DB won't use the queries used by the A... |
I'm new to AKKA and i can't figure out a general proper way to integrate a backend actor system with my WPF views.
I studied a few examples i found (all very similar, probably based on this), but in my opinion they can't be really taken as a guideline.
How do you tipically make an actor system and WPF communicate?
|
I am looking for suggestions/examples on how to setup permissions for my project.
I am using ASP.NET Core 2.0 with EF Identity 2 (on one server) and will be using IdentityServer4 (secondary server) as my authentication source.
I have multi-tenants (Organizations) that have multiple locations below them.
Users may have... |
I’m wondering whether a busy websocket connection uses significantly more battery on iOS than a sparsely utilized one - or if there is a constant overhead simply for maintaining the connection that dominates. This will inform some architectural decisions. Thanks!
|
Sometimes in Single Page Applications (SPAs) there are pages like Welcome, About, Help or Support which are just static content and which doesn't require frameworks like Angular. I often see that people just create component for these pages too which is managed by these frameworks.
The other reason is often these pages... |
The general question is what kind of mechanism can I use to transfer data to and from publishers and subscribers where publishers or subscribers can be permanently offline? Can message queues be used for this?
Possible approach
I am thinking a message queue style approach where the online service (publisher) publishes ... |
We are going to implement Integration Testing at our project for an Embedded Product. The plan is to develop the Tests and execute them at each sprint.
I suggested that the tests could be executed after all the changes for that round are implemented, in parallel with the System Tests. A coworker suggests that it would ... |
I have been increasingly using immutable data storing for my web-app, due to some advantages it has (simpler writes, ability to view history / activity).
I am doing it using MySQL dabatases, simply by only doing inserts; no updates/deletes; and with the id (primary key) on each row being an autoincrementing kind of 't... |
Here is the case: according to ubiquitous language - payment can be sent for processing to payment gateway (which is in different bounded context integrated via ACL (anti-corruption layer) + OHS/PL)
In local context, payment is aggregate root so I would expect design like this:
payment.send();
but the problem here is ... |
As far as I understood it is already not possible languages like Java, C# etc. Because the method name of defining constructor in these languages must be same with the class name. That because I'll talk about PHP which creating the constructor is more abstracted from the class name.
public function __construct(Type... |
I've recently joined a project that uses a database model which is, to me at least, unconventional. Every column, except the primary key, is nullable. Instead, the constraint is enforced in the code used to access the database.
The reasoning of the developers is that it's more flexible to do so, and since the REST API ... |
I'm currently making an desktop application for the company I work for. The goal of the application is to control the flow of a manufacturing process and it will be used by 5-7 user (working of remote desktop clients) with different UI windows, two to input orders into a database and the remaining (like in a manufactur... |
As a rookie programmer, I've only recently been digging into benchmarking, and have been comparing various ways of accomplishing the same task in terms of speed.
Most of the time, the result is either that the difference in speed is negligible or that it is so huge that I'm definitely going to use the faster option.
Th... |
There are strings and each string has a weight in a data structure. The getRandom() method should return a string randomly with its weight/total weight probability.
There is already a question on how to define this getRandom() method on stackexchange.
But this question is about how to test this getRandom() method?
Any ... |
I am currently developing an SFML application which stores a certain value in my model, which the view is displaying.
As SFML operates on a kind of render loop, which refreshes the interface constantly, I need to fetch this value which has to be displayed from the model where it is stored in every iteration to keep it ... |
I recently picked up 'Clean Code' by Robert Martin and have taken to refactoring my recent project. I'm realizing how important it is to name variables and functions in a way that clearly expresses their intent.
One of my functions is called addEvent(). But the problem is, this function sometimes adds 1 event and somet... |
In the C++ community it is considered an extremely bad practice to type:
using namespace something;
in the scope of the file for any reason, even if the project size is only a few hundred lines at most.
However, other languages offer analogous constructs. We can, for example, do this in Python:
from some.thing import ... |
If I have a validator class with a validate function that takes a ruleContainer as input. Should the validation pass if the container is empty ( least astonishment?) or should I throw an exception or just return false ?
|
We're building a web application to monitor industrial facilities, and we need to add a module to notify the users when certain things happen in the system.
We get data (lots of data) from the facility machines as 10 minutes data series (a value each 10 minutes, like machine's components temperatures, output performanc... |
I want to implement an abstract module to store credits and I have the following structure:
Model: Credit (abstract)
Dao: CreditDao (interface)
Service: CreditService
The Credit model should be implemented in the application which is using the module. The application can choose how the model is stored in any database.
... |
My company developed a RESTful API that is used by a few internal applications. This API allows clients to charge one-time payments as well as recurring payments. Both of those things are made up of resources; a person needs a payment method to create a subscription that will create a transaction. The data is very rela... |
I'm building a small application composed of:
Client (command-line)
Business logic (remote server)
It's a simple game of tick-tack-toe where the client sends information to the server about which field has been marked and the server returns an updated ASCII drawing of the board.
My initial idea was to implement the c... |
Is there a nice way to test code which performs IO? In Java in particular, if you go the Mock route, you need to wrap most of the native APIs in your own mockable classes, something like:
public class Filesystem {
public void write(String filename, String text) throws FileNotFoundException {
try (PrintWriter out ... |
I want to completely sperate the front-end and back-end, the backend using Java EE stack expose restful web service, the front-end web application interact with back-end using json.
In such a front-end application, is it possible to using client side language only(html+css+javascript) ?
|
A follow-up to Difference between '\n' and '\r\n'.
It's been few decades since the schism was introduced. Nowadays, when documents are being exchanged over the internet, typically with no prior knowledge of the client's preference of line endings, the clients have to deal with both \n, \r\n.
To me it seems that it's sa... |
As a WPF developer, I was confused when I discovered that I'm not considered front-end because my platform isn't web, even though I clearly deal with user interaction and the front end of an application.
One thought I had was that desktop applications don't have a separation between the front and back ends (the UI and ... |
I started adding informations about the behavior of functions to their name recently.
Two big examples:
pure - this function has no side effects (besides the returned value), which I would use in Java like static int addingNumbersPure(int a, int b) (bad example as no one would expect side effects in such a method, but... |
I am currently working on a project where I am developing a library which will do HTTP POSTs to a backend service on my server. The data that the backend service receives is processed and stored in a database and allows the user using the library to see the data.
I want to ensure that the backend service only processe... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.