instruction stringlengths 34 36.1k |
|---|
In my MVC 5 web application there are many instances in which users will require to view thousands of records within grids, now I managed to get around many performance related issues by utilising the following:
Lazy data loading.
JSON compression.
Progrssive Ajax Loading.
Virtual DOM
Only retreiving the most importan... |
Say we start with a base class that states if an object is valid or not (included one interface and two child classes for discussion purpose), like:
interface IValid
{
bool IsValid();
}
public abstract class BaseClass : IValid
{
public bool Validity { get; protected set; } = true;
public bool IsValid()
... |
I have a complex environment which is mostly oriented around / ends up spitting out blocks of HTML, which make up the entire page.
Now, I need a way to "point and click" identify any block on my page from the front-end. At the user's command, they should be able to, when an element is clicked, pull an unique identifier... |
My scenario is like this. I work for a government agency that specialize in the Environment and Natural Resources. We want to make fool-proof functional system (software, hardware, people-ware, policy) that would:
prevent the reuse of a permit issued for transporting wildlife live species.
We have implemented a QR UR... |
Both basically have 2 parts:
Part 1: Divide up your data into many smaller parts that is small enough for you to work on each individually.
Part 2: Merge the results from all the small parts to one final result.
The only difference is that merge-sort is done on one computer while mapreduce is done on a distributed sy... |
I have just encountered this sentence:
Depending on the context, we may prefer to model integers as bitvectors rather than mathematical integers, since the Int type does not model overflow.
I am wondering what this means. I am new to learning about integer overflow. Wondering what it means to model integers as bitvec... |
Some of my colleagues tells me that using stored procedures in the database adds to much business logic in the database, and that you should keep the data separate from logic. Other colleagues tells me that adding DB Queries in source code as strings is not only hard to change, but also poses a security risk.
I'm leani... |
I am trying to understand how Polymorphism is used in a real life project, but I can only find the classical example (or something similar to it) of having an Animal parent class with a methodspeak(), and many child classes that override this method, and now you can call the method speak() on any of the child objects, ... |
My server and several clients are different JVMs running on the same machine, they need to share persisted time series data: server reads a time series from somewhere, writes to a persisted embedded storage. Several clients then read the timeseries from that storage in the same order.
Chronicle Queue seems to be the be... |
My app is consuming a third party api. One of the requirements of this api is that my app cannot send more than 20 requests per second. Because of the nature of this app, and because my user base is growing, we are now hitting that limit very frequently.
(One thing to note about my app: it consists of 4 separate backg... |
A big data job is split up into X partitions. The partitions are stored in a database. Status on each partition is also stored in the database and is used to ensure that each partition is only processed once by a single server.
I've got X servers, each with a unique id (int), each polling the database for the next Y pa... |
In wondering about math fonts in the terminal, I started to realize that you can't really have pixel-perfect graphics in the terminal:
How to draw a single pixel in a terminal?
Terminal with image support
The terminal also has weird features in that you have to use ansi escape sequences to change colors and move the ... |
Recently I am developing a new feature for my web application that must be Release Independent.
The feature requires to show some predefined data. Those data will rarely be changed or updated. Here is the part I am confused of. What will be the more appropriate approach to read the data from. There are two options in... |
I am writing an object oriented game for fun where players from two teams fight. I need to implement move function for players on a maze. Maze sohuld have location information with some features like height or type(hill, water etc.). So in order to implement location I have two ideas. First is that I need a Board class... |
In my 10+ years of experience in the IT field, I have never used foreign keys in any of my projects and I never felt the need. I did work with professional databases that had foreign keys constraints.
I am now at a position where we are building a new application/database and I am thinking should I use foreign keys or... |
I have a DDD repository for Employee entity. Employee will have some borrowed equipment from his employer. Because there will be more employee related records like work reports, wage reports and Employee entity could become huge I'm thinking to exclude these related records actions out of Employee entity / repository.
... |
Given a resource for which only its subsets of attributes can be edited, {E.g. invoice (resource) with a status (attribute) and paidAmount (attribute)}, in terms of API design, which amongst the following is the better approach:
PUT /invoices/{id}/status - here I'm afraid of an attributes explosion which will make the... |
I am not a developer myself so please bear with me. We are providing solutions for various customers and it is common to have a situation like this:
Our customer has a version 1.1, and wants us to provide maintenance and support for this version
At the same time, they request us to develop another version (let's sa... |
We have six very old systems where the newest one is built 1995. All these systems have batch jobs running from midnight to 6 AM every night, and these systems are offline. On top of these six systems there is an API from which different channels access data from the six systems. Every channel is naturally also offline... |
I am working solo on small development projects on my own time, using Git. For each project, I like to have a development journal which is associated with that project and not associated with other projects. The journal is a simple markdown file, journal.md.
Here are my requirements for managing the journal in my work... |
I have to integrate with another company's API, which they unfortunately decided to write in JSON RPC 2.0.
If you're not familiar with JSON RPC, it's a lightweight RPC protocol that defines a request that must always have the structure: jsonrpc, method, params, id.
Here is an example request I might make:
{
"jsonr... |
I need to know if is it correct to use pre-built codes on Github, or try to build it my self, while even I tried to build it I think it won't be as proffissional as that one on Github... the point is that I don't like to use pre-built codes but this consumes me, which I think I won't be a proffissional programmer by ti... |
We are new to c# and still trying to grok the async idioms.
We have a windows service that requires us to iterate a list of results queried from a PC database to feed the parse cloud server (which only supports async reads and writes). The results often have to be overridden with new results.
In a legacy java sdk, we... |
Let's say I have multiple Angular/React/Vue applications which I want to enable users to log in once and be able to access all my applications.
What I want to solve / ask about is where should I keep my login logic and UI? thanks
Should I create a separate project just to keep all my login logic and UI?
Yes:
Redirect... |
I am wondering why unicode encoding is necessary in JavaScript. I am looking at utf8.js as an example. I am also looking at the utf8 spec, but am not really following the different pieces of data. Also, I don't fully understand when and where you are supposed to encode/decode, and what the "current" format is of some s... |
It's no secret that in the early days of computers, they had only 1-4MB of RAM. I found an article stating you needed only 4MB of RAM to run Word, Excel and PowerPoint simultaneously. How was that possible, considering that nowadays you need at least 2GB, 1000x times more RAM to do the same thing? Sure, the new apps ha... |
I'm using a service to manage state in Angular:
import { Injectable } from '@angular/core';
import { Subject } from 'rxjs';
@Injectable()
export class DrawingAreaService {
itemChange: Subject<string> = new Subject();
private foo = 'foo';
get bar() {
return this.foo;
}
set bar(value) {
this.foo = v... |
I have a service, call it Service A, that is built on a Storage Layer, call it DB, that is 5-6 levels deep. This layer is depended upon by many other services.
Service A is having memory issues and the fix is to throw an exception from DB if the resource we are trying to fetch is too large for Service A. The resource i... |
We can do something like this:
// in base class
protected virtual void Init(){
//do stuff that all objects need to do
}
//in derived class
protected override void Init(){
base.Init(); // if you forget this but it compiles all hell breaks loose
//do derived stuff related to this object
}
I spent a good 15 min... |
I'm currently building an opensource administration interface to help people easily manage their contens/websites.
Application built on Vue.js and heavily rely on json configurations for which fields to show or which data to send server via forms.
Since rest apis doesnt have popular standardization (besides jsonapi) is... |
In my computer science exam there was a question as follows:
i=10, j=51 & k=7.
p = i+(--k +j) + (3*(i++))+i.
I am getting the answer as 111.
Here's my methodology :
k is decreased by one in (--k +j), and i in (i++) is increased, so (3*(i++))+i becomes (3*11)+11. But when i entered the statements into BlueJ, the answe... |
I'm implementing a Redux store for a React app using redux-saga for API calls. I've used Immutable.js before for other Redux-using React apps but the nature of previous projects always evidently required a normalized structure.
In this new app, the flow is less app-like and more a series of steps. There is an API call ... |
Let's say I have a web application where my users can log in, and save resources through my API and an ajax call. Now let's say I put my web application behind a Web Application Firewall (like barracuda).
As conscientious a developer I put a safeguard in my API code to check that the user currently trying to save the r... |
I'm making an graph layout optimizer and need to find paths from node a to node b in graph g. It has gone pretty well so far, but I lack an algorithm to take the next step.
So far I've used BFS to find the best path from a to b. The next step would be to find all paths from a to b, without loops. Q: What algorithms can... |
I am new to Git and am learning as much as I can about it.
The latest thing I would like to know is how to approach this problem: I have a single folder (R) that I initially set up as a Git repository.
Since setting R up, it now contains several projects and it is now the case that I have several branches, each reflect... |
So, I'm doing a project that needs to consume a REST service. I'm using C#, and I'm writing implementation myself with HttpClient class. I also try to create some Unit Testing for my library, but that class doesn't make it easy. Here are parts of the conflict:
HttpClient is designed to be used as singleton, as indicat... |
I'm working on a product that exposes a RESTful API to interact with system entities (the usual CRUD), which works very well.
In addition to CRUD, we've recently encountered a need to expose the ability to query different time series based data, with different filters and at varying aggregation resolutions (but based ... |
In the past we saw a big move from traditional MVC to MVVM for user interfaces:
One of the primary motivations for MVVM is that the view and viemmodel are competely indepedently of each other and can work/stay alive without each other. Since the viewmodel doesn't care about the view at all it was also easy to swap com... |
I have a repeated pattern in my code that is not easy to test: classes that execute periodically. Just to simplify things lets say assume something like:
while( running ){
long millisToWait = scheduler.getMillisecondsUntilNextExecution();
Thread.sleep(millisToWait);
executeMyTask();
}
Where Thread.sleep i... |
What's the proper URL structure in REST API for changing state of one particular record (e.g. change from "new" to "processed").
Now I work with this URL without request body:
PATCH /employees/123/items/456/process/ HTTP/1.1
But maybe better will be:
PUT /employees/123/items/456/ HTTP/1.1
and in request body specify ... |
Today, I and my colleague had a difference of opinion regarding the usage of default values in software configuration. We both agreed that for a consumer software, the default configuration should be determined by the most common usage and user experience.
However, the contention is in the usage of default values for e... |
I have a CRUD like service which have REST HTTP API. This service have two instances - only one recieving request at time. If first instance starts throwing exceptions or slowing down we change load balancer rule to send requests to second instance. Now I wanted to add some AMPQ messaging type handler to this service. ... |
I was recently tasked with creating a factory that processes webhook events. Any authorized application in the solution (1 app per domain) can post any meaningful payload and as long as the event's wired up for processing it should be able to handle it.
I have two domain projects: Core (logging, security, & common fu... |
For example, suppose I have a class to create a button with specific styles common to my app:
class ButtonFactory{
public:
static Button* createAppButton(std::string st,int font size){
Button* b=new Button();
//b->setColor();b->setText()...;b->playAnimation(...);
return b;
}
}
at other class
this->b=Bu... |
I'm having a trouble with understanding how to implement and find the median of a threaded binary search tree in constant time.
The tree consists of a worker's id and name.
The given details are given:
In a binary search tree with n nodes, There are n+1 left and right pointers with the value NIL. For every node z in t... |
We have inherited an application that is made up of small .NET web API's. Each API has its own Visual Studio SLN and git repo. All of the APIs are published to one folder ("All") and that folder is hosted on IIS with each of the APIs as a separate application on the same website and app pool. The folder with the publis... |
I have multiple classes that have the same properties to be exposed. Is it normal to create a base class, which will expose those properties, to be used with descendent classes?
By properties I consider plain
protected/public bool SomeProperty {get;set;}
but also a complex property that is being injected through const... |
After an unresolved argument with a friend I decided to ask the stack overflow community. Is there something like abstracting your code too much? Which of the following is the better option. We come from different coding languages so I am explaining this the same way I would to him. Assume everything below as summaries... |
I have a byte array and a value defining the type of the data stored in it (string, int, ...). What is the best way to get this data? I have two options in my mind:
Call a method which gives the type of the data and based on that call a method which gives me the correct data.
Call a method which returns both - the dat... |
I always hear how it is hard to implement shuffle algorithms for music players, but never really the explanation for it. What makes it hard?
Take for example how I would implement one:
First the user adds 5 songs to a playlist
let songs = [0, 1, 2, 3, 4];
Then the user enables shuffle
The program would then copy the ... |
In an interesting Twitter thread, Ron Jeffries (signer of the original Agile Manifesto) is suggesting that all user stories should be broken down so that they have one, and only one, acceptance test.
The aim is to remove the need for estimation on user stories: the idea is that such user stories will all have the same ... |
I know you're not supposed to test private methods, and if it looks like you need to, there might be a class in there waiting to come out.
But, I don't want to have a gazillion classes just so that I can test their public interfaces and I find that for many classes if I just test the public methods I end up having to m... |
Suppose we need an iterative algorithm for mathematical optimisation. Each iteration takes a long and random time. After each iteration, a stopping condition is checked for the iterate x, based on some pre-defined parameter b. An example is "Stop if ||grad(x)|| < b", based on the objective's gradient at x.
Here's is... |
While going through some lecture video on interface. I noticed
If we don't know about implementation, just requirement specification then go for interface.
What can be the scenario? Though I've used interface in many cases, but didn't gwt the essence of interface, as stated.
|
I've been doing agile planning for a long time, but always I get to the same question: where should I put the basic UI development tasks? I mean, for example, if we are developing a web app, we need some time to design and develop the basic UI.
Usually, we add extra points to related user stories so we can plan the spr... |
I've gotten myself a bit more roped into coming up with the design and architecture for a new system due to some departures and looking for some insights.
The system has a bunch of different high speed services on a network that a variety of data will be gathered from at regular intervals (50 to 1000ms, depends on the ... |
I'm in the process of outlining the intended business logic of a web service. At this point, I'm not too concerned with implementation details. On the contrary, I'm looking for ways to abstract them away in order to describe the business logic and data exposed by the web service in an implementation-agnostic manner.
I'... |
I am not sure if this is the best place to ask this question, but I was looking at a Wikipedia article and noticed there were a lot of edits for that article. Since you can view each edited iteration of the article, I figured the amount of space those web pages take would add up. There are millions of articles and Wiki... |
Given a literal type, for instance 1 | 2, assigning a value to a variable that correctly corresponds to the literal type will fail.
interface SomeInterface {
foo: (1 | 2);
}
class SomeClass implements SomeInterface {
foo = 1; // <- generates the following compiler error:
/*
Property 'foo' in type 'S... |
I am having a hard time understanding where the Application Services fit in with DDD and Onion architecture. Up until a few days ago I thought of them as part of domain model, but I began to question that.
I know what Application Services are for.
Orchestrating use cases.
Fetching Aggregate Roots via repositories (rep... |
I'm looking to persist a stream of events and I want it to be:
fast in both latency and throughput, looking at at least 100k events per second
ordered (not by timestamp, as multiple events within the same millisecond need to be ordered consistently)
for events sent by a single thread, they should be persisted in the o... |
In the same way that you can simulate the if statement and functions, I am wondering if there is a way to simulate the comparison operators ==, !=, >, >=, <, <=.
For example, in JavaScript, instead of doing this:
var x = a > b
Maybe there is a way to do it in a more primitive way, such as sort of a logic circuit or so... |
If I do this
import android.graphics.Bitmap;
import android.graphics.BitmapFactory;
import android.graphics.Canvas;
import android.graphics.Paint;
Then why don't I do this, it's more convenient
import android.graphics.*;
Do you agree that the latter is a risk that I might import classes which conflict which my own (f... |
Hopefully I am posting a question in right forum. As per https://meta.stackexchange.com/questions/68384/whats-the-difference-between-stack-overflow-and-software-engineering-se-previo `software engineering' seems to be the right choice for my question.
So question is,
We are in IoT era, and most of new bee's like me ha... |
I have read two opinions on the subject. Let's assume the following simple code:
class Enemy
{
public virtual void CheckHealth()
{
if (Life <= 0)
Dispose();
}
}
class Boss : Enemy
{
public override void CheckHealth()
{
if (Life <= 0 && PowerSourceDestroyed)
D... |
Question:
If I have to fetch an entity from another Bounded Context in order to map it to something in this Bounded Context, how would I go about doing that?
Do I call the foreign Bounded Context's Application Layer? Perhaps I need a new "Query" Application Layer for such queries?
Do I call foreign Bounded Context's r... |
What's the __version_info__ function?
I am reading a open source library uritemplate, I found:
__version__ = '3.0.0'
__version_info__ = tuple(int(i) for i in __version__.split('.') if i.isdigit())
there have __version__ already, why there still define the __version_info__ variable there? what's the function of it?
ED... |
You can find whole articles theorizing when you should use what METHOD in what edge case.
It mostly comes down to this; every action needs to be simplified to in just four flavours (GET, POST, PUT, DELETE) - and this is often insufficient to be expressive.
Especially if you look at domain driven design, this is unfit. ... |
I am trying to learn web app MVC in PHP.Most of the articles discussed about 1-to-1 MVC pattern given bellow
Controller: gets user request & update model,
Model: receives orders form Controller & update the data.
View: receives the updated data from Model & display it.
However, in my MVC project I need to create a h... |
I came across below statement at this blog
Computation intensive operations should use a number of threads lower than or equal to the number of cores, while IO intensive operations like copying files have no use for the CPU and can therefore use a higher number of threads
I am not getting the logic/reasoning behind wh... |
I have a java class where I have few booleans and one arraylist. If the boolean field is set to true, I need to add it to the arraylist. One of the ways I can do this is to use the setters of each boolean to add elements to the arraylist.
But is it a good programming practice?
I couldn't find concrete information on ... |
I have a class with some default/shared functionality. I use abstract class for it:
public interface ITypeNameMapper
{
string Map(TypeDefinition typeDefinition);
}
public abstract class TypeNameMapper : ITypeNameMapper
{
public virtual string Map(TypeDefinition typeDefinition)
{
if (typeDefinition ... |
We have a Raspberry PI (with raspbian OS) that runs some application, this application uses a local configuration file that contains some data like username, password, server url etc. We will provide raspberry pis (with the software installed) to users, they will have to connect them to their local network. We want to ... |
I have an old website (https://www.recordsforliving.com/) with a search feature. Up until recently, it was running on Windows 2012 server, and used Microsoft Index Server, and
...
OleDbConnection IndexServerConnection = new OleDbConnection("Provider=msidxs;");
...
//Index Server Catalog name
string CatalogName = "R4L... |
I feel like I've heard the phrase "Automated Test Coverage" but not really sure what it means. I am wondering if there is a way to do some sort of program analysis that will tell you which parts of your code are untested. In this way, figure out what is left to test to build a robust system.
|
I'm implementing a simple 3D rendering engine for my game, I'm using DirectX11. I created a simple architecture for the rendering engine, with a central rendering system (RenderingSystem class, a singleton) that contains and manages specific renderers, and each of them has a render queue and can draw a particular entit... |
I'm creating a variable which should describe that an object is currently in use. Lets say we have a form with a password input, and I want to describe the state when someone is using that input.
Is that variable name correct?:
Boolean editingPassword = false;
I don't have any idea how it should looks like.
|
Currently my company has a single internal application that our support agents use. It only supports one product at this time. Tech stack is angular on the front end and spring micro services for middleware.
We are launching a new product and the internal application will need to support that as well. However, for the... |
I have some set of data with key-value pairs, but there is only a finite and known set of keys, all of the key should always be present on that data, and they all have the same type for the value. Does it make more sense to use an enum for the key in a map (like Map<SomeEnum, String>) or make a new class to represent t... |
I have two classes called Player and Enemy both inheriting from a class called GameObject, how do I store them both in an array of type GameObject while still keeping their own unique information?
I tried making an array like this:
std::vector<GameObject> _gameObjList;
and then tried pushing a test object in it like t... |
I have two classes:
public class Child {
public List<Vector2> localPoints;
public List<Vector2> localEdges;
}
public class Parent {
public List<Child> children;
public Vector2 worldPos;
}
A parent has a position in the world worldPos. localPoints and localEdges in child contains points relative to wor... |
For example, suppose I have a class to create a button with specific styles common to my app, I can have either
Return a new modified object:
public class ButtonFactory {
public static Button createAppButton(String st, int fontSize) {
Button b = new Button();
b.setColor(...);
b.setText(...)... |
A bit of background. We are in the design phase of an HTTP API, and we are facing the question of how to define complex queries in JSON format. We have a items in our product that have A LOT of fields and properties, and proper filtering is vital for both the users and the interface built on top of the APIs.
Currently ... |
I recently applied for a position as a software developer. As a part of the recruitment process, I was given an assignment that involves reading data from a file.
The thing is that the example file contains extraneous data on purpose. For example, there's a CSV file in which decimal numbers are sometimes written using ... |
I am trying to learn how to handle complex context-sensitivity in parsing. Say you have this simple example of code:
var x = 10
var y = x + 10
var z = y + 10
var a = z + 10
var b = a + 10
var c = b + 10
If it were just plain JavaScript, the variables would evaluate to this:
x == 10
y == 20
z == 30
a == 40
b == 50
c ==... |
I'm applying Clean Architecture + DDD (maybe) in my project (web Application + REST API).
The good thing I learned from the Clean Architecture is using "Interactors" to show business use cases in my code, which is naturally fit with Command pattern. So that I use Command Patterns in my project.
Normally, I named my co... |
I am implementing a similar feature like the StackExchange Inbox and I have many considerations about the resource usage.
My system has inbox messages, system health notifications and Achievements.
On each page request I am querying the DB if there are any notifications from all these three resources (2 tables and one ... |
The ideal goal for my system is the ability to perform an arbitrary number of deployments per day to production while making sure each 'push' goes through the full test suite to make sure it holds up to our specifications/user stories.
This is a manageable challenge with Integration / Unit tests which usually are rock... |
I have a situation that occurs 5 times in my code, and continues to grow. Basically I have the same switch statement structure every time I need to perform an operation that involves my matrix and its type (which is set dynamically at runtime from files and user input). Here is one such example:
//QTableWidget m_matri... |
I'm currently writing a bigger program in C++ and have reached a point were I get problems with the organization. I wonder if namespaces are a way out.
I will try to explain what the program does and show a simplified example of the mess I'm in with it.
Part of the program configures so-called Devices. Each Device need... |
We have our REST API running on AWS Elastic Beanstalk (NodeJS/Linux), there are some legacy devices that their only way to communicate with the world is uploading a file using FTP.
These devices would upload a file to FTP(s)://ftp.example.com, the file is processed generating some output (updates stuff using the API), ... |
So basically I am writing a wrapper for a REST API in objective-c so that our customer can easily use them in their iOS development.
I am trying to find a good design pattern for this purpose, it seems Singleton Design Pattern is the only choice here. Without a public initializer, it is a shared manager accessible by ... |
We know a regular computer basically only knows two states and that we name these states 0 and 1 respectively. This seems arbitrary, we could name them "a" and "b", or even 3 and 4. Is there a reason for the convention of naming them 0 and 1 ?
|
We have an internal tool where our account management teams can say "whenever we send this type of SMS message, use this text I specify instead of the default text". They would call this 'configuring a custom SMS'.
Minimum viable info about how our SMS-sending code works -- the API takes a message name and a user to se... |
I have recently started on a project involving a REST API. The API requires authentication with requirements for administrators to be able to view logged in users and to be able to revoke specific login-sessions immediately. The API is consumed primarily by a SPA and a native application.
During my search for existing ... |
i have a sytem a that include system b and return the result.
simple!.
concrete example an API, one controller that internally call another class then perform the operation.
route
--> controller
-----> class
I would do this
a series of unit test for all piece the code
then a series of functional test for the contr... |
When I recently started doing some 3d graphics, I carefully (tried to be careful, anyway) decided to use the conventional mathematical standard for labelling axes, which was much more convenient for "doing the math" in this pretty math-heavy problem domain. And to try to avoid any confusion, I even included an ascii co... |
Let's say in an effort to improve quality, your team agrees on the following policy:
all commits to the master branch (direct or via pull request) have to be categorized as either bugfixes or feature changes; never both at the same time.
to easily distinguish the two, commit messages have to start with e.g. [bug 123]... |
How can I avoid duplicate use of doSomethingCommon() in the following block of code?
doSomething();
if (conditionA) {
doSomethingSpecificToConditionA();
doSomethingCommon();
}
else if (conditionB) {
doSomethingSpecificToConditionB();
doSomethingCommon();
}
doSomethingElse();
NB: Calculating condition... |
Sorry for the unspecific title but I can't find a concise way to state my issue.
I am reading the book Clean Architecture, by Robert C. Martin. It has a short chapter about the LSP with a couple examples, but I am unable to understand why the first example does respect the LSP.
The principle
What is wanted here is som... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.