instruction
stringlengths
34
19.9k
I own a web application that make use of Twitter Bootstrap 3. This eases the design of the mobile version since it brings some responsive features. However, I would like a really native-mobile aspect for the mobile version, but not a native for the Desktop one. I searched..and I found this really promising framework: I...
Our company is looking to introduce remote working as an option for its developers. This book (Remote: Office not required) has been offering some valuable guidance. However one issue that is not addressed is the employment and management of junior level developers. In a remote working environment, how do you ensure th...
I am working on an application that heavily depends on asynchronous data operations. I am dealing with those through promises. However, while my code works, I have the feel that it is getting chaotic and hard to maintain in the future. Assume this: validate().then( // success function(promise){ $http.post('stuff.p...
I'm actually arguing against this, but want to see if I'm out of line. We have a PaymentQueue table and a simple UI. This table is, at the moment, primarily used by the UI and no other business logic. The UI requires data that is only in a subset of possible statuses. One developer put this status restriction in the ...
Background So, I'm developing a project, and I'm writing setup.py script for it, using distutils. I'm using CPython3.3. I use some libraries that have invalid distributions in PyPI, so they have to be installed by cloning repo and running setup.py manually (I've tried many things, both libraries help said I just need t...
Given the class: public class Foo : IFoo { private IBarRepository repository public Foo(IBarRepository repository) { this.repository = repository } public IList<IBar> Bars { get; private set; } } My long standing instinct is to initialise the list of IBar in the constructor: this.Bars = new List<IBar>...
I have my (JSON) API structured like this (which I'm pretty happy with): API Project /_V1 /Controllers V1EntityController.cs // Applies to version 1 only /_V2 /Controllers V2OtherEntityController.cs // Applies to versions 2 and below /Controllers/ EntityController.cs ...
I've recently become quite taken with conditional expressions in Python. Apparently some people consider it unpythonic and whether or not conditional/ternary expressions are even A Good Thing seems to be up for debate -- but I've been digging them lately. x if C else y So far I've noted there are two ways Python will ...
I previously had an issue with my node.js app on Heroku. I added the dependency into my package.json and now it is working. But, is this the best way to do it? { "name": "application-name", "version": "0.0.1", "private": true, "scripts": { "start": "node app.js" }, "dependencies": { "express": "3.4....
What is meant by a step-by-step refactoring plan describing how to implement a certain design? As little as I know about refactoring it regards improving a (UML) design model and has nothing to do with the implementation of it. Therefore I'm pretty much confused by what this question means. Does anyone know and wil...
Consider a hierarchical structure like this directory [ [item_0;item_1;...;item_n] [item_0;item_1;inner_directory[...];item_m] other_directory [...] ] A directory contains An array of strings (delimited by ';' in input data) A map from name to sub-directories (the name ...
I'm writing a basic web API in Java that does what almost all others do: take input, validate it, then do CRUD operations on the DB. I've written several APIs before, and I've pretty much already figured out what constitutes a good response back to the client. However, like most APIs, there are several layers of object...
I'm working with a framework where the fields displayed on each web page are defined in the application database. Administrators can add new fields to pages or hide/completely delete old fields. The logic for each page is in a Java class - sometimes there's a one-to-one relationship between a page and a class, sometime...
Could someone explain this line: In more complicated contexts, such as "+=", a rewrite is performed by doing both get and put. Taken from: MSDN - Property What do they mean by rewrite?Is it a compile-time rewrite or does it induce run-time overhead?As far as I know in release mode properties are compiled to the sam...
Right now I am using Google C++ Style Guide in my C++ code and I was pretty happy with it. Recently I was told that this guide is very bad: it is used internally by Google (I knew that), is outdated, and promotes some very bad practices. So I want to use another coding style. What good and fairly used C++ style guides ...
On python I can group arguments into a tuple, something like def func((a, b, c, d), x): print a, b, c, d, x I was wondering if it is possible to group arguments in the same way on C++, something like: void func((int a, int b, int c, int d), float x) { cout << a << b << c << d << x << endl; };
I'm planning on providing some GPL software to visitors after they interact with an advertisement. This advertisement will generate revenue for our company, so this would fall under commercial usage. I understand the GPL requires us to either provide the source or a written promise to provide the source upon request wh...
Functional Programming in Scala explains a side effect’s impact on breaking referential transparency: side effect, which implies some violation of referential transparency. I’ve read part of SICP, which discusses using the “substitution model” to evaluate a program. As I roughly understand the substitution model with...
In this answer of mine, I used _t at end of types, which ended at best, controversial. This is the practice I use in my current projects. typedef struct { int x; int y; } point_t; This was intended to be consistent with C types from stddef.h like size_t or ptrdiff_t. However, according to certain comments in m...
Is it possible to rename a portion of code extracted from a Apache 2.0 licensed software, releasing it as a new repository under a new name?
I'm trying to chain a series of methods that are async. I have heard of promises and futures but what I'm looking for is: obj.setup() .do_something() .do_another_thing() .end() and not: obj.setup() .then(...) .then(....) I have come across a tutorial that explains how to do this, but unfortunately...
I have a question about object oriented design that is not specific to Python but since my code is in Python, I tagged it as such. How do I decide which of my classes should be responsible for implementing certain functionality that may affect more than one class? What are some good guidelines >(if any) or consideratio...
Consider the following piece of code class Foo { public: //... bool valueFirstGet(int& value) const { if(this==nullptr) {return 0;} value=values[0]; return 1; } //... private: int* values; size_t n_v...
tl;dr Is it possible to include an external library (and create instances of objects represented within that library) based on some condition? This must be done at compile-time, so separate builds? Background information Warning: Wall of text. If I have some code that requires a link to an external class: using myExter...
As I understand, the idea with Agile methodologies is that you deliver something functional and you deliver it often. The application gets into its final shape increment after increment. But in the early iterations you might build the framework or foundations on which the application will stand so it's something import...
I recently ran across an idea put forth by Jaron Lanier called "phenotropic programming." The idea is to use 'surface' interfaces instead of single point interfaces in computer programs utilizing statistics to winnow out minor errors that would typically cause a "classical" program to catastrophically crash. The two-li...
Background info (May Skip): I am working on a task we have been set at uni in which we have to design a grammar for a DSL we have been provided with. The grammar must be in BNF or EBNF. As well as other thing we are being evaluated on the Lexical rules in the grammar and the Parsing rules - such as if rules are suitabl...
Whenever a new project starts, it usually makes sense to start by committing straight to master until you've got something "stable", and then you start working in branches. At least, this is how I normally do it. Is there a way to immediately start branches from second commit? Does it make sense to do it this way? Obvi...
I'd like some input on how to keep databases that are running on different servers throughout our organization synchronized. We have a registration system of sorts, and when user "John Doe" registers on server 1, this registration information needs to be instantly available on server 2 and 3. Currently, our network adm...
I have a RESTful API that offers eCommerce functionality. One area I'm struggling to decide on the correct implementation is how to process payments. Lets say I have the following URI GET .../checkout/{id}/payment. This resource provides details to the client application of what details needs to be submitted to make a ...
If I'm giving an interview coding question in Java, I can specify the most of the question just by giving a method signature. (Made-up example follows.) public class Table { public String identifier; public int seatCount; } public static List<String> tablesWithEnoughSeats(List<Table> tables, int minSeats) If the...
I was hoping someone might have some ideas on how to create a RESTful web API where models/entities are searchable by a foreign key. I see a a lot of tutorials where the functionality consist of listing all records in the entire model or retrieving a single record from the model by a primary key, but not by an arbitrar...
I'm having trouble designing an inheritance hierarchy. In the figure: Base class: This uses the Template Method. Contains core logic/algorithm that calls virtual/abstract methods Derived types: These classes provides concrete implementation of the virtual/abstract methods expected by the Base. Conditions: I have...
I'm faced with the following problem: I have an array which is produced by the parsing of a yaml file which contains patterns in the following structure. "Programming books" Title: a list of titles Author: "Art Books" Title: foo bar Author: Mrs. Foo Mr. ...
I am developing a C# windows service application, which have different configuration files for development, for production system, for test system, like: Dev.config Test.config Prod.config Now we are using SVN version control system, and configuration files stored in projects directories: -trunk -MyFooService -C...
Currently, I'm using Parse to handle my backend, and I have multiple ways to login -> via regular email/password and via linkedin. Parse has a specific method of logging in requiring username/password. If a user registers through linkedin, I hash a combination of his information as his password, and login through parse...
I am trying to find out how to block a whole area/controller from being accessed by typing url website.com/area1/basecontroller/method1 (this area also contains the views that will be displayed) , while still being able to inherit said controller and use the method from original controller like so website.com/area2/ext...
In C++ a reference argument to a function allows the function to make the reference refer to something else: int replacement = 23; void changeNumberReference(int& reference) { reference = replacement; } int main() { int i = 1; std::cout << "i=" << i << "\n"; // i = 1; changeNumberReference(i); std...
I'm working on a business application (C#, WPF, EF, MVVM). I need to load a bunch of items from database, create view models for them and put them in a window. Is there a way to create the view model in another thread or do something similar to speed up UI? The approximate average time needed to fetch all items from d...
I have to create a flowchart to a C# programm and I am not very familiar with it. My problem is that I do not know if one should represent variables initialization in a flowchart and if so how should I do it. Second problem is that I am not sure about the correctness of my for loop. Here is the flowchart I created tot ...
What's the term for an error caused by executing a block of code before its relevant ajax response has come back? e.g., a timeline: 13:00:01 execute getDataViaAjax(); 13:00:02 execute doSomethingWithMyAjaxData(); 13:00:03 ajax data comes back, too late since I forgot to make the code wait for it... I have a feeling I m...
I need to design a database table that holds the data of programmers work hours. The problem is that I have a compound type - two pieces of data belong to a category. Specifically, the work hours are classified into categories: design, program, test, troubleshoot, etc... and each category is divided into two types: hou...
I would like to write an algorithm which can traverse a graph and hopefully later I can implement it to use for an indoor navigation system. The graph would come from floor plans of a building and the graph nodes represent the building objects such as doors, corridors, stairs, rooms, etc. The navigation system will ac...
I need to realize a database in this mode: TABLE restaurant with "classic" fields of a place: address, street number, phone, website, etc etc etc. I need to indicate also the days of opening // closing. E.g. From Monday to wednesday close, saturday only evening and sunday lunch + evening. So, I did think at another ta...
I've read countless posts on differences between Entities and Value objects and while I do think that at least conceptually I understand how the two differ, it appears that in some of these posts authors consider a particular domain concept to be a VO simply because it is immutable ( thus its state will never change, a...
Let's say I'm developing a web application. My first choice is to use PHP with Fat-Free Framework (F3) and MVC pattern. Next year, I might decide I want to switch to Zend Framework, or maybe even ASP.NET MVC. Does it make sense to try and design my application in such a way that it is loosely coupled to its framework, ...
Okay, so here's how I understand IoC and DI in Web API to work when using Castle Windsor. Note, though, that my confidence that I understand it as I should, though, falls somewhere between my confidence I could best Dennis Rodman in a one-on-one basketball game and my confidence in his sanity. Another way to put it is ...
I know this is common question, but why should a programmer be aware of software licenses as well as extensions and plugins licenses? I'm working in a company which focuses on the business process (Ruby on Rails) and I'm curious as to why they are strict on such licenses in the project development. What licenses should...
Is this user story substantively correct: As a system owner, I want everybody that uses the system to have to log in using a secure password and login system, to prevent unauthorised and random access to system data. And then: As a user, I want to be able to log in with my secure password, so that only I can a...
I am coding a Java program on my development machine. Maven packages this a myjar.jar, and I can run it from the command line using java -cp myjar.jar my.FantasticClass. It uses library somelib.jar. I use Maven, and the project is hosted on github. When I want to run my project on the target machine, what is the best w...
I have a JSON API that includes some discusssions. I want to build a static html site on another server, pages that are built from data on that API. I am more comfortable using Rails than Node. The API is done in Node. The idea is that I periodically call the JSON api to get the data, and dynamically build the html pag...
In the game there are 5 players, each with 8 cards in hand. No other card is present. Using Monte Carlo (MCTS) I run many simulations of the game from the current state to the end of the match. In those simulations adversaries play with very simple dumb rules. When generating a new simulation I assign to them unknown c...
I am plaining to use Ubuntu for developing Android and php application which I will sell in market. As far as I understand Ubuntu falls under GNU GPL license. In this case do I need to make my source code open for all?
This question is about PSR-0 autoloaded libraries and the way main configuration constants should be declared and used. From your point of view (lib/framework developer), where/how should be declared your library configuration PHP constants (such as ESCAPE_SOMETHING, USE_DOM, API_URL, ...) in such a way that your cod...
In the current Cocoa app I'm working on, I've got an object, RecordScheduler, which responds to two types of notifications, "day did pass" and "quicksaving interval did pass". In both cases, the RecordScheduler tells a Recorder to do its recording job, among other things. Now I want RecordScheduler to issue a recordin...
Just trying to get some ideas on what people do for this scenario. We have a system database(SQL Server 2008 R2) that has tables and every table has a field we can call "Deleted". It's basically a bit field if its a 1 the record is deleted, if it is a 0 it is not deleted. The field is not nullable and its default is ...
There is a popular quote by Jamie Zawinski: Some people, when confronted with a problem, think "I know, I'll use regular expressions." Now they have two problems. How is this quote supposed to be understood?
Background: I have a CSV file, which I need to ready and validate each element in each row and create a collection of a class, having valid data. i.e CSV File looks like: EmpID,FirstName,LastName,Salary 1,James,Help,100000 2,Jane,Scott,1000 3,Mary,Fraze,10000 Class looks like: public class Employees {...
I won a bid on Elance and was had a request to fix some css and html issues with a WordPress site. How do I make changes to the document without working on the live site? Do you set up a development environment for every job you get? This would be time consuming on a job that pays very little. I was offered access to t...
Reading this article (by Eric Lippert), it has four arguments as to why you should use sealed, however, I don't understand why we actually need it. Philosophical/aesthetic reasons aside, why do we need to use sealed? I can see how things like readonly from C# or const from C++ actually catch genuine errors. Is there an...
We have data stored in a data warehouse as follows: Price Date Product Name (varchar(25)) We currently only have seven products. Once every business day, seven new data points are added representing the day's price for each product. On the website, a user sees this information on a page load. Analytics shows that the a...
Is checking count/size/length less than 0 necessary in modern languages anymore? For instance, in C# I quote often will check if a collection's count is less than or equal to 0. I assume that this was done in older languages, like C, where you could potentially have a size of less than 0. Is there ever a case where you...
I had worked in the past for a small company developing web applications. Back then the current lead developer, who is also one of the bosses, told me that he is incapable of making a JOIN inside a SQL query. I was amazed how a person who has developed and maintain big ecommerce site is incapable of doing that. Are da...
In java, to print the date we could do either of the following: Fully qualified public class MyMain { /** * @param args */ public static void main(String[] args) { // TODO Auto-generated method stub System.out.println(new java.util.Date()); } } Using an import import java.util...
I am the only one at my company that is familiar with MVC and they are getting more pressure to modernize and switch to MVC for future projects, so I was tasked to create a template to use as a base for any training or as a base for new projects. This is perfectly fine and I'm glad to do it. However, one absolute requi...
We all use if ..else if.. else. But still I'm confused as to why we use else if. Where if does the same thing as else if. So why are we using else if? Any specific reasons behind this? Is there any algorithm where it's mandatory to use else if?
Why do we need the switch statement if there is the if statement? Why can't we use several ifs like if(a==1) do this1; if(a==2) do this2; ... instead of switch (a) { case(1): {do this1;break;} case(2): {do this2;break;} ... } My teacher said that the answer is built on how assembler works, but ...
What is the difference between an ambiguity in a proposed algorithm and an ambiguity in the representation of an algorithm? I have done some research and found out that ambiguity in the representation of an algorithm is when the representation can be understood by a group of people and not clear to another group e.g. a...
I found it's really hard to divide the task of developing a website to a team of people. The problem is a website should have consistent looking and be integrated in users' view. The style and page template need to be shared by all parts. Most of the website is access restricted, the access control system is dependent ...
Does it make sense to write default constructor when it has no arguments, empty body and no other constructors exist? The only benefit I can think of is reducing the risk of forgetting to add the default constructor when another one is created. But this error would show up anyway if the default constructor is actually ...
I came across Instagram's API client written in Python. In their class InstagramAPI, they bind the methods to a function in bind.py. When called, the function returns an instance of the class InstagramAPIMethod and execute the request call. What are the advantages of doing it this way? (over directly creating instan...
To improve some lookups, I am considering the use of Bloom Filters. But in my use-case, the most probable outcome is that the element do exists in the target set. Bloom filters can have false positive, but no false negatives. That would make me check the real (big and slow) storage most of the time because of the uncer...
I have an automated invoicing web app and I'm trying to build in some failsafes and a structure that will, under no circumstance, allow an invoice to be double charged. All things working perfectly, the scheduled task runs and everything charges as it's supposed to. But there are a few scenarios we know of that can cau...
I am working on a new project which will query data from a 3rd party REST API. This is for a real time sports data feed, so the feed only works when a game is actually taking place. Although the 3rd party provides good documentation (XSD, etc), they have no way to simulate a game happening, and so to test code I have w...
Consider the following hierarchy in C++ notation: class A { public: virtual void doStuff()=0; virtual void doOtherStuff()=0; }; class B:public A { public: void doStuff(); void doOtherStuff(); }; class C:public A { public: void doStuff(); ...
I have to write a decent size database, 1GB more or less. I have only taken an introductory semester regarding SQL databases. During the course we learned that the relational model under SQL has no implied order and that therefore when querying we should always have a variable that sets the correspondant order in the ...
I am beginner in algorithms. Last year I participated in Google Code Jam. One of the major issues I faced during the competition was my code was working fine on my test cases, but when I submitted on a large number of test cases, I failed to pass them causing some logical error. So, my question is basically how can I t...
I've been trying to find information online about where WWF 4.5 fits with in an architecture based around an enterprise message queue using central broker(s) (RabbitMQ in particular). It seems like responsibilities overlap a bit since WWF offers the ability to pause-and-resume (persist/restore) workflow instances. I'm...
In Don Norman's seminal work "The Design of Everyday Things", the author coined the phrases and explains the difference between "Knowledge in the World" and "Knowledge In Your Head"; an example of this is a multi-switch light panel that can either incorporate "Knowledge in the World" by being a model/map of the room, ...
I have a part of CQRS pattern implemented using S#arp Architecture like this: public class MyCommand { public CustomerId { get; set; } // some other fields } public class MyCommandHandler<MyCommand> : ICommandHandler<MyCommand, CommandResult> { Handle(MyCommand command) { // some code for ...
I am developing and maintaining a web-based application that's used internally at my job. I am the only developer and so I'm not really using branches; everything happens on the trunk. I do tag releases in Git with the date and time, and I'm starting to transition to using a build number instead of date/time. In the p...
I would like to know what should be the best way to keep data on a server related to the following points: Chat logs Heavy text content User references like amounts of ids (1,4,14,524,23220,...) I'm using PHP and a mysql database but as obvious I know the topics above don't go well into mysql at large scale and maneu...
I have an automated invoicing web app and I'm trying to build in some failsafes and a structure that will, under no circumstance, allow an invoice to be double charged. All things working perfectly, the scheduled task runs and everything charges as it's supposed to. But there are a few scenarios we know of that can cau...
I still don't understand the difference between a native app and web or hybrid apps from the interface point of view. Now, apps such as Twitter, Facebook, etc. Are they native? or web? or hybrid apps? In those apps what is the most code was used? is it HTML and JS? or is it a language such as Objective C or Java? I'm ...
I'm doing it in C++, I can't post the entire thing, because it's gigantic, I'll just sum it up with a simple example.I have: class B; class A { //Members and methods... void DoSomething(B* owningSystem); }; class B { //Members and methods A memberA; } So the problem is, A needs to know about B to use its DoSomet...
for (i = 0; i < 3; i++) { for (j = 0; j < 4; j++) { cout << arr2d[i][j] << "\t"; } cout << endl; ..... Like that for example. Do you read the for loop inward-out (starting from for (j = 0; j < 4; j++)) or outward-in (starting from for (i = 0; i < 3; i++)) Just wondering. :D
I am trying to better understand what would be required for a compiler to be able to make intelligent choices regarding concurrency on behalf of the programmer. I realize that there are many difficult aspects of this problem for instance: Ensuring that there are no race conditions Ensuring that the code to be run conc...
I have a couple of questions about UML. Firstly, how would you show "Use Case Ends" on a sequence diagram. Secondly, if you have an alt in a sequence diagram for "Variable == false", would you need to show what would happen if the variable is true, even if nothing would happen other than moving onto the next method ca...
While studying IOS, i generally come across viewcontroller. That gives me, confusion, if this "ViewController" has to do something with controller ( in MVC ) ? But how come both "view" and "controller" are combined in this terminology. What does it actually mean ?
So, I've inherited one of those "Engineer's Special" spreadsheets -- the kind developed by Mort the Engineer, with lots of hairy VBA and WTF, complicated calculations, and no documentation. Fortunately, most of the primary inputs and outputs are on a single page. Maybe not enough for full test coverage, but a start. I'...
Recently I wrote some (I hope) useful application. I would like to share it with every person on the world, making it open source. I would like to publish the source code as well as binary files (both for Windows and Linux). I used only free tools to write my application: Code::Blocks, MinGW, gcc/g++, Linux Ubuntu/Linu...
I have a File database table with the following columns: Id (PK), Filename And a Document database table with the following columns: Id (PK), Name, Description, FileId (FK) When a user wants to "save" a Document, my client-side JavaScript does it in two quick AJAX calls (in an attempt to be RESTful and save each resour...
How important is it to initialize variables? Does proper initializing avoid memory leaks or have performance advantages?
I have a scenario where I will implement Command pattern like described in this article. Actually from an Asp.Net MVC view, some user will invoke different commands/actions like Start Live Video, Start Live Image, Start Recording etc. A Web Socket Server will then receive these commands and dispatch them to a Receiver ...
I am trying to develop a simple system for sharing data across several websites. Most of them are developed in PHP while some are developed in Wordpress/Drupal. Redundant information is spread across several websites and this has caused a problem where we have to update the information across several websites separatel...
I made a search on google to find out who are the people in Oracle responsible for updating the Java API in other words who are those responsible for adding new classes and methods to the API and updating the Java Documentation. I could not find an answer to this question which leads me to the next question, what if I...
I'm quite a CSS beginner. I've read some introductory books but now I came across a sort of question that isn't answered in any of them: Let's say I have a basic HTML-based website with a standalone CSS file. Now I'm creating a new CSS class or ID and I want it to have a meaningful name of course because I'll probably ...
I am working on a networking site where I need to reload the notification div every second. I wanted to know is it good or bad to load it every second as there are some other divs also loading after every 3-4 seconds. Will it cause any problem like hanging, slowing down, etc? Reloading is done by ajax: var auto_refres...
I have a Rails server that connects to a json API on another server to get data to build the pages dynamically. These pages, however, don't change very much and not very often. I was thinking I could cut down the page load time, also, cut down the calls to the JSON API significantly if I just periodically called the JS...
As far as I know, it generally refers to late or dynamic bindng. So why a word like late or dynamic wasn't used?