instruction
stringlengths
34
19.9k
I am testing a resource management class that is interacting with a database or a file system, or a combination of both. I was wandering if it is the norm to test all possible permutations of read and write for all columns of a data-set when a database is involved. What I mean is: Database table of test case: +--------...
We lease an appliance to our clients (4 physical servers running 12 VMs). One of the servers exposes a website which in turn uses the other VMs. Clients have no access to the VMs or the software which runs on them. One of the reasons is that we process classified documents (and while security through obscurity is no de...
I understand that ssh keys are a cryptographically secured way of authenticating yourself to a service or to another person, but beyond that I'm frankly at a bit of a loss. What confuses me is that I see many developers mention their public key on their site, but how does one have just one key? I have a few for differe...
I'm working with a binary structure, the goal of which is to index the significance of specific bits for any character encoding so that we may trigger events while doing specific checks against the profile. Each character encoding scheme has an associated system record. This record's leading value will be a C++ unsigne...
In our work, we have several different .net applications that share a lot of base functionality. We've built these applications using a clean n-tier architecture, but we've hit that moment where we realize that we've re-implemented the same functions several different times. Obviously this violates DRY, and we would ...
The Sleeping Barber Problem is a classical synchronization problem that many of you may be familiar with or at least heard of. It's based on the premise that a barber (a thread) sleeps when there are no customers (each customer is a thread) in the waiting room (which is a semaphore). If there is someone, he cuts his ha...
Many programming languages permit natural manipulation of strings, and some languages permit the manipulations of lists too. More often then not (always?), these operations are done as procedure calls, or as member functions. Many programming languages do implement in syntax the fairly typical set {prepend, replace, ap...
I am a bit in a dilemma: Let's suppose I have a very general function and a specialization of it for convenience reasons. Let's also assume that the specialized function is used 90 per cent of the time, hence being "the common case". Should I use a shorter function name for the general case (e.g. do) and a longer one f...
Say I want to assert that a certain option menu is displayed in the front-end of a project. The menu is on screen X and I have to first select data in Y to get to X. Now, it doesn't matter at all what data I select in Y, it will always lead to X. But sometimes, depending on the data, I will get a screen Z which I can ...
I am writing a Windows Phone application which I intend to release into the public domain (the source code and releated resources, that is). My application does, however, use a few third party open source libraries (statically linking to them). Does releasing my code into the public domain make any difference regarding...
I have noticed where I work people are keen on storing information in file names, and parsing the file names. To me this doesn't seem to be especially good practice. I already see the occasional issues with scripts globbing for a file, and getting the wrong one because another file matches first.We are also discussing ...
Often I am writing a function that returns multiple values, such as a pair of coordinates: function get_coords() { return ???; } If I was using a language like Python, I would use a tuple: return (x, y) Or, in an OOP language like Java, I would create a custom coordinate class: class Coordinates { public int x; ...
It's a good practice to let a client specify the format in Web REST API: GET /api/items/123.csv However, not only GET can return some answer, but POST also can do Status: 201 Created { mgs: "Your item has created successfully", href: "/example.com/items/123" } How should URI look like for a POST (PUT or whatever...
I am sending a huge amount of data to server. Now while I have sent the data and waiting for server response, suddenly my android device gets internet connection lost. So what I used to do is, showing an alert dialog of connection lost, but at server side the data was already processed and it updated somewhere e.g. on ...
I need some help or maybe only a hint for the right direction. I've got a system that is separated into two applications. An existing VB.NET desktop client using Entity Framework 5 with code first approach and an ASP.NET Web Api client in C# that will be re-factored. It should be possible to deliver OData. The system a...
I'm sort of torn on what to do for implementation of my distributed genetic algorithm problem. I would like to be able to have nodes join and part at will and not take down the whole system. But this introduces the problem of mismatch of generations. Often times a genetic algorithm simulation is capped by a certain amo...
I have a homework problem for an Artificial Intelligence course that I am having trouble answering. Consider solving the Sudoku problem using A* search. The start state has some number of cells filled in, and the successors of each state are all legal ways an additional cell can be filled in. At any time we know...
What are the real life use cases for tagged pointers? This is mostly coming from reading about small 64-bit systems and possible uses of 64-bit word pointers. To my understanding tagged pointers are addresses which can containing extra information in bits due to possible address space on that particular architecture is...
It seems that Helgrind treats atomics the same way as normal read/write operations. So, using atomics will result in lots of false positives. I don't know exactly how ThreadSanitizer deals with atomics, but I have found a method called tsan_atomic32_load. I assume that it can distinguish between atomics and normal read...
I have a class, but every method in it should be private (apart form __init__ and __str__). Should I denote every method with a double underscore, or is that deemed bad practice?
I'm a java developer and I want to develop an android app that capture a photo and extract its bags of visual words. To extract those bags of words I use the TOP-SURF toolkit which is written in C++ I'm new to C++ development and I want to know how to develop an android app that use this toolkit I read about the NDK. ...
I've been self employed for a long time now and have recently decided that PHP development within a company is the route I'd like to go down. I had an initial interview/meeting yesterday with a potential employer and It seems like a great place to work... so I wake up today and start to do a bit more research on the co...
I have two Classes, with very similar behaviors, both from a third party library. Both needs to be populated with some value object and sent to specific queues in order for logging. Please note both of them does not have a common parent. I am scratching my head to find out ways to refactor this. Here is the sceanrio. C...
Whenever a software license reads: ... The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. Does this mean you have to include it with the executable (the version customers get) or just the source code (for the programmers)? Sorry if this is a si...
Say someone puts their code on GitHub, under the MIT license. Then I forked it and use it in my project. Then they change the license so that it has a strict license that does not give permission to modify, sell, etc... Would the new license apply to my code, since the code I have was from before they changed the lic...
I am browsing some online coding challenge online and got struck somewhere . Objective of program is to find maximum number of swaps required in sorting an array via insertion sort in efficient time the first approach that is brute force approach gives the O(n^2) complexity The next i can think of is merge sort algor...
I'm about to take on a new project for a client designing a server-side python program that will poll a number of XML streams at regular intervals and populate a Postgresql database with results. The system will basically act as an XML cacheing daemon and populate a database. That database will then be accessed by a se...
Now that Lucene supports joins (at indexing time and at querying time) can one use Lucene as a databse (a NoSQL one, with Eventual Consistency)? Note: I was pondering on that for sometime and this is an idea that comes around again and again from time to time and there are proof that on actually can do that - to some e...
Most often, in a general-purpose imperative language - semicolons as statement-delimiters are either required, or completely disallowed (e.g. C and Python). However, some languages, like JavaScript, allow you to opt out of delimiting your statements with semicolons, in favor of other delimiters (such as a newline). Wha...
I'm developing an ERD for a graduate student manager program (it's for a university class, so it's a fairly trivial implementation). In this snippet of the model, I'm trying to work out the 'application' and 'committee' entities/relationships. Basically, a committee - comprised of staff members - can be formed and ass...
tl;dr Rich Hickey describes datomic as a system which implicitly deals with timestamps associated with data storage from my experience, data is often imperfectly stored in systems, and on many occasions needs to retroactively be corrected (ie, often the question of "was a True on Tuesday at 12:00pm?" will have an inco...
We all know these fields, database admins so like to add: UserCreated & DateCreated UserUpdated & DateUpdated They need to be displayed in the UI so I want to put them in some ValueObject but I can't come up with a good name to call the class...
I see a lot of source code that uses PImpl idiom in C++. I assume Its purpose is to hide the private data/type/implementation, so it can remove dependence, and then reduce compile time and header include issue. But interface/pure-abstract classes in C++ also have this capability, they can also be used to hide data/type...
I have a PHP program running right now that is processing database rows of over 6 million. Considering the speed at which number of records have been processed so far, it looks like the whole process might take few days to complete (due to hardware limitations). I was thinking if I could make changes in the program to ...
We are currently working on using an API provided by Mercado Libre which is a maket place for selling various goods. Their APIs use OAuth 2.0 for authentication. The problem is that OAuth 2.0 as implemented by Mercado deals with the case that the Client application and the Resource owner are different entities. So if ...
I've realized that I refer to <%@ as 'angle bracket percent at' and <%$ as 'angle bracket percent dollar', But this is very clumsy. I think <%$ should be referred to as some sort of bind, I'm not 100% sure what <%@ does, and Google doesn't like that as a search term. How do programmers normal label these terms?
I'm taking a legacy classic asp project up to more modern technology (I've been working with ASP.NET MVC lately so using this concept is stuck in my mind), but I'm trying to think of how to structure the project. The idea is that the company provides a service to clients, but the service is housed on the company's web...
My course text suggests creating a 'facade' class to completely abstract the user interface from the domain layer. That is, the UI uses only basic types, and if it needs a reference to a domain object, it only knows it as an Object. To give you an idea, this is what it might look like (example in Java but could equally...
Say, I have a class A which has methods m1,m2,m3,m4,m5.... m100. I am making another simpler class B and I require only m2,m3 and m5 in B. Should I be ideally using compositions and put a reference of A inside of B and just delegate the functionality ? or I should just re-write[copy=paste] those 2-3 methods out of clas...
So I thought about this, and I don't know if it's included or not in any methodology. I think the advantages of this coding style is that, at the lowest level, the code is extremely testable, and then the integration tests should also be very easy to build. I also think this would make the code more readable and the UM...
My company wants to release the code for a Ruby on Rails demo app, which includes our own LGPL'd library code. It it legally kosher for me to state that the contents of the entire repo are released under the LGPL, although it includes "stock" Ruby on Rails files which are generated with every app, like boot.rb and appl...
I am writing a lot of software and I feel that writing good documentation is very difficult. Since I am not aware of any structured theory about software documentation I started to organise my knowledge in this field and hope that doing this will help me to break down information in sensible units and organise documen...
I'm developing a simple text editor, just to practice a little bit. I'm developing it under Linux but since I am using Qt as GUI Framework I can easily compile this on a Windows or Mac with the same code (in other words, it's cross-platform). Qt offers a function QIcon::fromTheme(). This function allows me to get the...
I am developing an RESTish web service. I think I got the idea of the difference between aggregation and composition. Aggregation does not enforce lifecycle/scope on the objects it references. Composition does enforce lifecycle/scope on the objects it contain/own. If I delete a composite object then all the objects it ...
The main language I'm interested in doing object pooling in is AS3, which is known to need it in many cases. In the past I've always made a brand new factory class for every type I was going to try to pool, the parameters of its "object-producing" function being the same as those of that type's constructor. Essential...
Recently, I've become deeply interested in Haskell. While attempting to learn new concepts (e.g. the forall keyword and ST monad) and Haskell's type system in general, I continually run into concepts from category theory and lambda calculus. So, I wonder: What other branches of mathematics are important to a strong u...
Perhaps there's a name for what I want, but I'm not aware of it. I need something similar to a LinkedHashMap in Java, but where it returns the 'previous' value if there's no value at the specified key. That is, I have a list of objects stored by an integer key (which is in units of time in my case): ; key->value 10->A ...
Primer: We have a mobile app being served by an API (written in PHP). The main point of the app is to display products from a large items table in the database, in a multitude of different configurations. Categories, suggested items, user compiled feeds, "similar to" feeds. Basically most, if not all of the display dat...
I was looking at wikipedia - Category:XML-based programming languages. Why would someone take this approach for designing a language? What are the advantages of it? I can only think of disadvantages. hard to maintain hard to read hard to write
When planning the architecture for a mid-large scale MVC web application how do you implement the layers to be as decoupled as possible and easy to test? (basically follow best practices) Let's say I'm using code first as my data access. I struggle with what to define "business logic" as, and how it is meant to interac...
I'm working on a simple in-browser 3D model constructor using THREE.js. The user picks a plane body, and adds wings, cockpit, tail etc of their choice, choosing from multiple options. I need to be able to define relationships between many bodies and many add-ons, and of course I don't want to manually have to define th...
https://stackoverflow.com/questions/10941249/separate-rest-json-api-server-and-client In light of this post, I wanted to ask questions regarding Django and specifically the implementation methods of getting one of these client side technologies to work with Django. Currently, I have a backend that is setup that uses Dj...
I have taken a small chunk of open-source code, around a hundred lines, and found that for whatever reason, I have modified it so drastically that my end result has essentially no resemblance to the original. Maybe a line or two, and a few variable names, are carried over, but the diff is just one or more big chunks of...
Is it bad coding practice/design to make a class which will only be instantiated once? I have some variables and functions that can be grouped together under a class to "look good" (for a lack of a better description) since they are somewhat related, but they can just be global variables and global functions. (Btw, I a...
I now have a Python project that is in charge of generating the simulation data and visualizing the simulation and processed data. A C++ console application is already available in my Visual Studio. The processing sequence is as follows: Python project generates the raw data into data.txt. Visual Studio C++ console ap...
I'm having difficulty finding resources on how to write programs in a functional style. The most advanced topic I could find discussed online was using structural typing to cut down on class hierarchies; most just deal with how to use map/fold/reduce/etc to replace imperative loops. What I would really like to find is ...
I am a hobbyist programmer who makes and maintains one production system, largely coded in Python, which now has to be ported to Android. I don't know Java at all. However, SL4A in Android makes Python a bit of a second class citizen re APIs, such as Google Cloud Messaging etc. However, for me, Java appears intimidati...
I have records that have dates against them and an occurring field that contains none,yearly and monthly id status note date last_updated occurring 1 open --- 01/01/2011 01/02/2010 yearly 2 open --- 05/05/2011 03/05/2011 monthly 3 open --- 06/06/2011 05/06...
I have an if/else if structure that on some cases does nothing. From the code I have seen in my career, the "empty" case is normally left out. But when I wrote my code, it just doesn't feel right to leave this case out, but to show it as a real case that simply does nothing. For example, in a case where something is do...
Say I have a variable name len in a function and several strings. Can I use this to store length of those strings one after the other or should I create separate variables? Basically this: size_t len; len = string1.size() ....//some code len = string2.size() ...//more code versus size_t str1len, str2len; str1len = str...
Whenever a new framework is released it is a given that someone somewhere will benchmark it against other available solutions. One interesting benchmark is the "Requests per second" benchmark. For example look it this benchmark: Now AFAIK Zend framework and Symfony are 2 of the biggest frameworks out there with major ...
I have developed a web application using zend framework, mysql, and other client side technologies like javascript, jquery ajax, kendo grid, and so on. I have completed development and have done several rounds of testing to make sure the functional part is correct. Now I would like to check for the vulnerabilities in ...
I wrote a Python program that has to perform some expensive spatial searches while holding lots of data in memory. I tried to improve the performance, that is tried different approaches (see my question here for example). First, and maybe not so surprisingly, I found great performance differences when running the same...
I have a php website that will be experiencing high levels of traffic in a few weeks. We scaled the servers to accept the traffic, but want some sort of fallback page in the event that something happens. Does anyone know of an easy way to implement this? My initial thought is to check for the headers when the page is r...
I would like to create a web application (meaning that will run from browser). The point is that I want to write just the UI in HTML5 + CSS + JS (or maybe even some PHP). On the other hand, I want to write the functionality of the application in C or C++. Then, I want to combine the code about the UI and functionality....
It is commonly agreed that team managers should not be scrum masters, but I am struggling to see why. For context, I am an Application Development Manager with 4 devs in a Scrum Team. I come from a Scrum Master background, and have introduced scrum to the organisation. I have built the team from scratch and made it ...
As in the question above: What the best way to wire up Entity Framework database model (context) to viewModel in MVVM (WPF)? I am learning MVVM pattern in WPF, alot of examples shows how to implement model to viewModel, but models in that examples are just simple classes, I want to use MVVM together with entity framewo...
I've been working in a relatively complex application with 10's of database tables (Aggregates, Entities/Value Objects) and applying DDD. At this point it appears to be basically DDD-Lite meaning that there are Application/Domain Services, the Domain Model (Entities, Value Objects), and Repositories. I picked up a boo...
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 ...