instruction
stringlengths
34
19.9k
I was creating a language and discovered that my language tokenizer would have to change depending where in the parse it is. I.e. abc[1] would be parsed as 4 tokens (abc, [, 1, ]), where as { abc[1] } would be parsed as 3 ({, abc[1], }). Is a grammar that would change its tokenizer mid parse defined somewhere? Does a g...
Context: I'm working on a fairly large Access database (which I inherited) that has its interface and tables separated. In order to make this work together, we have a lot of SQL queries (dozens). Some pointing to that database and some pointing to our datamarts. The code at this moment is somewhere around 12k-14k lines...
I've been trying to think outside of the box as to how desktop GUIs can be designed in code(not a graphical designer!). I've come across basically three ways this is done: XML Raw code (create a window, create a text box, add text box to window, etc) HTML and friends I'm sure that someone has done something other tha...
Occassinally I have to write methods like this: string GetReportOutputDirectoryAndMakeSureExist() { string path = Path.Combine ( ... ) //whatever logic if(!Directory.Exists(path)) Directory.Create(path); return path; } or string GetAndVerifyExistenceOfReportConfigurationPath() { string path = Path.Com...
Whenever the question comes up on which Agile tool to use use there always some people that answer "don't use an electronic tool because you will lose the big-visible-board advantage which better generate team conversation". Is this always the case or are there any contexts where an electronic tool is a better choice? ...
I have a class Base that has several children, say A, B, C. For testing purposes I'd like to mock those derived classes by deriving from them. So MockA derives from A, MockB derives from B and so on. The problem is, that MockA, MockB, ... all inherit protected members from Base that have to be set in the same way in ea...
I want to save some user-generated data with some signature of the user that generated it (let's say that the user has to fill some forms with some data and I want him to sign the written data). The server side is some random server language (that has big enough libraries to cover everything I'll need to do), the clien...
I've been facing a problem recently, in which I want to optimize two programs. For that, I wanted to create some kind of "Common Interface" which I could reuse between my two programs. However, the code of these are approximately 1000 lines, and I don't want to spend a big amount of time checking if this or that functi...
Google has given a reason that All apps on iOS have to run in the sandbox environment except for special apps by apple that get to tap into some private APIs. So Chrome on iOS uses whatever the UIWebView provides plus it might be doing its UI stuff and some external caching to add something extra to it. But Why does G...
The Apache License states: "You must give any other recipients of the Work or Derivative Works a copy of this License;" So if you've copied a bunch of functions from some Apache-licensed code (so it's not just linking, you've borrowed code) into a product that is not itself Apache-licensed, what's a good way to indicat...
I am currently working on creating a toolkit for work and I've gotten to the point where I'm wondering about error reporting. Basically all of my tools, which consist of a grouping of classes, will eventually be ran from a main method. Many of these tools will be doing operations on file like reading them in and con...
I have to create a github-presence for an open-source organization. The aim is to distribute code snippets and reference implementations in different programming languages. These contributions are going to be (ideally) created by people outside of the organization and should be collected. I know that good practice is t...
edit: so clearly I didn't explain this well, so let me try again with examples. I have a 'pipe' of a given size with signals routed through it at given offsets. The pipe can get fragmented with signals in different offsets making it impossible to fit a new signal. I want an algorithm that will tell me how to arrange...
I have created a windows form using visual studio design, that is simply drag n drop component into the form from Toolbox. Is it possible to import it into Blend and change its appearence using Blend? I opened the project from Blend but ony the code appears not the form itself. Thanks in advance!
So I saw this video on Youtube with all these C++ masters on GoingNative 2012 : Interactive panel where everybody could ask the questions. This is the video I was talking about: GoingNative 2012 - Day 1 - Interactive Panel: The importance of being native And at time 0:24:00 someone put a very interesting question: We'...
After reading for what seems days on the specifics of GPLv3 and more specifically AGPLv3, I have one question as far as distributing and to whom. If I create a web app (server and client) for a client. They pay me, I hand over all source and ownership. The web app is currently only accessible to employees and contracto...
This extends off this other Q&A thread, but is going into details that are out of scope from the original question. I am generating a parser that is to parse a context-sensitive grammar which can take in the following subset of symbols: ,, [, ], {, }, m/[a-zA-Z_][a-zA-Z_0-9]*/, m/[0-9]+/ The grammar can take in the fol...
I often find myself returning a boolean from a method, that's used in multiple locations, in order to contain all the logic around that method in a single place. All the (internal) calling method needs to know is whether the operation was successful, or not. I'm using Python but the question isn't necessarily specific ...
I've been catching up with the modern client-side JS ecosystem and reading up on CommonJS and AMD (incl. associated tools - browserify, requirejs, onejs, jam, dozens of others). If I'm writing a Javascript library, how do I modularize/package it such that it can be most broadly accessible (ideally by users who swear b...
We are a small team working on a web application using MVVM design pattern using technologies like .NET, Knockout and HTML. I am trying to come up with a code review checklist for this, so that my team can make use of it while coding as well as while reviewing. I tried to find in google, but no help there. Can you guys...
I am in a search of a better performant algorithm to implement a program, to find the count of each word in a sentence i.e.., a String in the programming sense. I know my algorithm is too basic and Noob. Here's my algorithm. Read the String. Tokenize the String with the delimiter, put each token in a list(ArrayList)...
I need help with coding something. I'm trying to design a system that will allow users to setup rules for the system to process (similar to email processing rules, in a way). When I receive a chunk of data (in this case, it is a object that has properties with values related to the client system's hostname, OS version,...
I'm building a REST API. I don't want to have real folders in my directory structure, but I'm not quite sure what to use else. My REST API uses paths like this: api.server.com/<object>/<action>[/] Here, <object> is the object the action <action> should be performed on. For example, a URL api.server.com/user/create wou...
The only way I could figure how to do it was create the schema on the localDB with code first and then manually change the database string to Azure and then run the code on Azure.. But that only gives me the schema and not the data.. Is there a better way like ? bacpac? Create a script instead? Or some other concept ...
I have a database sanitizing function that I use when the user enters some data into my website. I escaping the mysqli characters with mysqli_real_escape_string(), but I wish to also output the content with htmlspecialchars(). The problem is, let's just say the user enters something with a single quote; that will be ...
Many languages use the concept of an iterator. The c++ STL expands on this with input iterators, output iterators, forward, bidirectional, random access and others. As far as I know, these distinctions don't exist in other languages. In this talk the author of the STL, Alexander Stepanov, talks about iterators (among o...
I have recently started learning the nuances of scalable and enterprise computer architecture, and one of the central components is a messaging queue. In order to learn the most I can from any programming paradigm, I am trying to implement my own version of a messaging queue service. So far, my initial design runs on a...
When doing unit tests the "proper" way, i.e. stubbing every public call and return preset values or mocks, I feel like I'm not actually testing anything. I'm literally looking at my code and creating examples based on the flow of logic through my public methods. And every time the implementation changes, I have to go a...
I work for a small software development house (10~ developers, a few product managers and a few support staff) that sells various products and services to organisations internationally through resellers. I arrived in the job 7 months ago into a role opened up by a developer who left after 3 years. The company has maybe...
So you've made some code changes that should hopefully speed up some part of an application. But there is just one problem - you don't know how it will perform in live. Different networks, different machines, different memory, different configuration, different times of day, different users, different server loads etc ...
How would you define Continuous Integration and what specific components does a CI server contain? I want to explain to someone in the marketing department what Continuous Integration is. They understand Source control - i.e. they use Subversion. But I'd like to explain to them properly what CI is. The Wikipedia Articl...
I was evaluating the various ways in which the big guys implement auto suggest. These are my observations.(Search string used was "ab") Questions towards the end. Yahoo tries something like this, where the response was a JSONP. Response is readable and serves the purpose. Yahoo's response yasearch({"q":"ab ","gprid":"Y...
I'm planning to build a eCommerce web application(similar to http://zovi.com/) using JSF 1.2 and node.js. All front end components will be jsf components binding to backing bean. I want to achieve real time functionality ( such as displaying Today's hot sellers ,Customers who viewed this item also viewed such patterns)...
I was applying markdown comments in the xml comments of a config file when the XmlParser reported that two hyphens (--) are not allowed in xml comments. Checking the XML Specification, it appears that xml comment isn't designed to contain two hyphens for compatibility reasons with SGML parsers. Why do SGML parsers disa...
I've seen some projects that - with each new year - start to change all files in their source-tree to update the copyright year. Isn't this just pushing hot air on a level of magnitude? AFAIK: Copyright year is based on relevant changes of a work (also) - not only because of a trivial change of the copyright year in a...
I'm about to start working on a new commercial PHP project with a friend that will be licensed and sold as a script to run on your own shared hosting account or server. Looking at the statistics (http://w3techs.com/technologies/details/pl-php/5/all) 50.3% of PHP 5 installations are still PHP 5.2 or lower (43.5% being ...
I'm doing a PHP application with CodeIgniter and most of my controllers accept record ids as parameters for retrieving purposes. I also pass record ids in my forms action. Like this: www.sample.com/records/save/sFKu=4 Is this the right way to do this? Note that the record ids are encrypted.
We have an existing ERP system written in VB 6 that we are converting to .Net incrementally. Now, every module in the system is being separated into DLLs so that the product becomes customizable and flexible. I'm not sure if this is the way to do this. I think this will cost a lot of maintenance in the future. What do ...
Perhaps a bit of an odd question but I can't think of a way to achieve what I want. I produce a product which ends up installed on-site at clients premises. It is a business critical and high availability application, and has to handle processes very quickly. While obviously most of the work goes into the actual applic...
I'm doing a lot of work with XML, our legacy XML generators use the ruby template language ERB to create the XML files. I've been experimenting with Nokogiri and the builder model of creating XML, but I seem to be able to accomplish everything I want using both methods. So, what should I be taking into account when cho...
Let's assume the modeling of User model in a context of a social network. User concept is composed of two notions: Authentication elements like userName/Password/Email etc... Extra data information sometimes called "User profile" like firstName, birthday, pictures etc.. At first glance, this analysis involves separat...
Been trying to come up with a flow for a basic tiered web application, and have been reading conflicting information online. What I'm trying to figure out is if there is an advantage to still using DTO objects from your DAO to Service layer through the use of some sort of mapper. The basic flow I foresee is as follo...
Ok so I need to create a bunch of utility classes in python. Normally I would just use a simple module for this but I need to be able to inherit in order to share common code between them. The common code needs to reference the state of the module using it so simple imports wouldn't work well. I don't like singletons, ...
I think it's generally good practice to #include the header for any types used in a CPP file, regardless of what is already included via the HPP file. So I might #include <string> in both my HPP and CPP, for example, even though I could still compile if I skipped it in the CPP. This way I don't have to worry about whet...
I have the opportunity to rewrite a core piece of a project (C#) that is inheritance-heavy and feels increasingly restrictive in how it is designed. The scenario is pretty simple, imagine an application that is built to handle various small tasks. Every task is unique in it's functionality so it implements an ITask int...
I have the opportunity to rewrite a core piece of a project that is inheritance-heavy and feels increasingly restrictive in how it is designed. The scenario is pretty simple, imagine an application that is built to handle various small tasks. Every task is unique in it's functionality so it implements an ITask interfac...
When writing software I'm often forced to at some point to make a decision that involves a design pattern of "by convention" naming and behavioral patterns. This normally makes me feel kind of slimy as a .NET developer because nearly everything is statically typed (arguably even the dynamic type is statically typed, b...
What is the best way to implement automated updates? I've gotten as far as libcurl, I imagine I need to ping the server every now and again with the current version of the software. But then what should I do? What server tech needs to respond, and how?
I notice that when I code I often use a pattern that calls a class method and that method will call a number of private functions in the same class to do the work. The private functions do one thing only. The code looks like this: public void callThisMethod(MyObject myObject) { methodA(myObject); methodB(myObje...
What's the best practice? This : for ($i = 0; $i < count($array); $i++) { //stuff } Or, what I usually do : $count = count($array); for($i = 0; $i < $count; $i++) { //stuff } Is it the same with the magic of compiler optimization?
Me and a small team of engineers are considering using SVN to store our electrical schematics and parts libraries; currently we just have a network folder where we put all of our files. Our company also has a separate SVN server that we have access to. I was wondering if there was some way that we could use the SVN rep...
What is the name of λx.λf.fx in lambda calculus? Does the corresponding function have a standard name in functional programming languages, like Haskell? In object oriented programming, is there a usual name for a method foo which takes a function as an argument, such that x.foo(f) returns f(x)?
I'm not asking for legal advice; just some rough guidance. I have a host application in Java that uses the Rhino JS engine to execute JavaScript. That JavaScript can then make calls into other Java libraries, some of which might be licensed under the GPL. I distribute my hosting app, the JS files as source and the unmo...
A Transaction contains one or more LineItem. One LineItem has a relation with an Item. Every Item has a number field that represent quantity in stock. Using this approach, every Transaction creation will need to decrease quantity in Item. If user update a Transaction then quantity in Item will need to be adjusted. ...
Take the following examples: public static String returnOnce() { String resultString = null; if (someCondition) { resultString = "condition is true"; } else { resultString = "condition is false"; } return resultString; } public static String returnMulti() { if (someCondition) { ...
When the context class can accept a null strategy, is there another way to do it without check if its null? Is this considered a good strategy design implementation? class MainApp{ static void Main(){ Context context = new Context(); while(true){ Strategy strategy = createConcreteStrateg...
Since I discovered the joys of AJAX, I tend to do all my requests to the server using AJAX. Is this a good idea? According to you, what should I do in PHP and what should I do in AJAX? I like to do my requests to the server with AJAX because I can use it as a kind of web service.
You can find many frameworks with an example todo list for demonstrating a small but full application in the framework. You don't have to consider large problems like scaling or caching, but you still exercise most of the fundamentals of that framework in a todo list. Is there an analogous application for systems-leve...
Say I want to build a website that support multiple language and use MongoDB datastore. I wonder what is a good approach to have multiple versions of the body and title of an article, one for each language. Should I keep all versions in the same article document? Like a collection of key-value pairs of language code an...
Basically, I'm trying to understand why layered and tiered are that different, and why they don't translate easily to each other. I understand that layered could be 3 separate class files for UI, BL and DAL. Whereas tiered can be a Project for the UI, which links to a BL project which links to a DAL like entity frame...
I'm releasing an open-source jQuery plug-in that is free to use, modify and redistribute as long as you don't directly or indirectly charge your customers. Your software doesn't need to be open-source, it just need to be free. If you charge your customers, you need a commercial license. I'm not sure about the licensing...
I want to use the MorphAdorner library available free for commercial use. But it uses several other libraries that restrict commercial use (like Gate etc). Can I use this library in my application?
I am working on a software project in my college. And I want to make it open source. But I want that people to only contribute to the project. I don't want that they should also release a project using my source with some modifications. So what will be the best Licence to use with my project ?
In our webapplication we have a list of questions that have to be answered by the user. These questions are served to the user one by one and will be saved once the last question has been answered. The problem we faced was saving all the 'help'-data that goes with this: storing the index of the last question, returning...
Are there any languages that support foreach over multiple lists at once? Something like this: foreach (string a in names, string b in places, string c in colors) { // do stuff with a, b, c } Sure, this can be done with a regular for loop: for (int n = 0; n<max, n++) { a = names[n]; b = places[n]; c = ...
I'm writing a module that runs a finite state machine* based on the contents of an array of records passed in at initialization. Each record describes a state and includes instructions on how to act on inputs (i.e., when in state S1, input I triggers a transition to state S2). For the FSM to work correctly, the trans...
From the book Think Like a Programmer (emphasis mine) The Luhn formula is a widely used system for validating identification numbers. Using the original number, double the value of every other digit. Then add the values of the individual digits together (if a doubled value now has two digits, add the digits individual...
In Fred Brook's Mythical Man Month chapter 4 (Aristocracy, Democracy, and System Design) page 49, he says: As Blaauw points out, the total creative effort involves three distinct phase: architecture, implementation, and realization ... implementer has plenty to do ... designing module boundaries, table structures, pa...
I've recently had a little disagreement with fellow developers. We're transforming various ontologies from the original source format (Pica+, RDF, etc) into our data format and have several converters dedicated to exactly this task. The argument came whether or not we should use the full ontology-data file, or create a...
I started my career as a .NET developer 3 months ago and after a long training plan on diverse technologies, patterns and concepts the developers who were supervising me have decided that I am ready to join one of the many projects the company handles. I am very excited to finally be able to start coding. The team I ha...
Before starting on a current project I was wondering if there is a terminology for what I am planning on doing? Basically what I want to do is map out every object in layers such as all the controllers and what they'll be called, the methods that will exist under the controllers and their purpose; Including, the models...
I am planning to implement the Websocket protocol and currently learning how handshake headers must be structured. According to this link http://datatracker.ietf.org/doc/rfc6455/?include_text=1 To prove that the handshake was received, the server has to take two pieces of information and combine them to form a resp...
I am currently develop a website application in codeigniter, and I'd like to do something in PHP / CodeIgniter where I can make a common template for separate sections of the website. I was thinking that I would keep the header / footer in a separate php files & include them separately. The thing I'm not sure about is...
I'm going to try to make this as concise and concrete as possible, but apologies since I can think of multiple ways to make it work. This question might also relate to handling production workflows or manufacturing, but I have no experience in these areas. I have a problem where I need to move an Object, O, from diffe...
I program in C mostly. However, it is pretty obvious that many more commercial applications are done in C++. As far as I can tell, C++ is a very complex language, with seemingly convoluted syntax and too many constructs. C++ also encourages the abuse of Objects where structs and functions will do. In fact, the only sig...
It's fairly obvious that OOP is viewed as a sort of silver bullet of programming today. In any computer science course, the merits of OOP are heralded. I would like to know why people like OOP. To be honest, combining procedures, types, and data structures into a single conglomerate seems bad to me. I'd much rather vie...
I have a website where users are directed to go through a sequence of pages to perform a sequence of work tasks (transcribe a paragraph, answer a survey, interact with another user, etc). For short, let's call these tasks A, B, C, etc. I'm using Django, and each task is currently implemented as a view function (or meth...
I am trying to write unit tests in javascript for an application made in nodejs. What I want to know is - Say there is a class Vehicles which is dependent on another class Roads. Should I mock the Roads class and send it as a parameter to Vehicles for unit testing? OR Should I just create a new object and send it as ...
In our project we work in a zero-bug (a.k.a zero-defect) methodology. The basic idea is that bugs are always higher in priority than features. If you're working on a story and it has a bug it must be resolved in order for the story to get accepted. If a bug is found during the sprint for an older story we need to put i...
When User A decides he want to pay a visit to http://example.com/ it all begins with a Request. A short moment later he is given a Response. In this cycle Request-Response a lot is going on, in different frameworks it's decoupled in different components among them Routing, Dispatching, etc. I'm looking to make a simple...
I am going to make a website for a client that wants to be able to alter the site about every week (changing pictures and textual information mostly). It is for a restaurant and so the client wants to alter the menu and images on an almost weekly basis. I've always made my websites and web apps from a framework or from...
I have a simple MVC project. My current packages: gui controller db domain I want to put extra classes which I will use, e.g. md5 hashing, email validator (methods which I will use in more than one class). Where do I put them? I will probably not use them in only one package, but in two or three (not in model for ...
I need some advice on how to structure our projects in Git. We use Java and Maven is our build tool. Maven kinda assumes all of your projects have a common ancestor eventually. Maven can also be a real drama queen when things aren't setup exactly the way the Apache foundation sets up their projects (anyone using the re...
I am just moving into freelancing (my primary sector will be web design / web development). I've got a few projects for friends as well as one or two 'professional' projects in the pipeline. I would like to know what are some of the most important things you need to hear from your client before you start the process of...
My friend and I are working on an application that already works for Windows 8 and is written in Javascript, HTML, and CSS. Our desire is to make it cross platform for areas like windows mobile, chrome, firefox, and android. So, our directory structure looks like this: . ├SomeApp.sln // Visual Studio solutio...
I am considering learning Go. As far as I know about it, it's a systems language geared toward parallel programming. (correct me if I'm wrong) Should I have a very good understanding of C in order to be good Go programmer? How much systems concepts (*nix OS concepts) I need to master before delving into Go What other ...
It is said that programmers should prefer composition over inheritance. I was wondering if RTTI can be achieved as easily using composition.
I'm developing an enterprise website, and I have to define some sections like this: I have many sections and each section have many (or one) sub-pages. The number of sub-pages vary per section. Each sub-page should not be longer than 2500 characters Also, I have to use a relational database (MySQL). I'm in doubt whi...
I'm a PHP programmer and I've done any projects based on PHP and MySQL without using any framework so far. Now I'm going to create a big link sharing system (excel-able,modular,fast,theme based,secure etc.). But I have no experience to use any frameworks before. I need to know which is better to me.Choose a framework (...
For the past week I have been attempting to write a proof-of-concept project using dependency injection, a service layer, unit of work pattern + repository. I am looking to design something that can easily be consumed by any type of application - be it a Windows desktop application, a CLI application, an ASP.NET MVC ap...
I have an application that has about a dozen reports that provide totals and summaries of data in the database based on date ranges given as parameters. The application is near the end of user testing. The end-users are saying that the numbers in the totals don't match what they expect based on test data they have ente...
I am interested in knowing how to deal with a current software development process that has not been changed for years and will eventually lead to product and team failure. Yes, probably the easier way to solve this is changing jobs, but with this economy is easier said than done. However, if you have specific examples...
I'm current working on a command line app that will grab resources online for you when you're setting up a new project locally. Right now all the urls for the resources I need are hardcoded into the application and adding new targets require updating the software. What are the benefits of hosting a database remotely th...
In a typical (well-designed) MVC web app, the database is not aware of the model code, the model code is not aware of the controller code, and the controller code is not aware of the view code. (I imagine you could even start as far down as the hardware, or perhaps even further, and the pattern might be the same.) Goin...
I am trying to develop a series of unit tests for a production system that are dependent on a person's social security number. While I am more than comfortable hard coding a clearly bad social security number to test for failure, I'm uneasy about including one that is good for proper (and passing) results. The followin...
I have a problem with a ranking system I am using. Scenario: An online game with around 10k players calculates a real time ranking of points when a certain event occurs. Events don't occur that often, around 1 time per minute. This ranking is kept in the cache for quick calculations, sorting and access. Now players can...
It is little depressive, but it seems to me that there is much more support for manipulating ugly proprietary closed format like xls in rails (and ruby) in general that to documented open Open Document format. Why it is so? (I know it is kind of philosiophical, but I just do not get the fact, that the opensource is not...
What's the recommended way to serialize dependent objects, especially when objects are being freshly constructed (to avoid malicious byte streams, or whatever)? For example.... After creating a (genericized, but setup through Spring for my company) fiscal calendar based on JodaTime, I'm creating the next version based...
I'm building a big website, and using the normal old mysql_query method for transactions and communications with the database, and everything i going fine, including security. I'm a little bit confused, should I switch to the new PDO interface? cause I learnt that's safer, or keep using the old mysql_query() and mysql_...
I'm a web developer, but lately I have been learning Clojure and now I'm interested in creating a p2p application. And since Clojure is a general purpose language, I guess I can just use that. Any suggestions?