instruction
stringlengths
34
19.9k
I know it's a broad question so I'll try to be as specific as possible. This question is more an "organisational" question than a technical one. We have a multi-sided project with these main components: A server, hosting the core business logic (data models) A backoffice for clients which uses the core business logic ...
Imagine the following interface: interface Service { addListener(Listener l) removeListener(Listener l) } Should I check for null values while add/remove? Is it a good idea on remove to check if the listener was registered before (e.g. listener B was never registered and should be removed)? What behaviour hel...
I have downloaded some software which I'm using. I'd like to include it in my project but I don't know if I'm allowed to do so due to the software not having a license. What are my rights? If the software doesn't have a license, does that mean that I am allowed to do whatever I want with the software?
There are tons of questions like "Can I use GPLed code X in my commercial project?" but I found nothing which answers my question. I take ExtJS as an example, but actually you can any commercial / community edition dual licensed software. If I contribute to the community edition, isn't my contribution GPLed? Even if my...
I have an interesting situation, and I am looking for the best way to solve it. My app runs like this: 1) The user gets a Promotion Pin from Some Company, and I have a db table with these pins also. The user submits my form to recieve a reward. 2) I first check if the pin is valid/non-expired using a basic stored proce...
I adapted some code from the Apache Ant project in my work. The part I used is really small: ~70 lines, ~2000 characters. Adding dependency to ant to use that a single method seemed like an overkill. The project I work on is internal to the company, so I initially included a javadoc like @see <a href="...">original...
The company I work for is evaluating some middleware solutions for governace, metering and security of web services. Currently, we're using an Enterprise Service Bus (ESB) for this purpose, but some cool guys in management decided they are going to deploy some API Management Middleware. I researched a bit about these A...
I've always been taught that your tests should run in isolation, and other than a db for ActiveRecord etc., your tests should not rely on any external software/services. e.g. I always mock my other web-service responses but what about responses from web based key-value stores and aggregators like elasticsearch, redis,...
Modern compilers often inline functions when they decide it is worth it. But here comes my question: how does one define if it is optimal to inline function at given time, or more important how to decide that it should be avoided?
I see in the GPL license FAQ : Does the GPL require that source code of modified versions be posted to the public? (#GPLRequireSourcePostedPublic) The GPL does not require you to release your modified version, or any part of it. You are free to make modifications and use them privately, without ever releasing them. Th...
I have a general question about testing search applications, and what I'm looking for is pointers to resources on the topic that I can go and research on my own. I've tried semi-informed, semi-undirected googling, but that's yielding a lot of distractions and blind alleys (or maybe my search skills aren't all that shar...
I am working on a multi client/single server app. Communication between the two happens via RESTful API. There are several resources that need to stay in sync across all clients, including images captured from camera, likes and comments on these images, user profiles and user followers/followings. My current approach i...
The book Pattern of Enterprise Application Architecture has the following description over the Table Data Gateway pattern: “A Table Data Gateway holds all the SQL for accessing a single table or view: selects, inserts, updates, and deletes. Other code calls its methods for all interaction with the database.” They do n...
I got this from one of online video tutorials. Author binds form data not to Value Object directly, but first to validable DTO, and THEN to Value Object, using service. Example: package com.foo.spring.dto; import javax.validation.constraints.NotNull; import javax.validation.constraints.Pattern; import javax.validation...
In my app, I'm using both strategies: I have a Utils class, it only has class methods that I call for doing common global methods, like NSString validation, etc. I have an app-wide singleton class which I instantiate during app Did Finish Launching, and use this throughout the app to hold global objects / state, perfo...
I'm creating a notification system for particular events. A user can set the criteria that match particular events (ie. New item, changed item, closed item etc) Items have different characteristics (ie. Minor, Major, Critical). So a user may set up a search for All New Critical Items. What is the most efficient way to ...
Suppose that in a single processor system, an average of 6 process arrive each minute. Each process needs an average service time of 8 seconds. How would you calculate the fraction of time the CPU is kept busy ? What I have done is -: Since a 6 new processes arrive each minute and 8 seconds is required to complete one ...
If I want to load an object from a file, there are a number of things that can go wrong. Thus, one needs a way of handling errors when doing so. In some languages, like haskell, one can return a Maybe object that might contain the newly created object. In C++, although it is in principle possible to create such a conve...
We are building some business modules that must be intuitive for developers to use, so the code itself explains and forces developers to use it in certain way. This applies both for enhancing the existing features (by our developers) or reusing it (by 3rd party developers). All modules are part of big infrastructure, s...
I've created a heavily modified and more reusable version of this Qt Quick Scene Graph example. Every source file includes a BSD license. The following lines basically say I have to include the entire copyright notice and list of conditions with the modification distribution: ** "Redistribution and use in source and bi...
I have rather big git branch with code that was created on may of this year and never before was merged with master. Compare shows huuuge difference between branch and master: about 50 new files and about 150 modified files. I'm really worried about forthcoming merge. What can you recommend? Any advises about how bett...
Lets say I want to implement an API from an external website, for example like Dribbble or Last.fm. I'm fairly new to this new generation of front-end MVC's (angular, etc), and most example's I've seen implement API's in the front-end with use of ajax calls. So my question is this, is there a benefit of doing this, in...
When I design and create the software I work on, I typically design and create the back-end SQL tables first and then move on to the actual programming. The project I'm currently working on has me down right puzzled though. This is probably due to a lack of good, solid requirements, but there's unfortunately little I c...
I have an angular app that concentrates most of its functionality around a primary entity that has several satellite entities. The UI for this is effectively one screen, with a few tabs, one for each satellite. There are also some modal dialogs with content for a couple of the satellites that deserve their own subview,...
I'm in the planning phase of making a website for calculating various mathematical problems, as a school/sparetime project with a couple of friends. We're gonna start off with implementing a "right angled triangle calculator", and then gradually implement more mathematical stuff. So, basically, we want some boxes that ...
I understand that GPU's has hundreds of cores that can handle thousands of threads all at once and that with the Jacobi iteration you're essentially using the same numbers over and over again to update a vector. Is this why implementing the Jacobi method on a GPU is a good idea especially if we have a really large syst...
I'm having a case where I'm handling the logic of a search in one controller and I'm generating some data based on searches and returning as statistics. Is a good practice calling a controller function from another controller? Or two controllers should never 'talk'?
I am developing an ASP.NET MVC application, and I have three projects: UI (with the system.web.mvc reference, BL and DAL references) BL (business facade and business objects) DAL (contains my entities/poco classes and connects to the DB using an external assembly) I am building my viewmodels in the UI layer, using t...
I'm wondering if there are other approaches, old or new, to writing unit tests, and how viable they are, other than the traditional and tdd unit testing approaches. I know there is behavior-driven development, which also uses test-first, but the tests themselves can be used as specification. What others?
I am reading msdn documentation for this keyword. They gave three usages for this keyword as follows To qualify members hidden by similar names To pass an object as a parameter to other methods To declare indexers and there is no word about the usage of this during constructor chaining. My question are : Why they m...
I was reading this post: http://www.quora.com/What-are-the-advantages-of-Python-over-C++ And I am wondering the converse of this question: what can C++ do that Python cannot? For example, in the realm of performance graphics and GUIs: I understand that C++ would be a better language for high-end game development that ...
I am learning to program in Java and have run into a situation I don't understand. I have this code import java.io.*; class temp { temp() { Finish f=new Finish(); f.end(); } public static void main(String args[]) { System.out.println("STARTING JAVA PROGRAM"); } } class Finish { ...
We have completed 11 sprints so far in our current project. In most sprints we have not been burning down well and usually finish with our velocity gradient flattening as we approach the end of the sprint. However, having looked back at our last few burn downs it seems we are consistent with how much work we carry over...
I would like to know how the default package is defined in Java.I know how public and private access is defined but I don't know whether there is any default package access that is defined in package level access in java. I'm asking this question because when I compile java file containing two classes since no modifier...
I have an application that connects to databases based on a json string that contains connection information. The json is sent just when the application starts. How do you manage such connection pools? Because I can get multiple configurations that point to the same database with the same user. I know I cannot create n...
There is a PHP library of classes (generated from a WSDL) that cannot be changed. These look like the below for simplicity. class System extends \SoapClient { public function __construct(array $options = array(), $wsdl = 'http://example.com/system?wsdl') { // Do configuration and include required classes...
As software design paradigm which is better? to let various methods manipulate a member variable, or define each method or function to take some inputs and provide some outputs? For example class Test { void FooMethod1() { Foo = ... } void FooMethod2() { Foo ...
Consider public void Do(string[] aBunchOfStrings) { } or public void Do(IReadOnlyList<string> aBunchOfStrings) { } Would it be a bad idea to allow the function call Do("woei"); resolve automatically to an internal call Do(new[] { "woei" }); to C#?
I'm not saying I want to create a whole new compiler that's completely independent. I'm using C# Windows Forms and I want users to be able to write filtering syntax in a textbox withing my managed application in a basic query language, for example: inCategory(Animals) where(animal.age > 40) take animal; It's basically...
I understand the differences in capacity and values they can represent but it seems as though people always use Int32 regardless of whether it is appropriate. No one ever seems to use the unsigned version (uint) even though a lot of the time it fits better as it describes a value that cannot be negative (perhaps to rep...
I know that with regression it is possible to generate a mathematical function based on experimental data. I was wondering, maybe there is a way to generate something more complex. I have a single player logical game which is hard to solve: There are 37 glass globes in holes: |o|o|o| |o|o|o|o|o| |o|o|o|o|o|o|o| |...
I've searched for the definition of a "node" in a programming language and I am still finding it hard to understand. Could anyone advice me in simple, layman's terms: What is a node?
I've inherited an API to maintain. Users can pass a callback function to the class which gets called on some event. The callback function is currently passed in a single argument. I need to change the expected signature of the callback function to accept additional arguments. This would be fine if everyones' callback ...
I am learning that member variables are to hold the state of an object? Is it their recommended usage? Are all member variables state variables too? or state variables have specific definition and are defined according to a class? In general what is the definition of an state variable? In fact, I look for the best usa...
So I'm using a C# framework that has a great example of where generics would be useful, except they weren't used. For simplicity's sake, we will say it was a list (I know C# has its own list), but instead of being List where I can specify the T, they made it List, resulting in nightmarish type checking throughout the ...
I have a question here and I am trying to find a solution of it. But I want to see some other opinions as well. The problem is the following: There is a matrix NxN which holds integer numbers. You should count all the different numbers in the matrix with the following conditions: If two-or-more same numbers are adjac...
I have a fairly simple application that is divided into two classes. The first class is the Manager class and the second class is the employee class. These are simple classes and do not inherit from any other class. Now what I want is to keep others from instantiating the employee class.The Manager class has an instant...
I have a database table in which each row is one movie (with fields like 'title', 'director' and 'writer'), and a related table where each row is one screenshot from a movie (with the fields 'movie_id' and 'jpeg_data'). Each movie has 2-8 screenshots. I want to output data in the order Movie 1 Screenshot 1 Screenshot...
I'm trying to wrap my head around Scala, and one thing that keeps throwing me is the ordering of a variable/value declaration when specifying the type. val a = 0 makes perfect sense. This looks pretty much like any other language. val a: Int = 0 parses really weird in my head; it just seems nonsensical. Why is the ty...
I'm relatively new to the world of OOP, and having read through some design patterns, I'm struggling with that 'aha' moment. I have the following objects Event (Single event, with start time and end time, and it's availability) EventCollection (Contains multiple instances of the Event, either cloned and set, or instant...
In simple cases I can see right away which direction to go. If I'm passing a working directory to my program, and it's the same for the vast majority of the runs, make it a configuration variable. Conversely if I have to change a configuration for every single run of the program than it should probably be an argument...
I'm building a service that will consist of mobile and desktop apps, which will require me to build my own RESTful web API to easily keep the data for the service in sync. I am also building a web app in Ruby on Rails. Initially I plan to host everything on one server due to cost. I'm curious which is a better design...
First of all, I would like to know if passing an object as parameter is much better than creating another object again in a class that will use it again and second what are the pros and cons of each one? Here's an example: public class ClassWithTheObject { TheObject obj = new TheObject(); // Somewhere around the code...
I was recently asked by a recruiter if i knew component development with javascript. Since i was hearing this for the first time, i said i had no idea regarding it. I google it and got very few results which did not clear the exact meaning. So what is component development mean with regard to javascript? Is it a new co...
I have an enterprise application running that uses both MySQL and MongoDB datastores. My development team all have SSH access to the machine in order to perform application releases, maintenance, etc. I recently raised a risk in the business when users started storing highly sensitive data on the application that the d...
Suppose multiple objects of the same class should do something which takes a memory consuming resource. Which of the following approaches is recommended to define and use the resource by the objects? Each object create the resource in its own Declare one resource instance and pass it to each object Using a static obje...
I would like to do SELECT * TABLE t (using data from 1st of march 2012) I already have a nice audit trail of all tables in the database. It basically makes a copy of all rows that change, storing all columns of the changed row in an hstore column. This means that we have the data available, but I am unsure of whether...
In Android if you use a library in your app (such as the Support Library) the code for the library is duplicated on the device for each app that uses it. Why can't android use the linux "shared library" concept, so each app wouldn't have to duplicate the library's code?
I am writing a parser and as a part of that, I have an Expander class that "expands" single complex statement into multiple simple statements. For example, it would expand this: x = 2 + 3 * a into: tmp1 = 3 * a x = 2 + tmp1 Now I'm thinking about how to test this class, specifically how to Arrange the tests. I could ...
I've been using the Javascript Date API for a calendar application, and I noticed that for every month between 3 and 9 (April and November) the methods Date.getDay() and Date.getUTCDay() return different results. For each of these months, Date.getUTCDay() will consistently return the same as Date.getDay() - 1. I eventu...
I use DjangoREST & MySQL as a backend for a mobiel app. I have two models, User and Feed and for any call to api/feeds/ returns all feeds for authenticated user ordered by created_at parameter of feed. However, I need to customize order of feeds for each user by simple scoring algorithm. Details of algorithm is not imp...
I have two questions that are linked : 1) Can someone sell a fork of an open-source software under GPL without distributing the source? Example: Can I modify a little bit GIMP, repackage it under another name, and sell it as a commercial product without giving source code (like Adobe Photoshop) ? Is this explicitely fo...
I've been programming in Java for about 6 months, and I thought a good and challenging test of my skills would be to build a GUI calculator. I have very recently heard about this MVC idea, and I thought (perhaps foolishly) that it would be a good fit for this pet project. But I'm running into trouble during the design,...
Currently, I am trying to set up deployment procedures and GIT for a group of websites. Code and assets are between 15 and 20GB. The code and related text files are probably closer to 150MB. When deploying code from the developer machine, to a server, or from a server to another server. What are the common solutions us...
Is there a single timeline-style resource available showing the history of the modules available in different versions of Python? I'd like to, for instance, easily determine which version of Python introduced the pipes module, without needing to perform a binary search by installing different Python versions until I fi...
I am not sure whether this question is a good fit for this site, but if it is not, please let me know and I will take it down. If it is off-topic, some general info on where I can look for these answers would be greatly appreciated. I am wondering how the data that determines how text is to be formatted is stored. For...
DefinitelyTyped has a Dojo solution which uses named modules and may work with legacy Dojo and explicit typing. But these declarations do not facilitate TypeScript import, since there are no anonymous modules. It seems to be a more exhaustive and consistent version of schungx/Dojo-TypeScript, but without the declared m...
In an extreme programming project, programmers do pair programming most of the time. As these pairs also rotate, that is, you pair program with different people, and there is a sense of collective ownership, source code is being frequently reviewed and updated. Being so, is there a need for code reviews? I mean, stop ...
I got a question about licensing of android app icons. At the moment I am developing an app and I implemented a share function. The user can select a prefered app to share a text message in a popup dialog. Like Whatsapp or Email or whatever app he would like to send the message... The set of apps he can choose from is ...
TL;DR I need help in identifying techniques to simplify automated unit testing when working within a stateful framework. Background: I'm currently writing a game in TypeScript and the Phaser framework. Phaser describes itself as an HTML5 game framework that tries as little as possible to restrict the structure of your...
Let's take an example: User A MIT license Copyright (C) 2014, User A User B other license (not MIT) in which people who fork won't require mention of the current copyright notice Copyright (C) 2014, User B & User A User C any license Copyright (C) 2014 User C (No link with User A because User B's license...
Say I'm developing a piece of Open Source software (BSD-Like permissive license) and I write the initial release entirely on my own. After the initial release however I would like numerous other developers to contribute. How do I deal with the Copyright of this project? Obviously I completely own the first version, but...
I've been using CSS for a few years, but there are some "quirks" that I cannot quite fathom. One of them is the height property when specified with a percentage. To quote the CSS 2.1 Specification (under percentage): If the height of the containing block is not specified explicitly (i.e., it depends on content height)...
I want to connect and transfer data between a PC and an Android device both of which are on the same local WiFi network. I cannot use the local IP as such in the code to actually get the connection going because it does not remain constant every time. I know I can set the local IP to be constant but I am looking for a ...
I was wondering if there's a one liner for PHP that would allow me test multiple values against a function call. As example, say I want to test if foo() returns either 1 or 2, (in pseudo code) if( [1||2]==foo() ); Maybe above is a bad example of what I mean. Currently if I want to test two values against a function c...
I was wondering if there is a program in the common unix toolset such as grep that instead of filtering the lines that contain a string, simply outputs the same input but highlighting or coloring the selected string. I was thinking in doing it by myself (should be simple enough), but maybe it already exists as a unix c...
Is it possible to call a method using infix notation? For example, in Haskell, I could write the following function: x `isAFactorOf` y = x % y == 0 and then use it like: if 2 `isAFactorOf` 10 ... Which in some cases allows for very readable code. Is anything similar to this possible in Scala? I searched for "Scala in...
I am now on the job of extending and refactoring a set of APIs and core data structures that most of the other components depend on. The team is small (5 people ). A manager told me that before checking in my changes, I should search throughout the code base, find out all the functions that are dependent on the APIs ...
First things first, our company has decided to do code reviews. All of the engineers agree with (or accept) this. Code reviews are required as part of our development process for all commits. The problem is that they are done... weeks (or occasionally months) after the stories are code complete. So as a developer, how ...
Should there be a separate code coverage report for unit and integration tests, or one code coverage report for both? The thinking behind this is that code coverage allows us to make sure that our code has been covered by tests as far as possible (as much as a machine can now anyway). Having a separate report is more c...
Given an integer range and a number within that range, what's a reasonably robust and efficient way to randomly select a new number within the range such that it's not equal to the given number? Whenever I need to do this, I usually use something like: // Randomly choose an integer within an inclusive range with the co...
I am not sure if this is the right forum of this question, but I will try here since this question about the c++ language. The problem: I use one global variable in my code which is a graphics object. The thing is that when I shut down the program I tried to delete all the created objects (in a function called close, s...
Is it a good idea to create an API in such a way that clients can post different shaped JSON documents to the same Resource? Let me give you an example and and explanation to why I am asking this. I am hoping to create an API that is supposed to serve clients in the US as well as other clients across the globe. I have ...
I've become interested in futures lately, mostly due to their inclusion in standard C++ - but I see there is an active debate over futures vs. callbacks in many programming areas, such as Node.js. I'd like to ask is if there are any well-known patterns/use-cases where futures provide a clear advantage (in terms of read...
Alan Kay said "OO" was about messaging, not objects and drew a parallel to biological cells. His views are enticing, but vague. The way I understand it is something like a Cellular Automata. In a Cellular Automata there's a grid of cells that can be in a variety of states. Then an update event is sent to all the cell...
If I include MIT licensed source code in my program, am I obliged to provide my whole software under MIT? The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. How is "substantial" determined? The wording is not very specific.
I used a open source software to build an application about few months back. The license on the software states, "XXXYYY is Free Software, licensed under the MIT license - so it's free to use for all purposes." MIT license says that - http://opensource.org/licenses/MIT Permission is hereby granted, free of charge, to ...
I was interested in finding (or if necessary developing) an XSLT equivalent for JSON. As I have not found any, I was considering the possible query language to use for matching JSON paths so as to apply templates (from JavaScript) when there was a match (probably just checking an array of matching patterns in order, an...
I'd like to create a piece of software that has the functionality of a common written planner. To do this, it will have a Calendar. When planning the program, I became confused as to how I would implement the functionality of a Calendar. I thought have a Calendar class that stores and array of Date objects, and each Da...
I know autmatic getters and setters are considers bad as they tend to break object's encapsulation. They also move the work that should have been done within the object outside. Allen Holub is a big advocate of avoiding them. In one of his presentations he gives this example as bad design: Here currency conversion ha...
Banned.h is a list of ANSI C functions that Microsoft is trying to persuade programmers to deprecate. I already know how to enforce automatic inclusion of banned.h (such as the answer to Ensuring that headers are explicitly included in CPP file). Unfortunately, that answer has an important drawback. Forced inclusion in...
I'm rather new to distributed computing and would like some assistance with the overall architecture of my application. My application has Jobs that can be added to a JobQueue. Then one or more JobRunner instances can be setup to run the jobs on the queue and generate JobResults. The JobResults will then be sent to som...
Some background: A colleague and myself have different interpretations of MVC which means, given the same problem, we are coming up with radically different solutions. He comes from a Java background where every component of MVC may traditionally model an object and I come from a Haskell background and have little or n...
I have a class that represents a list of people. class AddressBook { public: AddressBook(); private: std::vector<People> people; } I want to allow clients to iterate over the vector of people. The first thought I had was simply: std::vector<People> & getPeople { return people; } However, I do not want to leak th...
Usually in C, we have to tell the computer the type of data in variable declaration. E.g. in the following program, I want to print the sum of two floating point numbers X and Y. #include<stdio.h> main() { float X=5.2; float Y=5.1; float Z; Z=Y+X; printf("%f",Z); } I had to tell the compiler the type of var...
I'm developing an application with 3 sides, desktop (JavaFX), server (Tomcat) and Android. And a MySQL Database Server. The app receive mails and convert them into tasks. The tasks are sent to the android devices from the desktop app. The user of the Android device do stuff with the task and send the task with new info...
I'm trying to get started with node.js. For example en Java and .net programmer often use the port 8080? Is there a convention like that in node.js? I know that any port above 1024 will do it but I will like to follow the conventions so working with other programmers would be easier. I heard that it is Ryan Dahl's (the...
I am looking to contribute to some Python projects on Github, and I am looking for a bit of clarification on the mechanics of doing this effectively. As I understand it, the typical workflow is as follows: Fork the repository you would like to contribute to. Clone the your forked repository. Create a Python virtual e...
So I am developing a Web Application and I have some concerns about the database. I use a lot of boolean settings at the user table with the form privacy_allow_1, privacy_allow_that, privacy_allow_this etc etc. As they keep stacking would it be just better to use a different table just for the privacy settings and lin...
I am new to continuous delivery, so please help me understand if my ideas are incorrect, I have XY problems, etc.. My organization runs web services, with services-oriented architecture. Currently, we have about a dozen services. Naturally, these services share some code in common. To date, we've done batched releases ...