instruction
stringlengths
34
19.9k
When I first started working a mainframe assembler programmer showed me how they swap two values without using the traditional algorithm of: a = 0xBABE b = 0xFADE temp = a a = b b = temp What they used to swap two values - from a bit to a large buffer - was: a = 0xBABE b = 0xFADE a = a XOR b b = b XOR a a = a XOR b ...
Let's suppose I want to create an extension for Joomla that uses a jQuery plugin or any third party library. Imagine that I create a Joomla module that uses jquery Nivo Slider plugin (MIT License) http://nivo.dev7studios.com/license/. I'm not sure If I could sell this module with this license. Could I sell it if the p...
I'm solving a graph-search optimization problem. I need to find the k best acyclic shortest-paths through a directed weighted graph. I know there are a number of exact and approximate k-best algorithms, but most of the recent research seems to be oriented toward very large, very sparsely-connected graphs (e.g. road rou...
I am author of growing framework, which is focused around User Interface building in PHP. Essential requirements for the up-coming website redesign is ability to run code examples. I am willing to extend this option to add-on authors which would mean other people will be able to execute code on my server. Please sugges...
In programming contests like Google CodeJam, Facebook Hacker Cup, each question is provided with an input file for testing one's code for that program. I get struck at this point only. I don't understand whether that input file should be read by my program or it is just for testing the correctness of my program for var...
In agile methodologies (e.g. SCRUM), the complexity/effort needed for user stories are measured in Story points. Story points are used to calculate how many user stories a team can take in an iteration. What is the advantage of introducing an abstract concept (story points), where we can just use a concrete measurement...
Given a numerical range and a list of used numbers that fall within that range I need to compress the range into blocks of used and unused numbers. For example: range: 0 to 10 used: 3,4,5,9 I need an output like 0-2: free 3-5: used 6-8: free 9: used 10: free Not sure where to start with this, so any guidance appr...
I know Haskell already has the ability to parametrise a type over another type (similar to template programming in C++), but I'm wondering whether Haskell can also parametrise a type over values – whether it supports dependent types. With dependent types, you can have a type that's parametrised over integers, for examp...
I have a mobile app built using jquerymobile, PhoneGap and some custom CSS and JavaScript. The data objects are received in JSON and used to display different forms to the user. For example { id: 1, type: personal_details, question_1: "First name", question_2: "Last name" }, { id: 2, type: work_details, question_1: "O...
Where I work, new applications that are being developed that will use their own relational database, must have their database-models (conceptual, then physical ) reviewed and aproved by DBAs. Things looked after are normalization, antipatterns, table and column naming standards, etc. Is this really a DBA's responsabili...
Recently I was looking at python's shutil and subprocess etc... And I started wondering: wouldn't it be ok to use python instead of e.g. bash? What am I missing?
I am doing arithmetic operations on really huge numbers. For example, I am given six variables, a_{11}, a_{12}, a_{21}, a_{22}, x_1, and x_2. Although the above are math terms, these six variables are each 1000-bit integers. What I want to do is to calculate (1) two numbers z_1 and z_2, and (2) the matrix inverse. (1) ...
I have been going round in circles with this question for days - which is the best PHP framework to use to create a RESTful Web service? I've trawled the web for info and have come across three main factors that are important: must have REST architecture built into the framework must be a stable application must be fu...
Is the concept of OOP intimately tied to allocating objects on the heap? Is it possible to write normal OOP without creating excessive objects on the heap?
I have a codeigniter app and in my model, I always return true or false for all functions, and if I have data that needs to be passed, I also set a property that contains my data. The only trouble is, in my controller, if I have to call 3 or 4 methods in my model, the code gets really repetitive. If ( $this->my_model-...
I'm writing some documentation in a project in a tool. In this tool of mine, and write in specific area, I have here use Case, Business Rule, N-Diagram Types, and Functionality and Functional Requirements. So I got me wondering, Are there differences between Functionality and Functional Requirements? In my vision, a Fu...
I'm a python beginner, and I just learned a technique involving dictionaries and functions. The syntax is easy and it seems like a trivial thing, but my python senses are tingling. Something tells me this is a deep and very pythonic concept and I'm not quite grasping its importance. Can someone put a name to this techn...
I am working on developing a relational database that tracks transactions that occur on a device I'm working on for my company. There are different types of transactions that could occur on the device, so we have a "trans_type" field in one of our main record tables. My group has decided to make the type of this field ...
Getting a few projects started with EF, but I had some questions about join tables and keys etc. Lets say I have a table of applications and a table of permissions. Applications have many permissions and each permission can belong to many applications (many-to-many). Now, the Application and Permission tables are easy:...
Many modern Relational Database Management Systems automatically support referential integrity, i.e. when you try to delete a tuple which has a reference (in the form of foreign key, for example), the DBMS doesn't complete the operation and brings an error. Consider a database where every table has an attribute, which...
I always have trouble figuring out if I should name a certain method starting with getSomething versus findSomething. The problem resides in creating helpers for poorly designed APIs. This usually occurs when getting data from an object, which requires the object as a parameter. Here is a simple example: public String ...
I know it has something to do with 2's complement and adding 1, but I don't really get how you can encode one more number with the same amount of bits when it comes to negative numbers.
What's the difference between WTFPL, CC0, and public domain? Are they essentially the same thing?
As someone who's still new to agile, I'm not sure I completely understand the relationship or difference between user story, feature, and epic. According to this question, a feature is a collection of stories. One of the answers suggests that a feature is actually an epic. So are features and epics considered the same...
I am stuck with a very old large website which I need to do some modifications. I can't use or integrate a new MVC framework due to current site is outdated with some custom coding done long time ago. I am writing custom reflection class for the user table in the database, but I find it easy to work on the model creat...
I would have two questions related to cyclomatic complexity: Can I use this metric for a whole app? I guess I cannot, as it would be incredibly large number, considering functions calling functions etc. Is it just for module/method/unit? In Visual Studio, for starting app with just calling the Main method, the cycloma...
I recently came across some newly written code that was interspersed with lots of Debug.Assert (C#). Should we still use this widely despite the usage of TDD, BDD and Unit Testing in general?
I am tasked with designing and implementing a flexible UI solution for deployment across a series of "kiosk"-ed Windows endpoints. There is some debate about what is the considered to be the best technology solution for the actual UI itself. The requirements are: Must be hardware accelerated Must play WMV video (for l...
I deployed a Redmine installation yesterday and today I try to fill it with some relevant data. One issue I came across is the organization of projects itself. While I took a look at how Redmine itself uses parts of the software, they unfortunately have only one project set up and I haven’t seen any other examples. I ...
Possible Duplicate: Asking for a code sample of the company at an interview Last year I changed jobs twice.. In the interviews with the companies, everything was so ideal and perfect. Latest frameworks, design patterns, distributed systems, scalable and enterprise systems, etc.. But in both cases something was not a...
Sources usually mention that dynamically created variables are allocated on the heap, while functions' variables on the stack. Also the ones on the stack cease to exist automatically when e.g. the function which contains the variable exits. If I understand correctly, data fields of class are on the heap. I do not under...
Possible Duplicate: Why were Java collections implemented with “optional methods” in the interface? I was looking at the javadoc for Collections and I noticed the unmodifiableCollection/unmodifiableList/etc. methods and I thought to myself, could this API be better? Here's one of the API signatures: public static ...
Preamble One of the concepts used in writing Python code is "Easier to ask for forgiveness than permission", aka EAFP. Literally, this means that instead of doing checks, whether an operation is possible, you do the operation and "ask forgiveness" if what you do fails. Technically this means (just an example with no pa...
I am a founder and only developer of an open-source software designed for a small subset of enterprises. It was originally developed for and now runs at one of businesses of the type it was designed for. It's my biggest project and I wanted to make something even bigger of it. Creating a software developing company and...
Is it possible to use the Windows 8 Store controls in a Windows 8 desktop app? Controls like the FlipView and SemanticZoom would be useful. I haven't found any information about this and would presume the answer is no, but thought someone would have a more definitive answer.
I have an exam on Programming Concepts this Saturday and I am struggling to find some information to understand some concepts better. What is the difference between loop invariant and assertion? To me they look the same. Also, what exactly is while loop invariance theorem? Not sure whether it is me or it is ridiculousl...
I'm a big fan of using open source software but I mostly use community binary releases for the job. I'm wondering about companies that go the extra degree and build everything they use in their production server application infrastructure entirely from source, in-house, in an effort to promote transparency and supporta...
I'm fairly new to OOP (and programming in general), but what I find myself doing is that in the event that I don't need to pass a value from one method to another, I'll have my method calls centralized in some class within a Form.cs file. For example: public void CentralMethod() { MethodA(); MethodC(); Meth...
Possible Duplicate: Should developers enter bugs into the bug tracking system? Should I log trivial fixes? For a project I'll be doing in school soon I will be working with 6 other people. We will probably be using YouTrack to track our bugs and we can obviously see the value in this system. My question, however, is...
As part of the interview process we initially ask the candidates to do 'FizzBuzz' nowadays the percentage of candidates that can correctly answer FizzBuzz has increased dramatically - this may be due to it's popularity on the web. About a year ago, as a second question we began asking a question very similar to the ori...
I'm confused between aggregation and containment. I'm wondering if the following represent an aggregation or containment? class Auto { private string model; private int speed; class AutoCustomer { public string LastName; public string Address; public DateTime DateOfPurchase; ...
Today I got yelled at for developing an application on a production server. Quote, "developing on a production server is not acceptable - ever!" Here is the situation. I set up a development instance: http://example.com:3000 The production instance is: http://example.com I complete all my development work on http://ex...
Just wondering what the accepted convention is for Rails controller design. Currently, every controller in my app that I've written it set up to send a JSON response when necessary. Thing is, I only ever utilse HTML responses in my app. So is it a good idea to have them defined? For example: def show @dog = Dog.find(...
I need help understanding a problem I have, and that others surely have had as well. I'm working on a web-application that allows users to interface with a database. The application in general has multiple pages with tabbed navigation, that displays and allows most content to be editable. So far, it works well. I need ...
Why is it often said that the test cases need to be made before we start coding? What are its pros and what the cons if we don't listen to this advice? Moreover, does that advice refer to black box testing or White Box testing or both?
I need to describe an algorithm that finds the second smallest element in a Fibonacci-Heap using the Operations: Insert, ExtractMin, DecreaseKey and GetMin. The last one is an algorithm previously implemented to find and return the smallest element of the heap. I thought I'd start by extracting the minimum, which resul...
I was reading about some development interview practices, specifically about the technical questions and tests asked at interviews and I've stumbled quite a few times over sayings of the genre "Ok you solved the problem with a while loop, now can you do it with recursion", or "everyone can solve this with a 100 lines w...
I have a page Object, which has Paragraph and Image object Collections And each paragraph has only image_id(s) that are assigned to a paragraph. All other information about image is stored in Page->Image Now from the paragraph object I want to access the image information where paragraph has only image_id and all other...
The question in general is: is there a more effective way of implementation of table with structure like Dictionary<int, Dictionary<string, string>>? The reason I am asking this is because I have made few performance tests and it does not perform well for data with > 5M rows. Now, I dont really need this amount of data...
Neo4j eases relationship traversals => especially useful for a social network for instance. But are there any scenarios when it's advised to associate an additional relational database (or other NoSQL database that isn't specifically oriented graph) for specific query types. In short, can Neo4j be sufficient to itself ...
in my application, I have a request type associated with variety of API calls I make to the REST server. when the response from server comes in the same delegate method for web engine's response, I have to check the API type in the request object passed as a parameter to the delegate method and then take the correspon...
This is what I call a "combined" getter/setter method (from jQuery): var foo = $("<div>This is my HTML</div>"), myText; myText = foo.text(); // myHTML now equals "This is my HTML" (Getter) foo.text("This is a new value"); // The text now equals "This is a new value") This is the same logic with separate (theoreti...
Recently we had an issue on our site where someone attempted SQL injection via a cookie (we'll call it lastID). NOC was in a frenzy and angry about how the cookie as an attack vector could be ignored. They had a developer create a class for managing cookies that will sanitize lastID (and eventually other cookies) to ...
For my final project in school we have to develop an online shop. This shop should have a cart where items can be placed whether or not you are logged in. If you log out the cart shouldn't empty and should still be shown. So my question is would it make sense to store the cart as xml in the database(ms sql server)? The...
I have been trying to understand why the JDK 8 Lambda Expert Group (EG) decided not to include a new function type into the Java programming language. Going over the mailing list I found a thread with the discussion about removal of function types. Many of the statements are ambiguous to me, maybe because of the lack o...
What are the most obvious drawbacks to this idea for an enterprise(ish) model using the following technologies. Browser based and native developed GUI using Delphi to connect to Datasnap server (Delphi, obviously) via Rest which stores documents in A CouchDB Server But gets the structure for those documents from ...
A user on Stack Overflow posted a question related to overriding a native JS function. The question is here and this is the code: function throttle(fn, time) { var handle; var execute = function() { handle = null; fn.apply(this, arguments); }; var throttled = function() { if(!handle) { handl...
I have the following project structure I would like to implement. I would like to know if there are any pitfalls to structuring my code this way. It is going to be using Microsoft's WebAPI, an MVC 4 project, and Plain Old C# Objects (POCO). The explanation follows. First off there is going to be a class library project...
I'm working on a project which runs as a process, on a regular basis. The results of the projects daily run are used by other projects. This brings me to question how our team writes stories. The normal format, As a [role] I want [goal/desire] so that [reason] does not seem to apply, but at the same time I'm doubting t...
I'm developing a series of repository classes and a UnitOfWork class (plus its IUnitOfWork interface of course). I'm using Castle Windsor, which injects dependencies via constructors. My business tier has classes such as "CustomerBusinessLogic", with methods like RetrieveCustomer, SaveCustomer, etc. These in turn use t...
I am working on a project with legacy code where it does not have much code coverage. One of the idea to improve that is to enforce a rule that each code check-in must have test, not only test but functional test as well, so that we can verify that the existing code did not break. I would like to get some ideas, both p...
I am designing a simple GUI that will allow a user to create a GPX route by clicking repeatedly on a map panel. I am faced with a design dilemma for how to represent the nodes and route. This construct can be abstracted as follows: the user clicks n times on the screen in sequence to create a chain of n nodes after ...
I understand that two of the many more options for inter process communication can be : Shared memory Sockets Actually I saw these two options being exposed by Intellij Idea for debugging a Java application . I want to know what are the pros and cons of each approach .
It's more of a scenario, but it isn't far fetched at all. Let's say I have an Aggregate Root (AR) Warehouse which it's used to manage product stock. The Product itself is an AR in a different bounded context (BC) but in this BC is represented only by an id. In the Warehouse I can add a new product (must be unique), Ica...
I'd like to know what would be a better approach to invalidate/update cache objects. Prerequisites Having remote memcached server (serving as cache for multiple applications) All servers are hosted by azure (affinity regions, same data centers) Cache object size ranges from 200 bytes up to a 50 kilobytes Approach 1...
In what all aspects, calling a function with and without new keyword differ in javascript? I mean what all things are differing between? testFn() vs new testFn()
A bit of background (in case I'm mistaken)... I think I understand that (it's an oversimplification): manually entering codes into memory (or on a punchcard) is "first generation language" using mnemonics corresponding to CPU instructions would be a 2GL (like assembly language) C/C#/Java/Objective-C are all 3GLs SQL i...
I've been attending quite a few interviews recently and have been asked by companies to answer "design a [insert model]" questions more than a few times. Is this normal in the industry nowadays? I've been in the software world for more than two decades and have attended my share of interviews, but I am seeing this pa...
I'll be quite to the point, is there any way to make Javascript a bit more concealed than it usually is or is Javascript always out and open if you look in the source code ? This is about hiding proprietary algorithms that would dispense a service that does not exist yet (to my knowledge) on the market and is not reall...
Currently, I'm a long Eclipse user because my past and current companies always deal with eclipse. Recently I met some example java codes created using netbeans. I downloaded and tried Netbeans 7.x and 6.9.x, but they're more heavier and eating memory resources than Eclipse Indigo. So anyone know which past version of ...
This might be one of those "not answerable" or "just opinions"-questions but I thought I'd give it a shot. I'm developing an app with health care information with a friend who's a doctor. The basics of app are done and the information in the database is shaping up so now I've come to the question of wether, and if so h...
I am newbie to TDD (writing first project following TDD practices). I have fairly basic interface IProfiler and an implementation Profiler. interface IProfiler { bool IsBusy {get;} long Elapsed {get;} } A Simple Test IProfiler profiler = default(Profiler); [TestInitialize] public void Initialize() ...
I'd like to ask how to protect my code that is running on a client server from being altered and/or copied. It's running on Ubuntu Server with the standard Apache Php Mysql stack. Any software needed would preferably be open-source. I'd also like to terminate the application when there is a license problem. Doing thi...
I would like to use a timer in my C# program with millisecond accuracy to keep a camera in sync with some events and keep shooting a picture every 250ms (or 1/4 sec, or I might adjust it to even shorter times like 200ms or 100ms). The normal timer event can be used for this. But I wonder what would be the best way to d...
I don't know what best to give as title to this so pardon me if it sounds weird. I saw this question asked on IT Security and another site asking people to disable Java from their system or browser because it's vulnerable. As a lover of Java, though currently doing C#, I would love to still do more Java in future, but ...
As I have been learning to program, be it in my intern-ship or school, I have often come across situations where an extra piece of software is needed (from fairly basic to quite complex) and I am almost always told that I shouldn't waste my time developing a solution and use something someone else has already done. Doe...
I've heard people saying usage of JDBC (Java Database Connectivity) isn't recommended in Java applets. All I they say is: 'because of the security reasons'. What 'security reasons' do they mean? What would a potentially 'bad person' do when he/she found out about JDBC used in an applet, placed somewhere on a website? ...
I have a software patterns exam this week and one of the topics we are to study is Efferent and Afferent coupling. I understand a package has a high Ce (efferent coupling) if it depends on a number of other types. For example: class Car{ Engine engine; Wheel wheel; Body body; } This class would have a hig...
I'm resistant to calling the "main" class the same as the namespace, but I sometimes find myself needing it. Considering I'm using the Vendor.Namespace.[Subnamespace].Class formula, imagine this scenario: [MyFramework] [Database] Database Sql Schema DriverAbstract DriverInter...
In the C++ STL, priority_queue (heap) can be used with any underlying container, such as a deque. How does the implementation stay O(log n) if deques don't swap an item in index a with index b in constant time?
I want to understand how web accessibility experts deals with websites if they want to confirm that those sites are compatible with accessibility guidelines. Do they have to understand any server-side language? or just HTML and CSS? For example, if there is a company website which provides services for other sites to e...
Lets say I'm displaying a bunch of data (model) using a View class for rendering. However, a lot of the data has sub-data (models) complicated enough to require separate rendering classes. In my design, a View class has a model which it is rendering, and has many children Views which display the sub-data. In some cases...
In our company, we need to build a web interface onto an embedded Linux platform. I kind of see 2 options: You use a technology where the HTML and JavaScript is generated on the server side (Think JSP, Grails, but is is something that is using C++ and generates HTML/JavaScript) or you create a HTML5 'client' applicatio...
Stumbled upon this post that talks about making async web requests. Now simplicity aside, if in real world, all you do is make an async request and wait for it in the very next line, isn't that the same as making a sync call in the first place?
I'm rewriting a set of file readers that a former-colleague of mine created that read raw-point data of XYZ (Cartesian) coordinates or RTZ (Polar) coordinates. Currently the data is stored directly in the reader, making everything rely on the state of those objects. I'd like to separate the reader from the collected da...
I am implementing inheritance of something called Contexts. Each Context holds a link to its parent context. If that Context is the root Context, its parent is null. In order to walk up the inheritance tree and get the data from each Context, I want to do this (in pseudocode) private Hashtable getDataAsMap() { Hash...
So far all my development in C++ has been targeted to Windows, however I have always had it in the back of my mind that I will someday be targeting Linux. I am aware therefore of the need to select cross-platform libraries, and to keep my code as portable as possible (or provide alternative implementations for code whi...
Django creates a table name by joining the app label with the model name. A project can have many apps. If two have the same label, how can both be used in the same database? I'm currently using very long app names to minimize that risk (such as foo_bar_baz instead of nesting modules like foo.bar.baz - app label baz). ...
I want to make Python script that will accept input from Vim and send it to my web-site. So basically I want to make Vim my text-editor for blog articles. Of course, I need to authenticate and authorizate. I wanted to simply ask username and password. My college asked me why not to take login data from file. I answered...
I am new to web development and just started exploring the things. I read about how web page is processed and sent to client by a web server but I got confused with application server. what is the difference between them ? why app. server is needed ? and few examples of both of them .
I have been in various Agile projects and seen many release burndown chart styles. Most of them were handled manually since somehow all the tools that I have run across don't produce really useful burndown charts. In reality, we may not be dealing with all stories estimated and we just keep burning down. Many times, th...
I know pair programming is an agile software development technique in which two programmers work together at one workstation. One, the driver, writes code while the other, the observer, reviews each line of code as it is typed in. But I just wonder the strategy still work in the case. For example if they have a very ...
I have some experience in Java programming and enterprise application development. I have done OOP, data structures in C++ for my undergraduate studies. But I couldn't touch C++ for years. Now I am interested in C++ again and I would like to polish my C++ knowledge and become an expert in C++ . How do I start my journe...
We develop social-based applications for mobile. Every application consumes RESTful API web-services. When I implement login I usually store the username and password somewhere on device. Then I send them and as a response I get access to my profile. But I also know there's another way to do this. One somehow generates...
This isn't a rare case and occurs with me often and I spent countless time trying to debug the code. Latest example, this PHP code where I used $email for the parameter and for object as well. private function _mail( $email ) { if( filter_var( $email, FILTER_VALIDATE_EMAIL ) ): $email = new Zend_Mail(); ...
I am in the process of a creating a small web portal for the department I'm working in. For this is need to present some data, and have found the following: http://www.pchart.net/, which could seem to be of great help to me. The above is licensed under GNU GPLv3, and my question is whether it would be allowed for me t...
Context I'm currently working on a personal project involving functional reactive JavaScript, and I've come up with an odd question. Note that this question is not JavaScript specific, but that is the context in which I am asking it. Scenario When filtering a collection of data, you end up with a smaller set of data. T...
I have a function that accepts either a string or a dictionary as an argument. That is, it can be called as either: lookup_person({name: "John Smith", age: 57}) or lookup_person("John Smith") My first inclination is to use type or isinstance to distinguish the type of the argument, but I've seen a lot of ink spilled ...
Background Software engineering is the application of a systematic, disciplined, quantifiable approach to the design, development, operation, and maintenance of software, and the study of these approaches; that is, the application of engineering to software. My instructor, when explaining this definition has told me th...
This is what I guess would happen: If two cores tried to access the same address in RAM, one would have to wait for the other to access the RAM. The second time that each core would try to access the same address, they may still have that RAM cached, so they could access their respective caches simultaneously. If two...