instruction
stringlengths
34
19.9k
I was recently creating a small technical documentation for an application. The document is to be used by newly hired programmers to get acquainted with the application. It is much friendlier than the Javadocs we have, and includes information that usually isn't being documented. When describing a function, I first bri...
I have a local repository with a toy project that has turned out to be more serious than I had thought. So from a single development branch where I have carelessly committed, I have started to use branches kind of like in the famous http://nvie.com/posts/a-successful-git-branching-model/ I would now like to have a "cen...
Logging was always a nightmare for me! Now I have to implement it again for a proxy system. In this proxy application, some systems ask proxy system to call some other services. What I have to log is Request Time Requester IP Request Parameters as XML Requested Service Name Requested Service Method Response Time Respo...
Why do requirements interviews never pan out as they are planned - and how do I prepare for that? I'm looking for the following kind of help regarding how to prepare for these interviews and what I can pay attention to in order to make the most of them. My information project, centered around management reporting withi...
I have a list in Python 2.7 of about 10000 point co-ordinates, like [(168, 245), (59, 52), (61, 250), ... (205, 69), (185, 75)] Is there a faster way to search for all the points in a bounding box, instead of just iterating over the entire list each time and checking if the co-ord is inside the 4 sides?? I'm using thi...
I am desiging a file format and I want to do it right. Since it is a binary format, the very first byte (or bytes) of the file should not form valid textual characters (just like in the PNG file header1). This allows tools that do not recognize the format to still see that its not a text file by looking at the first fe...
Here is the situation I have inherited: We have approximately 10 websites (Asp.net web forms) that each have their own database. Each of these databases houses some site specific data, and each has some form of a user table that will map to what is called a User Service. The User Service is just another website that h...
Our website has a login form that shows up in the header on every page on the website. This is what my boss wants however we need to get PCI compliant and it says any sensitive form (login/password) requires SSL. So does that mean the entire website has to be running under SSL while a user is not logged in? Another que...
What classes must I put in a class diagram? Only classes used in Business Layer and associations between them? Or also other classes in the Data Access Layer, Service Layer, etc.?
The PHP engine interprets the PHP code and is perfectly capable of working with sockets, forming HTTP packets, etc. Why then do we need a separate Apache server, when the http serving duties could be embedded into the php application along with the page creation code?
Well I don't want to make it open-source! That's the problem. But I do want to use it on my current job. Company did not agree to sign any alternative license with me and told me to rewrite everything from scratch so they will own it. :( So how can I do it in a safe way so later on the company don't come back to me and...
Instead of a database I just serialize my data to JSON, saving and loading it to disk when necessary. All the data management is made on the program itself, which is faster AND easier than using SQL queries. For that reason I have never understood why databases are necessary at all. Why should one use a database instea...
I am new, so forgive me if my question is mistaken or anything, just give me an alert and I'll be glad to fix it. Me and my team is about to develop a system where the database is located in a private server, and the applications is distributed between clients on distant location. It is actually a simple CRUD applicati...
My school programming club is setting up a tutoring program. We have 12 tutors who specialize in a range of different languages, and each is available for a different set of hours each day of the week. I want to set up a web interface where students can select the language they need help in, and then be shown a list of...
Suppose we have estimated 5 user stories to complete in a sprint and completed all of them with testing, buffer time and for expected bugs. Still we have 2-3 days left for one of the developer. Can we pull a future user story in current sprint knowing that only development or part of development can be completed in cur...
My development team is migrating from SVN to Mercurial. Having researched DVCS best practices, it has been suggested that we develop against feature branches of the repo mainline, test them separately, then cherry-pick the features we want in each release, before merging those selected branches into the mainline and ev...
I'm wondering how to set up the organization with Scrum Masters. I would prefer to see real examples of where the scrum masters are located in the organization's hierarchy and how report-to / chain-of-command issues are handled. we are service company. We have one agile project done for agile customer where team manage...
I would like to make windows desktop application using HTML5, JavaScript and CSS. I am trying tidesdk XULRunner appjs I read the documentations of these technologies. But I didn't see how to export the application as a .exe package. I want to write an application in HTML and JavaScript and export to an exe file. How...
I am in the middle of designing a next generation database access class for one of the programs I am building. We use PostgreSQL exclusively. Our current approach is procedural (largely inspired believe it or not by RESTful web services, but paying attention to discoverability as well). The database defines (rather ...
I need to send automated emails to customers whose language I am not sure about. 90 % are french and would probably not be able to read mails in english. The other 10 % would probably be able to read in english and clearly not in french. I don't know what their language is. I investigated the multipart/alternative that...
I am trying to program Discrete Wavelet Transform in Matlab. I do understand that their are various libraries available, but my project requires that I must implement it from scratch. I am taking a vector of length N. I then provide this vector as input to my my Low Pass and High Pass Filters. My first question is, wha...
I do a lot of c# development work. Recently, our company decided it was important for webservices to be able to run on Unix machines, and decided that we should write new services in Java as a result. We've got licenses to IntelliJ, so I'll probably start with that as an IDE. I've found it pretty easy to find resourc...
I'm studying the differences between NoSQL and SQL, and what makes the first more scalable. I think I got the point, so I'll try to explain: Suppose an app has a list of billions of users, each with a quantity of money, and it wants to display the sum of the money of them all. In SQL, it'd have to SELECT SUM(money) FRO...
I'm writing a simple little program to transmit MIDI over a network. I know that the program will encounter transmission problems and / or other exception situations that I won't be able to predict. For the exception handling, I see two approaches. Should I write the program so that it: fails with a bang when somethi...
I have a php/mysql applications which I designed, and the client doesn't want it to be online (installed on a webserver) or available on the internet, he wants his employees to use it on a local system. I don't want them to go through the process of starting up wamp to access the program, is there a simple way to make ...
I've been working for a couple of years on a small project, almost by myself, with the eventual help of some colleagues. The project is getting out of my hands, because the size of the code is growing (around 20K lines now) and the initial expectations I had for it have outgrown my own ability and time. So now I want t...
This question got rather a freezing reception at SO, so I decided to delete it there and try here instead. If you think it does not fit here either, please at least leave a comment on suggestion how to find an example I'm after... Can you give an example, where using C99 VLAs offers a real advantage over something like...
I have two applications, called A and B. The current version of these applciations are 7.x (some customers run 7.1, others run 7.2, ...). Both applications use a same common framework (let's call this C), like this: +---+ +---+ | A | | B | +---------+ | C | +---------+ Because of some important new customers, ...
Some programmers avoid regexes in some situations (see this popular @nickf comment), perhaps using a parsing framework such as Lex/Yacc. Others prefer to stay within PHP, perhaps using regular expressions, as it avoids the need for another framework. When must we use a "real" parser generator instead of coding a parser...
I'm going to be writing an application that is pure HTML5 and JS and MVC.net back-end. We have .resx files that are getting compiled to .js files for resources in the html5 application. The application has to work in English and in Chinese which I understand to mean that we need to use UTF-16 everywhere. Does anyone...
I am currently implementing an expression evaluator (single line expressions, like formulas) based on the following: the entered expression is tokenized to separate literal booleans, integers, decimals, strings, functions, identifiers (variables) I implemented the Shunting-yard algorithm (lightly modified to handle fu...
I can remember a very Very long time ago (pre Y2K) , reading an article by some "expert" that theorized that software communicating over the internet, especially video games could get mixed up with Military communications meaning that a user could inadvertently mobilize a B52 nuclear bomber with a click of his mouse on...
I want to call a DLL in my programming language of 'choice'. The documentation surrounding this clearly states that it must be a 32-bit DLL written in C, C++ or Delphi. But I wanted to call a DLL written in C#. It goes on to mention that the default calling mode is cdecl. So my question is: why would this be the case? ...
Can anyone offer any tips or experience on developing a test plan for an Agile sprint? Most of the time our team simply creates a "Test Feature X" task and goes about writing ad-hoc test cases. There typically isn't much strategic forethought put into how features will be tested and how we'll communicate the expectatio...
I was playing around with Go, and found this particular interesting code for the abs function in the math package: http://golang.org/src/pkg/math/abs.go 14 func abs(x float64) float64 { 15 switch { 16 case x < 0: 17 return -x 18 case x == 0: 19 return 0 // return correctly abs(-0) 20 ...
I have been reading about traits in Scala. They are pretty amazing. I am curious how they extend a class without actually resulting in multiple inheritance. I know that the JVM doesn't support multiple inheritance, so I am wondering how these extensions work. Is the language just providing syntactic sugar for compositi...
At work we have a legacy system written in Visual FoxPRO. Everything in foxpro is a table, even forms, so basically if you open a form file with a text editor you don't learn much. Does anyone know about a tool for source control, that support merging and managing binary files? For now I'm converting what I can convert...
I've written a patch for a GPL'ed JavaScript library. To check how the patch works one needs sample CGI (or PHP) backend. I want to write a demo PHP to show that my JS works and put the open code on my site. The question: What it the best way to have PHP on server both executed and viewed as the source? Note that recen...
OTServs are open source MMORPGs with a huge community. Mostly all of them have a serious problem: if the server crashes, people can clone items. This is a dirty trick that can be executed because the state of a player is saved to the SQL database when the player logs out. This means the the database is not always in va...
I'm still trying to wrap my head around OOP. All of the following examples work, of course, but is there one (or possibly another) that best exemplifies OOP concepts? /** * For the following examples the Image class queries an image * and associated info from a database, which is passed on * instantiation via depend...
Recently I had a discussion with a colleague regarding code style. He was arguing that your usage of APIs and the general patterns you are using should be as similar as possible with the surrounding code, if not with the the codebase as a whole, just as you would with code appearance (brace positioning, capitalisation ...
What is a : Key-Event Dispatcher ? in keyboard-interactive apps. What does it really do ?
I'm writing a C++ wrapper for my C library (my C++ skills are a bit rusty) and I'm wondering what's preferable: allowing user to construct objects themselves or give them objects via getters? What would be idiomatic C++ equivalent of that C function? result* process_foo(library_handle*, foo*); a constructor like this:...
I'm a programmer currently working in rounds of meetings along with BAs and PM to gather/describe modules and functionality of our case management system; after a few meetings I saw that using 'use cases' would be a very very good fit to document many of the things and functions discuessed and/or proposed for the new s...
I recently read http://simpleprogrammer.com/2013/02/17/principles-are-timeless-best-practices-are-fads/ and it resonated with me. I find the more experienced programmers/architects go against current best practices and their excuse is some best practices don't work with their problem domain. For example, I have just st...
The string type is immutable. We can use the const keyword with strings in high level language like .NET. My understanding of 'const' means constant (it remains the same, we can't change the value). Are strings not always constant (IMO the term constant should not be applicable in the same context if the type has to b...
I have a WCF web service hosted in a load balanced environment. I do not need any WCF session related functionality in the service. QUESTION What are the scenarios in which performances will be best if keepAliveEnabled = false keepAliveEnabled = true Reference From Load Balancing By default, the BasicHttpBinding s...
In Java, the String object is both immutable and also a pointee (aka reference type). I'm sure there are other types/objects which are both immutable and a pointee as well and that this extends further than just Java. I can not think where this would be desirable possibly due to my own experience I've only used either...
In Java: I have a class Students. I would like to read a list of students from a file. Which one is more elegant: Reading and constructing the list in main(), and creating a Student object with the new list passed to the constructor Passing a FileReader to the constructor, who does the reading? Something else?
C++ has a feature (I cannot figure out the proper name of it), that automatically calls matching constructors of parameter types if the argument types are not the expected ones. A very basic example of this is calling a function that expects a std::string with a const char* argument. The compiler will automatically gen...
I hope this question gives some interesting answers because it's one that's bugged me for a while. Is there any real value in unit testing a controller in ASP.NET MVC? What I mean by that is, most of the time, (and I'm no genius), my controller methods are, even at their most complex something like this: public Action...
What is the difference between the terms concurrent and parallel execution? I've never quite been able to grasp the distinction. The tag defines concurrency as a manner of running two processes simultaneously, but I thought parallelism was exactly the same thing, i.e.: separate threads or processes which can potentia...
I have a Java Web application backed by a database. Both are hosted in Amazon EC2. If the Internet is down, I need to allow internal users to be able to continue to work and somehow update the hosted service when the Internet is available again. Is this possible? How would I design such a solution.
I'm trying to understand more about shells. I'm looking to implement one and want to look at what's been done in the past. In a regular shell, you have features like aliases and relative paths, and strong syntactic conventions, like --flag and so on. The IPython community have added loads of nice features to their shel...
I find myself writing (hopefully) helpful comments in code (C++) documentation of the type: The reason we are doing this is... The reason I use "we" instead of "I" is because I do a lot of academic writing where "we" is often preferred. So here's the question. Is there a good reason to prefer one over the other in do...
At work we have a lot of code like this (pseudocode): response form_submit(string username, string password) { if ( username == "" || username.contains(invalid_chars) || password.length < 5 || ... ) { return "errors: blah blah"; } else { try { db("insert into users(username, pass...
Say we want to enforce that a table represents a tree. I have found this method for doing so: create table tree ( id integer[] primary key, parent integer[] references tree (id), item text not null, constraint tree_parent check ( (id = array[]::integer[] and parent is null) or parent = id[1:array_len...
I have my own little project I am creating using RoR, I plan it to have small-medium load. With no doubt I started with BDD and TDD (Cucumber and RSpec to be exact, but I am also experienced with TestUnit), I like it but since it's my own project and it's a somewhat startup - I am changing many things in it, many requi...
I am most of the way through my games programming degree. This is not a computer science degree, so a lot of the theory is eschewed in favour of practical portfolio building and what I see as JIT learning, which is apparently more important in the games industry. The first subject was "Introduction to Object-Oriented...
I am using PHP Codeigniter MVC design pattern and I had this project with some sort of specific business processes In my application I will be dealing with 2 existing REST APIs: Google Trello I came up with idea to create REST API to act as Business Logic Layer (BBL) that in turns access my models directly to fetc...
I admit that I am a junior developer, and so far I've only built simple web applications in ASP.NET MVC. But I've never had to use the inheritance aspect of Object Oriented Programming in my own classes! It is true that in using ASP.NET MVC I inadvertently use inheritance (any controller I create will inherit from the ...
I've worked for a number of companies that have, over time, branched out their core service to provide additional services and/or revenue streams. My question is when is the proper time to separate these concerns into multiple applications, even when they're operating on the same/extensions-of-some data? For example, s...
I own a VPS with Windows Server 2012 on it. I can install whatever I want on it. In the past when deploying an ASP.Net MVC project, I would right click the project in the solution and Publish it. I would then copy over the files to the IIS folder and that would be a deployment for me. But this is no longer something I ...
I've been programming for a little under a year and have some experience writing systems applications, web apps, and scripts for businesses/organizations. However, one thing I've never really done is working with a framework like Django, Rails or Zend. Looking over the Django framework, I'm a little frustrated with how...
Was reading an interesting blog post on Singleton design pattern which is so widely used. If it's stupid or as in some quora posts, its an anti-pattern why is it so widely used even in frameworks. For e.g., Spring framework (java) makes all the classes available through dependency injection as Singleton classes and a...
Existing architecture: nodejs server with mongodb backend. I have strings coming in describing images that can have #hashtags in them. I wish to extract the hashtags from the strings, store the hashtags and associate the image with that hashtag. So e.g. an image is uploaded with 'having fun at #bandcamp #nyc' #bandcamp...
I'm building a rather large and extensive wrapper in Delphi for an email system called Mandrill. There are wrappers for this API in many other languages, but not for Delphi. So, I'm hoping to produce the first full wrapper. The problem is, I'm utilizing a third-party JSON parser called superobject. I'm afraid that if I...
I am developing an application where I draw large number of lines (color is given as black) and update them where I need to remove them from screen. I thought of making their color to match with the background so that I can make them hide. It seems to be simple and works but in the practical sense I have 10000 points a...
I have started using OOP in PHP recently. For every model, I create two classes. One class for read operations and another Manager class for all the create / update / delete operations. For example, <?php // This is a sample class, just to convey the idea class Image { public static function loadById() {} publi...
I wanted to perform some actions in my Java program whenever a particular interface comes up (network interface ppp0 e.g.). However I figured out it was way too clumsy to keep polling the interface to verify its status. After finding out if-up.local file in Linux, now I can run a bash script whenever the interface co...
Sorry for the long question, but I want to be sure to define my problem clearly. For my thesis (in aerospace engineering, so not much programming experience) I want to develop a (prototype) mobile application which will facilitate the reporting of safety related events in African aviation. Although the content of my t...
Let's say I have an object like this: function Foo() { this.parser = new DataParser(); }; Within Foo I have a method that does something like this: Foo.prototype.getResponse = function(message, callback) { var payload = {data: message, type: 'normal'}; var response = this.parser.parse(payload, function(data){ ...
Back in college I've been told that using break; and continue; outside switch statements (e.g. to escape for or while loops) is wrong, bad practice and bad habits at the same time because it only means that you cannot write loops properly. Is it really? A friend of mine also told me that using conditional ?: is bad pra...
Sometimes interview questions are hard, whether the interviewer intends them to be, or not. It can come down to a choice of whether to use the limited interview time to code up an ugly, inefficient, brute-force solution, or spend the time understanding every aspect of the problem with the interviewer. For example, Pro...
I'm new to dependency injection and I have a few questions about which style I should use in my applications. I have just read Inversion of Control Containers and the Dependency Injection pattern by Martin Fowler, but I can't get the practical difference between constructor, setter and interface injection. It seems to...
In class I am learning about value iteration and markov decision problems, we are doing through the UC Berkley pac-man project, so I am trying to write the value iterator for it and as I understand it, value iteration is that for each iteration you are visiting every state, and then tracking to a terminal state to get ...
Say you have a situation where you divide and then multiply a float, and you need to guarantee that it survives macheps (ie multiplication output equals division input). What are known strategies for guaranteeing this? Rounding would work, but anything else?
According to this blog post: Kiln now supports repositories accessible from both Git and Mercurial We decided that the awesome way would be to make Kiln fully bilingual. It stores every repo in both formats. It automatically converts everything back and forth, always. The translation is 1:1, reversible, and roun...
I was lately doing some research about different programming languages. I was interested particularly to learn unique features of popular programming languages and situations where these assets shine. I believe this can help me to decide what language to use depending upon the problem to solve. I found that many langua...
Although Joda is feature rich and more sophisticated than standard Java time, it may not always be the best thing to use. How do I decide if I should use Joda Time or Java Time in any Java code? Is there some kind of guideline which tells us how to pick the right one depending on our requirements?
I've came across a question transform this text with sed [sed only] and it got me wondering what class of problems is solvable by stream editors or programs/computational models with similar constraints. For E.g Regular expressions can solve problems that require fixed/const amount of memory (Can solve all problems tha...
I've been asked to look at converting our traditional client-server software into a web-based version (using PHP). One of the first questions from management was how we'd limit the number of concurrent users, currently handled by our licence manager that every client connects to when running our apps. My initials thoug...
I'm writing my CV, and having trouble explaining about the software for enterprise I developed in my previous job. Now I'm thinking of writing following 4 things for each software. Abstract explanation about what the software is used for How much was the software sold About how many data does the software usually hand...
While inheriting a class in C++, user can specify the access specifier like, class Base { public int mem1; protected in mem2; }; class Derived1 : **private** Base { // mem1 will be private here. // mem2 will be private here. }; class Derived2 : **protected** Base { // mem1 will be protected here. ...
The A* Algorithm is the optimal (provided the heuristic function is underestimated), complete & admissible (provided some conditions). I know the proofs of admissibility & optimality. But how do you prove that the A* Algorithm is complete?
I'm trying to figure out what are currently the two most efficent algorithms that permit, starting from a L/R pair of stereo images created using a traditional camera (so affected by some epipolar lines misalignment), to produce a pair of adjusted images plus their depth information by looking at their disparity. Actua...
This question is similar to the question posted on Does groovy call partial application 'currying'?, but not completely the same, and the answers given there do not really satisfy me. I would like to state right at this point, before I go any further, that currying is one of the concepts that have been hard to fully un...
I usually do database and web development but at the moment I'm learning desktop development with Mono and Gtk# using using the MonoDevelop IDE. I'm also using the Stetic GUI Designer inside MonoDevelop to create the GUI. What are the best practices when using a GUI designer to encapsulate extra logic that is related t...
I was thinking about it. You may have access to endless memory (one computer with lot of RAM) so that you can keep on adding more and more elements to your ArrayList. But, I think that you can only access elements BY INDEX up to a certain value of index. The maximum size of this index could be = maximum number your co...
I see most immutable POJOs written like this: public class MyObject { private final String foo; private final int bar; public MyObject(String foo, int bar) { this.foo = foo; this.bar = bar; } public String getFoo() { return foo; } public int getBar() { retu...
I'm planning to write a single API that is syntactically valid in most major programming languages (to the greatest extent possible, so that only minimal amounts of code will need to be re-written when moving from one language to another). I think the simplest way to do this would be to write a group of functions that ...
I'm managing a small team of developers. Every so often we decide we're going to spend a day or two to clean up our code. Would it be a good idea to schedule regular time, say 1 week every 2 months, to just cleaning up our codebase?
I'm interested in how operating systems work. I've been reading some articles about Linux and seem to understand how it all generally comes together, but I feel like there's a chicken and egg dilemma when it comes to constructing an operating system. Since Linux is written in C (and Assembly), which needs a compiler to...
This is a rather vague question, but it's something I've never felt has been answered in a satisfactory way when reading about proper design. Generally, when learning about Object Oriented programming, abstraction, factoring out, etc, the holy grail of design - and the reason they always claim you're using the developm...
I am relatively new to programming (1yr field experience now) and I think that I am overusing the singleton pattern and I need some input on how to do it in a better way. Right now I am using singletons as an excuse for static global data. I use singleton for Application Status, Application Settings and also a lot for ...
I'm thinking about open sourcing a project of mine. I'd accept contributions under a CLA that grants me a copyright license (I'll explain what I mean at the end of this question). — Now, if someone submits a contribution, is it then okay that I write Copyright (c) 2013 My-Name at the top of each file? And mention any ...
What has changed with regards to the design patterns? Do both use the same development techniques? If I'm faced with the option of learning Windows Phone 7 vs Windows Phone 8 will learning windows phone 7 will qualify me for directly start development for windows phone 8?
I am using a shared host that which doesn't support CRON/TaskScheduler (it is a windows Godaddy server). I need to search on email server for new emails on each 1 hour, I have the script on PHP. Can I use PERL to emulate a task on certain times, or is there any other alternatives?
The following is a programming interview question: Given 3 sorted arrays. Find(x,y,z), (where x is from 1st array, y is from 2nd array, and z is from 3rd array), such that Max(x,y,z) - Min(x,y,z) is minimum. This question is discussed here: http://www.careercup.com/question?id=14805690 One possible solution discussed i...
I'm creating a piece of software, that will run on windows and will act like launcher for the game, to serve as an auto-updater and file verifier in client side PC. One thing I don't understand, why my antivirus software (Avast) is considering my exe file as dangerous and won't start it without asking to put it into sa...