instruction stringlengths 34 36.1k |
|---|
A side project I'm working on with some friends currently deals with an API interface that, for many reasons, is slow and cannot be changed to improve speed. I'm talking API responses that take anywhere from 5 seconds to 25 seconds. It's old software, but we have to integrate with it, period. After that API response co... |
I am bit puzzled as for why this does not throw an exception - I believe the CLR does not delete the object because there is a reference to it?
static void Main(string[] args)
{
List<A> listOfA = new List<A>();
A a = new A();
listOfA.Add(a);
((IDisposable)a).Di... |
Many projects need more than a Dockerfile or a docker-compose.yml in their root to work out of the box (e.g. for local development or a demo): For example a web application might need its runtime, a web server and a database, each one configured for the application. Are there already "best practices" or at least common... |
I work in a team of 8 people and today it receives demands from several stakeholders, some development demands, others operational. When there is development, it is usually done by one person of the team only, and in several situations this model is harmful, for example, when there is exchange in team members.
I've be... |
I'm working on an application where I need to save basically :
CreatedBy (FK to the person table)
CreatedDateTime
UpdatedBy (FK to the person table)
UpdatedDateTime
Right now I have these fields in all the tables in my database.
But I feel like there should be a better way to do this.
|
I have 3 Lambda functions that do very similar things: scrape data from different sections of a website.
Each function returns a collection of objects that have similar properties. The method of fetching of the pages is all the same throughout all 3 functions, only difference is the HTML elements that are being scraped... |
This video mentions the following:
What does it mean for the DMA controller to be granted the data bus control, does that mean the CPU cannot use the bus to access memory and IO devices until the DMA controller re-grants the data bus control to the CPU?
|
I was recently watching a great Computerphile video on passwords in which Mike Pound brags of his company's supercomputer having 4 graphics cards (Titan X's, to be exact).
As a numerical simulation enthusiast, I dream of building a desktop solely for simulation work. Why does Mike Pound measure his computer's computati... |
I am an amateur developper and would like to share some of my code via GitHub or GitLabs.
The problem I am trying to resolve is that I have a configuration file with my real credentials (used during development) and would like to provide a generic one (with placehholders for the credentials) -- all this without changin... |
I'm communicating with a device that's connected to the computer via com port.
The device accepts certain predefined commands in order to interact with it.
I'm essentially creating a more abstract API on top of the one provided by the device.
I encapsulated the charactersistics of the Commands I use, so that I can just... |
Encapsulation tells me to make all or almost all fields private and expose these by getters/setters. But now libraries such as Lombok appear which allow us to expose all private fields by one short annotation @Data. It will create getters, setters and setting constructors for all private fields.
Could somebody explain... |
i am working on a SaaS project that provides some services that people can call via API. My problem is how do I build the billing algorithm. I want to charge on every call to the service.
Now I'm looking for ways to make the call faster and I fear adding a billing algorithm to would make it slower. Because the billing... |
Relatively new git user here, so just trying to figure out the best way to keep my project as 4.0 and 4.5.2 framework variants in parallel. Maybe this shouldn't even be done within git? Just create a completely new/separate project that uses the 4.5.2 framework as the target and start a brand new repository?
Thoughts? ... |
This is a simple question, but one I've never seen a definitive answer for:
In the majority of the world that has postal codes, is it safe to assume that given a postal code, there is only one time zone associated with that postal code?
Or alternately, even if it it's not safe in principle, has there ever been an act... |
I'm making a blackjack game, and I want to take my cards images and give each a value for the game.
I'm not sure how to determine their value. Should I just do a big switch statement with all the images names?
Or maybe should I check for contains with a big if statement? Like if the image name contains "king", then the... |
I'm trying to solve the following problem in the most efficient way I can find.
I want to trade my items for someone elses items, every item have a price and a value.
I want to maximize the value of the items I trade, so for example:
My items:
Banana, P: 10, V: 5
Pen, P:3, V:1
Paper, P: 1, V: 1
Their Items:
Phon... |
Suppose I have the following class:
public class Course {
// data
public string Name { get; }
public List<Student> Students {get;}
//...
// logic
public int AverageGrade() {/* do something*/}
public bool ReachedMaxStudents(){/* do something */}
}
I have some operations that interact with t... |
In the code snippet below, I have a class that holds a vector, and a getter to access it. When I compile my code with optimizations turned on, I would have expected that the call to get_value() would be optimized out, and one accesses directly the data. Instead, the process is slow, and a quick profiling shows that the... |
I have a class
public class CertificadoHandler : ICertHandler
{
Type typeAfirmaValidate;
public CertificadoHandler(){
typeAfirmaValidate = typeof(AfirmaValidateCertificate);
}
//testing
public void SetTypeAfirmaValidate(Type t)
{
typeAfirmaValidate = t;
}
public Crede... |
I am thinking how to implement the login of a new web application and as I search the net, most search result as about authentication instead of encryption.
Assumption: The web application is designed for corporate purpose. The web application are going to use REST api to communicate with backend.
The first two search ... |
I have started working on a new project and to my surprise its written by a single developer with almost no tests at all, the remaining tests are either buggy or feel error prone throwing a lot of NullPointerException when anything is changed. To my surprise a release was scheduled just after I started so I hardly had ... |
Why do we need to write same methods in Service Interface, when we just want a replica of DAO Interface.
interface DAOI
{
method1();
method2();
}
interface ServiceI extends DAOI
{
}
instead of below
interface ServiceI
{
method1();
method2();
}
|
There are situations where we can store values in local variables and work with them. For example:
String data;
int a, b;
data = Integer.toHexString(memory.read(PC));
a = ("00" + data).substring(data.length());
data = Integer.toHexString(memory.read(PC + 1));
b = ("00" + data).substring(data.length());
Or we can jus... |
I am starting to get into versions/releases more now with Git and wanted to know if the structure I am doing now is correct.
Right now, there is typically a few feature branches. A few commits from those then get merged into the develop branch for review.
After that I merge them into the master and the package.json ve... |
I have an issue with structuring som data.
The idea is to have some sort of menu card, where you can build your own menu. The different products are categorized into groups, and in some of the groups you can choose between eg. three different predefined 'submenus' - so you would have nested menus.
As it is now, they ... |
I'm currectly reading the book JavaScript: The Good Parts by Douglas Crockford.
The opening of the Chapter 3 Objects immediately confuses me with a (possible) contradiction. I re-read the two paragraphs at least a dozen of times and am still not sure which part is correct, and which is wrong.
I will definitely try thin... |
I have a program that produces a command line tool called GetFood. The source code lives in a directory named GetFood/, and I have a main file that interacts with a class that gets the food. It seems to make the most sense to name the class "GetFood" since it provides all the functionality of actually getting the food,... |
The release method I am talking about is this:
Release code that works with both old and new clients (forwards and backwards compatible)
Release client that only works with the new code released in step 1
Release code that removes the backwards compatibility that was supported in step 1
Example:
Add new stored proce... |
Long story short
What is the best way to design a shared CD for multiple Git repositories (frontend and backend)?
I'm struggling to find the best design for our CD.
The whole picture (The details can be changed)
Frontend - Angular 2 (Javascript), no artifactory.
There will be only a single frontend in the project.
Ba... |
In the Google C++ Style Guide it says:
Preincrement and Predecrement
Use prefix form (++i) of the increment and decrement operators with iterators and other template objects.
When a variable is incremented (++i or i++) or decremented (--i or i--) and the value of the expression is not used, one must decide whether to ... |
I am learning about the PCI bus, and there is something that I am not sure of. A motherboard have some PCI slots to put the PCI cards in:
Now when we say that we have a PCI bus, do we mean that the PCI bus only consists of the devices in the PCI slots, or are there other devices that are not in the PCI slots that are ... |
I'm working on a IT service desk system and I'm trying to figure out how to raise tickets via an email or add comments to existing tickets via email replies. For example something like the JIRA Service desk where customers can open and work on requests from the comfort of their email inboxes.
Currently I have a system ... |
Java author mentions: Threads can simplify the development of complex systems by turning complicated asynchronous code into simpler straight-line code.
Again the book says: Threads make it easier to model how humans work and interact, by turning asynchronous workflows into
mostly sequential ones. They can also turn oth... |
In general, what is the legality of website forking?
I am based in the United Kingdom and intending to host my website on U.S. or Canadian servers.
I am looking at creating a website about automobiles (with original MSRPs and specs) that is a sort of fork of http://www.autos.ca or http://www.parkers.co.uk in terms of d... |
A team simultaneously made several refactorings (to raise system genericity) to the same project with some overlaps (yes, unfortunately, more like "big bang"). Code is spanning representation, application, domain layers and has pretty high code coverage. There are N branches waiting to be merged into the master. Some r... |
I want to make some software which relies heavily on Plugins. I plan on writing it in C++ and will most likely be getting plugins built in C++, Python and possibly Java But most likely C++ and python but since I don't want to rule out any languages that may be slightly more obscure or uncommon. How do I design a plugin... |
If we have an array in Java like this-
int[] arr = new int[10];
Then, it's sorted like this-
Arrays.sort(arr);
Instead of this, if we had a LinkedList-
LinkedList <Integer> ll = new LinkedList();
We'd sort it like this-
Collections.sort(ll);
How can this be explained using design patterns? Why this design and is i... |
According to LSP wiki:
Substitutability is a principle in object-oriented programming stating
that, in a computer program, if S is a subtype of T, then objects of
type T may be replaced with objects of type S (i.e. an object of type
T may be substituted with any object of a subtype S) without altering
any of t... |
I did a lot of reading on popular git workflows including A Successful Git Branching Model, merging, rebasing, and cherry-picking, but I'm still not able to apply all this on how to solve the problem described below. I feel like cherry-picking might help here, but I'm not sure if that's the best idea.
Let's say I have... |
For example a CSV parsing library looks to be the most popular CSV parsing library, yet it only has 301 stars.
C++ is one of the most popular languages yet C++ libraries on github do not look to be very popular?
I realise that some of it is due to C++ being more difficult then many other languages. On the other hand a ... |
I was recently reviewing a few Helper-style "utility bag" static classes floating around some large C# codebases I work with, things basically like the following very condensed snippet:
// Helpers.cs
public static class Helpers
{
public static void DoSomething() {}
public static void DoSomethingElse() {}
}
Th... |
This doc states the following:
If you happen to modify the public API of Angular, API golden files
must be updated using...
Also this commit has the following heading:
fix: public API golden files #16414
I'm wondering what is usually referred to as "golden files". I've googled around and it seems that this phrase... |
Please see the code below, which creates a Session Factory per Unit Of Work:
public int Update(IdentityRoleView role)
{
var role2 = AutoMapper.Mapper.Map<IdentityRole>(role);
ISessionFactory SessionFactory = NHConfiguration.BuildSessionFactory();
using (ISession session = Ses... |
Usually passing data inside a project isn't a big problem as long as everything is written in one language. However things may turn ugly, if parts of the program are written in different languages. For example: A java method suddenly needs to call a method written in python or vice versa. This is of course manageable, ... |
Suppose I have the following requirements:
We organize books by author first name, this might change in the
future.
When ever an Author we carry at our store releases a new book, the
Authors previous works are discounted at the managers discretion(i.e
10% 15%).
Storage is done in an SQLite database with the appropriat... |
I'm wondering why all databases seem to store hashed passwords and typical hexadecimal data as char(x)/varchar(x)
MySQL uses latin1_swedish_ci as default character encoding, where each character is made of 8 bits.
When storing hexadecimal data as strings, you're only using 4 bits of those 8 bits you can use, as there a... |
I'm making a self-stabilizing camera mount for a Digital Systems project using Arduino. I plan to read angular position from a gyrospcope and adjust servos on the mount accordingly to keep it level.
I've found that the gyro I'm using only reads angular velocity. I've only taken Calc 1, which was three semesters ago now... |
I am trying to understand how the Base Address Registers (BARs) in a PCI card work, this is how I think they work:
Each function in a PCI card have 6 BAR fields, and each BAR field is
32-bit in size.
The PCI card manufacturer will write in each BAR field how much
memory it wants the Operating System to allocate, and e... |
Our company buys second hand valuables (item) from clients and resell them for them. In order to do the client comes to our site and ask for a shipment he may choose the time that the delivery man comes to collect the valuable. If he does not choose the time a salesman calls him and arrange the time for him. It is also... |
Im working on a application that uses camera motion detection to determine changes from high to low level of motion and vise versa.
The motion detection algorithm returns a single score value for every frame of the motion at about 10-30fps.
What i need is a way to accuratley determine where these changes changes occur... |
Should messages that will be shown to the client be resolved in the client-side or in the server-side? Any design (dis)advantages that you can think of between the two approaches? If the system maintains sensitive information and different sets of information is maintained by users with different sets of authorities, w... |
This is an example of what I want to do via code. I know you can use jump point search to easily get from the green node to the red node with no problems, or even A*. But how do you calculate this with warps.
In the image, you can see that it only takes 8 moves to get from the green node to the red node when taking th... |
I have a NoSQL DB with parts of my data denormalized and duplicated. For concreteness, let's say I have:
A document set called "people" containing full specifications of people.
A document set called "votes" containing outcomes of voting rounds in a certain organization. Each vote document has an embedded list of peop... |
While studying for Data structures and Algorithms, I noticed that there is a pattern/group in which every question falls into.
Example - Given this, do/find that - Category 1. use these methods/techniques first and then approach it.
Similarly for another set of questions.
Do we have a list of patterns which we can u... |
A while back I wrote this answer to a question on how to avoid having a getter and setter for every mutable variable. At the time, I had only a hard-to-verbalize gut feeling that this is a Bad Idea, but OP was explicitly asking how to do it. I searched here on why this might be a problem, and found this question, whose... |
I am working on a multiplayer collectible card game. Server side is node.js + websocket.io. I am now considering which database to implement.
I got really intrigued by MongoDB, mostly due to the fact that I can exchange JSON between DB and my application and also because I can describe entire game state in one mongodb ... |
As mentioned by Java_author,
When defining which variables form an object's state, we want to consider only the data that object owns....
In many case, ownership and encapsulation go together— the object encapsulates the state it owns and owns the state it encapsulates....
A class usually does not own the objects pass... |
I'm refactoring my desing to use a service layer - however I'm confused about how you would pass arguments, when it's only allowed to update certain fields of the entity. For instance I have some fields which are only allowed to be set at creation (meta data). But every examples I see about service layer takes the enti... |
Pretty straightforward fundamental, albeit naive, question:
Would having 4 states per "bit" rather than 2 mean twice the storage space? In case that isn't clear, I mean as in if every "storage structure", rather than only representing 2 values, (base 2 : 0, 1), could represent 4 values (base 4 : 0, 1, 2, 3).
|
I have made a custom DialogBox that accepts a key in the constructor then sets itself up based on the key.
It functions as a box for adding editing or deleting objects depending on which key is passed in the constructor.
For example, if the ADD key is passed then there are TextBoxes to allow editing of parameters for ... |
I'm trying to develop a small solution with the possibility of user authentication. Because this will be later hand over to other developers, i want the first iteration of the solution secure as possible for user data.
After reading some stuff about security and hashing, i'm decided to store hash + salt in a single fie... |
I am developing a web based vehicle tracking application. Clients buy GPS devices and the company I work for mounts it on their vehicles. The client then gets a user name and a password for the software and this is how he is able to monitor his fleet.
However, when the company started to grow some clients want to mount... |
In a wpf application, a Model object is created either from scratch or deserialized from some .xml file. To create a connection to the ViewModel, the following method (on the Model!) is used by the application:
class Model
{
public override UserControl View
{
get
{
if (_view == null)... |
Recently, I started to work on some legacy system. People that developed it, came to an idea to store list of strings in single field of database table. Lets say that it is an identifier for object that does not have any representation nor data in database. The range of that identifiers will be relatively small in prod... |
XML is labelled tree, a special case of graphs. So, why there are separate XML databases and why is it that XML is not stored in graph databases? At a first glance it seems so easy - one should map XML parsing and storing operations to graph database insert/update operations and one should translate XQuery queries to t... |
Let's take Spring web socket (with tomcat) for example.
Does Web Socket blocks thread while keeping the connection between server and client? (For example, connection can last 2-3 hours).
(
Does web socket uses thread the same way as regular http request does (e.g., blocks/owns thread while performing the requests)
)
L... |
I am perplexed by comments under this answer: https://softwareengineering.stackexchange.com/a/358851/212639
A user is arguing there against the use of getters/setters and properties. He maintains that most times using them is a sign of a bad design. His comments are gaining upvotes.
Well I'm a novice programmer, but to... |
We have an application using a bunch of services. As soon as the application is launched it should call a webservice method, "RegisterMachineSession". In this method we accomplish some basic work that should be done before any other service call. For example, we load in memory a set of parameters associated with the ma... |
Let we have a (finite or infinite) directed graph and a start vertex. For each vertex we have the set of edges from this vertex totally ordered to specify the traversal order. Let we also have a set P of "preferred" edges.
I want to traverse this graph. This could be accomplished as either depth-first or breadth-first ... |
I'm developing a program where twice I've found the solution to a problem was to use hash tables with iterators as keys and some other arbitrary type as the value.
I found my self using this pattern in initially to deal with two data structures affecting one another, but not being coupled in their own right. In this f... |
I have the following abstract class which implements the "Allocator" concept, using policies and traits to customize behavior:
#define FORWARD_ALLOCATOR_TRAITS(C) \
typedef typename C::value_type value_type; \
typedef typename C::pointer pointer; \
typedef typename C::... |
I know this is a common question, but I haven't found another that solves my doubts.
Usually, if the project is small, I've persistence annotations in the same object that represents the domain object. This allows to load the entity from database and keep all the setters private, ensuring any instance is always in a va... |
I've experienced cases where it would be valuable to restrict access to the API of external libraries and frameworks to prevent negative consequences in the system.
For example, in a SharePoint application it might seem natural to call spList.Items.GetItemById to get a list item, even maybe in a loop, without realizing... |
I was wondering where to do/put calculation of fields to be calculated from other data. Yes, I am talking about computational field. Also the computed data needs to be saved in database. So..
Weather it should be done at Database or by some external code like a windows service. ?
Let me put my need/scenario:
I am dev... |
I know that in C code using L after a number tells the compiler that the respective number is L.
However I do not see any practical use for this. Do modern compilers still have a use for this language construct?
If there are still use cases what would be those cases?
|
I'm writing a class that read lines from a file, process them, store them in an accumulator and when it reaches a threshold bulk inserts in a SqlServer database. Like this:
class FooImporterToSqlServer
{
private string ConnectionString { get;} //initilized via constuctor
private AccumulatorCollection Accumulato... |
I'm having a design issue in my REST api, where I have a resource Device, which happens to represent an IoT device, can be partially updated using PATCH, but some of the things that get updated will begin a long running job.
For instance,
Here is class Device:
public class Device
{
public int Id { get; set; }
p... |
Background:
Currently I am working on a C++ project. It's for business use, so this project is not open sourced. However, this is a project with a fairly large code base (around 10k lines of code) and a couple of external linked libraries and binaries. The problem is nearly 80% of the code base is written in C style ra... |
I am working on a medical application which will be implemented for USA patients and health providers.
I want that there should be only 1 record of a user without any duplication. And I believe that putting a unique constraint on email across the application solves this problem. Mobile number, address, and name are su... |
I was reading about code architecture and the MVC/MVVP paradigm. Ideally, we should have the model as a high-level policy/component where it should not know or directly depend on other components, such as the view. Essentially, one of the roles of the controller is to send inputs to the model and thus has the model com... |
The site I'm building currently has three different regional versions (Australia, Germany, rest-of-world). These will be deployed to seperate urls.
It's a static site, hosted on s3 using react. The three versions share 99% of the code and use the same assests (images, video) but have different text and possibly an ext... |
I need to convert a large number of XML files into JSON. The XML files all have same structure, and differs only in data that they contain.
I could write a basic C# utility that would parse XML and then create JSON file. However, since all JSONs would be same in structure (since all XML are same), would it be better t... |
I have a large data set (more than 3 Million distinct data points that have 6 integer numbers). I want to compute the shortest route in terms of hamming distance. (amount of numbers that change between two data points, meaning that the distance between two points can either be 1, 2, 3, 4, 5 or 6).
Using even nearest ne... |
I have currently an application that have various forms that are basically about scanning some barcode/RFID tags and displays the List.
As such I have some generics components and even a generic sub forms used by others forms.
Basically this form contains :
A top bar with some labels about how many objects were scann... |
Relational database management systems can’t have M:M relationships, so before converting a data model to a database in Access, SQL Server, mysql, or other relational DBMS, the data modeler must solve the M:M into something else.
when drawing the er diagrams what is the correct option regrading many to many relationshi... |
The company I work for now doesn't implement continuous delivery yet. We still deploy the project manually to server, file by file. Which is best practice: to manually deploy one project artifact for each deployment or keep doing the file-by-file deployment?
|
In my company, there is a KPI about code coverage. We measure results by code coverage percentage.
So we combine code coverage result of unit test and end-to-end test together.
Does it make sense to do this?
|
We always used C# to query Active Directory, recently we need to add a patch to some code and it would be easier for us to query Active Directory straight from SQL DB as then we won't need to make any change to our code base other then stored procedures.
I got no clue how it would be seen in world of best practices, ... |
I've been learning some C++, and often have to return large objects from functions that are created within the function. I know there's the pass by reference, return a pointer, and return a reference type solutions, but I've also read that C++ compilers (and the C++ standard) allow for return value optimization, whic... |
Im studying about software architecture but Im with some doubts. Because for example if you dont have any or much experience in developing a application how can you build an useful architecture for a application?
For example if we already have the requirements phase for a web application like a ecommerce app where we ... |
I do believe that my question is similar to: Is it OK for interfaces to depend on concrete classes? and see/understand what the answer explains about how the dependency-inversion principle should be followed. But I am interested in a slight variation of this question. Would it be acceptable to define an interface conta... |
I am curious to know why does the function clock() only returns values in increments of 10,000 and is not able to return values in between.
I have the following code:
#include<iostream>
#include<time.h>
#include<stdio.h>
using namespace std;
int main()
{
int a;
clock_t clock_start;
time_t start1;
time(... |
Currently we are developing the data access layer of a CRUD application. We have the following structure:
We have business entities which are used outside the data access layer to perform the business logic.
We have DAO entities which are used in the data access layer to store the data in our database. These entities ... |
I've read a lot of definitions of abstraction and how it is achieved in programming languages such as Java and C++ using interfaces (Java only) and abstract classes.
I understand that abstract classes and interfaces are required to allow multiple classes to provide their own implementations of the abstract methods and ... |
I've implemented a rule engine like this:
public interface IRuleEngine
{
List<ValidationMessage> Validate(param1, param2, param3);
}
public class DefaultRuleEngine : IRuleEngine
{
readonly IList<IRule> _rules;
public DefaultRuleEngine()
{
_rules = new List<IRule>()
{
new ... |
Our code base is growing for 20 years now. We are about 10 devs + sqa working with 500kloc. Some time ago a small team of us (2 devs, one from sqa) started working on an automated test program. Currently one run takes 11h and is somehow an integration test. We are working on it to get this down and reduce false positiv... |
I'm currently working on a large application (a hundred libraries, several thousands classes) with several entry points (MVC website, webservices, some background running agents, job schedulers...).
Most of those entry points use a non negligible part of the core services (I'd say around 50% at least).
I know from cred... |
My team is developing a system with embedded and Windows components. Currently we have seperate repositories for the Windows and embedded platforms.
The rest of the team have concerns that there is not enough visibility of the current branch status to make assesments about user story completeness. The goal is to perfo... |
NOT ASKING FOR CODE TO ANSWER TO THIS SPECIFIC QUESTION, ASKING HOW TO APPROACH PROBLEM IN GENERAL
there's a question on codefights that asks to find all unique sums of two arrays, one size, the other quantity.
I'm using a cartesian product to determine all the possible permutations. This seems to be too much overhead... |
I've been working on implementing a customer-facing REST API at work the last few weeks. Although there's not yet a requirement for it, I think it'd be really nice to have analytics for this.
For example, to track how many requests are being made by which client, etc.
I'm planning on creating an analytics app over the ... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.