instruction stringlengths 34 36.1k |
|---|
Background
In our start-ups documentation, we got this:
Difference between a pull request and an issue page
In a nutshell, an
issue page should only include information and discussion about the
issue itself (ie clarifying requirements, suggesting edits to the
requirements etc) It should never include any informa... |
I have built a blogging application, running in several containers that are managed with docker-compose.
Now I'm wondering - how does one run multiple instances of such application on one server?
I'm thinking about two scenarios:
What is the right way to connect my project to the port 80, so I could run it along with ... |
When I first started learning PHP (about 5 or 6 years ago) I learned about Ajax, and I went through "the phases":
Your server returns HTML data and you put it inside a DOM's innerHTML
You learn about data transfer formats such as XML (and say "oooh so THAT'S what it's used for) and then JSON.
You return JSON and build... |
Please excuse the poor example/analogy, I'm only interested in the code sample.
I have a Dinner_Chair class (inherited from Chair class). It is as follows.
Dinner_Chair = class(Chair)
Private
theUser: Person;
Public
Dinner_Chair()
{
Back = new Back();
Seat = new Seat(... |
We are working on one legacy framework and it is continuously evolving.
Problem 1 : If somebody want to run the application with latest code then he/she spend lots of time in doing so (like somebody forgets to commit code or commits partial code).
Solution : We started using Jenkins and integrated it with our SVN repos... |
I am currently working on an algorithm for comparing two list of objects. Something like this:
I have a lists of sales:
class Sale
{
protected $client;
protected $products (ArrayCollection of Product objects with id and amount);
protected $status;
}
And I am receiving an unordered list of SaleProducts li... |
Let's have a simple class, and main method:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text.RegularExpressions;
namespace Rextester
{
public class Program
{
public static void Main(string[] args)
{
bar bar = new bar();
bar.foo("a");
}
}
public class bar
... |
I am working with jQuery like elements from the cheerio library to manipulate SVG images.
These objects represent XML nodes and have a hierarchical internal structure.
I am writing a function (in JavaScript of course ) that visits each child node and, if it is a Basic Shape (ellipse, circle, rect...), calculates a set... |
Backstory
I have an XML type document (SSML, which is used forText-To-Speech), which will be used to generate audio files when ssh transferred to a remote server. As such, I will need to include metadata for the ID3 tags that typically are used in audio files (Genre, Title, Composer, Album, etc...).
My approach thus fa... |
Consider this example of method injection:
static void SaveEmail(Func<string> getEmailFunction)
{
dbcontext.SaveEmail(getEmailFunction());
}
static string GetEmail()
{
var frmUser = GetUserForm();
return frmUser.GetEmail();
}
static void ExampleCall()
{
SaveEmail(GetEmail);
}
In this example, we are ... |
The Scrum Guide defines a single unit that consists of a Product Owner, a Development Team of 3-9 members, and 1 Scrum Master for somewhere between 5 and 11 members. I've seen instances where the Product Owner may have support staff or the team may not have a dedicated Scrum Master to vary that number slightly, but it ... |
I'm trying to design an asynchronous component. Requirements on this component are :
Component might receive events at any point in time
Component might start a long-running operation and wait for its result. This operation is executed by outside system.
Long running operation might be cancelled, either by the compone... |
I have come to a struggle to design invoice generator module in my project. I have following design;
Once an invoice is generated , it will be stored in database. In case user need to regenerate an invoice in the future and if product has been changed (e.g price), regenerated invoice will be different than the origina... |
Let's say I have an application which eventually saves and retrieves it's data to/from DB. For the sake of explanation let's imagine the application deals with students.
I have a complete API that lets me work with business logic classes and seamlessly save/load them from/to the database. So I can instantiate a "Stud... |
I have a table/collection called scores and it has 3 relevant identifiers based on which calculation need to be done.
sample
{
score : Number,
company : String,
zone : String,
unit : String,
timestamp : Number
}
Everyday we get huge amount of data in this scores table which has 3 identifiers. On client side dashboa... |
I'm trying to provide a convention, or standard, for a parent controller to communicate with a directive in Angular.
Basically the directive will have a "settings" object containing callbacks and initial data received from the controller, and an "api" object containing public functions.
I've created a service called "... |
I'm reading about pure-functions in functional programming and am wondering, whether a function being deterministic implies that the function is also side-effect free? (and vice versa?)
|
Say we have 2 Classes: Account and Contact like this:
class Account {
string Id;
string Name;
}
class Contact {
string Id;
string FirstName;
string LastName;
}
An account can contain many contacts. This data is managed in a class "DataManager" which acts as the repository for the rest of the progr... |
I deploying a web scrap server using scrapy. The scenario is a Linux server running mongoDB (or maybe mySQL I'm not sure at all...) and python scripts with scrapy framework.
The main question is what to use to provide data to other servers. I'll try to explain:
I have a delphi app running in another server, the idea is... |
There is an enterprise project, which all the business implemented in databases and in the stored procedures, and web API is just like a light wrapper which get the request and deliver it to proper SQL server sp and return the returned response from SQL server to client.
(except some discussions, and pros and cons of t... |
I am coming more from the web development angle. We build a module, test it and then deploy it. Some people call this last step (deploy) as 'release'. What's the difference? or are they the same things?
|
I'm currently setting up a Jenkins pipeline for a web application and am wondering which methods of deployment are most common or recommended.
Currently Jenkins polls the SCM for new commits and triggers build when there are new commits.
Assume that the build process is:
composer install
phpunit tests
rsync workspace t... |
I am designing a new application that deals with a lot of business logic.
To avoid the usual entanglement between different application layers that often sneaks into such systems over time, I want to implement clean separation of concerns right from the start. Broadly speaking I want to separate:
presentation layer
bu... |
I was hired to develop a custom Qt application for a customer, but I'm concerned about the licensing.
My software will not be publicly distributed and it is going to be used exclusively by this customer.
Do I need to disclose my source code for this customer, if I link my application with Qt libraries, such as QtCore a... |
In our company, we need to do many seemingly not complicated things, like develop Mobile UI.
Let's say the experienced programmers costs us 4x as much as the beginners.
Both are basically able to complete the seemingly simple things in the same amount of time.
The difference is, that the experienced programmers produce... |
I'm migrating my team's app to use NSURLSession instead NSURLConnection's because of the numerous now-deprecated APIs in the NSURLConnection family of classes and protocols. As part of that, we need to decide how often the app should be creating a new session vs. reusing sessions that exist.
Based on Apple's documentat... |
I have a stream of binary data. Assume no prior knowledge about the expected pattern in input data.
The symbols can represent binary data or other symbols, hence hierarchical.
The output should minimize space, but does not need to be optimal. But the algorithm needs to be online - that is, with more input, the represen... |
We're just starting off with using Entity Framework Code First approach and I'm playing with the Code Migrations system.
So we were wondering, are the migration files intended to be treated as generated code and shouldn't be modified or are they supposed to be generated for you as a scaffold and then you can add extra... |
I am building a JavaScript application that makes AJAX requests to a PHP API Back-end to load JSON data for different views.
The app UI consist mainly of a left sidebar menu which has items loaded that when clicked on will create a View for a Right content panel. Like this image...
The left sidebar will have up to 6... |
With the help of AOP, I can remove the logging code from my business logic. But I think it can only be used to log simple things (i.e. logging method entry/exit and parameter values).
However, what if I need to log something in my business logic? e.g.
public void SomeDomainMethod(string id)
{
//Get user by Id
Us... |
Company is new with microservices. Conceptually, it makes a lot of sense, and really describes SaaS applications as the true enterprise grade apps that they're meant to be. I've had applications talking to REST APIs for a long while, so it seems like a good fit.
However, there are concerns with downtime. Specificall... |
I'm currently writing a program to read a body of text and compare it to search-engine results (from searching for substrings of the given text), with the goal of detecting plagiarism in, for example, academic papers.
The two strings being compared are the original paper and the plaintext of the webpage (as returned by... |
So I was searching for a good way in ASP.Net Core to create some "controls" that render into a view. So far I found there are 3 options, and I wanted to get some feedback on them.
ViewComponents: These are like mini controllers and use methods like actions to render from a razor page (view). I believe they can have ... |
Background: I need to render the same information in two text formats. To do this, I have a set of model classes that store the appropriate information. I then need to render that same information in two different ways.
Each model has a list of 'actions'. Different actions have different attributes.
How do I handle... |
What is the best option for sharing DAL code.
We have a nice c# library that wraps SQl.Data.SqlClient methods like .ExecuteNonQuery, ExecuteReader, ExecuteScalar etc. Its adds logging and helper functions around Parameters and generally returns nice pre-polutated IDataRecords. This is boilerplate code that we would lik... |
Background
I'm researching the ability to add some services on top of git web hosts (ie github, gitlab, bitbucket etc, I'm not even sure what they're called, I borrowed that term from the github wiki).
An example of what I'm trying to do is integrating a spreadsheet with one such git web host so that whenever a user a... |
I am using Java, Spring and Jersey.
I have a REST API A which receives a query parameter called q and sends this to another API B to get a response.
I need to implement a change where I first need to pass the query from the client to another API C and use the response from API C to create a new request, i.e. basically... |
Should one make a code change by beginning to refactor at the "entry-point method" or the "inner-most method" of a call-stack?
A colleague and I were talking about a code change that would go through many application layers and touch a number of classes. The end goal was to assign a variable to a SQL table name at the ... |
I am writing a type of Queue implementation that has a TryDequeue method that uses a pattern similar to various .NET TryParse methods, where I return a boolean value if the action succeeded, and use an out parameter to return the actual dequeued value.
public bool TryDequeue(out Message message) => _innerQueue.TryDeque... |
I'm writing a framework that automatically documents applications dependencies in a distributed system, the idea is to produce something close to an UML component diagram of the whole system at runtime.
Components are usually applications or one of the resources they consume (database, HTTP API, file...).
Each compon... |
I'm working on a piece of code processing loads of messages and passing these to another service. This process may fail, resulting in a faulted reference to the service. Whenever a failure occurs, the message accepting code should continue to accept messages, but just discard those for a predefined period of time after... |
Let's say we have a rather large project written in Python using the Django framework that is made up of multiple modules (proper term in Django is a project made up of multiple apps, but for the sake of generality we will use the term "modules"). This is to achieve low-coupling for easy maintainability (among other ad... |
I'm doing a code review at the moment on Java Android code. I am looking at a function where a programmer has decided to use a switch statement to wrap a single condition.
I am considering making a comment that this should be an if block instead. What are your thoughts, what would you do if you saw this in code?
It loo... |
I'm concerned about floating-point determinism and the fact that different CPUs have different implementations of FPU operations such that the same C++ code will have different results when compiled and run on different machines.
How can I test my code on other platforms (i.e CPUs) without having to physically buy new... |
Backstory
I'm a newer developer and have just started on this project and I've been trying to avoid copy-pasting code wherever I can and make the page be built as dynamically as possible, so that when someone comes along and wants to add features here or there, they don't have to add code into 20 different places. So f... |
I know that transactions use locks. It is claimed that actors liberate us from shared state and locks
make sure all crashes are the same as clean shutdowns: this can be done through practices such as shared-nothing and single assignment (which isolates a process' memory), _avoiding_locks_.
Is the Actor Model an alter... |
I have traditionally not utilized much of other peoples code libraries in my code, but now I am starting to use open source projects more, and am needing an efficient way to understand quickly how to utilize their methods, classes, and objects. What are the best practices used to accomplish this most efficiently?
La... |
Looking for resources that teach multithreading in Android and list best practices. I want to do some image processing on the preview frame of the camera (already have this part set up) but want to parallelize the processing. Results from the async processes should come back to the main thread and update the UI.
I'm c... |
I have a number of visual studio solutions and projects (many projects may belong to multiple solutions) that I would like to add to Visual Studio Online (GIT Version). An example would be:
Solution 1
Project A
Project B
Project C
Solution 2
Project B
Project C
Project D
Should each Solution be created as a Projec... |
I’m working on a proof of concept for a personal project and am unsure how to go about handling ‘permissions’ on content that is uploaded into the application.
Problem:
In this application users will be able to upload media/files onto the web server. Some content will be public, some content will require the user to b... |
I can find many questions about libraries to use for representing amounts in some currency. And about the age old issue of why you shouldn't store currency as an IEEE 754 floating point number. But I can't seem to find anything more. Surely there's a lot more to know about currency in real world usage. I'm particularly... |
having a bit of trouble getting started with this problem, and not much luck googling solutions.
I can't use MS Project to display gantt charts, so am wanting to use VBA to draw a pretty gantt chart in Excel from an Access database of tasks, time to complete task, preceding tasks, etc. I know VBA, but am having troubl... |
What strategy would you use to detect memory leaks?
I was asked this question in an interview that was mostly focused on C++, and couldn't find an answer. I said that there are tools that do it and that I would use them, but that wasn't sutisfactory, and I had nothing else I could think of.
When I searched later for an... |
I have a custom non-blocking I/O server that supports (among other things) HTTP and websockets.
I have two timeout concepts for connections:
idle: connections that don't do anything are closed after (by default) 5 minutes of inactivity
lifetime: connections that are older than a certain age (1 hour by default) are kil... |
I have an ASP.NET MVC 5 site.
I have several complex view models - usually subsets of a far larger model. Should I create items in the repository that take the ViewModels - then just use Dapper.net to map them to some SQL?
If not I would have to map the ViewModel to the Model somewhere. I can then use the standard Mode... |
I want to set up basic "permissions" for a website. It has a basic "roles" system where users are part of certain groups and get all the permissions allowed to that group. However, I need more than just a basic Role, Permission, and Role_Permission setup because I want to allow for specific exceptions - certain users m... |
Is it possible to submit a pull request if I originally cloned a repo locally rather than using the GitHub "fork" functionality??
The scenario is that I have created a local clone of a repository and made some changes. I would like to submit these back via pull request. I can create a repo on GitHub and push my changes... |
I'm currently working through Robert Sedgewicks "Algorithms in java" (3rd edition, german) on my own and am currently at one of the more complicated questions there. I think I may have the starting point for a solution, but I'm not sure if its really the best way to go.
The exercise (translated):
Create an abstract da... |
There is a software component Processor that processes objects Item in a dedicated thread. Item may be processed multiple times (more specifically, it's a timer object).
One of the fields of Item is a pointer to BaseObject. So all derivative classes of BaseObject (for example DerivedObject) can reside in Item. Item in... |
I am frequently writing parser and mappers of some sort. This means that the switch statement gets used a lot and often many if statements for checking for valid input.
This of course creates a lot of cyclomatic complexity. I usually split out value parsers. So I have some data format and I have to convert/map the data... |
I am researching about Extreme Programming, and saw in Scott Ambler book 'Agile Modelling : effective practices for extreme programming' that XP has an lifecycle.(exploration phase, planning phase, iterative development,maintenance So whenever someone wants to use XP process to develop, can we follow this lifecyc... |
I'm mainly interested in answers in regards to a Swift language, but more general answers are always welcome.
I want to test a class (CUT), and for that I will use dependency injection. Now, I can:
Create some protocol that my CUT will use, which some concrete class and some stub class will conform to.
Just use concre... |
I have some properties in a property file that I referenced in a singleton so that I can access them easily from different parts of my application. For each property, I put the properties along with some additional information for each property in a list of objects. I'm doing this in the singleton's private constructor... |
I had to develop an application in Java for a school project, so I designed a UML class diagram oriented towards Java (including structures, attributes and types). For example:
-getLists() : List<String>
So the question is: should I assume which language I'll be using when creating a UML class diagram or should I take... |
Background:
Developer is the best person to know/understand the dark corners after any development/enhancement of enterprise software, compared to QA technician.
Developer can assess the depth/breadth of production problems that can arise from such dark corners.
FOR Quality reasons(only) but not for cost cutting, my... |
I am using MongoDB in a project, where relationships between collections are created via referencing a unique document ID of a special BSON ObjectID type.
So I can have a School document like this:
{ name : 'Country School', _id : ObjectId("aaaaaaaaaaaaaa") }
Also, I can have a Subject document like this:
{ name: 'Mat... |
What would you call the function that takes a list of n lists of values, and returns a list of all the unique lists of length n where the ith element is chosen from the ith input list?
For example:
[[a,b], [c], [d, e]]
=> [[a,c,d], [a,c,e], [b,c,d], [b,c,e]]
At first I called it permute, but then I realized that woul... |
According to Python documentation, super() can be used without arguments inside class definitions, because the compiler implicitly feeds it with contextual arguments:
class C(B):
def method(self, arg):
super().method(arg) # This does the same thing as:
# super(C, self).meth... |
Sometimes I ran into errors which are really hard to debug. So my meta question is the following:
You have multiple chunks of code, let's say A -> B -> C -> D
Your code don't crash but the result isn't what you expected
You clearly don't know from where the error comes, so you tried to change all chunks one by one t... |
To prevent long, procedural business classes like e.g. BookService with many, many methods that does the same, we decided to make a command class instead of each method - or set of similar methods. For example, if BookService has the following method:
Book createBook(String name, String author, String description) {
... |
I've come across a problem like this more than once and I'd like to know the recommended approach(es) for dealing with it. Alternatively, I'd like to know if it has a name.
For concreteness, let's suppose we have a Colony object, one of whose members is a list of Organism objects. Organism objects have an Update meth... |
in my situation i have too many parameters(1000 parameter or more ...) the number of parameter may change. every parameter contains a defined number of values .the problem is that the combination of all parameter values is too long which make it impossible to cover all the testing cases , so is there a solution to gene... |
This is the first time I'll be writing an application (personal) that involves money computation.
One of the potential issues I found is with regards to precision and repeating decimal.
Ex.
1 / 3 = 0.333
0.333 * 3 = 0.999
Where'd the 0.001 go?
What's the correct way of doing this operation without losing 0.001 that m... |
I am an amateur programer in a CS class trying to learn proper programming skills.
This is how my code looks, the edges of it extends to 103 columns.
int extractMessage(char keyWord[25], char cipherText[17424],
int rowSize, char message[388])
{
int keyColumn = 0;
int cipherColumn = 0;
... |
Here is a json which comes in the request param. I am constructing a class with getter and setter for accessing the values in json so that I could be able to pass the class object to different methods and able to access the member variables in them.
public class RequestParams {
private String student_id;
privat... |
In application which has about 1.5 mln lines of code there is using many pointers as a class members and in other places in code. Classes are usually very huge.
It is possible to change to make it safer in quite fast way? Refactor it can take years. It will be hard to change all methods to check if pointer is not null ... |
In our code we have some classes that represents business logic. Prior to usage, they are created and populated with two types of inputs:
business data required for execution (e.g. name, maxValue...)
infrastructure references to e.g. database, message bus, http client... etc, anything that is not related to business, ... |
I'm finishing off work on a complex rule-engine for Hotel Rates with real-time queries. There is a lot of conditions addressing intersections of periods for options, restrictions and policies. All of these are per date, meaning the time of day is irrelevant.
It varies wildly, from customer to customer, whether period s... |
I am focusing on writing easy to test code these days and I realize that most of my classes follow the skeleton below:
Some class ObjectManager needs a DatabaseRepo, while there is only one type DatabaseRepo in production (OracleRepo), I am still implementing it against an interface because I want to be able to mock o... |
Most of my production code has fixed types of dependencies, illustrated below: the House for example, at run time, always depends on the same Kitchen.
Therefore, I am wondering what I gain by having the House force whoever constructs it to inject its dependencies as opposed to provide the option to inject the dependen... |
I have an application which basically inserts some rows from the current front end web application.
All the calls before the service layer checks/validates if the user is allowed to insert data or not (This is where I am stuck with my current approach outlined below).
I have to create a REST API which will allow other... |
It is easy enough to create unit tests for conditional blocks which follow the expected path, but it can sometimes be difficult to contrive data for sources/objects I do not directly control, (databases I do not want to modify or access, environmental variables, etc.) without modifying the source code to add debugging ... |
I recently built a small web application using riotjs, a library that facilitates creating UIs in the spirit of functional reactive programming, i.e. defining the UI as a pure function of the application's state, much like the far better known reactjs.
Or so I was told, I think. I'm still not sure if I grasp the concep... |
I am designing application for multiple users.
Their data (e.g Surname) might change in time.
But documents they create should contain their data for moment they created it.
For now i am adding new record for any change in user data except those that change password or account expiration. Thus if document record is "si... |
For a completely fun project, I want to write a Markov chain chat bot.
The algorithm used is quite simple - break down incoming sentences into tokens, storing what words tend to come after each token (with perhaps a "weight" as more usage is brought in). This would mean that, on average, a sentence would take up twice ... |
I am trying to understand a general pattern. Suppose I have an application where I show User and all the Jobs listings where he has applied, here User and Job are many2many relationship. In the same interface I need to show the all the Address of the logged in User.
So, I will have following classes:
class User {
Lis... |
I am a user of SVN and now I am learning Git.
In SVN I usually checkout on my local machine a repo, which includes all branches in my project and I used to select the folder for my branch I am interested to and work there.
I see a difference using Git.
Currently I am cloning a repo and clone a specific branch using git... |
If I need to design the system architecture for a scalable site like amazon/BestBuy, what can be high level system architecture. googled it but did not get much data points.
Below is the high level system diagram based on mine understanding
To illustrate mine understanding I will take two use cases
Inventory addition... |
Basically the lamport clock helps the host to order the events rather than the exact time. How does all the logical clocks end up being converged in the long term?
|
We have a Symfony backend server for our Android and iOS application. Recently we need to extend our application by supporting real time interaction such as chatting, and we decided to use NodeJs with SocketIo to support it.
Currently our design is to let NodeJs acts as man in the middle. Nodejs would just receive requ... |
Given:
a list of 'leaves' that each have a cost,
the cost of creating an 'edge'
The constraint that a constructed tree node can at most have two children.
We now want to find the tree with the lowest maximum cost when adding up the cost of edges from each leaf up to the root node.
When naïvely attempting to build al... |
We are a big team (10-12 developers and 4 qa) working on multiple projects with the same git repository. Its a spring boot based backend web service. We are looking for a good git branching and deploy strategy. we also have a qa team who ensures that our features are working as expected (bug free to a certain extent).
... |
I want a class which will have a single method on its interface to add updates. These updates will be stored in an internal variable of the class until a specified batch size is reached. At that point all updates will be sent and the list of updates is cleared.
When my program is exiting, and there are still updates... |
I would like to automate the following sequence of events;
A new version of Angular is released on Github
'Something' triggers causing all our angular applications to update their npm dependencies for angular to the latest
The applications build, run unit tests and push to UAT on success, notify success/failure condit... |
I have a parser that can be defined as
int = a:/[0-9]+/ {parseInt(a)}.
It is supposed to match an int and convert it into a number. There can also be a parser like
sum = a:int b:int {a+b}
As you can see, it is a series of tokens, which means that they must be parsed as an array of tokens. When we start such an array... |
I am currently refactoring a piece of code to keep things testable and maintainable in our c# application.
I've stumbled upon a scenario where an existing method returns data with lists and enums that is then processed with lots of if else conditions in a big long method that is 800+ lines long. Lucky me!
I was tryi... |
This is going to be a very non-technical, soft question and I am not sure if this is the right platform. But I am a beginning CS student so I hope you guys tolerate it.
In the first semester we were introduced to OOP concepts like encapsulation, data hiding, modularity, inheritance and so on through Java and UML. (Java... |
I'm currently developing an app using the Azure Service Fabric. My question comes in regards to balancing outgoing connections. One of my services is going to be making a large number of outgoing connections to remote services. I'd like to be able to load balance these connections out, so when nodes go up, the new node... |
This is a simple example, but it reflects a tension between SOLID principles that I often find myself struggling with.
A popular example of the Open/Closed Principle (e.g. [1], [2]) imagines that you have many Shape classes, and a drawShape() method, e.g.:
// Open-Close Principle - Bad example
class GraphicEditor {
... |
I'm working on an in memory on disk cache and am starting to think about strategies for scaling the system. At the moment the system persists data by creating a file for each key value pair, where the key is the filename and its contents are the value. I want to be able to scale the system horizontally but am unsure of... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.