instruction stringlengths 34 36.1k |
|---|
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... |
I was arguing with my colleague on how to implement a dashboard function in a web site. Suppose a user can create a dashboard, which contains multiple gadgets in the web site. We planned to add more gadgets later on, and allow users to customized more on each gadgets, such as the formula to calculate the pie chart data... |
So I have to do a project for about 10 days. About the work, lets just say Im going to develop a Website with a front-end and a few interfaces between internal services. Now I have to use a projectmethod and I'm thinking of the Scrum Method. But since I'm only one person, I'm asking, if it is possible to implement the ... |
I use "reference" term here like in C++ world, not like in C# (for example). I use non-C++ syntax on purpose -- this is general question, not about this particular implementation.
Starting something like C++ afresh I would like to make rules and validation in order to prevent a case when reference outlives its source. ... |
Motivation: (Skip to "The Problem" if you don't need motivation for it)
As a project for myself, I'm writing an expression parser for certain kinds of mathematical expressions, and I'm using the interpreter pattern (as it often is used) for my Expression classes.
At the same time, I'm also using the template method pa... |
Imagine I have a set of houses I want to sell and I want to present then on a website. The user should be able to filter the house they want by price, city, number of floors, area etc. However, I don't want it to be like this:
First select price only, then you can select city and only after that can you select the numb... |
According to Is it wrong to use a boolean parameter to determine behavior?, I know the importance of avoid using boolean parameters to determine a behaviour, eg:
original version
public void setState(boolean flag){
if(flag){
a();
}else{
b();
}
c();
}
new version:
public void setStateTr... |
I have found many posts about how to organize work on develop branch and up to release branch. Or even how to work without the develop branch.
The trend of the "develop" branch going away, GitFlow branching strategy, but without the develop branch,
To branch or not to branch?... But I have problems about how to organ... |
I'm having a hard time to decouple two classes.
I have my code behind (will call it "class A") that I use to tweak the interface (defined in xaml).
Next I have a class B that is only logic. But while the logic is executing I have to update the UI.
My problem is that I can't "return" from the class B back to A to update... |
I'm trying to get into TDD, and a lot of examples sugests that we should use stubs to make our code more flexible. If I'm using javascript (for example) then why should I use stubs, since methods and even whole objects can be easily replaced for a mock?
Should I favor this:
const fetcher = require('some-async-lib');
f... |
Assuming I have a paginated api endpoint:
GET /api/meetings
My client is consuming this api endpoint and displays it in an infinite scroll that underneath gets page by page as the user scrolls down.
Now I want to add real time capabilities to the api.
New meetings can come in and also existing meetings can change (for... |
Say I have a Business Object like this:
public class CustomerBusiness
{
Guid ID;
decimal Salary;
datetime DateOfBirth;
}
and a data object like this:
public class CustomerData
{
Guid ID;
decimal Salary;
datetime DateOfBirth;
string Name;
}
Say I know the Name and Address when I m... |
I have an application that receives a number of values that need to be applied to various properties of an object (sealed class). Originally I just set the value without checking anything and updated the object, but of course sometimes the new values wouldn't be valid, and other times they would be identical to existin... |
When you are using frameworks like Angular, Angular2+, and React, the way you put data in the UI is by binding a property to an attribute of a UI element.
On the other hand, when you're doing standard iOS dev or traditional JS/JQuery dev, you extract a UI element reference, and do what you need with that reference.
My ... |
I am looking into Event Sourcing (ES) and having a play around with some code Greg Young put together (Greg Young Git Repo).
I like what ES offers in terms of functionality, but I am trying to apply that to my knowledge of a specific problem domain. Most applications I have worked on are all based around storing all d... |
At work I'm dealing with a situation where we have a large amount of time series data and need to display sections of it to the user at a time. The data essentially has an infinite number of records, and so it's not possible for the client to load the entire dataset at once. However, the API call to request sections of... |
I was reading this paper about the differences between software development in general and game development and the authors made some good points regarding software testing, pointing out, for instance, that
...game developers are hesitant to use automated testing because of
these tests' rapid obsolescence in the fa... |
In this article Mark Seemann explains how Onion/Hexagonal Architecture (or Ports and Adapters) are somewhat similar to a layered architecture when the Dependency Inversion Principle (DIP) is applied. Especially if you consider the claims made in this article to hold water, I think it's all quite clear and straight-forw... |
For example, let's assume we have a class that is imported three times from other classes. This would lead to a reusability of three. However, as there might be functions that are called only once, it would make more sense to count the called functions.
One general suggestion from measuring code reusability is to answe... |
Currently working with a client and their lawyers to launch a web application.
The website will be hosted in AWS on Debian Linux instances.
Debian contains (among others) the GNU General Public License which in my understanding is a Copyleft license.
We are being asked by lawyers, given this is a Copyleft license and w... |
I'm designing an application which will in an early stage collect data A, B, and C from clients, but later on will instead collect data A, B, and D.
A, B, C, and D are very related and right now exist as columns of a single database PostgreSQL table T.
Once C is no longer needed, I want to remove its references from my... |
As time passed by I learned that not strictly following the rules of a architectural pattern like mvc kind of counteracts the actual purpose of having a maintable software. Usually I end up with fat monster controllers or a model that does too much. Usually this happens because I didnt modularize my code enough just to... |
Let's assume that I have such a simple database scheme:
CREATE TABLE tbl(key INTEGER PRIMARY KEY, cap TEXT NOT NULL);
I want to show at least three independent GUI windows.
One window (window A) with list of items,
if I choose one item it should be possible to open window B,
that allow delete or update item. Also it s... |
On our project we have this data format that we use to process and record data on. As of late our application changed so that many of the data formats parameters have become obsolete. Currently we receive these data "packets" over internet (UDP or TCP) and from saved binary files.
We want to create a new more space... |
I've heard that changing a function's behaviour based on argument type is called ad hoc polymorphism:
program Adhoc;
function Add(x, y : Integer) : Integer;
begin
Add := x + y
end;
function Add(s, t : String) : String;
begin
Add := Concat(s, t)
end;
begin
Writeln(Add(1, 2)); (* Prints ... |
I understand Role Based Security.
I have read about Policy Based.
I have read what others call Activity Based.
What I want to know is if I do Policy-Based, am I avoiding what Role-Based requires and what Activity-Based seems to avoid - hardcoding security, refactor because of some new requirement, hardcode some more, a... |
I have a website that allows users to be "tracked" and track their time/work. This involves the users being able to update their account with my site at most every minute, but typically users do it only a few times per day. However, there is nothing stopping other people from updating your account.
Each update creates ... |
What is a widely accepted naming convention for date variables or properties in an Object-based, strongly typed language like C# (and by extension, for date database columns)? Do you use the word "date"?
Are there any official or semi-official style guides that recommend such a format?
I'm going to avoid an example wi... |
I'm writing a WebExtensions browser plugin that will modify the DOM of the current page when the user presses a button in the toolbar. More specifically, I need to insert HTML tags into the DOM. Even more specifically, every word on the page needs to be wrapped in a span tag.
In principle there's no way to predict how ... |
If you want to implement a layered API design for example, you may have one API layer that represents the application layer. And I assume that the application layer is represented by an endpoint and uri. Let's say we implement a Spring MVC Boot based controller, within that controller we may make a httpclient rest ca... |
I have bunch of keys and values that I want to send to our messaging queue by packing them in one byte array. I will make one byte array of all the keys and values which should always be less than 50K and then send to our messaging queue.
Packet class:
public final class Packet implements Closeable {
private static f... |
I just read https://techfindings.one/archives/2652 about functional programming and came accross this:
anonymous functions can often not be JIT compiled and will never be
optimized
Can someone explain to me why this is the case?
|
I'm trying to follow Uncle Bob's clean code suggestions and specifically to keep methods short.
I find myself unable to shorten this logic though:
if (checkCondition()) {addAlert(1);}
else if (checkCondition2()) {addAlert(2);}
else if (checkCondition3()) {addAlert(3);}
else if (checkCondition4()) {addAlert(4);}
I cann... |
I have to build a Windows Service which requires OAuth2 authentication. The service is intended (like all services should be) to run unattended (no user need to be logged in in Windows). The problem is, there is some user interaction required to get the OAuth2 authentication.
The service uses a third party API (I have... |
I have a function a plugin that is called whenever the WebAPI's "Plugin" endpoint is called in the main project, and that has to process the HTTP request. The request holds more information about what to do in method and query string, and I have for now copy&pasted the code to choose methods based on these:
public obje... |
I am working on design of a financial xchange system and especially the order-matching part.
I couldn't find a clear/complete design article especially for scalable/high available order-maching system. There lots of implementations which gives an idea about the system but none of the solutions are scalable and high av... |
We are a fintech startup that trying to re-build monolith php to microservice. As typical web app, we use to manage master data in admin page. How do i distribute this master data through microservice? We build a two API management service. One for the frontend user entry point other for admin/backend user entry point.... |
I'm doing an assignment for my school site and I'm trying to find a "best practice" way to go about solving my problem.
So, whenever a certain method is run I have to reupload five different files, to five different FTP. Each one of these FTPs require different credentials, so for each upload I have to create a new cli... |
I'm having difficulties assessing a design decision regarding entity relations in a JavaEE persistence data model.
Let's say I want to design a simple data model that's supposed to represent a chamber orchestra comprised of different types of musicians.
For now I know that there will be a flute player, a piano player, ... |
If we have different objects,
[A1, A2, A3, B1, B2, B3, B4, B5]
Some calculations will be performed to find compatible objects. For example, lets assume following 3 sets were formed and every set contains compatible objects:
{A1, B2}
{A3, B2}
{A1, A3, B4, B5}
Now we need to perform filtering. One node can participa... |
Consider the following c# example:
public class MyParentClass {
public int MyInt { get; set; }
}
public class MyChildClass : MyParentClass
{
}
public class AnotherClass
{
public MyChildClass GetChildClassFromParentClass(MyParentClass parent)
{
return new MyChildClass() { MyInt = parent.MyInt };
}
}... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.