instruction
stringlengths
34
19.9k
I have an REST API endpoint which the JSON response looks like: { "products": [ {"id": 1040, "price": 2.95, ...} {"id": 4545, "price": 3.95, ...} ] } One of my colleagues suggested that I should add a key for each item in the list. He said it would make easier to browse the browse the API. The ...
I have a bit of a dilemma. We are choosing our DBContext using a dynamic builder. This is done because in the current database structure we have a separate server for every "Customer". All of these Customer Databases use the same model so they are all exactly the same structure. Enter picking the context to use with ea...
TLDR; Where and possibly how should I implement scope based logic in the example code? I have got a ASP.NET Web Api. The Api uses OData (on top off REST) for data endpoints and OAuth 2.0 authentication. Now I want to add functionality to handle an Access Token in several different scopes. Some of the scopes are: U...
One of the things I seem to struggle with frequently is the need to deploy a software application to test the database interaction. More often than I'd like, I have a syntax error or typo in my sql statement that triggers a runtime error when the statement is invoked. In some of these projects, there is a very large n...
I have seen numerous projects have a file named commons for example: commomns.go I was wondering, why was this convention adopted and what did the meaning of naming a file or a package or something as commons?
I am doing a small software project on my local PC. I'm the only person working on this. I'd like to back this up to the cloud every day so that if anything happens to my HDD I have a various copies going back in time. I have a box account although that seems to want to sync continuously and with constant file changes ...
I've noticed that when I load/store large data files in a binary format, the program runs much faster than if I load data from an ASCII encoded file. Why is this the case? The data in my case is plain, with limited parsing involved other than read() or fscanf().
I'm often told by my friends and colleagues that I use way to much whitespace. I guess I do use a little too much whitespace. I often add a line break almost after every line and large blocks of whitespace, often 3 or 4 lines because it helps me see what I've written and understand what I've written when I look back on...
My condition: A WCF service which is self-hosted and it's on a Win8 Machine. Client is a WPF Program on another machine. Then I follow the article on Codeproject about how to set X509 certificate for WCF. Problem Description: Communication between Client and Service was OK when they are on the same Machine. When I ...
The title says it all. I'm a .NET programmer, working mostly on WPF applications with C#. But I need to be familiar with latest web development technologies, JavaScript, HTML5, CSS, ASP.NET MVC, latest WebAPI, Azure and other non .NET ones. I want to work on Windows Store apps & Windows Phone apps. I want to be an effi...
Being a small department of developers, it's not uncommon for us to outsource projects. We have a set of companies that we really like to work with, very reliable and good local people who appreciate the work. This has happened a couple times, most recently today: We receive a project, set it up in our environment, an...
I am using HMAC to hash some data before inserting it in a database and currently I have my key as a static field. Just wondering what the best practice regarding storing the key would be. Is having it in code good enough, or should it be in a configuration file. Thanks!
Python is my first programming language, and I'm learning it from "How to Think Like a Computer Scientist". In Chapter 5 the author gives the following example on recursion: def factorial(n): if n == 0: return 1 else: recurse = factorial(n-1) result = n * recurse return result I understand t...
I am writing JUnit unit tests for my classes. Is it better to have a separate class for each method, or have just one test class for every actual class?
For example I have a server [c#] and 4 clients. When the first client sends a request to the server I want to push a notification to the other 3 clients that they should send a request to the server with some required data. After I receive requests from all clients I want to send the same response to all of them. What ...
In my thesis, I want to show the structure of the program, like this: > Menu --- Settings ---- Audio ---- ... > ---- Video > > --- Perform ---- Calculation > ---- Video demo You know, like a map for a website, I would like to present a tree for the menu. But does th...
I am creating a solution where I essentially put all rules regarding communication with customers (including automatic invoicing, reminder emails, welcome emails, etc.) into a Google Sheets and use Ultradox to create emails and PDFs based upon Google Docs templates. For the three automatic emails I have currently imple...
If I write a C program and compile it to an .exe file, the .exe file contains raw machine instructions to the CPU. (I think). If so, how is it possible for me to run the compiled file on any computer that runs a modern version of Windows? Each family of CPUs has a different instruction set. So how come any computer tha...
We have a messaging gateway in AWS (Amazon Cloud) that comprises of a number of nodes (Linux servers) responsible for receiving, routing, despatching and escalating messages (emails, SMS' and voice calls). They all talk to a backend MySQL database on a dedicated machine. Every few minutes we run a maintenance script - ...
I'm being asked to implement IDisposable on objects that are 100% managed resources, which contain no streams, and no large resources. I understand the importance of properly disposing of large resources and unmanaged resources, but what about the other side of the equation? For an object that doesn't benefit from impl...
I have a college degree in CS, and learned about Java and OCaml. Java was used as introduction, and in most CS classed, except the theoretical ones. OCaml was part of learning a different programming paradigm. Since OCaml wasn't a successful entry in my CV, I became a better Java programmer. Also, most jobs are for Jav...
Right now we use a very simple system for version control. We have a completely flat master repository for our entire product line. As our codebase grows and we add more products to the product line, this starts to present some serious drawbacks. We'd like to move away from this, especially with out flat style, but ...
A constant pointer is a pointer which points to a fixed memory location throughout.The question is how do you ensure that this behavior is ensured without using the keyword constant while declaring the pointer in a C program.
I am pushing my project over to Visual Studio Online in order to have some source control. I am developing this project by myself. I have never used Scrum, Agile, nor CMMI before, and the detailed description I read at http://msdn.microsoft.com/library/vstudio/ms400752.aspx is assuming a lot of knowledge. (It makes no ...
I need to design a 'queue' of jobs (in a a very much UI oriented application) that can be run by a user and I need some other thoughts to pick optimal approach from ground up. My jobs can be in a different states (imported, sent from elswhere, created by user, even to be just simulated with their imported recorded prog...
I want to build a system which uses dictionary of many different language. There are 2 options: Build 1 central dictionary Table & each language is identified by langType (ex 1 for German & 0 for English): CentralDict word - meaning - langType car - .... - 0 auto - .... - 1 or 2 separated Tables EngDict word ...
If My WCF service have big number of clients through the Internet,then whether should all of them share the same Client Certificate(X509)? And if their certificates should be unique , what should I do on the WCF to identify all the certificates? Last question: Must I import the server-side certificate into TrustedPeo...
I have been programming java for like a year or more, and i have always used the this and super keywords. And yesterday my mate read one source of mine, and told me not to over use it unless you are overriding the method. class A extends JPanel { public A { super.setSize(400, 400);// instead of not using ...
I have an application that basically consists of a lot of screen so user needs to navigate a lot (like go from A>B>C>D) etc. I have been thinking how to implement this (mainly hold the structure of the menu) as it needs to be on-screen menu (custom, no menu strips etc.) and did not find any solution. Now I realized I c...
I'm creating the architecture for a new embedded project. The system has some inputs that go to wildly different outputs. The whiteboard pattern is very useful for this (see Listeners Considered Harmful: The "Whiteboard" Pattern), as it decouples the input component from the output components (a 1-to-N relationship). H...
I've read on stackoverflow explicit warnings against using eval() to create objects. The reason that seems to be given is that malicious code could be injected and blindly created objects could compromise a system. Isn't this malicious-intent argument invalidated by the consenting-adult argument, though? Some sampl...
Generally speaking, is it better to make all the functional parts or get UI working first - or a mix of the two? Assuming you're working on something large, is it generally accepted practice to get all the functional data harvesting blobs working before any UI, get all the UI working one piece at a time as you go, or...
I've developed some software that allows my users to attach a blurb to some non-language specific information: Pseudocode model: item(): ID creationdate byline //Only one byline for the object description //Only one description for the object faq: faqID question answer itemID //ForeignKey So this is b...
I'm trying to tidy up the Git repositories for the few sites that I maintain. For each site, I usually create a separate branch in the repo that holds a "maintenance page" or "holding page", which I checkout if I need to take the site down for any reason. This branch is usually called maintenance_page. Normal developme...
I'm using multiple third party javascript libraries in my website, and right now I'm keeping each third party library as a separate .js file, with its own <script> tag. But I would like to use the Closure Compiler with Advanced Optimizations. This requires that I either concatenate all the javascript in my website toge...
I'm reading a relatively 'friendly' and simple book about compilers named "Let's Build A Compiler" (originally a series of articles). The compiler written in the book generates instructions in some assembly language (68000 assembly). Since I don't know this assembly language, I decided that my compiler will also genera...
In the chapter of Professional JavaScript for Web Developers on OOP, Nicholas Zachas describes a JavaScript inheritance pattern which he refers to as combination inheritance. The basic idea is that methods are inherited via prototype chaining; whereas parent properties are passed on to descendants by calling the parent...
I have general understanding that what thread safety means , but I don't know much about threads in context of a java webapplication. I am just curious to know that do I need to concern about thread safety while working with web application. Can their be chances that my web application will cause some problems if I hav...
I'm working on a WPF application, trying to stay strict in separating View, ViewModel and Model. My application has a few different views in a relatively flat hierarchy. There is one view for editing something we call a substance, and one for classifications, where each substance has a number of classifications. My que...
I have an object, which has an event which in turn has subscribers. I know that the subscribing objects won't get GC'ed since the delegate they stored for the event is connected to them, thus keeping them connected with the object graph, until one explicitly unsubscribes them. This is only logical since otherwise nothi...
I have an external thermometer connected via USB that is controlled by my SW. Different parts of my system will use it but never at the same time (all in one thread). However, it is a single device communicating over an established connection so for some reason I think either its method (GetTemperature) should be stati...
I've recently started working on a legacy application that frankly doesn't do all that it should. It's lacking a lot of features, has barely any administration capacities and doesn't check half the data it should. As such, it's very easy for users to do something stupid and get stuck. "Oops, I added this item of the wr...
All real computer hardware works in parallel. So why most emulators of retro systems (like NES) are single threaded (or I'm not right?)? You have main loop and you counting CPU cycles and after certain cycles activating other hardware like PPU. Same thing applies to IBM PC and (MDA/CGA/VGA) emulation?
I am working at the client-side part of a web application, that is responsible for getting answers from users for specific questions and storing and restoring them from the database (or cookies) and I am running into the issue that updating the answers from the db will also trigger saving them again (because the same m...
The first compiler was written by Grace Hopper in 1952 while the Lisp interpreter was written in 1958 by John McCarthy's student Steve Russell. Writing a compiler seems like a much harder problem than an interpreter. If that is so, why was the first compiler written six-years before the first interpreter?
Background I'm trying to decide the best way to manage a change in requirements. Currently when an admin is assigned to a ticket, the ticket header record is given an owner and the ownerID field is updated with the value of the id which corresponds to the record in the TeamMembers table. The owner (Team member) is noti...
I am trying to figure out the best way to accomplish this so feel free to criticize my thought process. My tool has different locales and each locale can have different settings for the tool. For example, Arizona could have the top 5 stats turned on where as California does not. I pull all of the settings based on the ...
I have a classic Java webapp. It is composed of a database (PostgreSQL), a servlet container (Tomcat) and my code (deployed on Tomcat as a *.war file). I want to package/deploy it using Docker (mostly for testing for now), but I'm unsure what would be the best way to "map" it. My initial idea was to have an app-in-a-b...
I recently used a library from http://www.braemoor.co.uk/software/index.shtml (the EU VAT No validation library at http://www.braemoor.co.uk/software/vat.shtml) in a project at work. It mentions as the license (or something that looks like one): All software is provided as freeware for personal or commercial use witho...
I have labelled the connected components in a binary image and found their areas and bounding boxes. The components are not necessarily filled, and may contain holes. I wish to identify the component that resembles a pupil the most. For this, I would also like to extract (only) their outer perimeter lengths, for calcul...
I work for a company that, in my opinion, should be doing all of it's web development work in a fully agile manner. We have vague, competing ideas about the product at any given time. And we have strict deadlines. So, in the web arena it seems to make sense to operate in as agile a manner as possible. However, I could ...
I'm reading a compiler textbook that compiles to some form of assembly. Since I don't know this assembly language I decided to invent my own simple "assembly language" and implement a basic "virtual machine" which will execute these instructions. Currently I'm thinking how I can implement function decleration and func...
I'm working on an idea that i can't seem to find a good answer though hours and hours of searching, I'm planning a small Canvas/WebGL Application this application will be using WebSockets to talk to a game server for syncing data to and from so think of it as a MMO type service so im planning to have a queuing system...
This answer really made me wonder. I've written CSS before and (usually) I don't really bother to support browsers other than recent firefox and chrome, but in researching I've noticed that, for the exact same CSS property, there are usually at least three different forms which behave identically, and can have the same...
I have been making a website with PHP and I have a few classes, so far none of them really follow encapsulation rules of OOP. Lets say I have a user class like so: class User{ public $username; public $uid; public $date; public $location; public $bio; public $avatar; public function __co...
I want a function that will interpret a string as a strictly unsigned integer, failing when the string overflows, represents a negative number, or does not represent a number. strtoull() does set errno to ERANGE on overflow or EINVAL for a string that does not begin with a number, but accepts negative numbers as valid....
I'm working on a server for a very large (feature wise) MMO. After some bad experiences with breaking changes that caused bugs weeks down the line, we'd like to add unit/automated/regression tests to our project before we get much father (we've implemented approximately 5% of our requirements). We haven't really used "...
I want to design an API backed by some database (doesn't really matter which, but to make the discussion more interesting, let's say it's Mongo - explanation below) which sends data to a client. The database contains several types of records. Some of them reference other types of records. It's not uncommon for a record...
I am learning system design (on my own) and still I am not clear on a few things. Assume there is a simple application with a front-end and a database for storing of the data. In the system architecture diagram, will there be only two parts (UI and DB) or should I include some UI modules for calculations, for example? ...
I just started working on a project where I am trying to implement some backend logic which includes creating a data model for the given problem. Here is a problem I came across and I am curious what approach would be more suitable for tackling it. Model: There are various users in the system with different rights and ...
Most VMs have a "call stack" to keep track of where to return from each function that was called. This is often simply regarded as "the stack". However often a stack is needed for operations that aren't related to function calling, such as performing arithmetic. My question is: is the same stack (i.e. the call stack) u...
Over the last couple of months I have been diving into coding standard IfSQ. As a part of this IfSQ standard, a rule is to not use Magic Numbers. While I don't have a problem with building this rule into checks as FxCop or StyleCop, I am confused as to what actually IS a Magic Number. According to Wikipedia there are 3...
Sorry if my (simplified) example is too broad. Given this model (written in C#): class Ball { } Let's assume that a ball can be launched. To implement this feature, I can define something like: class Ball { void Launch(); } or something like: class BallLauncher { void Launch(Ball ball); } In which situations...
I'm reading a book on TDD: (btw this question has nothing to to with TDD) link to the book on amazon Author often mentions/uses Service Classes For example we would have a Person Object Person would would have: - a "regular" class for deifining the entity Person - a data access class (lets say we have a db for data...
I want to create tree-view for display or show family member's relation. For this I created 3 tables i.e following. familyDetails->[f_id,fname,lname] relations -> [r_id,relation] .....//e.g father,mother,son,etc. familyRelations ->[fr_id,fk_f_id1,fk_r_id,fk_f_id2] //to show A is Father OF b. Here problem is, if I...
I'm working on a Java project in which we want to have data collection plugins that collect data to be processed by one or more data aggregation modules. The plugins will all written in-house. Say for example we have data collection plugins A, B and C and data aggegration module X. The modules A, B & C input data into ...
If I create a game in C++ on a mac using a library which is the same for both windows and osx, will the game be playable on both windows and os x or it will only work in os x because I done it in Xcode? Is SDL a great library to do your first game after learning the basics and syntax of C++ (I found syntax to be close...
I need to do some very specific web search, but in order to do that I need to know what's the technical name of the category/type of variables like NEW, OLD, USER ( the could be more ) that you can accessed inside a trigger in a RDBMS without having to declare them. The question I want to post is "does <RDBMS> support...
I am a bit confused by the choice of Haskell syntax for type definitions, like in data Foo = Bar Namely: does the equality sign here really mean an equality in some subtle sense, or is it just a random notation choice? For example, in foo x y = bar y x the equality is really an equality: if this line is present, foo ...
We are implementing a RESTful webservice that will allow client applications to POST documents to it and it will store the document returning a unique identifier in the response. The clients will mostly be Spring MVC applications, but do not have to be. The two client applications that we are currently working on have ...
During a meeting regarding the rollback of a third-party SDK from the latest version it was noted that the our developers already flagged in the commit history that the latest version should not be used. Some developers argued that this was a bad practice and it should have instead been noted either in the source file ...
I'm fairly new to Collection+JSON. I have a bunch of questions regarding Collection+JSON and user operations. Use Case Having user permissions in a Collection+JSON response would be useful in telling the client what operations can be enacted on a particular object. As an example, it would allow the client to know which...
I will try to simplify my problem. Let say I have a collection (more specifically a List) with different types of elements, for explanation purpose let say we have objects "Person" with different age of birth and an ID. I will represent a person like this: {<id>,<year>} At some point, I want to get a sub list of all th...
I was recently working on some prototype code in Python. The code worked great, then I realized that I needed a little more feedback from one of my functions so I changed the return statement from return x to return (x,y) Then going back to refactor existing code I realized that unless I search for invocation of this...
I am using EF 6 as my ORM. I am trying to decide how to handle CRUD failures. Option 1: Use exceptions (custom or built-in) to inform the web layer that an item didn't correctly save. Handle the exceptions at the Web Layer as either error messages to the user or to trigger an AJAX post to try again depending on the rea...
My product owner wants us to report more information on the state of the product when a user contacts customer service through an in-app form. The form eventually results in an email being sent to a customer service email list and handled elsewhere. The part I'm struggling with is how to augment my existing iOS projec...
For creating a large Django project with many apps, my first initial thought was to used Class Based Views (as the Django tutorials seem to emphasize). However, I noticed that due to a lot of the customizations to each app (multiple forms on each page etc), it became very tedious and was much easier to just implement F...
In one of many anti-OOP rants on cat-v.org I found a passage by Joe Armstrong raising several objections against the OOP model, one of which was the following: Objection 4 – Objects have private state State is the root of all evil. In particular functions with side effects should be avoided. While state in programming...
I'm a long-time Python user. A few years ago, I started learning C++ to see what it could offer in terms of speed. During this time, I would continue to use Python as a tool for prototyping. This, it seemed, was a good system: agile development with Python, fast execution in C++. Recently, I've been using Python more a...
I'm trying to learn about Agile methodologies through the Head First Software Development book and after reading about it, I've tried to apply the concept of User Stories to a recent mini-project (set of new features added to an existing application). Besides the fact that I have a hard time not thinking in terms of "t...
What are best practices when it comes to designing a social network app for Android (possible iOS port later depending on uptake)? It's my first time architecting something this scale from scratch, and I'm probably already making mistakes in the design phase. What I already have in mind is to: Have a Postgresql backen...
I am creating an interface and would like the implementer(s) of this interface to throw exceptions in the case that something goes wrong. Let's call the implementer a plugin. I have a director which can call any one of the plugins. Rather than each plugin throwing it's own random exception, I would like plugins to thro...
I know C++ had private variables inside classes, and Java, C#, Javascript, and others picked up on that and ran with it. Aside from variable scope, most languages before that just made everything visible. Certainly in assembly, all of memory is accessible (except as limited by hardware). But was C++ the first language ...
So, this is pure curiosity. I've heard the term 3rd party, as in, "3rd party library" for quite a while. I wonder why we say 3rd and not 2nd (or 4th)? Who are the first and second parties and where did the term come from?
I am currently following along a youtube tutorial here and from what I understand we are starting out by creating an engine to run the game. Should I be able to implement all of this by myself without outside help in the future or should I just make sure to have an understanding of everything that is going on? Would a ...
I think I understand the theoretical benefits of automated testing, especially unit testing. However, I'm not sure what the optimal amount of testing is when the project is a non-critical, rapidly developed (and deployed) web app with a reasonably large user base. My current reasoning goes like this: Most of the cor...
I have the following domain models: public class User { public int Id { get; set; } public ICollection<Product> Products { get; set; } } public class Product { public int Id { get; set; } public decimal Price { get; set; } } My User entity has a collection of Products, and no Product can be created w...
I am working on the design phase of a paper folding project. I have a few queries in this. Part of the problem statement says " A web can contain one or more ribbons in it. It can also contain a group of ribbons folded together inside it." How do you model the association for this? I found two solutions i) Maintain ...
In C# .NET there is two main possibilities to serialize and object. Implementing the ISerializable interface? Using the [DataContract/DataMember] serialization attribute of WCF? What are the differences of this two possibilities and what is the better in term of execution time.
For the backstory, I'm developing a GUI application in C#/WPF. I already had in my code quite many instances of <ComboBox ItemsSource="{Binding Items}"> <ComboBox.ItemTemplate> <DataTemplate> <TextBlock Text="{Binding ItemName}"/> </DataTemplate> </ComboBox.ItemTemplate/> </ComboBox...
One thing that bothers me while I'm writing unit tests of my code is if tests of methods should include validation of the outcome of other methods? Of course, public methods. Let's see a - rather trivial - example: public int Solve(string forumla) { if (forumla.Contains("+")) { return SolveAddition(fo...
Let's say I have an application that has constantly changing data. Changes are so frequent that you basically need to refresh data every time you open some screen and keep refreshing it. Is it worth implementing local database for such application? Implementing database in such application seems redundant because: Dat...
Assume there is a request which is going to look up a list of items from a service which requires authorisation (e.g. it's behind a Basic Authentication domain). If the service didn't require authentication, I would always make this request as a GET (it's idempotent). But because the credentials would end up in the que...
I basically have a counter variable that is decremented and frequently polled. There are three options to implement that, that I can think of: Number 1: private volatile int count; public void Finished() { Interlocked.Decrement(ref count); } public bool Done() { return count == 0; } Number 2: private int coun...
I'm in the process of writing an image analysis pipeline and I've hit a bit of a roadblock. Here's the 30,000-ft view: Images arrive as base64-encoded PNG images over standard input Images are decoded, and processed. I don't think the details are particularly relevant, but I am happy to offer specifics in the form o...
In .NET we've got Resource files which are great for allowing providing translations across your application. In the past I've seen these resource files grow into monolithic unmaintainable lists of words and phrases. What is the best way to avoid this? A single resource file for your entire application? It's easy to t...
Over the last few years, the trend for client-side (browser) applications has really taken off. For my latest project, I have decided to try and move with the times and write a client-side application. Part of this application involves sending transaction emails to users (for example, validate signup, password reset em...
We're a small-medium size enterprise (~50 devs), working on several DirectX 9 applications. (not games) DirectX 10 and 11 both were deep interface overhauls, as DX12 will probably be. We didn't upgrade to any of them, and since VS2013 (now migrating) working with DX9 is getting very inconvenient to say the least - whil...
I am working in Scala/Java. I'm testing the messaging infrastructure of a part of my system that I did several years ago with CXF and Java. More specifically, I'm re-writing the specification of the message exchange. This is because i'm changing few part of it. At the time, I was not using TDD/BDD. Now I'm driving out ...
I'm trying to implement a phone number based login and not sure if I should ask the users for full number, i.e country code + number or just the number. What I have in mind so far: Attempt optimistic login using whatever number user gives. Most likely, it'll come back with a single user match. In case there is a colli...