instruction stringlengths 34 36.1k |
|---|
I am creating an ASP.NET MVC website in which I require a number of different sections such as admin, current deliveries, an inventory of products, etc.
Would it be more beneficial, a subdomain for each different section, for example:
admin.mywebsite.com
or using this sort of routing:
mywebsite.com/admin
Which would ... |
I'm attempting to figure out if an algorithm currently exists to accomplish what I'm trying to accomplish.
I have a series of time slots over the course of a week where I wish to assign a roughly equal number of people to each time slot during the week. Unlike this question, the time slots are provided as just ranges o... |
I am struggling to fully understand the usage of constructors in Java.
What I have learned so far about constructors is the following:
same name as class
abbreviation ctor
overloading
no return type
create an object of a class
every class has a default constructor
When for example a string has to be returned from a c... |
Let’s say I have an object, called “Tile”, which has both a name and a list of directions. We’ll assume that each tile has a 3x3 grid of pixels, which can either be on or off. The middle center pixel (designated with a “N” in the diagram) of the tile turns on when the North direction is “True”. The center left pixel (“... |
As described here, a function can be said to be a query when it returns a value, and a command when it modifies a value. It also states that a function should not be both.
That a query should not be a command seems popularly enforced by functional programming, in that it is a pure function.
Does a language exist, where... |
I have a website built on PHP, and now I want users to be able to log in. I do not want to take care of user management myself, so I'm thinking that social sign in would be convenient both for myself and for the users. The website is a traditional "server rendered" site, i.e. I have a database on my server, and my PHP-... |
I'm specifying an API for a REST service. The REST service will be primarily accessed by web browsers using XHR requests running code hosted from remote origins. Therefore, I'll need to add CORS support, such as the Access-Control-Allow-Origin header to allow for XSS.
Should I add CORS headers to non-200 responses, suc... |
If I have a custom type (or maybe an enum) like for ex. a Range:
Public Class Range
Sub New(minimum As Single, maximum As Single)
Me.Minimum = minimum
Me.Maximum = maximum
End Sub
Public Property Minimum As Single
Public Property Maximum As Single
Public ReadOnly Property Delta A... |
The Steam Client application allows one to download games purchased through the associated Steam account. A typical modern game uses quite a bit of disk space (in the order of 50-70 GB), so it is not unusual for users to download the files in several Steam sessions.
However, when resuming a download that has been stop... |
I noticed a pattern in my code. It applies to situations where things can be selected. It revolves around classes which I call (and in code often suffix with) Registry, Slot and Updater.
Registry
This class is pretty much a combination of what is known as the registry pattern: ("A well-known object that other objects c... |
I have a Aggregate Roots that use the event sourcing technique of being built from a series of events in a Repository. This is all great for when I just need to manage change of state etc, but when I come to using the Specification pattern to apply my app specific business rules, I am hitting a wall on what Entities to... |
I've been studying DDD and I'm currently struggling to find a way to apply the concepts in actual code. I have about 10 years of experience with N-tier, so it's very likely that the reason I'm struggling is that my mental model is too coupled to that design.
I've created an Asp.NET Web Application and I'm starting wit... |
I see size of boolean is not defined. Below are two statements I see at java primitive data size
not precisely defined
Further explanation says
boolean represents one bit of information, but its "size" isn't
something that's precisely defined.
Question came to my mind was why boolean in java can't be represented ... |
I'm learning about OOD and good practices in OOP and find myself struggling with some key concepts. As a practice I'm rewriting my custom PDO database abstraction layer which used to be a single file class with >2000 lines of code.
I learned one should use inheritance if classes are in a "is an" relationship and compos... |
I have a search box I'm going to use on different pages (I use the term 'page' loosely here).
The search box puts its value (the search string) into the Redux state.
The results are populated from an external API
Another component displays the results of the search as a list.
Example state:
{
searchString: 'Cheee... |
Sometimes my Aggregate will be very simple; some scenarios are simply not complex enough to require deep trees of objects and relations.
Consider a Website Monitoring application, which periodically pings a URL to check if it is alive.
The Web App will have:
Id
FriendlyName
URL
IsAlive
It doesn't have much data, do... |
Whenever I need division, for example, condition checking, I would like to refactor the expression of division into multiplication, for example:
Original version:
if(newValue / oldValue >= SOME_CONSTANT)
New version:
if(newValue >= oldValue * SOME_CONSTANT)
Because I think it can avoid:
Division by zero
Overflow whe... |
I know someone has probably already thought of this, but here is a way to replace DAOs and Domain objects: For example
public class Bike {
private int id;
public Bike(String model) {
//Create bike object in database.
id = getAutoIncrementKey();
}
private Bike(int id) {
this.id = id;
}
public... |
If I understand correct, a Git head pointer generally/usually points to the latest/last (end) commit of a branch.
I know head can point other objects, such as:
A specific non-end commit of the branch.
A specific tag of a group of commits.
But my question reference only the general or usual usage of that term, hence I... |
This older question tells us that in functional programming "true" randomness cannot be achieved since in FP functions are pure/idempotent and return the same value irrespective of number of invocations without any side effects.
But if that is true, how is FP applicable for problems like picking randomly a Captcha or s... |
Let's say, I've the below logic. How to write that in Functional Programming?
public int doSomeCalc(int[] array)
{
int answer = 0;
if(array!=null)
{
for(int e: array)
{
answer += e;
if(answer == 10) break;
if(answer ... |
I came across a tutorial which says this code is Exception Ducking
public class SomeClass {
void doTask() {
try {
//..Some Exception prone code
}
catch(Exception e) { }
}}
Though, I think ducking means to just let the exception propagate up the callstack by just not handling or throwing, whereas ... |
Please see the link here: https://lostechies.com/derekgreer/2010/04/19/double-dispatch-is-a-code-smell/, which describes Double Dispatch as a code smell. Now see this link: https://lostechies.com/jimmybogard/2010/03/30/strengthening-your-domain-the-double-dispatch-pattern/, which talks about double dispatch strenghten... |
I have code for a game that I want to change, make different game but with same mechanics and design.
There are some features that I don't want to have in game.
I have 2 options:
1) Remove feature
Deleting code will definitely remove feature but may take time and cause some bugs.
Pros:
Less complex code
Better for ma... |
Using Functional language, How can 2 different parties achieve the result of increment/decrement operations concurrently?
For the below scenario,
Let's say, I've 2 quantities in stock and 2 users in e-commerce site block 1 quantity each concurrently.
How can I mark the remaining stock as '0' in FP given the state is ... |
I have read OAuth2 and its statelessness using JWT as token. Token expires based on expired time, then how do I control token like blacklist and block its access immediately without being stateful?
As far as I found the solution is you need a database that store token blacklist. Then now what is the different with stat... |
Does any programming language have a concept of checking the type and value of a given parameter without adding an explicit if (myParam < 0) { .. } within the function?
A pseudocode example:
function myFunction(int myParam >= 0) {
return myParam + 2;
}
// myFunction(1) would return 3
// myFunction(-1) would... |
I am working with a small team that is developing a CQRS/ES "semi-microservice architecture. We are pretty far along, but running into some interesting challenges with our projections and further challenges are we start to move our projections out into a reporting database to handle cross domain concerns. I realize the... |
This is my first post here. I want to do the following with the help of embedding in GO,
extend the html.Tokenizer with new methods of my own
while still able to access all existing html.Tokenizer methods in
the mean time
define a function WalkBody() (or an interface method if possible)
in which an interface method o... |
I have a database that stores client data. All data is in one table. For each client, there is one row per day. Clients have different kinds of contracts, their data format remains the same, however, the underlying dynamics are different.
I am creating an application to simulate those dynamics and I am struggling find... |
I have a dynamic array that can often be empty, and I need to iterate over all its elements.
So far I have such code:
array.forEach(function(item, index) {
//stuff here
});
It works fine of course, but I wonder if there is any overhead for the forEach method when the array is empty, in such case maybe better check... |
I've been reading about CPUs and how they are implemented, and some big complex architectures (looking at you x86) have instructions that load from memory during one clock cycle. Since one address points to a single byte, how is it possible that I can write:
mov eax, DWORD PTR ds:[esi]
where I'm loading a double word ... |
Using Functional language, How can 2 different parties achieve the result of increment/decrement operations concurrently?
For the below scenario, Let's say, I've 2 quantities in stock and 2 users in e-commerce site block 1 quantity each concurrently. How can I mark the remaining stock as '0' in FP given the state is sh... |
I'm rewatching Rich Hickey great talk "Simple Made Easy"
And around min 35:40 when talking about state, mentions that State complects value and time, but I'm not sure I'm understanding this well.
Is it that because immutable data is always the same, being independent of time in the sense that it doesn't change over tim... |
I have a Surgeon class that is constantly changing
class Surgeon
{
string name, discipline;
public:
Surgeon(string _name, string _discp) : name{_name}, discipline{_discp}{}
void writeDir(string _dir);
void readDir(string _dir);
}
Now I need to add recording settings to Surgeon. Keeping in mind SOLID pr... |
For example, for Firefox the cookies are kept as an SQLite DB in user's folder. Any program can read these cookies. So, for example, can't an .exe program read the contents of a cookie and pretend to the web site of that cookie as if it is the logged in user and start sending requests on behalf of that user?
|
I am curious about your approaches/heuristics to the exploration of domain (subdomain, bounded context) during DDD modeling session.
As everyone knows most of programmers tend to be perfectionists (especially in the places where it is definitely not needed). Our industry has learned that it is extremely important to pr... |
During one of my lectures today about Unity, we discussed updating our player position by checking every frame if the user has a button pushed down. Someone said this was inefficient and we should use an event listener instead.
My question is, regardless of the programming language, or situation that it is applied in, ... |
After doing some researches I can not seem to find a simple example resolving a problem I encounter often.
Let's say I want to create a little application where I can create Squares, Circles, and other shapes, display them on a screen, modify their properties after selecting them, and then compute all of their perimete... |
In the University one of the lecturers was insisting on a piece of advice I found odd.
This lecturer insisted that his pupils do not care too much about decisions like the choice of the programming language, target platform, or other design choices that are not strictly necessary to make a working prototype. When peopl... |
I am using PHP with Symfony and Doctrine but my question should be independent from any used language or framework.
Suppose you have an entity Product with a One-To-Many relationship to another entity Price. Price has (among others) the properties validFrom and validUntil. Now I want to know the price of a product on a... |
I have project that need some UITest and UnitTest. If i should do it like in code below. What problems can arise with such approach? Or it's better to use small isolated UITest and small isolated UnitTest. Maybe somebody already faced with this approach. Or maybe it is greate paradigm. I think that this approach will ... |
Maybe I have misunderstood this concept. But is it common, when developing the backend to an app, mobile or web. To first write it in a high level programming language such as php, python, javascript to quickly develop a working prototype with fewer lines of code.
And then if performance becomes a priority rewriting th... |
How can I tell in an application if there are parts that will benefit from using the C# Task library (I believe that is the Parallel processing library.)
Given other optimizations have been done, how do I know other than just try it? In C#, can I use Visual Studio for this analysis?
|
I was hoping to get some advice on a particular task I'm trying to implement.
I have a table that stores secure data and returns an ID as a representation of that data. No problems there. So, for example, if a social security number is stored, the code generates a representational ID and stores the social security numb... |
If I fork someone's else repository (say, under my brand), for instance when I need the code for another, my own bigger project consisting of a number of such repositories, would it be preferred to send a message to an owner about such intention? I mean, should I inform him or her that now it will be under "my brand", ... |
Most of the resources I've seen about the Decorator pattern look like the following:
interface Tea
{
public double cost();
}
class BasicTea implements Tea
{
public double cost() { return 1.99; }
}
abstract class TeaDecorator implements Tea
{
private Tea base;
public TeaDecorator(Tea tea) { this.base = t... |
When passing around functions the term "predicate" is often used for a [short] function that returns a boolean. Is there a term for a function that selects a single field on an object?
For example let's say we build a custom sort function, but this sort is generic so it takes an argument for the user to specify which f... |
Our team is tasked with querying an external 3rd Party database to pull information. We don't own the database, so it could change without notice and our queries would stop working. We are currently storing the DB queries in SQL files in our C# project as embedded resources, and running them as SqlCommands.
This wo... |
I'm starting to use ES6 arrow functions more, but haven't found a coding style that I like, especially when chaining them together. e.g., Eric Elliott gives this code:
mix = (...fns) => x => fns.reduce((acc, fn) => fn(acc), x)
And touts how ES6 lets you write it all on "one line of code", but that's partly due to form... |
I'd like to be able to have a (Eloquent) Model implement a class based upon a property of the model once it is created. I think this is the Strategy Pattern, but since I'm doing it from inside a Model and not passing the dependency, it's not the perfect fit. I'm trying to avoid using switch or if-else blocks to create ... |
I apologize in advance for the vague title. I didn't want to make it overly verbose, so allow me to explain more in-depth below:
I've currently been developing a strong, statically typed language that compiles down to C++(11) code. Using the answers from How does garbage collection work in languages which are natively ... |
I have a set of operations that need to be executed as part of large process and subclasses may slightly differ part of the step. This problem seem to be solved by using the Template Method design pattern so I have something like below.
class BaseTemplate(object):
def perform(self)
self.disable()
se... |
I was reading a litte about clusters in nodejs, and in all cases it was trivial to clusterize the application. In fact, it was so easy that I began to wonder: are there any cases that I shoudn't use clustering?
|
My web app (under development) need to login via http://devWebServer/ExtApp/login.aspx
After login via address above, it will pass cookie to http://devWebServer/myApp/Login/Default.aspx and continue from here.
I find it troublesome that every time I need to deploy my code to http://devWebServer/myApp and do testing fro... |
I'm currently developing a new device, which produces (text-)logfiles. There will be many devices of this type and I want to analyse the logfiles (for error-detection and statistics).
Until now, the log analysis was a side-product, logfiles of other devices were primary for peoples who tried to debug, so the informatio... |
I am working on a Python 3 program that will among other things write data to text files in a number of formats. I have one function per format, generating the data to be written. I see two possible ways of writing these functions - one using yield and the other using stream.write.
Consider this silly example, just wri... |
I have a typical use case where i am consuming to a message broker. The messages are <^> delimited strings. I parse each and every message create POJO's and then apply different validations to understand if the message is useful for further processing. We call these validations as filters.
These filters are dynamically... |
I had a conversation once with a with a senior development manager. I said that I aimed to produce "good" code, meaning code that is high quality. He said that good code is functional, performant and secure, and "quality" is not even an issue.
His justifications were that what makes good quality code is subjective,... |
I have no doubt regarding what each of the technology does. I have tried all of them as well. What I have doubt with is:
In case we use GraphQL, wont it act like a single point of failure if the GraphQL server goes down? Can it be clustered and if yes, any architecture available?
I know why kafka is used in the Microse... |
I'm a Java developer working on a new module for my app that connects to, inserts, and updates DynamoDB information. For a lot of our projects, I used an MVC design pattern with a service layer to abstract business logic and bridge the gap between my controllers and model/data access layer.
We normally use PostgreSQL w... |
I am using XML Documentation comments to document a new project. All of my public API methods are documented using the three slashes required for XML documentation.
My internal methods (protected and private) are documented using double slashes (//) and slash star (/* */). This is because I do not believe these comme... |
For people who will use an API, is it easier to see:
/createUser
/getUser/id
/editUser/id
The standard is to use nouns in URI eg:
/user/ POST (Create a user)
/user/ GET (Get list of users)
A developer is insisting on using verbs because it is easier for others. But I think there must be some real technical debts to... |
Compared to about 10 years ago I have noted a shift towards frameworks using the style of routing that decouples the URL path from the filesystem. This is typically accomplished with the help of a front-controller pattern.
Namely, when before, URL path was mapped directly to the file system and therefore reflected exa... |
I've got a microservice called ExamResults, with a very simple component structure:
ExamResults
(offers: IExamResults)
(requires: IExamResultsDAO)
ExamResultsDAO
(offers: IExamResultsDAO)
This service gets passed exam results (student ids, exam ids, given answers) in JSON format, and the component ExamResults c... |
What are the thoughts about calling a class function that doesn't return anything but instead sets internal property values that you then read.
var myClass = new MyClass();
myClass.DoFunction(specialDate, "A");
// after calling DoFunction() the Name and Type property are now set
var name = myClass.Name;
var type = myC... |
In the paper On the correlation between size and metric validity Gil and Lalouche conclude that all popular software metrics are only valid insofar as they are correlated with code size.
They use several definitions of size including lines of code, number of tokens, and size of gzipped code.
Are there any actionable co... |
I've started reading a machine learning book since a few days ago, and I've learned about how it can be used for classification/regression/etc. However, I am unsure if it will be able to handle the task I want to accomplish.
My goal is to build a machine learning algorithm that predicts the return type of a method base... |
I often face this problem when new requirements come along, but have never seen it discussed anywhere. In this case, I have an existing list of items (staves in a musical score). The requirement is that a user can add and remove new items - but they are not allowed to remove the original items. So what do I name the... |
We are creating REST API which will be consumed by Web and Mobile users.
My question is: do we need to consider user interface before designing the JSON structure?
For example, we have one resource Company. A Company has multiple customers with its experiences. We created API company/{company_id}/customers to fetc... |
Background
As mentioned in this article,
Inversion of Control can be achieved through various mechanisms such as: Strategy design pattern, Service Locator pattern(SLP), Factory pattern, and Dependency Injection (DI).
Am missing clarity in above statement, because below is my understading.
1) Creation of container
C... |
What is the right concept of calling methods of parts in composition?
I have a class
class Body{
Arm arm;
}
class Arm{
public void waveArm(){}
Finger finger
}
class Finger{
public void moveFinger(){}
}
And I want to invoke moveFinger(). What is the correct way to do so? Is it
Body b;
b.arm.finger.moveFi... |
I write my own 3D-graphics engine for education and have some difficulties with it's architecture. I wrote classes like OpenGLTexure, OpenGLMaterial, OpenGLGpuProgram, etc. I also wrote a class ResourceManager for loading textures, shaders and materials.
Now I want to separate OpenGL graphics component of my engine in ... |
I want to make a reward system in my application, where
Each user will get some points for each task in app e.g.. solving a puzzle, answering an answer etc.
I want to show the point earners on a leaderboard (like Stack Overflow leaderboard)
Leaderboard should have the option to show daily, weekly, monthly & all time t... |
I've been trying to design a backend architecture to a SPA that satisfies the following:
user constantly answer yes/no questions (ex: tinder swipe cards)
The application calculates each user's similarity to one another solely based upon their answers
Similarity between users should update as they answer more questions... |
What algorithm should I use, to simulate a continual stream of N increments each second — not writing a loop, but instead by timed-interval events, no more than M events per second?
I am implementing a incremental game, and the rate of increment for some resource Scrog has a widely-varying rate of increase. The system ... |
I am going to try to build a implementation of CQRS and ES for large scale application (1M users) authentication API. Below is my initial architecture draft (Ignore Azure related stuff). I am going to do this approach because I see the following advantages:
Even if the event store is down, the login system can still f... |
I think it happened to everyone, having side projects, trying to do something new and big in their spare time, or maybe having a little startup where everyone has clear in their mind what the software will do and what are the design goals to address.
I was wondering what type of documentation has to be produced under t... |
The need for the client user is to perform tasks while they aren't currently logged in (so we can assume it is time-based). For example: A user logs in, performs tasks, logs out and gets a 'reward' in 6 hours or so. How would time be kept in this situation as the client isn't logged in?
I have the option for a server ... |
Even though I'm programming in PHP, I'm open to reviewing language-agnostic suggestions, as they might point me to valuable directions.
To remove any possible confusion I feel some comments appear to allude to: the Pages in this question do not refer to web pages, but to in-memory pages for an API akin to word processi... |
Let's say I have a function which sorts a database in O(n^2) time. I want to go about refactoring it so it runs in O(n log(n)) time, and in doing so I will change the fundamental way the operation runs, while keeping the return values and inputs equivalent.
What do I call this refactoring activity?
"Speeding-up-ifying... |
Last years I made myself familiar with Python and Haskell. I am surprised and impressed about the short and readable code you can write in these 2 languages, especially in comparison to languages like Java, C++ and C#. Of course this is very motivating to pursue my journey in Haskell and Python.
However with languages... |
Many of us have that experience where you had to release a product that you know has the bugs in it while the development. The situation being rushed deadlines, the severity of the bug...
What do you call them?
Could just call them "known bugs". But this particular term I'm looking for puts emphasis on the bugs that th... |
In Haskell, lazy evaluation can often be used to perform efficient calculations of expressions that are written in a clear and concise manner. However, it seems that the language itself does not provide enough details to determine, in general, the time and space needs of a given piece of code. The situation seems to ... |
I spend a lot of time trying to figure out what MSSQL provide to update MSSQL schema without loosing the sync, but I find it hard to find a solution.
Does any of you faced the some problem ?
I found two solutions and both are not an option :
move to NoSQL DB
halt calls to DB until update finish.
The most simple ... |
I am working with 4 AWS EC2 instances (servers). Each Instance has Instance ID and Instance Name. Instance ID is unique. Each of them having multiple application servers, like on of them is running PUMA server and another one is running NGINX and so on. I want to store the running status of the instances and their appl... |
Given this code from the Symfony framework:
use Symfony\Component\HttpFoundation\Request;
public function indexAction(Request $request)
{
$request->isXmlHttpRequest(); // is it an Ajax request?
$request->getPreferredLanguage(array('en', 'fr'));
// retrieve GET and POST variables respectively
$request... |
I have multiple Models(Models in MVC), These models are injected into repositories and repositories are injected into Controllers. I need to create an api for several endpoints. The responses for these endpoints will use repositories services. Response will be similar to this;
{
"user": {
"userId": 1,
"id": 1,
... |
I am looking for some advice in regards of best practices to build a HTTP PATCH request that can edit multiple entities in one request. The reason I am asking is because to me Rest API is quite vague and I don't have much experience building Rest APIs.
My approach would be to create a request with this data:
[
{
... |
I have a service that needs to make a callback. Basically, it is an event that is expected to be handled in exactly one place, and that is too important to be optional.
The obvious approach seems to be to inject an Action. In the context of dependency injection, is it considered good (or acceptable) practice to do so?
... |
The broad question is: how are the licensing terms for a classifier that is trained with open annotated data (or manually annotated) data?
I am trying to train a dependency parser for German text with annotated data which is licensed under creative commons license (Attribution CC BY). To train the classifier I want to... |
During development phase, there are certain variables which need to be the fixed in the same run, but may need be modified over time. For example a boolean to signal debug mode, so we do things in the program we normally wouldn't.
Is it bad style to contain these values in a constant, i.e. final static int CONSTANT = 0... |
Default display of objects in the Windows PowerShell console
In PowerShell you have format.ps1xml documents. These are used to simplify what and how object data is shown to the end user. A simple default example would be Get-Process. If no changes are requested it will by default show the following property set..
Get-P... |
I am creating a desktop application that persists the data in the cloud. One concern I have is a beginning to edit an item in the application and leaving it for a while causing the data to become stale. This can obviously also happen if 2 people try to edit the same item at the same time. When they finish up their edit... |
We are using Git and want to add a server side post-receive hook that posts events to our bug tracking system.
In our company, the Git server is managed by IT, and the server of the bug tracking system is managed by us, developers. Because developers don't have access to IT's servers, if we made updates to the git hook... |
What algorithm can I use to describe a specified gradient (N/M) approximately as the sum of a set of rational fractions { (n1/m1) + (n2/m2) … } ?
Design constraints:
The algorithm takes as input (N, M), describing the true gradient N/M.
N and M are integers.
If it matters: M is typically around 100–1000.
If it matter... |
I am building a website which has a single page app frontend that connects to a REST API from the backend. I also want others to be able to write programs for this website.
It seems like providing public access to the same API I build my frontend in would be useful. There would only be one API to maintain and I know ev... |
I'm currently working with a window cleaning company that uses it's own set of heuristics for scheduling its small set of cleaners for jobs - basically a huge spreadsheet with dates and human assigned area codes. I've stupidly said that it can be done better.
Conditions:
Jobs have a 'last cleaned' date and a regularit... |
I've many core class that require ISessionContext of the database, ILogManager for log and IService used for communicate with another services.
I want use dependency injection for this class used by all core classes.
I've two possibile implementation.
The core class that accept IAmbientContext with all the three class ... |
I am developing an application that can be simplified as follows:
The application is basically a mailing list.
Users browse to http://mysite/subscribe.
It's on the intranet, and the site is using Windows Auth, so I can retrieve their email adress from Active Directory. This email adress is stored in an SQLLite DB, on... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.