instruction stringlengths 34 36.1k |
|---|
I've recently caught an odd behaviour in my own coding: At some point in the last year I began creating protected static methods to implement the logic of my public methods, ensuring that the protected static version contains all of the logic, but is not affected by state.
e.g.
class Demo
{
string someAttribute;
... |
I am writing automated test cases in Visual Studio 2017 test frame work. I am testing the ‘create user’ part of a web API. A user needs to be created with a unique email address. Once a user is created they cannot be deleted.
Is there way to write automated (run on check-in) test cases, that need unique input data for... |
I am trying to understand behind the curtain scenes of Javascript and kind of stuck in understanding the creation of built in objects, specially Object and Function and the relation between them.
When I read that all the built in objects like Array, String etc are extension (inherited) from Object I assumed that Object... |
A common pattern in database design is to append dynamic columns to a table with a design like so:
create table MasterTable
(
Id int not null primary key
, Name nvarchar(64) not null unique
, SomeColumn2 int not null
)
create table MasterTableAdditionalColumn
(
Id int not null primary key
, Colum... |
Where I work we've got wallets with transactions (i.e. every transaction belongs to a single wallet). Currently we're working on an addition of transfers between wallets. As a part of this, a new Transfer concept has been added to the ubiquitous language dictionary.
One functional requirement is to give users the optio... |
I see questions similar to this with regards to parameter names that match properties on the class, but I can't find anything regarding using a parameter name that is the same as the parameter type name except for casing in C#. It doesn't seem to be a violation that I can find, but is it considered bad practice? For ex... |
My question regards the best practice / industry standards to prevent rogue users/admins from directly logging into the database console and updating sensitive information such as financial info / balances, etc as opposed to using the software which would otherwise validate the user's actions.
I ask this because the so... |
My application consist of a web client (implemented in angular or reach) and rest web service, both hosted on different servers. For implementing the OAuth2.0 login for Google, Facebook etc., should i implement the same on client side or server side and why?
|
Maybe anti-pattern is a better word for this question. I do not know, but I mean a violation of DRY. Id like to reuse a partial view, and I can, but that partial view has other things in it I don't want in my div I'm populating.
For example,
I have a page with a name. I can browse to a view and it shows me informati... |
I have a system i've written on paper and am trying to write this into C# in a easy to use manner.
I want a series of connected waypoints (where by waypoints can be connected to any number of other waypoints).
But waypoints can either just be an arbritrary point along the path or an actual object in the system with som... |
I have a loader class that executes data loading functions at boot-time for my application to give me test data.
The idea is pretty simple, I'm reading in XML data, using JaxB to turn it into a POJO and then persisting the POJO using JPA repo.
Here is my code (pretty small):
Looking at the parseFile method, I create a... |
I have a project that is sufficiently large in size that I can't keep every aspect in my head any more. I'm dealing with a number of classes and functions in it, and I'm passing data around.
With time I noticed that I kept getting errors, because I forgot what precise form the data has to have when I pass it to differe... |
I was hoping to get some advice from you folks on my table design methodologies (specifically in MS SQL if that matters).
Let me start by showing a couple of example tables that I might have in a typical application:
EntityType
-----------
EntityTypeID int identity (PK)
Token varchar(10) (Nonclustered IDX, UNIQUE const... |
To keep classes decoupled I'm using the Mediator Pattern like so:
class Mediator {
constructor(canvas, selectionBox, undoManager) {
this.canvas = canvas
this.selectionBox = selectionBox
this.undoManager = undoManager
}
addText(text) {
this.canvas.addText(text)
this.undoManager.captureUndo()
... |
I am implementing a custom ILogger (interface for logging).
I have succesfully developed implementations of it with some famous loggers like Serilog or Log4Net.
Now I want to create a memory logger that stores all the logs inside a List (memory).
Since the List will only exist in the MemoryLogger:ILogger , I think th... |
We have a bunch of services which are using AWS Kinesis to communicate via events. We have different events such as MasterDataUpdatedEvent, PriceUpdatedEvent or AvailabilityChangedEvent.
Currently, we are using a dedicated stream per event:
MasterDataUpdatedEvents go to master-data-updated-event-stream
PriceUpdatedEve... |
I'm only a student, so forgive me if my understanding is poor or my ideas poorly expressed.
I want to create a purely client-side browser application that works with the user's Dropbox account. They would go to the page, click 'Connect My Dropbox', grant permission, get the access token back, and store it in local stor... |
I'm trying to determine the best application and database architecture for a project I am working on.
The idea is that there will be multiple, separate applications that will all share a few tables like a User and an Employee table. Each Application will have a web portion (which may require an API, depending if server... |
For the purpose of writing a library, I found to be nice to add types to some well known namespace.
Example:
I've written a couple of extension methods for BinaryWriter and naturally put them in System.IO namespace.
Pros:
they're readily visible and usable
I do not end up rewriting it and shortly after discover it was... |
I'm on a new CRM dev team. And simply put, I haven't seen sprint execution such a mess in my whole professional career.
I have a deployment plan moving forward. I have an idea how I want continuous testing done in our test environment. However, I am torn on how often to push to test; because some sprints have alot of... |
Suppose I have created an application that makes remote connections and does stuff, how does an anti-virus/anti-malware program decide if my app is harmful?
I know there is a signature they check for to identify a program as either good or bad but it seems to me that would result in a lot of false positives because a l... |
So I keep track of all my finances using an Excel document (and have been doing this for many years) and it's become quite a pain. So for a fun side-project I want to implement something to handle it for me.
Initially I set out using Entity Framework with a LocalDB to handle the backend for me. But as I continually r... |
If I have three entities like this:
WorkingGroup
WorkingTime
Shift
The WorkingGroup has one or more workingTime
public class WorkingGroup
{
public WorkingGroup()
{
IsActive = true;
IsDefault = false;
WorkingTimes = new List<WorkingTime>();
}
priv... |
There's a 1st software module (s1) that generates data and then there's one or more software modules (s2, s3) that will receive that data (objects), based on pre configured actions that define the type of data to transmit.
A middleware (api) needs to get the data from s1 and convert it to s2 or s3 structure depending o... |
According to Wikipedia, Functional programming languages, that are Declarative, they disallow side effects. Declarative programming in general, attempts to minimize or eliminate side effects.
Also, according to Wikipedia, a side effect is related to state changes. So, Functional programming languages, in that sense, t... |
So, from my understanding, Html Helpers are supposed to be for single elements or small snippets of html. However, I'm not really sure why I think this, or how I came to abide by the practice. I couldn't find anything from Microsoft that covers this topic either.
The reason I ask is that recently I've been asked to bui... |
I am developing the UI of an e-commerce. Actually it is the checkout page only.
The entrance URL looks like this:
myEcomerce.com/{orderGuid}
On load The ui takes the orderGuid as parameter to call the API and get the details. In other words, UI call getOrderDetails passing the orderGuid.
My main concern is in relation... |
Using .Net web api
I have a web page that renders a collection of items depending on filter values applied via an ajax call to an api endpoint.
The items are paged so that if the user scrolls to the bottom of a page then another ajax call to the api with the required page number of the next set of items is made.
I have... |
I've been researching microservice architectures trying to get a high level overview of all the pros and cons, whens and whys, etc. A lot of the information I'm reading/watching is coming from ThoughtWorks (Martin Fowler, Neal Ford, et al).
Most of Martin Fowler's work on the subject is a few years old, when Microserv... |
I have been reading Alistair Cockburn's article on Hexagonal Architecture. One question that occurs to me, is how to handle situations where there are database concurrency issues.
An obvious example is a situation where an entity is retrieved from the repository, has an integer attribute incremented, and then is saved ... |
As far as I got it correctly, as a result of Rice's theorem, the equivalence of two programs is generally not decidable.
Nevertheless, there exists a wide variety of testing and debugging techniques, which do change the program for their purpose - actually, I can barely think of a technique that does not. So in fact, y... |
I believe the concept of DevOps is the single person handling all the activities of a given requirement.
1) Understanding the requirement/problem
2) Come up with logic to solve the problem
3) Write code for the logic
4) Test the developed feature
5) Deploy it
6) Maintain it
Does this mean "Division of Labour" is ... |
I am writing my first state diagram for an approvals matrix and I am stuck. An Order in our system will go through a number of states and transitions for approval:
States
Start (state)
(submit() transition)
Awaiting Approval (state)
(approve() transition)
Awaiting Approval (state)
(approve() transition)
...
Live (stat... |
Take the following algorithm with two separate sections, and the sections do not influence each other whatsoever (the function is not recursive, as well).
void algorithm(int x)
{
// This section of the algorithm has linear growth... O(x)
// This section of the algorithm has x * logarithmic growth... O(xlogx)
}
... |
A colleague of mine is against using DTOs and rather feels we should just return Entity / Domain objects serialized for a REST api. He feels DTO is an anti pattern and sited this article Data Transfer Object is a Shame. Although the article sited has a different approach to solving the "DTO Problem" as my colleague is ... |
I cannot go into the specific details of my project since it is in a very nascent research stage.
However, there is a fair bit of information that I can disclose. My project architecture consists of various Github projects that preprocess the data in a certain way. After a few parallel pipelines of different preproce... |
Let's say I have a Widget object that I serialize and send back to the browser at a regular interval. This Widget object includes lots of different members (variables) and other objects along with their members. For example, in PHP, my widget may look like this:
class Widget implements \JsonSerializable{
private $_va... |
I'm pondering a project in which one component needs to make a large number of http requests at accurate times. It should, let's say, release a set of 'dozens to hundreds' of requests at 1 second intervals. It is important that the requests are received by the other parties as close to the target time as possible.
Not... |
I am currently designing and developing a programming language from scratch. Mostly as a learning experience. Although it's not entirely related to the question, it's important that you know a little bit of the backstory.
I have a fairly good idea as to how I'll turn the code from my language into the target assembly c... |
Background
We have a ton of GPS devices in vehicles. These devices need to communicate with our system. To achieve this, we need to parse the device's messages before proceeding.
The following describes my scalable and fail resistant architecture idea.
Architecture
The devices are black boxes that send us buffers of da... |
Is naming a regular method init only confusing or is it an error?
class A:
def __init__(self, x):
self.x = x
def init(self, y):
self.y = y**2
def reset(self):
self.y = 0
I have encountered such a construction during review. Should I mark is as an issue?
|
I'm developing a Windows WPF app that needs to edit a certain type of document and I need a highly customized editor to do so:
The text is a transcription of an audio feed, and I need to sync the the text with a time code of the corresponding word in the audio stream (red numbers on left). This may involve breaking te... |
I'm looking for some advice about which line of code is more appropriate, readable, and maintainable.
1:
var result = mediator.Send(query).Result;
2:
var accountDetails = mediator.Send(accountFilter).Result;
The above code was taken from a Web API controller. The pros for each:
1:
If the query needs to change and re... |
I already have a solid back-end permissions authorization (ie. admin can perform an action, a normal user cannot perform an action).
However, I'm wondering if there is a better way to do a frontend authorization for my single page JavaScript application then fetching a permission from the API every view.
Seems like I c... |
I have a set of data:
id | name | parentid
------------------------
1 | parent | 0
2 | child | 1
3 | child | 1
4 | parent | 0
5 | child | 4
6 | subchild | 5
7 | child | 4
Which I can map to a hierarchy that looks like:
1 parent
2 |-- child
3 |-- child
4 parent
5 |-- c... |
Im going to be rewriting a library from .net to something that can be used on different platforms (Mac, Linux, Windows, Android). But i am also hoping that it can be used accross languages (c#, python, java). My initial thought was that c++ would be the best option. But ive never done something like this so im not sure... |
Along the lines of How v8 JIT compiler manages dynamically changing variables, wondering how you would go about creating dynamically generated variables in assembly. Not necessarily looking for example assembly code. More looking for a general high-level description of how you would define and then update a variable a ... |
In UML class diagram in MVC software design pattern there are model view controller classes and in ASP.NET MVC all views are cshtml not classes my question is how to put views in class diagram ?
|
I'm a software developer, and the kind of developer we call "front end developer". I'm working on stuff like Angular JS, Angular 2 and others.
I wanted to know how we can organize our front end code so that we can fit a modular based microservices like architecture.
Basically I am thinking of Platform as a Service like... |
I now find myself in a scenario, mentoring no more than 8 beginner-level developers and tasked with the development of a reasonably complex SPA website. It is to be developed using React (which the developers know to some degree - as in, they can put together code that works on a small scale, but is far from perfect an... |
We've got a Web App where we have a lot (>50) of little WebComponents that interact with each other.
To keep everything decoupled, we have as a rule that no component can directly reference another. Instead, components fire events which are then (in the "main" app) wired to call another component's methods.
As time wen... |
i want to call more than one process from the main program which is written in C++.
how to call them with the most efficient way given that one process may open and close more than one time.
the program also can call processes that are written in different languages other than C++
|
We need to send 1000s (under 10,000) per day for a few years. The data is in a SQL Server database - we have many asp.net MVC 5 and .net CORE 2 MVC sites on a Windows 2012 R2 server on IIS.
The emails are sent to customers who are expiring, so some calculations are required to work out who to send what to but nothing s... |
Let's say I have something like this:
switch(i)
{
case 1: new Class1();break;
case 2: new Class2();break;
}
So what's the best practices of doing this if in class where I placed it actively uses DI constructor injection. Is it reasonable to inject all Class1 and Class2 if it ends up with only one i... |
Context
I'm developing a Spring Boot java application. Currently it is a monolith with the rest API and the front end (vaadin driven) in the same big project.
Although this is very easy to develop and deploy, it is getting harder and harder to add features. There are too many concerns in the same application.
Also, I d... |
I read a lot that you can't restrict your Public REST API to only your mobile application, but I have an idea and I want opinions on it:
Variable App Key Method
Mobile App
Get IP address of current connection
Use a secret algorithm to generate a hashed AppKey from IP address.
Send the AppKey with each API request
Ser... |
Do the words to, as and get have any special meaning when used in method names?
Examples
to
new Integer(4).toString()
get
Integer.getInteger("system.unknown.property",4)
as
Arrays.asList(myPrimitiveArray)
|
I have seen a few papers on parallel/GPU processing of trees, but after briefly looking through them I wasn't able to grasp what they did. The closest to a helpful explanation was found in Parallelization: Binary Tree Traversal in this diagram:
But having a difficult time following the paper.
Wondering if one could ou... |
I have a JS function that takes JSON data and creates an HTML table. As my project developed, I needed one specific table to be created with a button - so I added an option to the function and an appropriate if statement. Then I decided I wanted to add a table colour option - another option; another if statement.
Fina... |
Trying to imagine how you would go about implementing summation (or reduction?) on a parallel architecture and am having a difficult time.
Specifically thinking in terms of WebGL arrays of vectors such as this:
[integer1, integer2, integer3, ...]
Wondering if there is a way to do this in parallel
var array = [ 1, 2, 3... |
Consider this simple example:
Tables (in a restaurant) can be booked for a period.
Business constraint: No two table bookings for the same table may overlap in time.
How might one prevent business constraint violations using Read Committed isolation level for the business constraint validation and optimistic locking?
|
I am looking for opinions about how bulletproof could his captcha system be to avoid spam in a contact form.
The form submit goes through ajax.
So I generate 2 random numbers with javascript.
The sum of those numbers must be correct.
On form submit, I validate the inputs and the sum.
If all is correct, I send the form... |
I am thinking, if I do proper testing for all methods in all my classes, then - disrgegarding UI - do I still need system testing? I mean, what would a simple example be, showing a case where unit testing is not necessary to reveal some errors? I tried to come up with something but failed, it always could have been cau... |
I'm working on ASP.NET MVC project where controller calling static class that run R scripts from external R project
Controller
public ActionResult Index()
{
Rscript.Run("WordCloud");// name of script file for example WordCloud
return View();
}
Rscript
public static class Rs... |
My question is
public interface IFoo
{
void HandleRequest(int i);
}
public class Class1 : IFoo
{
public void HandleRequest(int i)
{
if(i == 1) // just for example
{
//In this case i forced to call for async method
// await DoSomething();
}
//but in al... |
I have come across the word "warp" in a few places but haven't seen a thorough definition (there's no Wikipedia page on it either).
A brief definition is found here:
In the SIMT paradigm, threads are automatically grouped into 32-wide bundles called warps. Warps are the base unit used to schedule both computation on A... |
According to Are there guidelines on how many parameters a function should accept?, it is ok for a method to have few parameters.
According to https://stackoverflow.com/questions/11240178/what-is-the-gain-from-declaring-a-method-as-static/11240227#11240227, if a non-static method doesn't rely on any non-static members... |
Given the following constraints:
No multithreading.
No care about hardware cache utilization.
Wondering what a reasonably optimal memory allocation scheme would look like.
From my limited knowledge, one implementation is Free Lists, but it says they have some issues. Then there is buddy management and dynamic allocat... |
Overview
For company abc, teams are separated in terms of mission-critical applications and their extended applications. For example, customer xyz uses mission-critical data, but there are business constraints/flows that cannot be achieved with the mission-critical system alone. To maintain data integrity (mission-crit... |
I'm not that experienced in sql modeling, but i´m thinking of an intricate problem (or/and a silly one).
I have a project table(table 1) with many projectassignments(table 2), which is a join table. This join table have one person(table 3) with many projectassignments. I also have two tables(table 4 and 5) representing... |
Let's say we have a bidding system (written in Java 8), that according to some algorithm (bidding strategy) and certain conditions, we would increase or decrease the amount of the bid at a certain moment. We have different defined algorithms, but now we would like our users to define their own algorithm.
The user can c... |
In our application we have a page were we list our entities with many options to filter and to search. Over time this page got slower and slower especially for large datasets, so we thought about how to improve the performance. I have two ideas:
Use a service like Elasticsearch which is built for problems like these (... |
Our team wants to design a Web-Based retail pharmacy management system. A web based solution is good because no user installations are needed.
Some of the data fetched from central database are read-only and are shared between clients (5000 pharmacy users) and Clients maybe store their billing or anything else to a c... |
What would be an O(n) algorithm to maximize picks from a list when you can only choose 2 items from every 7 items. I've been thinking about this problem for a few days and I can't figure out an answer. I know it has to be a dynamic programming solution but I can't see how to relate any subproblems. I.e. if you have 2, ... |
Wondering what the general structure is for storing a tree in memory most efficiently (for access operation, and space).
For the access operation, it should take advantage of contiguous memory (memory locality) somehow which I am having a hard time determining how that should work for a tree. This way it can take advan... |
I am starting a new project and trying to decide if I should use a Javascript framework (like vue.js or react) and create a Ruby on Rails API, or use Ruby on Rails to server-side render pages and sprinkle javascript on to the pages (potentially leveraging Stimulus.js).
I am currently very comfortable using RoR to gener... |
Should I use HTTP status + message body for an error, or my own set of error codes?
For example, this is a request:
{
"number": 8
}
And these are two possible responses:
HTTP status: 400 Bad Request
Body:
{
"error": "expecting an odd number"
}
or:
HTTP status: 200 OK
Body:
{
"success": false,
"error":... |
I develop/maintain an in-house library in a growing company with about 12 other developers that write code. This library is mostly used for scripting game behavior and we have many different projects that make use of it.
This library implements simple, typed, event-aggregation in a static class EventBus.
It has the ex... |
I searched extensively and can't figure out what the infinity sign is meant in this pseudocode.
The code is taken from here, which has a detailed explanation of dynamic programming for the coin change problem.
|
I recently came across this license agreement on software:
Personal Use License
The content owner grants the buyer a non-exclusive, perpetual, personal use
license to view, download, display, and copy the content, subject to the
following restrictions:
The content is licensed for personal use only, not commercial ... |
Let's say I want to add a row to a table.
I send the query from the client (the website, not the user) to the database which is on another physical server. The query is sent over the network.
The query is executed successfully. The database then sends a message back to the client saying that the query succeeded. At thi... |
From what I understand, no-SQL databases differ from SQL databases because they allow the developpers to designe the tables to fit the usage, rather than fitting the model. Which means most of the time that if I have an API which uses Cassandra or Neo4J, Cassandra or Neo4J will have one view per API service.
If this is... |
I’m new to the whole programming society and the languages I’m learning right now are C++ and Lua. But as I’m learning it I can’t help but wonder how simple syntax such as print and if statements and such are used to program websites, games and more. I understand that they are the backbone of the entire project; it’s w... |
Scenario
A web application defines a user backend interface IUserBackend with the methods
getUser(uid)
createUser(uid)
deleteUser(uid)
setPassword(uid, password)
...
Different user backends (e.g. LDAP, SQL,...) implement this interface but not every backend can do everything. For example a concrete LDAP server does n... |
We as a team are writing an C# SDK which communicates with a Server endpoint. All our API's till now have been Task based. Like
Task DoOperationAsync()
Recently we across a need for API which gets an intermediate update (file location) before the final one if the user opts for it.
DoSomething(bool interestedInIntermedi... |
I created a small Desktop application (approx 15000 lines of code, so not that large) written in C++/Qt. This is non-commerical, just a hobby project and I am coding on my free time.
The larger the application gets, I find it more and more tedious to write C++, and adding new features takes a lot of time.
I find it e... |
In a book Doron A. Peled, he states that "
path coverage does not subsume multiple condition coverage because you
can execute all the paths without exercising all the conditions.
But I believe this is not right (it implies path is only "visible" branches), because even cyclomatic complexity is increased by one for ... |
I recently started reading Evan's book about DDD, and I decided to try and apply some of the principles from that book on a bounded context of a project I've been working on.
The context of interest deals with appointment and appointment scheduling.
I will present some of the business requirements, as well as the curr... |
TL;DR There are no methods in VIPER which are returning any value so how to test them?
Reasoning:
In VIPER, each layer is communicating with other layer by holding an abstract reference to it (Protocols/Interfaces).
For e.g, View has reference of a Presenter. If view calls presenter.getSomething() presenter will not re... |
In Clean Code by Uncle Bob, page 124-125 he states
Procedural code (code using data structures) makes it easy to add new functions without changing the existing data structures. OO code, on the other hand, makes it easy to add new classes without changing existing functions.
I'm reading about Multiple Dispatches like... |
Preface: I am not arguing against convention but rather want to have a greater understanding why convention is something I should follow and what are the benefits/drawbacks of doing so.
I have found in my development that convention is something that I feel I should strive for for whatever technology or platform that I... |
(I asked a similar question which answers focused on compile time instead of runtime. Instead of adding the runtime requirements to the other question and invalidating the good answers, I decided to ask a new question that focuses on runtime communication)
Scenario
A web application defines a user backend interface IUs... |
I have a lot of code that is needed for several projects - units, include files, resources and more. These files are writen by myself, downloaded or cloned with git and have their own place in the directory structure.
These (source)files have to be accessible during compilation. Now I'm struggling with two different po... |
We have all kinds of Lookups in our application, stored in a separate table, LOOKUP_T.
Should the application load them all on startup, and keep them in a global lifecycle variable -- or is it OK to keep making small trips to the DB to fetch these lookups depending on user action? In many cases these will be duplicated... |
I'm in a funny situation. We have a development model that works for an in-house software suite which is focused on responsiveness to the customer. To give you a sense of the environment, when we were using SCRUM, we would often intentionally commit to only 50% of our maximum workload, with a full expectation that th... |
When using factories, although more work is required up front, you know that you will be setting the correct pre-conditions for your test (up to what you have written.) However, when you use fixtures, although no work is required to setup the database state, someone (including the developer of the test) could easily ch... |
I used to think that the BOM is optional for UTF-8, but mandatory for UTF-16 and UTF-32.
But then I have read the following (in this article):
Let's look just at the ones that Notepad supports.
8-bit ANSI (of which 7-bit ASCII is a subset). These have no BOM; they
just dive right in with bytes of text. They are also... |
I am a consultant for a large organization. I work with CI/CD. Now sometimes the organization actually interrupts its services for upgrading the systems - I never do that with my own apps (where I use travis-ci and google appengine). I have ten years uninterrupted service with my own app. Is it alright to name our func... |
Currently I am working on an open source server control panel similar to cPanel, Plesk but I am not sure what would be the best approach to make system changes which require root permissions.
I was thinking to create scripts (with root permissions) which validate and execute commands sent by the app modules (which don'... |
I've really been focusing on making my tests maintainable by focusing on BDD-style tests and only focusing on interfaces. I do not want my tests to be brittle and prevent refactoring.
Is it worth it to test the presence of client-side web application DOM elements? For example, links on a nav-bar such as log in for when... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.