instruction
stringlengths
34
19.9k
I'm wondering if anyone has a good solution for when you're working as a team and there's a single file used throughout a project (like a styles.css file) and everyone needs to use it throughout the day - inevitably someone will make changes and save without grabbing the most recent version first. Is there some sort of...
I'm not absolutely sure if this is the right place for this question. But I guess StackOverflow won't be the right place. Is it for any reason a bad way to pass an object to a method from the same class? For some reason I don't feel well with the first solution. The method Start starts the game with the given playe...
I've read the flame wars over the use of spaces and tabs. When working with any markup language (when scope isn't very important and when pressing space 4 times is a PITA), I tend to minimize the tab width to just a space or two but I fluidly change to four full tabs for my other programming work. It is a matter of con...
There's a classic article named On the Criteria To Be Used in Decomposing Systems into Modules that I just read for the first time. It makes perfect sense to me, and is probably one of those articles that OOP was based on. Its conclusion: We have tried to demonstrate by these examples that it is almost always inc...
I'm learning functional programming with Haskell. In the meantime I'm studying Automata theory and as the two seem to fit well together I'm writing a small library to play with automata. Here's the problem that made me ask the question. While studying a way to evaluate a state's reachability I got the idea that a simpl...
So, I've been doing some googling, and haven't found a good solution to my problem. My problem is that I'm using PyGame, and I want to use a Sprite Sheet for my player. This is all well and good, and it would be too, if I wasn't using a Sprite Sheet strip. Basically, if you don't understand, I have a strip of 32x32 'fr...
I have a list of letters, this is just an example list: ['a','b','c','d','e'] How do I compute every combination of the list? The letters cannot repeat, for example. a,b,c,d,e a,c,b,d,e a,c,d,b,e a,c,d,e,b a,e,d,c,b ...
I understand that 0 is false because math established that a long time ago and C established it in the programming world, as talked about here. However, other than following established conventions, is there any reason a new programming language shouldn't make 0 equal to true? It seems like it would solve a lot of pr...
I am reading CLR via C# and came across this sentence in the first chapter and I did not understand what exactly it meant. Full line here: because IL offers no instructions to manipulate registers, it is easy for people to create new languages and compilers that produce code targeting the CLR. What does it mean? I ve...
In C and C++ you can return a single variable inside a function. Now in the case that variable is returning data, and not an error code, you can use exceptions. But how is that possible? If you data being returned is the data you tell your function to return, then there is practically no way for the function calling it...
Suppose there are 2 web site: example.com I don't own and example2.com I own. I want to extend the functionality of example.com somehow. example.com doesn't have any API. I want the users of example.com to be able to login at example2.com using their logins and passwords of example.com. However, since example.com does...
Lately, I've been noticing that a lot of software, be it a website, a client application, or a video game, often write a representation of quantity as follows: "1 result(s)". Now, I can understand why they would do that 20 years ago. But these days, shouldn't we have enough processing power and memory to be able to say...
I just moved into the Ruby on Rails world and with it I am being introduced to much more liberal use of environment variables than what I have been exposed to in the past. Specifically, it appears like there's an accepted convention to store third party API keys and secret tokens as environment variables. NOTE: this i...
I have a problem where I have to change all the Xs in a 2D array into 0s, and I have to calculate the minimum steps (where a single step consists of changing an entire row or column) required to do so. For example, in an array like- [[X, X, X], [X, 0, 0], [X, 0, 0]] The minimum number of steps required here is 2. I...
I've currently been assigned a project to create the following with javascript, you can view the final product here: http://i1245.photobucket.com/albums/gg583/leetpete1994/Infografic-TrafficSources_zpsf50dfa6d.png It's basically my job to take the provided PDF and create a way to dynamically display the data that the ...
I'm playing with pluralize at the command line, and it's beginning to scare me. Multiples of leaf is leafs (not leaves) Multiples of cactus is cactus- not cacti, or even cactuses. Radius becomes radius instead of radii Yet it correctly gets women, octopi, knives, and errata (the finer things in life). As I understand ...
And lets say, my application is a simple feed reader. Does my app really have to include the no warranty notice?
So I was not sure how to structure this title, feel free to edit it. My question is: When I have a Game Loop, I have 3 main blocks. Handle Events, Update game state, and draw. Let's say for example I check for keyboard/mouse events, and I want to move my character when buttons are pressed. Whenever KEYDOWN event occurs...
I'm trying to teach myself programming and I'd really appreciate some help with this issue. I've just read a tutorial on pointers but I have a problem with the example. The function copies one string to another. In the original function a copy is being made with ptr. What is the meaning of this? because as far as I can...
Hi I have a programming problem that I would like to solve using some artificial intelligence technique. I really dont know where to start. I would like some guidance as to what methodology to pursue. Lets say I have 10,000 images of random people, and I need to detect elderly people in images. I might have algorithms ...
It's a common knowledge that since the IT industry develops very quickly, most of the skills get outdated fairly rapidly: jQuery, .NET, Ruby on Rails, etc. They change all the time so that it is difficult to keep track of them and especially learn them. Once I learn Ruby on Rails 3.2, Ruby on Rails 4 has appeared; the ...
I'm trying to use REST (usign spring MVC) as my Ajax backend but got some problems when using it with jQuery. REST best pratices recommend using HTTP status code, e.g. 200, 403, 401, etc, and I have no problem with a 200 status code, jQuery's ajax method have a done(data) callback that let me read the reponse in json f...
What are the algorithms I could use to create an AI for the game TicTacToe. I have already used Alpha–beta pruning and Predictive modelling. What the other good Algorithms I can use to create this AI. I want to practice a new language this would a great way to learn a new language. Thanks
I am expert in PHP. There are some JavaScript related bugs in my assignment given by my supervisor. I tried to fix them using Firebug. It is time consuming. Is there any other ways? Are there any good IDE's to tackle this issue? Are there any other developer tools except Firebug?
There is a simple system, that allows users to do 4 things: ADD, EDIT, DELETE, PRINT data. I am due to model it (I'm entirely new to UML activity diagrams) and from notation, I dont understand whether a decision node can have more than 3 inputs? It should be, otherwise how would I do that. Anyway, the user can perfor...
In the book "Clean Code" Robert Martin makes a statement regarding the following code: public Money calculatePay(Employee e) throws InvalidEmployeeType { switch (e.type) { case COMMISSIONED: return calculateCommissionedPay(e); case HOURLY: return calculateHourlyPay(e); case SALARIED: re...
In the debate of Rich vs. Anemic domain models, the internet is full of philosophical advice but short on authoritative examples. The objective of this question is to find definitive guidelines and concrete examples of proper Domain-Driven Design models. (Ideally in C#.) For a real-world example, this implementation o...
I am working on a project at the moment that generates a table (among other things) based on the contents of a file-system, and in turn does some meta-data modifications on the things it finds. The question is: how should tests be written around this, or set up? Is there an easy way to mock this out? Or should I setu...
Consider the following scenario : User sends a request to transfer money. Server receives the request and transfers the money but the reply times out. The app reports failure. So the user tries to transfer money again. How do we avoid this kind of a scenario ?
I have two different apps in my django project. One is "comment" and an other one is "files". A comment might save some file attached to it. The current way of creating a comment with attachments is by making two API calls. First one creates an actual comment and replies with the comment ID which serves as foreign key ...
AFAIK the lowest priority has the highest number in scheduling and in my system all priorities must be different. But isn't other policies thinkable? For instance, how about a policy where priorities are not numbers but say that a task's priority would be defined only in term of another task's priority, and that other ...
I am currently developing my website with c++. I know that nginx handles connections with multiple threads to provide high performance. And not all c++ code is thread safe. What's the relationship between nginx's multithreading and c++ application's multithreading? Do I have to worry about this? What should I do to ...
I am a novice c++ programmer who kept an idea that function pointers are a thing of C and OOP in C++ does not recommend its usage. I know what I write here is vague/broad. But it will be great if somebody could comment whether my idea is completely wrong or something sensible. Thanks.
I'm currently writing a medium sized web-application and find myself asking this question many times. For example, let's say there are users, which have files (one-to-many). How should the UI access the data? One "extreme" would be to let the service layer "only" take care of the lazy loading, i.e. public interface Use...
I am building a new SPA front end to replace an existing enterprise's legacy hodgepodge of systems that are outdated and in need of updating. I am new to angular, and wanted to see if the community could give me some perspective. I'll state my problem, and then ask my question. I have to generate several series of chec...
I have a project written using Swing, and I want to make it more smoothly (like JavaFX is) by adding animation to some components(JButton, JScrollPane, JSplitPane) using javax.swing.Timer. UPD: That is not a game. I want to use the Timer for short animations like mouseHover events or dropdown, or scroll. But the probl...
AS3's got some awkward rules about variable scope, due to its use of hoisting. I don't like pointlessly leaving a bunch of compiler warnings lying around, but it's more important to me for my code to readable and properly written, regardless. This produces a couple of duplicate variable definition warnings: priva...
I'm pretty new to programming, and I've just started using GitHub to store and hold my source code (I keep losing stuff stored locally). As it stands all that's in there right now are source code files, nothing more, but I expect that to change as time goes on and I get better at this. Given that all the repositories i...
I'm wondering what the best practice is for my git repository structure where I have an Android application + a web service backend. In general, I'd like to release these two independently (e.g., perf fixes to the backend with no changes to the front-end), but I am worried that if I keep these in two separate repos I'l...
Currently I'm working on system that works with database, and I would like to have it done elegant way. So I have abstracted DBConnection into one class, DBCommands into another class. (DBCommands : DBConnection) There is also a class SQLUsage in which I'm creating new thread that works in a loop, it checks all the tim...
I have developed a small scripting language and I've just started writing the very first native library bindings. This is practically the first time I'm writing a native extension to a script language, so I've run into a conceptual issue. I'd like to write glue code for popular libraries so that they can be used from t...
When converting a string to a boolean, what are the advantages of having a programming language evaluate an empty string as true and what are the advantages of having it evaluate it to false?
I have a PHP script example1.php. How would the control flow be when I call another PHP script example2.php from example1.php? For e.g.: example1.php looks like this .... ... .... example2.php (calling example2.php from example1.php) ..... ..... How does the control flow work for this? Does example1.php wait un...
I had an interesting discussion with my boss today regarding exiting a loop before the terminal condition is met. He had a construct in some of his VB6 code that looked something like this: Dim Termination As Int Termination = 10 For Iterator1 = 1 To Termination If Iterator1 = 5 Then Iterator1 = Terminatio...
We are starting to build a new app and I would like to explore the idea of doing a thick JS client (backbone / angular) with only RESTful API exposed by our application layer. What are some of the best practices and potential pitfalls for doing this kind of web app?
It bothers me to see commented out code and it seems often-times a symptom of developers not being proficient in advanced source control features, but on the other hand source control does not really go all the way in solving the problem that commenting out is intended for. I've occasionally seen requirements flip-flo...
I wrote a cross platform application and I distributed it successfully for Windows and Linux (and tested them on "clean" virtual systems, with no other additional software and/or libraries installed). I have already compiled my application on my Mac computer, but I don't know if my application will work on other Mac co...
So I'm reading a book on Design Patterns (Design Patterns Explained 2nd Edition), and all throughout the book it says to "favor aggregation over inheritance". I'm trying to wrap my head around trying to design something, and I feel so stupid. So conceptually, I have Recruiters. I figured these recruiters can be an abst...
This has been troubling me for some time, and I'd really appreciate the input of other professionals. Short background: I started programming when my parents bought me my first computer in 1988 (at age 14, I'm 39 now). I followed a couple of other career paths before finally becoming a professional programmer in 1997. ...
I think this code: if(file_exists("amodule.inc.php")) require_once("amodule.inc.php"); is misleading because of the use of the require_once. I think that - to keep the logic and "wording" in line - "include_once" would be appropriate (where there are a number of arguments to not use the "if" at all but I would ...
I have .NET 2.5 installed in my computer unit, as a beginner I used VB.net As I went along I've also installed new .dlls that would help me with my VB.net programming Now, I want to study java as well, leading to Android programming. If I install the JDK 7.0, can I still be able to program in VB.net? Will installing JD...
An interviewer asked me this question: Tables are created with appropriate normalization rules, However the database is performing slow. [Ie.: The select, insert statements are taking time to do his operation.] What are areas we need to look to improve the database performance. Obviously this is a vague question. Wha...
I cant find plugins written in other languages other than javascript. There is browser support only for Javascript. Why didn't they use other scripting languages other than Javascript when people started using scripts on their web pages? Why javascript was given priority?
I have written an Android application. The application requires a Bluetooth connection to a very specific piece of hardware, currently a prototype. The only way I can test the app at present is to drive hundreds of miles to see if it works. If I end up with an ANR it can be very embarrassing in front of my client. The ...
I am working against an API where I can add and update items in a list that is ordered by a priority field I can set (which need not be contiguous but must be a positive integer). Updating a list member is an expensive operation, so I want to minimise the number of updates. What I want is an algorithm that will minimis...
To someone who knows database internals this may be an easy question, but can someone explain in a clear way why storing large blobs (say 400 MB movies) in the database is supposed to decrease performance and what exactly does that mean? This is a claim often found throughout the internet, but I've never seen it really...
I have a few FOSS projects that I want to release under the BSD license, since I only wish to maintain the intellectual property of the code, that others will know I've been writing it. I suppose all I need to do is: Have a file called LICENSE only in the main folder of the software. Write at the top of each source fi...
I work on a team that does frequent code reviews. But it seems like more of a formality than anything. No one really points out problems in the code for fear of offending other developers. The few times I've tried to ask for changes were met with very defensive and reluctant attitudes. This is of course not good. Not o...
For example a new research paper comes out and it describes some algorithm, say this is a cutting edge algorithm and came out last week, is there anything stopping me from using that algorithm in my codebase that is for commercial purposes? What if the paper includes some code and I use that code? There does not seem t...
This question relates to software-licensing. Someone familiar with open-source licensing may be able to answer this question. I am facing an issue in trying to interpret/understand some Licenses, due to a language barrier (English is not my first language). My situation is that I am using three products inside a distri...
I have a database containing just simple URLs. It is as simple as it sounds for now and URL can link to a website or a document(i.e. anything parseable to text). Now I have a simple code which inserts records to database. The problem is that website/document may be actually the same, just: Hosted somewhere else Not av...
I have a function, which looks something like this: ClassA& ClassB::Check(int x){ //some calculations in a loop, if a condition is met, a reference to a ClassA object is given } I'm getting the "control reaches end of non-void function" error. As far as I understand, this is because, the function wont always retur...
I'm developing a small system with two components: one polls data from an internet resource and translates it into sql data to persist it locally; the second one reads that sql data from the local instance and serves it via json and a restful api. I was originally planning to persist the data with postgresql, but beca...
I believe I have a fundamental misunderstanding when it comes to workflow engines which I would appreciate if you could help me sort out. I'm not sure if my misunderstanding is specific to the workflow engine I'm using, or if it's a general misunderstanding. I happen to use Windows Workflow Foundation (WWF). TLDR-versi...
Is it accurate to say that dependency injection manually using java (without spring) is nothing but implementing the strategy pattern (as per this example)? Furthermore, is it correct to say that Spring just provides a declarative way of specifying the dependency as opposed to manual method whereby the dependency need ...
I'm looking for an algorithm to infer a hierarchy from a set of tagged items. E.g. if the following items have the tags: 1 a 2 a,b 3 a,c 4 a,c,e 5 a,b 6 a,c 7 d 8 d,f Then I can construct an undirected graph (or graphs) by tallying the node weights and edge weights: node weights edge weights a 6 a-b 2 b...
I'm starting to develop a new program. It's basically a database interface, run a few queries, show the data in a nice way and be able to easy input new data (like this website). Thinking about which programs I use daily I realise that only my web-browser is a GUI program, the rest is TUI (in this case TUI is Text User...
I have a custom MVC framework that is in a constant state of evolution. There's a long standing debate with a co-worker how the routing should work. Considering the following directory structure: /core/Router.php /mvc/Controllers/{Public controllers} /mvc/Controllers/Private/{Controllers requiring valid user} /mvc/Cont...
We will be starting a new project this month. The project will be 1 year and production deployment will only occur towards the end of the project. We will be doing iterative development (1 month per iteration), so this means we will drop features to Test environment at the end of each iteration for QA testing. Our bran...
I have been preparing to do my first technical interview in a month, and I have a question about implementing common data structures like stacks or linked lists. I plan to do the interview in either Python or Java but I am not sure which one to use yet. I was practicing and tried to implement a stack in Python, using a...
On http://python.org there are two download pages, http://python.org/download/ for international users and http://python.org/getit/ for Chinese users. When accessed from a country other than china, the second link redirects to the normal download page. Why is that so?
When looking Python decorators someone made the statement, that they are as powerful as Lisp macros (particularly Clojure). Looking at the examples given in PEP 318 it looks to me as if they are just a fancy way of using plain old higher-order functions in Lisp: def attrs(**kwds): def decorate(f): for k in ...
My repository has a branch production and is filled with countless tags of the format production-20130101-1234 that point to what has been actually shipped on the given datetime. I think this solution is somewhat messy and unwieldy and I wonder if reflogs would skip in here better. The objective is "make sure you can a...
I’m trying to develop an AI for a card game and I’m a bit stuck about the technique/algorithm I should use. Here are a few assumptions about the game: After the cards are distributed to players, there is no randomness. I mean here that every player can choose which cards he plays but no random process occurs as when d...
Is it sensible to have micro-modules, say with only a very few (perhaps one) class in it? Or should I store things in bigger repositories? I am long-time Java developer with a software-engineering background. I try and write well encapsulated, focussed OO code. I have previously written code in large modules/projects/r...
I'm designing a language conceptually similar to Go. In Go, for example, the keyword func is used for defining functions: func abs (a int) uint { ... } Same for defining types. However, I was thinking of a grammar that doesn't consider these keywords. For example: abs (a int => uint) { ... } Or, for structures: Tree ...
I have a requirement to allow users to suggest updates to their profiles on a site I'm working. They would be able to view their profile details, then click on and "edit" button, which would basically make a copy of all their data contained in a handful of one-to-many related DB tables. They can then add or remove item...
I'm really confused when I see a lot of in-memory database implementation used for testing, because I also heard a lot from integration testing best practices that the environment running the test should resemble as closely as possible the production environment, including operating system, library, database engine, et...
I work for a software product company. We have large enterprise customers who implement our product and we provide support to them. For example, if there is a defect, we provide patches, etc. In other words, It is a fairly typical setup. Recently, a ticket was issued and assigned to me regarding an exception found by a...
For learning and understanding purpose, I currently want to try to make a small relational DBMS with simple features like (for now) only sequential reading/writing and CREATE TABLE, INSERT, SELECT, UPDATE and DELETE management. I am currently on the "think" part of the project and I am stuck on the way to store the rea...
I have an android application with a custom content provider set up to load data asychonously. The database is a local file so I'm not sure if I needed to set up a content provider at all. Sometimes I just need to do something like get a name back from a short list by id. Is it ok to mix the content provider pattern wi...
I've written some code that has some fairly deep nests (one time, I wrote something that was a conditional check inside a forloop inside a conditional check inside a forloop inside a forloop). Is there a general guideline on limits to the number of nested for loops/conditionals you have?
For the non-Brits in the audience, there's a segment of a daytime game-show where contestants have a set of 6 numbers and a randomly generated target number. They have to reach the target number using any (but not necessarily all) of the 6 numbers using only arithmetic operators. All calculations must result in positiv...
Suppose I'm writing a program in C in which several parameters are asked at the beginning of the execution to the user and then remain costant until the end. Now, I need to pass these parameters to some function. Since they are unchanged through the program, my temptation would be to declare them as global variables, ...
I am an author of project, that consists of two parts: daemon and library. I want to license library under BSD License (or MIT, will decide later), and daemon under GPLv3. I want to permit the library to be linked into closed-source products, but I want daemon to be GPL, as it uses GPL code heavily, and I do not want i...
I program primarily in python and have programmed a couple of GUI's with Tkinter, every tutorial I have ever seen has recommended defining and using a class for the GUI, but my GUI runs flawlessly using only procedures, without a class. Why use a class? It seems from my perspective to simply be an extra layer of comple...
Part of a system I am working on manages some securities information (stocks, bonds, etc...) and business rules specify certain fields be displayed only in all CAPS (stock symbols and CUSIPs for example). Users will have to look at data displayed on the screen as well as perform create/edit data-entry operations. Where...
I've only recently begun to learn about the tensions between free and proprietary software, and I've been very confused by the way that free software can make money. I understand that free software is "free as in speech, not as in beer," but if I release an open source program and then try to monetize it, what could po...
We are planning to develop a ASP.NET Web API project starting soon. For source control we use svn. We typically follow the pattern of the trunk being stable and doing all of our work in the branches. Most of the time we are lucky that one developer is working on the project. For this Web API project there are at l...
I'm developing a product related to printing. To work it properly in all windows versions I need to include few exe (lpr.exe) files from system32 folder. So I need to know it is legal to distribute these exe file with my product.
In a team that I used to work for, there was a policy that if you introduced a memory or other resource leak, you got a 'dummy of shame' hung on your door until you found the next resource leak. While it was effective at finding resource leaks, I felt like it placed more emphasis on blaming others rather than working t...
I am an intermediate programmer with a few years of professional experience who is halfway through a masters degree. In learning to program I've often heard two pieces of seemingly contradictory advice. The first piece of advice was get something working quickly, see how it works (either through prototyping or informa...
I am currently working for a small-medium sized company (~50 employees) as the sole IT staff. Recently, we are on track to replace one expensive yet critical legacy system in favor of an application I am currently working on during my free time at work. However, its been very busy lately with issues spawning left and r...
Do long (very long) variable names slow down the compilation of source code? I'm aware that the length of variables has 0% impact on interpretation as the compiler changes them to machine code which is always the same length. But my question is, does the speed at which the compiler vary depending on the length of varia...
Should a developer close a ticket in a bug tracking tool? Or should only the scrum master or testers should do it? What are the best practices?
How do the blogging sites, Q&A sites (or any other sites host prose like content) store their data? That is, how do you store blogs and Q&A content in the database? I hope it is not good to store this huge text data inside RDBMS table columns.
I'm writing a RESTful service (Java EE, Jersey) and a client application that communicates with it, and I wish to secure it and store any usernames & passwords dedicated in my own database. I do not want the client to store the username and password locally, not in any form such as base-64 or other encoding at all, I r...
A client recently had a new backend .net stock management system developed that hooks into their EPOS and allows their stores to keep track of orders, products, customers, etc from a single central database that utilizes MS SQL Server 2003. The client hopes to use this as an opportunity to renew/re-develop their site t...
I have an ASP.NET MVC 4 solution that I'm putting together, leveraging IoC and the repository pattern using Entity Framework 5. I have a new requirement to be able to pull data from a second database (from another internal application) which I don't have control over. There is no API available unfortunately for the sec...
Once I heard that a good book on any programming language cannot be short, so the number of pages is the first criterium when choosing a tutorial. The statement was half a joke, but it has some truth in it. There are tens and hundreds of books available for most popular programming languages, frameworks and technologie...