instruction
stringlengths
34
19.9k
In learning Python, I found that when two "names" (or "variables") are assigned to the same value, both of them point to the same memory address. For example >>> a = 10 >>> b = 10 >>> a is b True My question is, when assigning b, how does Python figure out that a 10 object already exists? One way might be to create th...
I have made a large number of modifications to some MIT-licensed source code to tailor it to the requirements of my project. Since this is JavaScript (for a website) the minified source code is naturally attainable by anyone viewing the site. Whilst I am happy for people to use the source code under the terms of the MI...
FlashPunk is a third-party graphics API for simple game development in AS3, and they take what are effectively sprites or display objects of some sort and refer to them as "Entities". Entity is the actual class name, and it's the predominant class to use to animate something such as a character moving on the screen. T...
I have written a python program to test a new network routing algorithm, that uses a Content Centric Network Approach for handling requests (CCN), where the CCN router keeps 3 data structures: A PIT or Pending Interest Table, that holds requests for which a router has not yet received a response. A FIB or Forwarding...
My project leader uses project based prefixes for class names, lets say projects name ABC, he create User class name as ABCUser. and he says he do this becasuse if he wants to make User.aspx Users get mixed. so I told him why not use namespace (Entity.User ie.) to make it specific but he against it. I would like to hea...
I am designing an API for a driver that manipulates HW. I have done the following: namespace HWRegister { //private: namespace Data { //accessible only within this namespace //Represents one of the four HW blocks. enum EHWUnit { Block0, Block1, ...
If I have server with 256 Gb of ram. I was wondering can I create a C# application which has a 100 GB of memory footprint? I want to create a dictionary like Dictionary<DateTime,Dictionary<string,Dictionary<string,DataClass>> Fist dictionary DateTime - Max 40 distinct values Second Dictionary string : 2000 distinct v...
I'm doing a research on PHP and wondering if there any other commonly used programming langues that use an associative array for both simple indexed element storage and key-value functionality. Does it make PHP unique in this sense? For example, a language like C# distinguishes clearly between a simple array and a map\...
Let's say I have a relational database application and a "user" object and a "message" object. Now I want to show the number of unread messages to this user. What's the best way to archive this? Do I introduce a field in the user and count it up if the user receives a message and decrease the count if he reads one? Or ...
So I am working with a customer who has an older application that has quite a few interesting quirks. Among other things, it has its own code version system for business functions, by storing the entire algorithm version in a database. The data is then retrieved and compiled on request (this is a web application, and y...
I am starting out in Java API design and in reading existing code bases, I have found that most APIs consist of interfaces only with their implementations bundled in a different package. Having read that interfaces are generally more problematic to use/maintain than abstract classes, why aren't abstract classes used i...
I have a REST API that looks something like the below where a person can belong to an organisation (but doesn't have to) and a person has many items. The items may also belong to the organisation instead of the person. /people/:personId /people/:personId/items /organisations/:orgId/items /organisations/:orgId/people/:p...
Everything I've read says to pass parameters to a REST service in the URI, whether by template, or query string: https://www.myapp/my/login/api/authenticate/ganders/mypassword or https://www.myapp/my/login/api/authenticate?user=ganders&password=mypassword But obviously those are exposing my username and password in c...
I've got trouble wrapping my head around a certain problem: In my data-flow app (a visual editor), I have both autonomous objects which communicate though ports via unordered simultaneous messages and thus represent an asynchronous system. Still, I also want to use functions which are synchronous, e.g they need input...
I am learning from Learn Python the hard way where I have come across a study drill where they want to know that whether a class can be used like an object. As I have experimented: class A(object): def __init__(self): print "in here" def cat(self,name): print "my cat ",name Here if I write A.ca...
I'm using OSGi for some time and I really like the ability to swap/replace components while my application is running. I simply have to build my module and push it to the OSGi container. Is there a similar concept/framework for clojure? I know about leiningen's dependency management which really helps modularity but I...
I wrote an application that tests the performance of evolutionary algorithms. This application performs a run of the algorithm which consists of several generations. The data which is produced by my application looks like this: run1.run // text file containing metadata run1_data // folder contain...
The .NET CLR is not an interpreter, since code gets compiled to native code by the JIT compiler. So I find the usual description of code "running on" the CLR confusing. How does the native code interact with the CLR? Does the compiler insert calls into CLR methods at the beginning and end of your methods, for example?...
There is a source file in a rather large project with several functions that are extremely performance-sensitive (called millions of times per second). In fact, the previous maintainer decided to write 12 copies of a function each differing very slightly, in order to save the time that would be spent checking the condi...
I'll change my personal code often and not worry about going back and changing the associated variable names. Should variable names be maintained in case of meaning changes? var accountCurrentValue = x; var accountYesterdayValue = y; var accountValueChange = accountCurrentValue - accountYesterdayValue; --> accountPast...
So, I work as a developer. We are a small team. The majority of the people (everyone except the project manager and the senior developer) are still in university. We have very flexible work hours, sometimes I don't see some of the people for 3-4 days. You can imagine that communication is key here. We write a lot of em...
I've built already a bug report system. It looks like this: It is accessed using a secret key combination detected by the JavaScript code. Not hard. It has everything - sends the standard emails to management and testers, logs the Javascript variables and current DOM HTML. We are also improving the backend of the syst...
Look at the following use case. I have a client (Java) application, which wants to get/set the state of another, remote application (C). The communication between them is done via SIP, which is run in another thread. The SIP interface can do the following: sendMessage onRequest I have two ideas for the architecture: RP...
I'm working on an Android social app which connects to a Postgresql database for up-to-date user data and is going to use lookups for dropdown menus, and these lookups will either have multiple options (e.g. for eye color, the menu would show 'blue', 'brown', 'green', 'hazel', 'red', 'white') or boolean options (e.g. f...
I have simple set of resources, not more than 10 types, with some one-to-many relationships. For example An order has many entries An entry has many comments A machine can have multiple entries associated A material can have multiple orders associated All the model objects are identified by a unique Primary Key I com...
Let's say Alice has a Git repository, and the version is kept track of inside the repository (e.g. package.json for npm). Bob sends a pull request to Alice which increments the version number from 0.1.0 to 0.1.1. Carol also sends a pull request to Alice (independently from Bob's request) which increments the version nu...
I use the Entity Framework often, but I have one area of confusion I would like to understand better. If I wanted to have a navigation property in an Entity such as public virtual ExampleObject Example {get;set;} it is also the done thing to have an Id property public int ExampleId {get;set;} My undertsanding is thi...
I am working in a team of 4 members. we have started reviewing code 2 months ago. we are using Gerrit as code review tool. while reviewing code initially we have found lot's of problem in the code i.e. no proper code comments. method are too big. no null pointer checking. no proper exception handling etc. but now a da...
I'm making an iOS game. All developers need to determine whether their app uses cryptography or not. My game saves files in the Documents folder. They are .plist files representing dictionaries. They are encoded in base 64. From what I gather, encoding is not encrypting. So we're fine there. However, the values inside ...
I'm looking for a reasonably(*) space-efficient way to encode arbitrary-precision decimals (e.g. BigDecimal), such that when sorting the bit-pattern of the encodings lexicographically, the numbers will be sorted numerically. This is related to this Stackoverflow question. One simple/naive approach to this would be to c...
Given a liked list, I'd like to swap every pair of nodes as follows: input: a-b-c-d-e-f-g output: b-a-d-c-f-e-g If there's an odd number of nodes then the last node is tacked on as-is. This should be done in-place. Implement the method: Node* SwapTo(Node* start) I'm using this Node definition: class Node { public: ...
We are currently designing an API that will hide different services (Product, Content, User etc) that will be used by our own website, our own apps etc. It is not a public API. We are looking into using ServiceStack as a foundation, and that might be right. However, the biggest concern is how to manage the users (each ...
Many mathematical operation (such as division, multiplication, etc.) are supposed to be computed faster when dealing with power of two numbers (C++, C#?, ...) For instance 15 * 256 = 0x0e right shifted (fast) 8 bits = 0x0e00 = 3840 Whereas 15 * 255 = 0x0e multiplied by (slow) 0xff = 0x0ef1 = 3825 Does this kind of opti...
I am not a professional coder, but rather an engineer/mathematician that uses computer to solve numerical problems. So far most of my problems are math-related, such as solving large scale linear systems, perform linear algebra operations, fft, mathematical optimization etc.. At smaller scale, these are best handled by...
I'm creating a database to store words. The intended usage is to query the database to find a word matching a set of filters. E.g. if I wanted to find a word with < 10 letters, < 3 syllables, rhymes with 'at' and matches the tag 'animal', it would return 'cat', 'bat', 'wombat'... Unnormalised, the table would look like...
I never developed for the Cloud, and to tell you the truth I am not fully 100% sure of what Cloud is when coming down to servers and services. I am starting to develop an App where I will need to be able to scale as needed. The App has a lot of User entries as well as file uploads. Think is as a "forum" (this is the ...
I have several projects in my solution: Logan.Web.DBContext defines the DbContext for the database and builds the data model Logan.Web.Objects defines the classes that will represent the tables in the database Logan.Web.Data defines the data layer that the application will use LoganMVC is the actual MVC website Obvio...
Currently we're starting to work on a project for which we're going to need image processing libraries. The problem is some of the libraries are GPL licensed. I'm reading through GPL licence and quite a lot of other ones (FreeImage public licence etc..) and I'm a bit confused of all the long text. So I'll ask bluntly: ...
According to this post, we should never rely on the finalize method to be called. So why did Java include it in the programming language at all? It seems like a terrible decision to include in any programming language a function that might get called.
I have an AppHarbor site where I need to do weekly updates to some of the data. I don't want to go the route of deploying an exe and adding an additional "webworker" to my site because those cost money. My thought is to add a web service/REST api service to the site so I can just call it, it will execute the "batch job...
My group has been developing an R package to simulate plant growth (see GitHub repository). The R package uses .Call to interface with C. We have decided that it would be worthwhile to create a standalone C library. The two key reasons are 1) to use familiar C debugging tools and 2) a large portion of the developer / u...
I need to use some software under the AGPL to populate a database with some data. This software has a web interface, which I shall disable. Then the data will be used "at arms length" with closed-source software by reading the database. I may also use some IPC, like datagram sockets to provide a bridge between the AGPL...
I need to create a simple web application for track expenses, with some basic actions (user must be able to create an account and log in, list expenses, edit them, etc) with a REST API for each one, and the trick is that I need to be able to pass credentials to both the webpage and the API. So, after some research I'v...
I'm trying to understand the differences between a traditional interpreter, a JIT compiler, a JIT interpreter and an AOT compiler. An interpreter is just a machine (virtual or physical) that executes instructions in some computer language. In that sense, the JVM is an interpreter and physical CPUs are interpreters. Ahe...
I'm writing a application that will decide the scheduling plan for a few dozen people according to their occupation (role) and availability (week day and hours). I've used a excel spreadsheet to help solve this problem, I was then able to devise a logical and decision based approach to assign these people to shifts and...
As I'm finishing a web development course with a few friends with whom I have worked in many projects we're aiming to begin a professional team of developers. Functions are well defined between programmers, analysts and designers, and the team shouldn't get to a much larger number than six members. To quicken developme...
Disclaimer: I'm not 100% sure I understand some of the practices and concepts in DDD, so this question may actually be answered by clarification of the ideas I'm working in a legacy system (written in PHP) in which the database tool provides no object relational mapping, and thus objects coming out of the database acce...
The GPL font exception allows the font to be embedded within a digital "document" file without requiring the "document" itself to also be shared with GPL. Now I wonder, what is considered a "document"? If the GPL+FE font is embedded in a software to render a user interface, the software can be released with a non-GPL l...
I have a hypothetical scenario where I need to pass data to APIs from multiple different providers, depending on the 'vendor identity' provided by one of the pieces of data. If I have the data as objects within an enumerable parent object, what would be a good way to pass the objects to the appropriate API in a reason...
My company has a client-side web application that we would like to open-source. We don't want to impose any restrictions on usage, except that any modifications and derivative works should contain a visible attribution, e.g. show our name and/or logo - we want it to be visible that our code is being used in the applica...
In our working group we had a discussion on using git tags in our projects. Some people argumented pro tags and some argumented against using tags. The crux is that we are talking about Magento projects which aren't really using version numbers, hence the tags only consist of 20140624 date references. The pro side was ...
I've been working for a year now in an agile project to redesign an insurance application. I really like working in an agile environment, although management and analysts I work with still have waterfall thinking ingrained and makes it a little complicated to embrace the new paradigm shift to agile. From a developer ...
Assume that the source file A contains the following license notice: "This code is Copyright 1234 by XYZ. It may be freely redistributed in its entirety provided that this copyright notice is not removed." Can I combine it with a project B published under the GPL version 3 license? In particular, does the lack of a per...
I am familiar with basic C pointers. Just wanted to ask what is the actual use of double pointers or for that matter n pointer? #include<stdio.h> int main() { int n = 10 , *ptr , **ptr_ptr ; ptr = &n; ptr_ptr = &ptr; printf("%d", **ptr_ptr); return(0); } **ptr_ptr is printing 10 but how?
How is testing handled within the same sprint as coding, if all or most of the coding is not done until the end of the sprint? (I'm referring to the "soup-to-nuts" development and testing of a single PBI within a sprint.) Most of the answers I've seen online involve QA automation, but even that isn't really possible si...
Terminology Element/Form Element -> Fields such as text list, combo_boxes, push buttons, etc. Problem I have a program that is basically a fat client that interfaces into a system that keeps track of traffic lights. In this program exists a form. The form contains several subforms. As it is right now, some of the subf...
I'm trying to understand why the output file sizes are significantly different when using a C and a C++ compiler. I was writing a small hello world program in C and C++, I noticed that in C version, the size of the executable was 93.7KB and in C++, the size of the same hello world program was 1.33MB. I am not sure why ...
I am working on an application with over one million lines of code. OPTION STRICT is set to off!. I want to set it to ON during the next work iteration. I believe the only reason OPTION STRICT should be OFF is when converting a legacy system e.g. VB6 to .NET. You should then set OPTION STRICT to ON ASAP. Am I right ...
How could an expert system tell following scenarios apart? How could we include some meaning of a sentence, if at all? A machine needs 1 day to produce x units, and, we know that two machines like the first would need 1/2 day for x units. However, if: a truck transports a container from a to b in 1 day, but two...
Currently our model, with respect to SVN and automated build, looks like Which, as far as I know, wasn't the way SVN was meant to be used. But the process works okay from a technical standpoint. The goal is to be able to run these chains in parallel, with different people working on new features, others fixing new bug...
I'm trying to model nWoD characters for a roleplaying game in a character builder program. The crux is I want to support saving too and loading from yaml documents. One aspect of the character's is their set of skills. Skills are split between exactly three 'types': Mental, Physical, and Social. Each type has a list of...
I am a beginner and am currently developing a kind of cms using PHP. The number of libraries that we can potentially use in the front end is large. I have a question about properly selecting, managing and using front end asset libraries. I don't think just including a bunch of front end libraries like this is the bes...
Suppose there are n lines for a hotline. Whenever a customer calls the hotline, the call is forwarded to one of the n lines. And I want to assign percentage of calling to each of the n lines. Suppose there are two lines and one line is assigned 60% and other is 40%, the total number of calls is 10 so the first line wo...
Is there a known standard data structure which is a hash table that resolves collisions using a binary tree? If so what is the name of this data structure? I imagine such a structure would be useful as it should reduce the worst case search time down to O(log(n)) compared to O(n) in a hash table, and the best case woul...
I am currently studying the refactoring methods defined by Marting Fowler (http://refactoring.com/catalog/). He states a tip for replacing chunks of code by a single method that does that job. So far, I agree, as we all learned about the downsides of Spaghetti-code. But the example for this rule looks as follows: Repl...
Having a larger WinForms application with several classes I currently pass references to several "central" objects around to function calls. This leads to more method parameters. Example: public static class Program { private static MyCentral _central; ... } ... public class SomeController { public objec...
When I write an unit test I usually provide a context (plain object or mocked/stubbed object) that I setup in some ways and then I can run assert statement on the context: note: code is in pseudo-code; groovy like syntax: test myTest() { def o = getTestContext(); o.string = "testme" o.number = "2" assert o.mul...
Say I have a list of 50 DNA sequences all of the same length (6, 8 or 16 bps/ chars). I want to group these to sets of say 5 or 6 sequences per set. I have some criteria that need to be met based on the sequence: 1) There has to be at least three mismatches (different characters), ACGTAC ACTTAT has 2 mismatches -...
I'm new to web development and I've started working on a project in my company that uses DJANGO. I feel it flexible to start my development straight first from the templates. I think it will be easier if I visualize things first. So my question: Is it okay to start with a template rather than starting with models first...
In have written a function which expects the caller to pass in a configuration file like XML. Then I parse this given file and extract something which i then return. In this function (at least) two "bad" things can happen: The given file does not exist or is not accessible in any way While parsing/validating the file ...
I am developing software where each action in my entities need create tasks that will be execute in my infrastructure. When I create a task it is only records in the database. Afterwards, a windows service will execute it. Actually, I use a Service and my Entities are Anemic, then when I change the state of my entity I...
Background I work in the Language Resource Center on my campus. It's a relatively small lab, and our job is to help students, not code software. Being a Computer Science student, I took the initiative to start coding useful utilities to make our jobs as lab assistants easier. Recently, Google declared a shut-down of ou...
I believe that the "Definition of Done" is created by the Team and the "Acceptance Criteria" is created by the Customer. Am I correct? Can a customer define the Definition of Done to the agile team?
I originally asked this question on StackOverflow, but I was directed here, and I think my problem is perhaps as much conceptual as technical, so here goes. If you’re defining a hierarchy of abstract class in C++, and then creating concrete subclasses with implementations, you could end up with abstract classes somethi...
At work, one of my projects is mostly about taking data passed in from an external client and persisting it in a database. It's a Java enterprise app using JPA and most of our logic revolves around CRUD operations. The majority of our bugs involve JPA in one way or another. Example 1: If you click the save button...
Lately I've been in the habit of "masking" Java collections with human-friendly class names. Some simple examples: // Facade class that makes code more readable and understandable. public class WidgetCache extends Map<String, Widget> { } Or: // If you saw a ArrayList<ArrayList<?>> being passed around in the code, woul...
I m trying to get the possible combinations of a given set of numbers say for example 123 The possible combinations would be 123 132 213 231 312 321 For this i have written a code as below - import java.util.ArrayList; /* Name of the class has to be "Main" only if the class is public. */ public class Main { /** * ...
Should a view call a helper function? Say I pass in data from the DB to the view. The data is a unix timestamp. Should I make a call in my view to convert it to a human readable TS or should I convert it in the controller before passing it in? OR should I make a method in the model that converts... Looking for a "best ...
I have a java/swing application in (hopefully good) MVC structure. Here is a overview of my model classes: One or more workers may work at one working location and one worker may work at different working locations (not at the same time, of course). A worker may have different types of a date assigned. The working loc...
I'm designing a library that binds to html elements on a page. In this particular case the input[type='checkbox'] will be checked if the likeItem property returns true and unchecked if the likeItem property returns false. What's the best practice for naming properties? input { check: likeItem } or input { checked: like...
Reading http://www.scala-lang.org/api/2.11.1/index.html#scala.collection.TraversableOnce: Directly subclassing TraversableOnce is not recommended - instead, consider declaring an Iterator with a next and hasNext method, creating an Iterator with one of the methods on the Iterator object, or declaring a subclass of Tra...
I'm working on an app which talks to a bluetooth low energy (BLE) device and exchanges customized data with it. Our team has defined the data models and there's a method that will parse the data payload and assign values to the corresponding characteristics. It works all fine until we have introduced a new firmware. In...
My .NET application does its work and then creates a report (an Excel worksheet). That report contains thousands of short text strings [KEY - VALUE]. So Excel worksheets suites very well, one column holds the keys and another holds the values. It's easy to examine this reports. But because of performance issues now, I'...
I am new to using nodejs completely, and it seems to be pretty much the go to thing for everything right now. But I program in Visual Studio, and I'm a bit confused about how this works. I will cite an example; One task I want to do is to get a list of all the files in a directory and all of its sub-directories, and re...
Our team has been using Git for a couple of years. I love it, after previously using Visual Source Safe, SVN and TFS. However, my manager has been getting increasingly agitated about it and is threatening to go back to SVN or TFS. The problem is human nature: Developers forgetting to push up to the origin every day...
Comparable questions have surely been asked before but I'd like to hear some words about my specific way of implementing Javascript classes. Let me first start with a Javascript example taken from a real-life application I've been working on recently. Example PageControl= new function() { var self= this; // exampl...
I am designing a REST API coupled with a service layer that takes DTOs as input and produces them as output. This works fine for most service calls where the DTO is used to access an underlying library (an embedded OLAP server) that does the work. There is one service, however, where something seems wrong. The service...
What is the best practice, when it comes to views' translation in MVC design pattern, in multilingual website: Always have only one view file and translate its particular strings with a framework translation function. Always have as many views as website supports, directly translated, one for each language, and let fr...
I am creating app(script) that is used similar to RSS reader for specific webpage that doesn't have RSS. So my app downloads that html page in defined intervals, checks new items and parses them into messages that are sent over network. But my app prototype is written in Bash (Linux is my primary OS), and I was asked t...
Often in my designs I define an abstract superclass whose subclasses will vary mostly in their values for the fields defined in the superclass. For example, in a game I'm developing there's an abstract class Missile with a number of subclasses. Each one defines a different value for member variables such as MAX_SPEED, ...
I've been convinced for awhile now that some strategies in functional programming are better suited to a number of computations (i.e immutability of data structures). However, due to the popularity of imperative languages, its unlikely that I will always be working on projects that are functionally implemented. Many la...
I have a task to convert CAN protocol Driver from Basic CAN to Full CAN. The project contains CANopen stack used in it. I have initiated the study of CANopen stack. I want to know is it necessary to study CANopen Stack and to how much depth should I study CANopen stack? Please note- Major task is to improve the drive c...
I am working on a project in MVC that has mobile application so one thing is clear that we have to use Web API so it can used in mobile application. After creating API when we started to develop Web site we are confused and had discussion on whether to use API or directly access to the Business object. And we ended up ...
In my nodejs project, I have functions like this for socketio. socket.on('draw', function (data) { socket.broadcast.to(socket.room).emit('draw', data); addEvent(socket, ["draw", data]); }); I'd like to rewrite them to something like this: function onDraw(socket, config) { return function (data) { s...
Is there any legitimate use for bit manipulation hacks in higher-level languages such as Java? I can see them being useful in speed-sensitive low-level and computation-intensive programs, e.g. graphics processing or crypto functions. I guess that's why all collections of them are in C. However, getting to think about t...
I've got long standing developers in my sprint team. They know the domain, they've been with the company 5+ years and as a team we have a pretty good burn down rate. There are other sprint teams, some with equally knowledgeable developers and others with newer developers who are trying to get up to speed. My manager is...
I have someone who wants me to develop a game for them. I do not intend to continue developing the game after its first release (he wants me to develop it for commercial use). To make the project easy, I was thinking of using the Unity game engine. I am going to say right now, I am a kid heading into college, he wants ...
I use Spring Framework to code my Web Service, using Dependency injection to inject a DataSource bean into the DAO bean that will be used by the Web Service. I have all the database properties(Url, Password, Username, the stuff I don't want people to see) written in the DataSource Bean XML! I have git setup to commit m...
From W3C Software Notice and License: Permission to copy, modify, and distribute this software and its documentation, with or without modification, for any purpose and without fee or royalty is hereby granted My app depends on the xml-apis 1.4.01 library that in turn includes W3C software and I need to distribute it ...
I'm doing a J2EE web application with Struts2, MyBatis and a MySQL database, so what I want is to allow the user to be free to choose different parameters to perform a select to a table in the database. For example, I have a Table called SALES, so I want that user to be able to select different parameters according to ...