instruction
stringlengths
34
19.9k
Consider the following scenario: I am writing a Dispatcher Servlet that delegates processing to various handlers depending on the request URL; the handler objects having previously registered themselves for URL patterns, pretty much as Servlets register themselves in web.xml. When a Handler registers or unregisters its...
Applications and operating systems have a ton of windows and controls, sub windows and sub controls. I've noticed its common to have sub controls have their coordinate systems reset to start at 0 making drawing much easier. However I'm not sure how that is done and how I'd be able to do that. I'm going to be creating a...
About a year or so ago, I forked a project licensed under Apache 2.0 and made extensive changes and additions to the code, a good portion of which I contributed back freely to the community. Recently, the code moderator changed the licensing to LGPLv3, and I wanted to find out if I was correct in my belief that this l...
I am working on a C# console application that loads the data from a third party and bulk inserts into tables. Basically the code consists of a static method with logging statements. In these scenarios, how does one write the unit test cases? Example code void Main(string[] args) { // for loop here to read config fr...
Mushroom cultivation requires fairly precise chemical composition of substrate (a.k.a. growing medium). Let's pretend we're growing shitakes and that this is the required composition of their substrate: Nitrogen | Benzene | Toluene | Dioxygen Diflouride 5% | 5% | 10% | 80% We want to create an appropria...
There seems to be divided opinion on this subject, and I wanted to get people's insights on whether they've found using underscore prefixes and suffixes to be helpful with coding or not. You know, code like this: class MyClass { private int _someInteger; // some advocate local vars prefixed with underscore privat...
I have a class that will end up having more than ~30 methods. They all make sense to be part of the same class because they require access to the same data. However, does it make any sense to split up a large class into several smaller abstract classes (by functionality, type, use, etc.) and have the main class extend ...
As far as I know, Apache Solr Lucene project is a web-app which is used for rich text searching. I just wanted to know: Why can't I use MySQL for that and just for rich text searching, why we use Solr? When all the other things can be performed using any DB ?
I am an objective-c/iOS apps developer and I was wondering if I perform Unit Tests on my code, how should I go about it? What is unit test anyway? Ain't I testing a specific part of code while running the whole app itself? What is its use? I have read few articles, wikipedia etc. but I am not sure whether unit testing ...
I have three questions about REST API design that I'm hoping someone can shed some light on. I've searched relentlessly for many hours but haven't found answers to my questions anywhere (maybe I just don't know what to search for?). Question 1 My first question has to do with actions/RPC. I've been developing a REST AP...
Where I work we recently switched the Agile development using Scrum. We went through the typical growing pains but have reached an approach that seems to work for now (whether it'll work in the long term is for another question!). Obviously, the department management is happy the transition to Scrum is working. But t...
I was going through the analysis of quicksort in Sedgewick's Algorithms book. He creates the following recurrence relation for number of compares in quicksort while sorting an array of N distinct items. I am having a tough time understanding this... I know it takes 1/N probability for any element to become the pivot ...
The concept I'm programming an interface over pygame as a personal project, to make the creation of games easier for me. So far I managed to design an architecture that behaves like this : Objects are displayable components that can appear and move on the screen Objects can have children objects When an object display...
Are there some best practices on the repository front, or some common newcomer-traps that I should avoid? I have recently been reading about the benefits of repositories even for single-developer projects and, in addition, I am likely to start working with multiple other engineers in a short while but, how do I go from...
From Real World OCaml (beta): OCaml distinguishes between non-recursive definitions (using let) and recursive definitions (using let rec) largely for technical reasons: the type-inference algorithm needs to know when a set of function definitions are mutually recursive, and for reasons that don't apply to a pu...
Would something like This program uses code written by Nathan2055 satisfy the requirements for the BSD license, or do I need to copy out the whole notice? I know it asks that the notice is kept intact, but if I'm only using one file of code it's a waste to have to copy the entire license into the main copyright file.
While getting my code reviewed here the issue of using the const keyword came up. I understand that it is used for implementing read-only behaviour on variables. I am confused about what are the various situations when it can be useful. Should it be used for the sake of clarity in function prototypes? Should it be use...
I have been working for a long time with PHP, and tried to be as good as possible on it (good coding practices, knowing how every request is handled from the start to the end, etc.), but now, for job reasons I have to start learning ASP.NET and C#. I've read and tried to understand it's foundations, as ASP.NET is alway...
Background The "all-PK-must-be-surrogates" approach is not present in Codd's Relational Model or any SQL Standard (ANSI, ISO or other). Canonical books seems to elude this restrictions too. Oracle's own data dictionary scheme uses natural keys in some tables and surrogate keys in other tables. I mention this because th...
We currently have 5 scrum teams that work off their own product backlog for the past year. Each team works on their own dedicated system but underlying technology is the same .Net. There has been a lot of discussion on moving to feature based teams working off a single backlog. The reason is one of our main systems ha...
A basic calculator can perform a wide variety of operations. How does the claculator 'get' the concept of adding two numbers in the same way a human does? I dont think people that make claculators store every possible result of every possible addition on the chip before shipping it. Soemhow the chip needs to 'learn' ho...
I need to write a server application that fetches mails from different mail servers/mailboxes and then needs to process/analyze these mails. Traditionally, I would do this multi-threaded, launching a thread for fetching mails (or maybe one per mailbox) and then process the mails. We are moving more and more to servers...
I'm in the middle of a redesign on the part of my current project that deals with user permissions and authorization. I have an interface named IUserPermissions that encapsulates this information. One part of a user's permissions are the Roles which they are a member of. I'm trying not to violate the Open/Closed Princi...
Preface: My question does not exclusively pertain to Google and it doesn't exclusively pertain to iOS. I'm only using Google and iOS as examples because they are familiar to many. I could have just as easily used 'Company X', apps 'A', 'B', 'C', 'D', and 'E', and 'Android', but I wanted to keep my question rooted in th...
A common operation in JavaScript is to replace an object method with a new one while still calling the original method. This is often done like this: var originalMethod = obj.method; obj.method = function(arg) { // call original method originalMethod.call(this, arg); // do my stuff new stuff } I'd like to ...
I was working with a query I wrote today had to change the code from the WHERE clause to use a IN(list of stuff) filter instead of using something like item_desc = 'item 1' OR item_desc = 'item 2' OR item_desc = 'item 3' OR item_desc = 'item 4' The above ran for 15 minutes and returned nothing, yet the following gave ...
This construction is considered wrong unless #.. else #.. end This is for the general reason of double-negative confusions. It translates to: if not #.. if not not #.. end We all agree this is confusing. Is there any situation (include semantic) that the unless..else construction would be more appropriate?...
This one's all over our codebase but I'm not sure I've ever heard a name put to it. We have C# and Java (and Rails but we don't have to touch it very often) so I'll speak more generally. It's like the data concerns never get fully established until you're literally right in a view controller preparing to drop it on the...
I need to do some text processing tasks with short XML fragments. The section "details" shows an example... My solution is to use a tokenizer based on regular expresions, but it is not elegant and not uses any build-in function. The candidate build-in functions (that others indicates to me) are strtok and SimpleXML. S...
I have commit access on an open source project named Foo hosted on GitHub (there are many other committers if that is relevant). I would like to make a change via pull request so that someone else reviews it before it gets committed to the master branch of the Foo codebase. To make this pull request, I can either make...
I am working on a tool (Python, may or may not be important) that will allow a user to maintain a configuration file containing arbitrary shell and/or language code to be executed on particular events and intervals. The code will potentially involve multiple statements. I understand there are potential behavioral and s...
I am developing a project in C# and due to a design decision it is not possible to have a static class inherit another static class. But I have, in my opinion, a case where this would make sense. I have a music player which is able to play music from many different music sources: local files, YouTube, SoundCloud, Jamen...
Background One of the advantages of decoupled components in systems is that you can extend the system without having to touch the existing code. Sometimes you don't even have to recompile the old code because you can dynamically load classes from disk like this: clazz = Demo.class.getClassLoader().loadClass("full.packa...
I was curious, why do we prefer byte[] array to transfer data over the network and not anything else? Or if I am missing anything, what are the other ways to transfer the data over a network.
Why Redis for queuing? I'm under the impression that Redis can make a good candidate for implementing a queueing system. Up until this point we've been using our MySQL database with polling, or RabbitMQ. With RabbitMQ we've had many problems - the client libraries are very poor and buggy and we'd like not to invest too...
We have a generic parameter table whose important attributes are : id number auto increment not null domain varchar (200) not null classification varchar (200) not null param_name varchar (200) not null value CLOB/text created_by, created_date, updated etc Here the id is unique for the table plus at the functional lev...
I am very new to continuous integration, but I decided to give it a shot. Unfortunately I found there to be huge quantities of different tools, and each one is sizable and seems to be difficult (I am new so of course it intimidates me). What I am looking for however is a tool that can run my junit tests execute my bui...
I've been tasked to correct some issues on the backend of a large website project that has been outsourced for some time. The original developers and us are not on good terms so it's not feasible to get them involved. The technology stack is as follows: MySQL 5.x PHP 5.3 (and a variety of supporting libraries) Apache...
I'm trying to provide a by-reference getter to a list of objects in a class. My setup looks something roughly like this: class c_Container { public: c_Item* Get(int uid); private: c_Item itemList[10]; } class c_Item { public: int uid; } c_Item* c_Container::Get(int uid) { for (int i = 0; i < 10; i++) ...
Suppose I have a function that I need to call a lot, maybe a few thousand times on every mouse down or mouse move. It uses an instance of a function (class), called Transform: function func1(a, b, c) { var t = new Transform(); t.rotate(a); t.scale(b, c); return t.m[0]; } So I'm creating thousands of new transf...
It was suggested on my Stack Overflow question that this might be better suited to this site, so I'm cross-posting it. I'm working on my first ground-up build of an MVC site. I have a collection of views, a collection of models, and I've tested most of my views and fixed the obvious bugs. The last step I need to do is ...
Let's suppose I have a code file that reads (I'll use Java-ish syntax) and it is being interpreted. Kind of like a ruby script. class A{ int fieldName = 4; A(){...} void doSomething(){...} } A instanceOfA = new A(); A.fieldName = 7; This is what I understand to happen when this file is interpreted. Fil...
I have a problem I am developing a solution for and currently I solve it with a brute force solution that checks all possibilities. It works for small numbers of bins but I'd like to work with a reasonable speed for increasing numbers, however the algorithm I use (brute force) increases in computing time in a factorial...
I picked up some Project Euler questions today and decided to find more effective ways to Answer the questions l had already answered. So on the question about finding the sum of the even Fibonacci terms up to 4 million; I noticed that if we had a separate sequence for the even Fibonacci terms (starting with 0 & 2 as ...
I am working on a set implementation in JavaScript currently. This should kind of simulate generics as known from Java or C#. I need a mutable version of that (allows for adding/removing set values) and an immutable one. My constructor signature looks like this: new GenericSet( 'number', [ 10, 20, 30 ] ); , // mutabl...
In my team, we are about to start the reimplement of a service. One of the important steps to do to accomplish this is how do we ensure that we are doing it in the right way and we are not introducing new bugs. So, what we have in mind is create a bunch of test to verify the following: The behavior. Both services sho...
I'm starting to introduce myself in CQRS concepts, but I get stucked with the following situation: Supouse you have an entity that must have an unique name. In order to verify that, prior to create the entity you must make a query, thus you are verifing against the query subsystem. But what happens if the syncronizati...
Problem I was just trying to debug a set of file-manipulation routines I wrote for a program I am working on. One of them kept returning an INVALID_HANDLE error. Explanation I figured out what the problem was. It turns out that because I provided several overloads so that I could call the function with either a file ha...
There is something not clear for me and this is how to prevent other people read my code. The thing is that I want people create their own branches but not to view the other's branches. If someone is responsible for networking, I don't want this guy to view graphics codes. S/He must be forced to work on his branch only...
This is not strictly related to C++ but its type system serves to illustrate the problem well. Assume: We have a generic template Container<T> (such as a std::vector<T>) which stores an unspecified number of elements of the same type T on the heap. Each element is allocated and deallocated via the constructor and des...
On wikipedia it says that GDI is an API and core operating system component responsible for representing graphical objects and transmitting them to output devices. I'm not finding much on what GDI+ actually does so I'm wondering, is GDI+ replaceable with gui frameworks like wxWidgets and GTK+ or are those frameworks ra...
As a software engineer, we are always eager to get effective tools to boost our productivity. And in our daily work, we are often unsatisfactory with the existing tools and would like to have better ways such as better GDB script config, Vim script and some Python script to make boring things automatic. However, it is ...
I have two tree data-structures that I made in C++ , and they give a response for range queries/point queries in that program. I am using Ubuntu. I need help in understanding the way to compare the performance of these two data structures (for answering the query in that program) in external memory. How can I do this? ...
I'm writing a small C++ class, Block, to transform serialized data into a memory structure, and supply the structured data to callers through several accessor methods. I've tried to keep its scope specific and limited. The users of the class are very low-level - they, too, are very narrow in their focus and have as f...
After learning the basics of computing simple die throwing games and calendar applications, I want to explore simple graphics - drawing and moving around geometric objects is ok to start with, eventually adding pixel graphic of course. I've taken an introductory Java course but would rather do it in C++, Python or a co...
Much has been said lately of continuous delivery. It does sound appealing, but runs against the grain of convention wisdom in big corporations. Jez Humble - Continuous Delivery Thoughtworks Presentation - Continuous Delivery - Part 1 Thoughtworks Presentation - Continuous Delivery - Part 2 Assuming the following: Y...
We were migrating from Java 6 to Java 7. The project is behind schedule and risks being dropped, in which case it will continue to use Java 6. What are the specific improvements in Java 7 that we could go back to our manager with and convince him it is important to use JDK 7? Looking for bug fixes that I could highli...
My team has about 18 members and the code is generally good, using TDD and good specifications makes for working code. But I think they abuse comments in favor of writing cleaner, more readable code. I would like to introduce them to the concept and I'm wondering how can I do that on a larger scale without sitting with...
When it is necessary to integrate with a web application, and an API is unavailable, is it a viable solution to simulate a web browser interacting with the web application as a real user would interact with it? UPDATE Some context. Web App belongs to a vendor/partner. Their timeline for building a proper API will not m...
I have just completed my Bachelors degree in IT field. I have deep interest in coding and really want to be a professional in it. Now, apart from college courses, I have been learning programming(C#) on my own (college level programming is too basic). Now I feel I need a little more time to be close to professional pro...
I'm trying to come up with a sane architecture to delay a task for 24 hours. So far I've thought of: unix cron job, but this will not be able to take the load we give it, since we will have many thousands of delayed tasks per day Use RabbitMQ with dead letter exchange, however, this is a hack and being a hack is ridd...
I jumped in to a project and I see that the other developers are adding a lot of logic in the setters of synthesized properties. I understand how this works, but I think that it makes it hard to understand the flow of the program; while reading the code, whenever I see self.something = whatever, I always check if somet...
I'm creating a simple game development framework with Ruby. There is a node system. A node is a game entity, and it has position. It can have children nodes (and one parent node). Children are always drawn relatively to their parent. Nodes have a @position field. Anyone can modify it. When such position is modified, th...
It is usual for me, when doing web development, to copy attributes from my model classes to the other class that will be sent to the client. Usually, with a class that accepts a model and extracts the necessary information this is sufficient (something like a adapter I suppose), but sometimes it is not that easy. In so...
At the end of the answer to "Can I do ++x and x++ in Python?" on this page: http://norvig.com/python-iaq.html, you can read: [...] I'm with my fellow Dane, Bjarne Stroustrup, on this one. He said in The Design and Evolution of C++ ``If I were to design a language from scratch, I would follow the Algol68 path and make ...
Background To start off, at work I work with a legacy system that, in its day, was quite spectacular, but now is ...interesting... to work with. It uses IBM (now Rocket) UniVerse as its backing database. One particular part of it that has caused some issues is its lack of data-integrity checks. By data integrity, I don...
JVM supports so many languages other than Java like Groovy,Clojure,Scala etc which are functional languages unlike Java(I am referring to Java before Version 8 where Lambda's are not supported) that doesn't support functional capabilities.On a high level what makes the JVM so versatile that it can support both Object O...
If I already have integration test for my program, and they all passed, then I have a good feel that it will work. Then what are the reasons to write/add unit tests? Since I already have to write integration tests anyway, I will like to only write unit test for parts that not covered by integration tests. What I know t...
I developed an intranet (local network) ASP.NET web project for my co-workers. In the development process I used Chrome and Firefox and didn't test much with Internet Explorer. The website works well with Firefox and Chrome and with IE it had major bugs. Is it legitimate to ask the users to use Chrome or Firefox? They ...
I've attempted test first in Ruby on Rails using Test Unit and RSpec. I'm wondering how to do test first in situations that are more closely tied to the OS/filesystem. Problem: Building a USB stick of MP4 files. Inputs: List of mp4 file name, destination directory pairs. List of source directories List of destination ...
Code Reuse as a Problem I was thinking about this question on software delivery, and I kept coming back to the issue of repeatability and / or reproducibility. They matter, because if you don’t repeat a project then it becomes more difficult to improve the process you used to build the project. Engineering involves c...
One year ago, I discovered the WPF technology and I developed a little application, as first experiment, to compare the content of two different directories. The content of each directory is shown in a different DataGrid. At that time, I didn't develop the application using MVVM pattern, because it was only an experim...
We need to define our requirements for a REST API. What are tools which aid in creating a document which will fully describe the webservice so it can be created by another entity?
I currently have a set of components named DataValues, ValueParsers, ValueFormatters and ValueValidators. The first one defines an abstract base class DataValue and contains a whole load of implementations. The 3 other components each define in interface similar to their name (minus the "s"), and also contain a bunch o...
I heard the terms "application-level testing" and "system-level testing". I think I know the difference, but I am not sure. I tried to do some research on the internet, but the closest explanation of the difference that I can find is this http://en.wikipedia.org/wiki/Software_testing#Unit_testing (unit testing and syst...
We currently have a complex VC++ software application, which uses a library like ObjectARX to build the dll. I feel there are many features in C# like Collections, Generics, and other libraries which can be used to build the current application in a better and efficient way. I have been thinking about it, but I am not ...
In JavaScript, every number you will ever use will always be represented with what C programmer would call a double. The official type is I believe number. If I recall correctly, that fact was mentioned by Google as a "fundamental" problem with JavaScript and one of the reason why they wanted to have clean break with D...
The title sums it up. I'm interested to know if there exists an algorithm capable of producing variable output given identical input without relying on other sources for randomness such as DateTime.Now or a number generated from a light sensor etc. In addition, the algorithm can not be run in sequence, just two distinc...
I have a code where I have to read some Binary files in database. I wrote a For loop that iterate over my file path array, then it call a READ function that read that file into database. I run this code with traditional for loop everything goes smooth, but then I change the for to Parallel.For and it doesn't go smooth...
I'm making a drawing program as my first open-source program merely to get a taste of the open-source community. To make said program, I am using Python 2.7. I'm using the following modules: EasyGUI 0.96 - Under the 3-clause BSD license Pygame 1.9.1 - Under the LGPL 2.1 license All I intend to do is create a program ...
I just joined a group of five developers (non-professionals) working on a medium sized Python framework (> 50 modules, > 10.000 lines of code). The project has no documentation whatsoever and there are no coding conventions of any kind. My job is to get an overview of what the framework does (theoretical physics calcu...
Let's say, I want to model an application which allows users to model class diagrams. The high level use case can be modelled as UC1:Model Class Diagram, which refines itself into UC11: Model Class, UC12: Model Connection, UC13: Model Composition, etc. Since UC11, 12, 13 are part of UC 1, I used the include-Association...
I am working on a new function for a ASP.NET MVC website. The execution time is quite long at present so I am considering options. The function takes an excel spreadsheet, uploads it to the web server. It then needs to select all of the rows and using Entity Framework insert the rows in to a database. Each row matches ...
I am using eclipse for android programming, and every here and there i see the statement, "TODO Auto-generated method stub." I understand that these methods were generated automatically by eclipse upon creation of classes and other trigger activities but I do not understand the need to have it mentioned everywhere. Wha...
I was just learning about sqlite in android programming from the New Boston Travis videos and I have come across something strange: It is said that if the database does not already exists, onCreate() method is called to create it. so far, so good. But, if the database already exists, then onUpgrade() method is called w...
I have a Qt application, which sends and receives messages. Messages are stored in a local MongoDB. The application has a message list window, which shows sent, received and all messages (depending on the view). For performance reasons the application has a QList, which holds QPairs of Mongo ID and the message itself, ...
Not only are our sprint planning meetings not fun, they're downright dreadful. The meetings are tedious, and boring, and take forever (a day, but it feels like a lot longer). The developers complain about it, and dread upcoming plannings. Our routine is pretty standard (user story inserted into sprint backlog by priori...
In order to submit a desktop application for the Windows 8 app store, you need to digitally sign any driver or .exe associated with the application. However, the application I was trying to submit contains several files that are redistributions of other companies' software, and some of these are not signed. My applicat...
Hi I have fairly complex program that is doing computations in a quite large loop. I want to log some basic statistic about the run to be able to analyze its performance over time and vs loop number. For now I am outputting a set of numbers, about 5 or 6, each loop. The problem is the number of loops is quite large so ...
I was told to create two lists concerning most frequently used words from a plain text (10 Mb arbitrary texts) as monograms (for single worded expressions such as human, water, is) and bigrams (for two-worded expressions such as basketball team, united states and etc) I am stuck here and don't know how I can go about...
I want to built an app that it will support In-App Purchases. In short, user will download the app (with some basic features), and he will have the ability to download extra layers (delivery content) with additional info (e.g. a recipe). I want the content of this layer (the recipe) to be dynamic, and be downloadable...
I am working on a set of REST APIs that needs to be secured so that only authenticated calls will be performed. There will be multiple web apps to service these APIs. Is there a best-practice approach as to where the authentication should occur? I have thought of two possible places. Have each web app perform the auth...
I've run into this challenge a couple of times and I'm hoping someone can provide some references, training or advice on how to explain the difference between a Product Backlog Item and a Task in TFS. I understand and have explained that a Product Backlog Item is the "What" and the Task is the "How". I have also expla...
When is it okay to open-source something? If I have a big project I like to publish it, but is it looked-down-upon to publish, say, a small function?
I work for an organization with one developer (me) and one DBA. When I started, the previous developer had developed applications that had bad architectural practices and it was getting and more time consuming after a couple of years to add features, fix bugs as the story usually goes. I came in and started re-writing...
I am currently working on a collection implementation in JavaScript. I need a mutable and an immutable version of that. So what I thought of first was something like: Collection MutableCollection extends Collection ImmutableCollection extends Collection. My main issue with this is that if I want to implement more spe...
Elgg is designing a permissions API loosely around the Activity Streams model. The user API could look (roughly) like: function elgg_can($capability, $subject = null, $object = null, $target = null) { ... } $capability is a string $subject is a user object $object is the object acted upon $target is the context in wh...
(On Windows 7 64 bit)... I am looking for a program, something similar to the default Windows Terminal, what I need it to do is: Load text from a given URL, split the code in two variables and then trigger a simple Windows command based on these two variables. Currently I am doing this with PHP ... <?php $my_vars = fi...
I'm creating a web application which on the client side consists of a Single Page Application (with Durandal) and on the server side an ASP.NET MVC site with a Domain Driven Design. The two are connected with a REST Api (Web API). I have a relation between two entities, which on the database level is many-to-many. (Hot...
I'm currently working on a Computer Science degree, and I want to build my own Web Server library. The problem? Every search I've done on interacting with web sites points to "Use this library that was built by someone else" - instead of explaining the basics of sending and receiving information. I'm not asking for a l...