instruction
stringlengths
34
19.9k
It seems to me that programming languages meant for use in science and engineering are consistently weird compared to general-purpose languages. Some examples off the top of my head: In Matlab, each function has to be placed in a separate file In R, <- is the assigment operator, as opposed to = in almost every other l...
Just finished Stanford lecture on SQL (by Prof. Jennifer Widom). However I have developed a confusion regarding the use of EXISTS clause. I thought it is just like a condition and an expression so that if it's true, the above query proceeds (much like the Boolean AND). So having a slight doubt regarding this question: ...
I'm a student currently on an internship. I've been asked to determine the feasibility of migrating an existing Windows-only C# software package to Mono. I've already conducted an analysis to identify the native libraries that will need to be ported or replaced with managed code, and identified the Windows-only API cal...
I am passing Menu items to View from ViewModel. My menu definition is a model with properties title, image, hasChildren and isEnabled. But this model is meant for UI unlike business domain models like Person, ContactDetail, Transaction, etc. So, when i see this menu model sitting along with business domain models i fel...
When a user browses some page and then switches a language, then the following actions should occur: If there's a translation for a page he's browsing now, then do redirect to that page. If there's no translated version of that page, then do redirect to a home page. So for example, a user browses /about-us page then ...
I have a non-language-specific problem which I'm having trouble finding a workable answer for. I have a 10x10 grid containing integer values from 1-10. Each value represents the cost of travelling across that square, moving north, east, south or west (cost is incurred while stepping off a square rather than onto it). I...
I forget the name of it but there's a rule that you aren't supposed to allow visibility into an objects inner makeup. It has to do with not allowing more than one dot in the implementation like this for example: return world = foo.bar.hello.world();
I feel kind of lost in this backend development process I am attempting right now. Most of the usual development practices I use while developing client-side applications don't apply here... Let me provide some context. The debugging process While developing a client side application (iOS, Java desktop app, or whatever...
I have to design a "widget", a script that partners will embed in their websites to display some UI and make calls to our API. Basically it will display our data on these sites based on some IDs they provide in our API calls. What we would like to avoid is someone abusing the API and using it to scrape the entirety of ...
There seems to be a trend towards immutable objects, and pure functional programming. While I recognize the benefits, I find it hard to apply these principles to GUI programming, for example. But I also find classical imperative languages with mutable objects lacking. I was wondering whether there is a language or syst...
I have recently joined a young hackerspace still in the process of setting itself up. We're fortunate because the space has a few internal projects that need working on and no shortage of volunteers to work on them. There have been some discussions on how to organize these projects. My most recent professional experi...
I am trying to create a timer that ever x minutes it will call to a server, get a JSON file and do something with it. The merits of that system are not in question right now, the question involves getting the JSON file. Currently I am using kimonify from KimonoLabs to create a JSON file from some other site. They sugge...
I've have two event queues(table mapped queues) based on two different states of same data stored in two different tables. The events are generated on create/update/delete on both the tables. Constrain is that both the tables have to be in sync. The create/update/delete in one table has to be reflected into other table...
For quick prototyping I have been actively using Hibernate. Recently I came back to an old project and I wondered why I had a lot of DAOs with what I suspect is commonly named feature bloat. E.g. I have a DAOs for single entities that contains from 15 to 20 methods each. Recently I have been using Hibernate Generic D...
For a while now I've been in the habit of differentiating different kinds of comments in my code. //this is an explanatory comment //!this line was commented out for debug purposes, DO NOT SHIP WITH THIS COMMENT IN PLACE //?this code was tested, and executed properly in 2.3 uS This has saved me a lot of trouble, as ...
I see a lot of talk in the OOP world about principles and laws such as Open/Close and Loose Coupling, I can understand how they are so high valued, However I seem to have ran into a problem with applying these principles and laws once I start to include relational databases. For example purposes, if I have a applicatio...
I'm creating a prototype scripting language similar to something like Javascript. In my language, every single reference to a variable is actually a function call (a getter function), whether it has parentheses or not. So for example, if do this: var foo = 3; var bar = foo; What really happens is foo.set() is called o...
This ASP .NET MVC application implements Entity Framework. I've declared the repositories in the DbContext like this: public class CompanyDbContext : DbContext { // constructor goes here public DbSet<Customer> Customers { get; set; } public DbSet<Order> Orders { get; set; } public DbSet...
If I chain some setters together and one of them does not return $this, then I will get a fatal error. But maybe that is a good thing. $object = new object(); $object->set('name','foo')->set('number',12)->set('color'=>'brown'); class object { protected $name; protected $number; protected $color; protected $al...
I'm writing a linear algebra library (long story short, it's a school assignment) that involves matrices, vectors, etc. In the process of creating this library, I'm going to be creating functions that perform mathematical operations on objects. For example, transpose matrix, invert matrix, normalize vector, etc. I wa...
An HTTP query can be parametrized to a list of pairs like name=value that can be encapsulated in general as Map<String, String> since an HTTP GET query is string pairs. I could need something for any combination of objects and primitives. A varargs method for example update(String s1...) could be written in general as...
I am currently learning functional programming using Underscore.js. What I want to do is add two co-ordinates together. Let P1 = (0, 0) and P2 = (1, 1). Therefore, P1 + P2 = (1, 1) I have a solution, but it seems so convoluted that I'm sure I'm doing something wrong: // Base 2D Cartesian Point var Point = function(x, y...
Scenario: a large existing system (~300 tables, 500 stored procs, 200 views and a code base of several 100k lines) with most security level stuff in stored procedures needs to be refactored (for maintainability reasons and just availability of skills more will likely be moving to the C# layer, as well as we are hoping ...
The way I usually do it is I make some namespace Platform in Platform.h and every OS call is encapsulated by a static function in this namespace. So the only place in the entire code base that knows what OS is being used is Platform.cpp. Is this a good way of making things easier? For instance when I call Platform::Mes...
I always thought pass by value is a legacy from the early languages, because the designers had never seen anything else. But after seeing the brand new languages like Go adapting the same principle confused me. The only advantage I can think of is you make sure that the value you are passing won't be modified. But ever...
What is the difference between dependent typed languages and languages like Spec# and Eiffel that allow you to specify "contracts" for functions in your code for pre/postconditions? Is dependent typing basically the purely functional version of Eiffel's "contracts"? From what I understand, dependently typed languages ...
The title question is unfortunately pretty vague (or at least may be asking differently than what I intend)... but let me elaborate. I know basic HTML5 and CSS. I don't need to learn the tags and how they work. What I'm looking for is some information on what sort of process to follow when actually coding a professiona...
Suppose the following DTO class. Which of the two getters breaks encapsulation least? class Foo { public: /*Return the most primitive type. Caller do not need to worry about what Array is*/ const RecType* dataBeginGet() const; const RecType* dataEndGet() const; /*Return ...
I have an array A of n integers, sorted from min to max, and two numbers a<=b, which are known to be in A. I would like to write a pseudo-code for a procedure whose running time is c1+c2log(n) and which returns the number of elements in A which satisfy a<=A[i]<=b. I wrote the following but am not sure it satisfies the ...
The cost of developing a feature in Agile is very high because it needs to be ready for shipment. It includes: Significant bug fixing Writing/updating and executing tests Writing/updating the user manual Polishing the UI design (placement of controls, color schemes, etc...) Updating the documents for FDA (in our orga...
I was faced with this question by my team leader. Statement 1 (written by me): lnkbtn1.visible = lnkbtn2.visible = lnkbtn.visible = false; Statement 2 (written by my team leader): lnkbtn1.visible = false; lnkbtn2.visible = false; lnkbtn3.visible = false; Which statement is better and why?
I am looking for a datastructure to handle cycling through a large number of ordered subroutines, some of which are active, most of which are not. I am thinking I need an implementation of a python set like object which remains ordered when modified, can be easily iterated over (I don't care if an actual for loop works...
I am looking to create a challenging AI project. There is an online card game that allows you to build a deck to play with out of randomly presented cards. You have to choose one each time out of a couple of cards. I want to build an AI that picks the cards as I would pick them myself using my knowledge of the game. M...
I was interested in solving several unrelated problems using generic graph search techniques, so after some fiddling around I came up with the following design: have each problem implement a generic "Problem" interface which has an initial state, and several methods that take in states and moves, and return new states ...
I have a website that is build with asp.net web forms. I would like to refresh design (using css, html5, responsive design) and also change it from web forms to asp.net MVC. To me this is more of a frontend project. Since there is already existing backend, it is "only" necessary to reuse it in MVC. Should I first star...
I'm trying to write a program to read GIMP curves files and apply them to an image. I have successfully implemented the curves for the red, green and blue channels, but I can't get it working for the value pseudochannel. For the colour channels I just create a lookup table from the curves, and iterate through the pixe...
I fully acknowledge that Python and Java are different programming languages and should be used differently. That said, "Program to an interface, not to an implementation" is good language-agnostic programming advice. Say I have some DAO interface in Java: public interface DataDao { Object load(); void update(); ...
Player A and Player B play a game. On the middle of the table there is a pot full of N apples of different weights. Player A starts first and choose an apple and start eating it. Losing no time player B do the same. When a player eats the whole apple, without losing time repeat the same procedure. In case both player h...
When I read well written code that checks to make sure all the input is of the correct format and type, and also catches all the things that possibly could go wrong, I find it difficult to understand the core of what the program is doing. It seems protection against the non-normal case obscures the normal case. This ...
I'm doing some android development in a relatively inexperienced group, and all of the data used by our application is managed in a database. There are several instances where we'll need to pull info from the database using the identifying information/PK of the user who is currently logged in. Because the only info fro...
We have several application servers (and different applications) running on Amazon AWS and our main method of logging is a combination of statsd, carbon/graphite, and an alert system based off of the metrics coming into carbon. This has been working great for a lot of different situations but I feel we need something ...
In a typical perfect-information strategy game like Chess, an agent can calculate its best move by searching the state tree for the best possible move, while assuming that the opponent will also make the best possible move (i.e. Mini-max). I would like to use this approach in a "game" modeling economic activity, where ...
Brainfuck is an esoteric programming language created in 1993 by Urban Müller. It was designed to challenge and amuse programmers, and was not made to be suitable for practical use. But still, it exists and some really cool stuff is written with it. My question is - will learning/practicing Brainfuck increase the depth...
I am stumped at this problem. Users authenticate at my client's website. Then the users see their profile page on my client's website. My client now wants me to provide a URL on their profile page, for his users, to download information from an external website. (This external website is not controlled by my client). T...
I have a code that highly relies on an Array structure like the following: $array['customer'][$customer_id]['details'][..]; // it goes to about 10 levels deep However, after almost two years since the initial development, now I have to include another high-level element to that array which will make it something li...
I am still very confused as to why and when to use Dependency Injection. If anyone could explain maybe using the below example that would be great, any other explanations would be appreciated. Lets say I am creating a web-app that will save movie reviews written in C# with ASP.NET MVC 5. If I have the following Model ...
Red zone is a fixed size area in memory beyond the stack pointer that has not been "allocated". Compilers do generate assembly to access that area in simple leaf functions. But I can't see any real advantages for red zone. Accessing memory beyond stack pointer is really dangerous and can easily lead to data corruption....
we have to migrate a very old project that are having more than 500 web forms and 400 tables and it is hugely depends on stored procedures, the current specification is: Asp.Net : .NET version 1.1 language: VB uses 2 Tier architecture (UI and business(includes DataAccess also)) xml is used to pass the data between UI ...
First of all, I know that reinvent the wheel is, usually, a bad idea, but I want to write a PHP framework to learn OOP in PHP and to understand MVC in my free time. Said that, I have to do two webs with few and simple database interactions, the basic funcionality of the webs is to show information. I want to use my own...
Is there a general rule of thumb, when we should pass a value as as class variable and when as a method argument? Or is it just a choice of the developer? For example -- are there any reasons, why following (PHP code): class SomeClass { public function __construct() { $this->id = $_GET['id']; $t...
Nowadays, almost everybody is using a dark color scheme in their code editor - dark background with light text. Even most web based editors (e.g on Github) feature dark color schemes. I honestly don't see the benefits. The human eye is much better at reading dark text on a bright background. Also, black on white color ...
Following my other question, is there a general rule of thumb, when we should pass a setting-like value, that controls class' behavior (for example displayed texts) as as class' constant or variable, one-by-one, and when it is better to "pack" them to one associative array? Or is it just a choice of the developer? For ...
When doing the Red, Green & Refactor cycle we should always write the minimum code to pass the test. This is the way I have been taught about TDD and the way almost all books describe the process. But what about the logging? Honestly I have rarely used logging in an application unless there was something really compli...
As I've been getting into embedded systems I've noticed that some projects (Arch Arm and OpenBSD for example) frown upon cross compiling. What is the reasoning for this? Is a cross-compiled binary somehow different from a natively compiled one? OpenBSD suggests that building on the hardware ensures that the system is ...
I have developed a search algorithm, which basically matches records on 3 different criteria types. Name, Address, and Keyword(s). "doh" , will find: Name: doh Address: re Keywords: me Name: re Address: doh Keywords: me Name: re Address: me Keywords: doh Now, when two or more records have a match, I am bas...
My question is about "big data". Basically, big data involves the analysis of a large amount of data to make meaningful insights from it. I would like to know: Whether or not large amounts of data can be pre-processed? (like say for example you are running some matching service for people, so you take all the informati...
I often see the following in HTML documents <link rel="self" href="http://example.com/something"> or like this in JSON link: { rel="self", href="http://example.com/something" } or in XML <atom:link rel="self" href="http://example.com/something" /> So I had some questions: Why include this link? What ...
I am having a problem in understanding how to apply camelCase syntax to some of my variable names. For example, how should I correctly write a word like "phonenumber" in camel case? Is it phoneNumber or phonenumber? Similarly with "username", is it username or userName? I think it doesn't look right with camel case l...
I've been thinking a lot lately about how to build a lean development team. Ultimately, I'd like to open up my own little software house with a small number of like-minded people. The goal won't be to become rich, but rather to have a healthy work environment. So far, I'm defining a lean team as the following: Small...
We've went ahead and purchased Microsoft Dynamics (see edit history for why) in order to write 2 functions to interact with one tiny part of it to fulfill one big need. What I want to know is, from other programmers who have integrated their software with MS Dynamics GP. Is there any way to connect with it (fully) wi...
Variables and the keys in key-value pairs are both identifiers for values, so, on a conceptual level, these seem very similar ideas. How would you explain the difference between these two concepts? Is it that key-value pairs are used in collections? Is it that variables point to a memory location? Or something else? ...
I have been looking into event driven programming in C and the language doesn't seem to have support for it. This has led me to wonder about the nature of event driven programming. Is it correct to say that an event handler basically spawns a thread that waits for a response from I/O and sets a variable? Or is there so...
Problem I am trying to optimize the architecture of my web-application developed in PHP using the Symfony framework. I have an object "pool" that contains "swimmers". I need to display the number of swimmers in my pool, but only those with a pink bath-suit. In order to do this, I see many possible approaches : Approach...
I forked a repo some time ago and created a few pull requests which went unanswered. Now, the software is MIT-licensed, and I kept the copyright notice there. Do I have to rename the software, or whoever forks a repo can keep referring to it by the same name? Thanks!
I have a method that generates a data URI from a byte array. In the event the input byte array is empty, what is the appropriate thing for the method to do? Here are the options I see: return data:, return an empty String throw an Exception By my read, RFC 2397 doesn't explicitly address the notion of empty data.
Currently, I have a system with a Data Mapper and multiple Domain Objects which inherit from the same class, let's say B and C that inherit from abstract class A. In order to retrieve data, I need to pass a parameter to the data interface (getObject('a'), getObject('b')), based on which data for class B or class C will...
I am writing a small game where a sea vessel (like a battleship) can be moved in a 2D place based on orders that it receives. I wanted to know if someone can help direct me to a post or example code that will help me move a ship from one location to another based on the speed and new vector. So, if I had a ship that is...
I've always been interested in how programming languages are created, so for the past 8 months I've been researching, practicing and more about the creation of compilers. I've been able to quite easily write front ends for languages and withing the past couple months have been reading more about the back end pieces of ...
I am building a web app in PHP and Symfony. Basically if we search there are plugins / extensions / bundles for almost 60% of stuff. The advantage of using them is that you can easily get your functionality and it will be maintained by the author and we don't need to worry about compatibility. But their downside is S...
We want to export some data from our data base as XML. For example, a Person can have age, name and some other properties. We have two choices to define the XML format. Choice #1: <Persons> <Person> <Age>16</Age> <Name>Richard</Name> </Person> <Person> <Age>34</Age> <Name>Eric</Nam...
I am an ASP.NET developer. I want to learn ASP.NET MVC. In fact I am learning it. But Now I am confused at a point. How can I connect my database to my application. Using entity framework or linq or ado.net. I have good knowledge about ado.net. But about entity framework I cant say anything. Now my problem is this whic...
I have two tables, project and photo. photo has ID,projectID,path : each project has multiple photos. Now one of these photos is the one that has to be displayed. The question is how to represent this in the database. Earlier, I used descending order of ID numbers and chose the latest one, but that failed and caused pr...
I tested two approaches to store session data: The classic: 1 key, 1 object (And every key as static final String in a class) "user" --> UserObject "preferences" --> List ... An approach with only 1 object "sessionObject" --> SessionObject And my SessionObject contains UserObject and the list of preferences as ...
Is there any situation in industrial object-oriented programming when the dependency inversion principle should not be used?
Memoization is definitely a powerful technique. But Dynamic Programming is slightly better IMO, since it does not involve the memory strain (in a recursive program, the parameters occupy memory and this memory increases as we go deeper into the recursion). But speed-wise, both are pretty equal. But definitely memoizati...
I'm developing an Android application which is responsible for showing multimedia such as videos and photos to user. I have a certain activity for a gallery of photos. In my phone where I'm developing the application everything works correctly. Currently I'm testing it in an emulator with a small screen for checking f...
With the advent of "the web is the platform", JavaScript is fast becoming the most widely used programming language in the world. However, many tasks that are easy to accomplish in other modern languages are difficult or puzzling in JavaScript, because the language design is so "unique": JavaScript has a prototype-bas...
I was reading about CMS and ERP. And got confused at this point that whether a system can both be an ERP and a CMS? is it possible?
The quality of the code in our software is indeed lacking. When you change a line of code in one component it usually breaks code in other components. Our software architect blames this on collective code ownership. He believes that if every developer was responsible for his own piece of code then he would tidy it up a...
I am trying to design an algorithm for optimal sensor placement in a given area. After doing some research I found the Art Gallery Problem. However, this problem assumes that the guards can see all the way to the perimeter from their positions, which is not the case with sensors (sensors have a range). Is it possible t...
Why in some frameworks the logic layer is called "Model" whereas in some it is called "Service". Are they different from each other or just different by naming conventions? UPDATE 1 The reason I'm asking is because in Zend Framework, a classical MVC framework, everybody uses the concept of Model. Now I'm learning Angu...
I am designing the back-end to a SOAP web-service and have a question about how I am thinking of doing it. I am going to go with a simple layered design which consists of 3 separate layers. Layer 1 -> Layer 2 -> Layer 3 Layer 1 : Will implement the SOAP skeleton interface, so this will be the main entry point of my ap...
TD;DR: There was some confusion as to what I was asking, so here is the driving idea behind the question: I always intended the question to be what it is. I may not have articulated it well originally. But intent have always been "is modular, separated, loose coupled, decoupled, refactored code" markedly slower by its...
If the plagiarized code is commented out because I found another way to solve the problem, but I forgot to remove the comments, is that considered plagiarism? I used the copied code to help me debug and compare the output between my own code and the copied code. In the final code, I commented out the copied code. Sinc...
I'm a C# developer who hasn't had the privilege of learning WPF yet. However, I recently initiated the architecture phase of a new project which I expect will eventually employ WPF (probably; although ASP.Net is still an option) -- but the GUI development won't begin for several months. (We need to get buy-in on a WinF...
Suppose I'm making an algorithm that identifies the subject of a picture. It could be anything that a computer doesn't do that well, but I'm not expecting to get the right answer every time - 80% is fine. Suppose further, that the accuracy of the intermediate steps was also somewhat fuzzy. Is there a way to incorporate...
Or to put it another way how to ensure that architecture or quality doesn't suffer, doing agile. Some of the understandings in handling architecture in agile are below(generally applies to testing as well) * Do architecture until risks fall off your radar * minimal design up front, so that you will not pay a horrible p...
I had a discussion with some peers and even some technical leads in the team around this and Im all for the purist MVC approach. Especially when the project is in its infant stages (its easy to implement a pattern going forward). Im a firm believer that anything to do with the back end should be kept separate from the ...
A question that has been vexing me lately has been about how to effectively test (end-to-end) features in a distributed system. Particuarly, how to effectively manage (through time) test data for feature testing. The system in question is a typical SOA setup. The composition is done in JavaScript when call to several...
I have a control where the user can select a value for the x and y axis from 2 dropdowns, and then there is a 4 by 4 grid (an image) which will show what their selections correspond to (updating dynamically). So, if the grid is: a b c d e f g h i j k l m n o p If the user picks 2 for row (column is null for now), e f ...
Both these trees try to keep the most frequently accessed element at the top. Is there any difference between these two trees?
Often boolean setters are pretty self-explanatory, like setLogErrors($bool). I do see some benefit of providing some additional information in the documentation, in this instance maybe where these errors are logged. But how much documentation is too much, especially when it comes to documenting the value that is passed...
I am trying to understand the definition of 'abstraction' in OOP. I have come across a few main definitions. Are they all valid? Is one of them wrong? I'm confused. (I re-wrote the definition with my own words). Definition 1: Abstraction is the concept of taking some object from the real world, and converting it to pro...
What T4MVC does makes complete sense to us. It converts the simple string input into strongly typed input, which eases things for the developer. Like this - return View("foo"); to return View(Views.foo); // better (T4MVC) What could be a reason as to why the MS people are NOT doing it this way?
There is a debate between my team members about the declaration of a Constants class. We are moving the constant variables into a separate class like below. public class Constants { public const string StateId = "ST"; public const string CountryId = "CI"; } A few of my team members suggested that we declar...
I have decided to work as a freelancer. I have developed a software and have successfully given the presentation demo. The client liked it and has agreed to implement the project in his organisation. But the client has asked me make it sure that I wont run away with the money without completing the project. The cost o...
I'm currently writing a Sprite Sheet Unpacker such as Alferds Spritesheet Unpacker. Now, before this is sent to gamedev, this isn't necessarily about games. I would like to know how to detect a sprite within a spriitesheet, or more abstactly, a shape inside of an image. Given this sprite sheet: I want to detect and ex...
From what I've learned last term on SWE courses, a big part of it is writing documents, so it seems that a software requirements specification (SRS) should earn points for my end-of-course project. However, I will be more comfortable if I use prototyping, i.e., I make a small thing that works for the most trivial of si...
We've been working with Scrum for a while now, generally successfully. However of late, as the pressure has started to mount up we've encountered several situations where items came through planning meetings but when it actually came time to code, it became apparent they were woefully under-specified. This is an annoyi...
I have a project with a git branching model that roughly follows that of nvie's git-flow. Our release branches are named in a SemVer format, e.g. v1.5.2 Once a release branch is given the green light for production, we close the branch, by merging it into master, applying a tag, and then deleting the branch. As we imme...