Is there a quasi-standard set of attributes to annotate thread safety, immutability etc.?

Except for a blog post here and there, describing the custom attributes someone created, but that do not seem to get any traction - like one describing how to enforce immutability, another one on Documenting Thread Safety, modeling the attributes after JCIP annotations \- is there any standard emerging? Anything MS might be planning for the future? This is something that should be standard, if there's to be any chance of interoperability between libraries concurrency-wise. Both for documentation purposes, and also to feed static / dynamic test tools. If MS isn't doing anything in that direction, it could be done on CodePlex - but I couldn't find anything there, either. <opinion>Concurrency and thread safety are really hard in imperative and object-languages like C# and Java, we should try to tame it, until we hopefully switch to more appropriate languages.</opinion>


Misconceptions about purely functional languages?

I often encounter the following statements / arguments:   1. Pure functional programming languages do not allow side effects (and are therefore of little use in practice because any useful program does have side effects, e.g. when it interacts with the external world).   2. Pure functional programming languages do not allow to write a program that maintains state (which makes programming very awkward because in many application you do need state). I am not an expert in functional languages but here is what I have understood about these topics until now. Regarding point 1, you can interact with the environment in purely functional languages but you have to explicitly mark the code (functions) that introduces side effects (e.g. in Haskell by means of monadic types). Also, as far as I know computing by side effects (destructively updating data) should also be possible (using monadic types?) even though it is not the preferred way of working. Regarding point 2, as far as I know you can represent state by threading values through several computation steps (in Haskell, again, using monadic types) but I have no practical experience doing this and my understanding is rather vague. So, are the two statements above correct in any sense or are they just misconceptions about purely functional languages? If they are misconceptions, how did they come about? Could you write a (possibly small) code snippet illustrating the Haskell idiomatic way to (1) implement side effects and (2) implement a computation with state?


What is the difference between _Procedural Generation_ and _Random Generation_?

Today, I got into an argument about the term "procedural generation". My point was that its different from "classic" random generation in that _procedural generation_ is based on a more mathematical, fractal-based, algorithm leading to a more "realistic" distribution and the usual randomness of most languages are based on a pseudo-random-number generator, leading to an "unrealistic", in a way, ugly, distribution. This discussion was made with a heightmap in mind. The discussion left me somehow unconvinced about my own arguments though, so, is there more to it? Or am I the one who is, in fact, simply wrong?


Class/Object with different sets of configurations, singletons etc (PHP)

I want to produce maintainable code for configuring one or multiple classes differently depending whether in a production or development environment. For example, making a `Paypal` class/object that handles API calls to Paypal, using different settings depending on some sort of global switch set to either Dev or Live. The first would connect to the sandbox account, the other the live account. I want to keep it as simple as possible - I would not be loading configuration variables from a file or database, but instead specifying them in either a subclass's constructor, one subclass for dev and one for live, or similar:               class Paypal {         private $endpointUrl;         public static function makeSandbox(){             return new Paypal('http://....');         }         public static function makeLive(){             return new Paypal('http://....');         }         // ....         public function Paypal($url){             $this->endpointUrl = $url;         }     }      However this leaves me with so many questions, like for other classes who's configuration is different between live/server, do I store the different initialisations in it's class, or should I have a class dedicated to all configuration details, should it be a singleton, and so on. The application will be rather simple, and only be maintained by myself so the idea of XML configuration files etc seems over the top, a PHP configuration file with a switch statement and global variables seems like bad form. Using a sort of global `Config` class brings a whole load of questions. I'm feeling pretty overwhelmed here. I've read around and there seem to be so many opinions. The one rule that sticks in my mind is use OOP patterns to solve a problem, not just for the sake of it. Being a very small site with just me developing it, I'm very hesitant introducing multiple extra classes or objects just for dealing with two sets of global configurations. Please help


Server requests optimisation - size vs frequency

my map-like app loads data from google map API but it also loads some extra data - in the form of XML - from my server. When the app loads it really needs only small amount of data to cover the currently visible area but there is a chance of 2% (aka conversion rate) that the user will interact with the map and more data will be needed. My problem is that I can not really estimate the probability that user will need certain part of the map data, therefore I can not estimate the optimal size of the data packet. Should I sent just the minimal chunk of data that user needs right now or should I send him data for all the nearby screens, or even more? **In theory, what is the trade of between sending one big chunk of data - lots of bytes (lot bandwidth) but few server requests - or sending small pieces of data whenever needed - small but frequent server requests?** The XML chunks will be cached but the bigger chunks I generate the higher the chance I will have to update it every time something changes in the data (that will happen quite frequently). I can not quantify the sizes and probabilities yet so please treat this question as highly theoretical. I would like to hear your opinions.


iOS Networking/Backend : has anyone found the ultimate knowledge source ?

I have a hard time trying to find a moderne (updated), complete knowledge source (book or tutorial) that would tackle from scratch the server side of iOS App Development. My goal is to create an app in which users can talk to each others, see each others' profiles, share images... I am fairly new to backend implementation, I only know the basics of PHP (but I am good in other iOS development topics). I have been searching for a lot of books/tutorials, but I am frustrated for the following reasons : \-- code is too old and needs to be updated \-- a third-party library needs to be used Has anyone ever found something that would take the newbie from scratch, explaining and giving examples of backend side implementation in a modern way? I know this is a broad question, but if someone has already stumbled upon a great resource, I'd be happy to read it ! Thanks, BM


Java GUI with JFrames

Today I started learning Java GUI and tried to create a simple window on my Ubuntu. I am using jre7 for now. I wrote code exactly from tutorial because from experience there are stuff that doesn't work even if it's correctly typed onto my screen. So, now I used thenewboston's first tutorial with Java GUI. Typed all syntax correctly, classes seems fine, no errors. He got window that was expected - mine only got blank window with no title and no text. Screenshot with that http://screencloud.net/v/ywtW Code in JFrames.java file:               import java.awt.FlowLayout; // importē plūstošo skatu / default layout     import javax.swing.JFrame; // dod iespēju piekļūt pamata logu struktūrai     import javax.swing.JLabel; // ļauj rakstīt tekstu logos          public class JFrames extends JFrame {              private JLabel item1;              public JFrames() {             super("The Title Of The Program"); // parāda title bar ar tekstu             setLayout(new FlowLayout());                  item1 = new JLabel("This is sentence with something");             item1.setToolTipText("This is tooltip on hover");             add(item1); // pievieno logam šo lietiņu         }     }      Please, ignore latvian comments, that's just for my reference. So I want to know - why my window appears blank?


What mistakes do your users make, and how can you update your application to handle them?

In fact this question is about cautions to be taken to enhance quality user experience and reduce avoidable support calls.


Repository Pattern: Exposing Data Context to Underlying Layers

My team is in the process of updating a legacy project. We've decided to incorporate the Repository Pattern along with `Entity Framework` in our Data Access layer. Below is a high-level view of this organization: ![enter image description here](http://i.stack.imgur.com/ATCVY.png) `IRepository<TEntity>` is a generic interface used to perform common operations on an entity set:               public interface IRepository<TEntity> where TEntity : class     {         ObjectSet<TEntity> EntitySet { get; set; }              TEntity Get(object key);              void Insert(TEntity entity);              void Update(TEntity entity);              void Save();     }      For example if I have an `Employee` entity, I can create the `EmployeeRepository:IRepository<Employee>` object. The `DataFactory` class is then used as a wrapper object to take care of `ObjectContext` generation, disposal, and exception handling:               public class DataFactory<TContext, TEntity> : IDisposable             where TContext : ObjectContext, new()             where TEntity : class     {         private bool _disposed = false;         private TContext _context;         private IRepository<TEntity> _repository;              public DataFactory()         {             _context = new TContext();             IRepository<TEntity> repoistory;                  bool isRepositoryFound = TryGetRepository(out repoistory);                  if (!isRepositoryFound)             {                 throw new InvalidOperationException(                     string.Format("Unable to find repository of type {0}.", typeof(TEntity).FullName));             }                  _repository = repoistory;         }              public DataFactory(TContext context, IRepository<TEntity> repository)         {             _context = context;             _repository = repository;         }              public void Do(Action<TContext, IRepository<TEntity>> action)         {             try             {                 action(_context, _repository);             }             catch (Exception ex)             {                 ProcessException(ex);             }         }              public TResult DoAndReturn<TResult>(Func<TContext, IRepository<TEntity>, TResult> action)         {             try             {                 return action(_context, _repository);             }             catch (Exception ex)             {                 ProcessException(ex);                 return default(TResult);             }         }              private bool TryGetRepository(out IRepository<TEntity> repository)         {             Type repositoryType = Assembly.GetExecutingAssembly().GetTypes().SingleOrDefault(t =>                 typeof(IRepository<TEntity>).IsAssignableFrom(t));                  if (repositoryType == null)             {                 repository = null;                 return false;             }                  repository = (IRepository<TEntity>)Activator.CreateInstance(repositoryType, _context );             return true;         }     }      And finally to use this class in the Business Layer, we would have something like:               using (var factory = new DataFactory<MyDataContext, Employee>())     {         factory.Do((context, repository) =>         {            // Interact with the repository         });     }      My coworker and I had a long conversation about whether the data context object should be exposed to the underlying layers in the `Do()` and `DoAndReturn()` methods. While I do see cases where having direct access to the context could be useful (for example in a case where we might want to turn on/off lazy loading for a particular entity set), I think doing so defeats the whole purpose of abstracting the Data Access layer (which is achieved by providing a common `IRepository` contract) since now objects can be directly accessed/manipulated through the `ObjectContext`. He suggested having two different versions of these methods: one that exposes only the repository, and one that exposes both the context and repository. Is this an acceptable approach? Any suggestions are appreciated.


Is it okay to use a language that isn't supported by your company for some tasks?

I work for a company that supports several languages: COBOL, VB6, C# and Java.   I use those languages for my primary work, but I often find myself to coding some minor programs (e.g. scripts) in Python because I found it to be the best tool for that type of task. For example: An analyst gives me a complex CSV file to populate some DB tables, so I would use Python to parse it and create a DB script. What's the problem?   The main problem I see is that a few parts of these quick & dirty scripts are slowly gaining importance and:   1. My company does not support Python    2. They're not version controlled (I back them up in another way)   3. My coworkers do not know Python  The analysts have even started referencing them in email ("launch the script that exports..."), so they are needed more often than I initially thought. I should add that these scripts are just utilities that are not part of the main project; they simply help to get trivial tasks done in less time. For my own small tasks they help a lot. In short, if I were a lottery winner ~~to be in a accident~~ , my coworkers would need to keep the project alive without those scripts; they would spend more time in fixing CSV errors by hand for example. Is this a common scenario? Am I doing something wrong? What should I do?


How to make the working environment of a programmer less shiny?

Last year I had a sport accident and since then my left eye is a little bit sensitive. Especially if looking in bright and shiny colors, I get tired very fast and can't literally focus on anything. White is the worst color ever! Unfortunately most application that I use in my work environment (Firefox, Eclipse, Visual Studio, Tetris) have a very bright white background. This really hurts my eye. So is there an easy way to generally use color schemes on the laptop so that everything isn't that bright? Obviously I could everywhere change the default color scheme, but isn't there a simpler solution to do that? Or any recommendations what are good color schemes to be less bright but still clearly readable?


What are good examples of using assertions to detect bugs?

Most examples of using assertions that I find seem to be about dealing with _runtime errors_ , such as out of memory conditions. That's not what I'm after. One good example of using assertions to detect bugs is the following excerpt from the Wikipedia article about assertions:               int total = countNumberOfUsers();     if (total % 2 == 0) {         // total is even     } else {         // total is odd and non-negative         assert(total % 2 == 1);     }      Here, the programmer erroneously assumed that `i % 2` can only have two distinct values, and the assert will catch that bug. What other good examples of using assertions to detect bugs are there?


Reading assembly useful for insights when writing C/C++?

While in most cases its not necessarily, recently I have taken to reading the generated assembly of my C code every so often, when I'm curious as to the kinds of optimizations my compiler is making. _Especially for low level code or functions which are called many times._ Examples include:   * Checking if a change to the C code has any impact on the generated code.   * Checking if the same expression used twice is optimized into one, or if assigning a variable makes a difference.   * Check for changes which may bloat-generated code-size. Now this is not a perfect method by any means, its possible that some difference in the generated output is a red-herring, because of all sorts of internal logic & thresholds within the compiler, but its still interesting at times. At this point while looking at the assembly I can lookup each command, but not really read the assembly _(amd64 as it happens)_. So my question is, has anyone found it useful to learn a certain amount of assembly to write better C code? (or at least get more insights into their code).   * If so, how much is useful to know?   * What kinds of issues did it help you resolve? * * * _Note, the danger here is that one writes C code targeting the assembly which is very specific to the developers own system - any advantage may be lost on a different compiler or architecture, taking that into account, Im still interested in other developers experience_


How to prevent the vicious circle of testing via customer

I recently asked this question and this comment and made me ponder the whole process of releasing an update to the customers. The next update for our software is planned and the previous time it went horribly wrong because of regression, bad testing, etc... This time we want to prevent the scenario that we test via our customer and made some unit tests and other minor improvements. However, there is not enough time to make unit tests for all the features that lack unit tests or the features that need to be build yet. So the answer for this question 'Make more unit tests' is not fitting because of the lack of time, infrastructure etc... Every bug and feature will be tested/reviewed by a different developer, but that won't be done perfectly of course (we're still human :)). My question is: Once we released the update, how do we prevent the vicious circle of testing via customers while not be able to add more unit tests? * * * The previous time we tried our best to test the software before and after release. After the deadline we were still searching and fixing bugs but the customer would also find some of these. So we post an update as soon as we were confident that the patch was increasing quality. We were so busy with finding bugs and fixing them that we weren't spending any time on creating unit tests. This time we don't have a solid plan yet, hence the question. As stated before we did added some unit tests, but surely not enough. We are also looking for new colleagues but they are not easy to come by and management has rather high standards. We do have quite some candidates and it looks like we do get at least one new colleagues very soon, but it still takes time to get him/her up and running. The first thing we put the new colleague on will be creating unit tests. So the dependencies there are experience, skills and the time he/she can join the time. Another problem that comes in hand with the lack of developers is that we are so focused on getting the bugs and features fixed that we don't have much time to spend on thinking about 'how we can improve the update process'. (I ask these questions in my own spare time). * * * Summary of steps I will try to take:   * Try to get a tester before the release is done   * Add unit tests while creating the features, if there isn't enough time, schedule them for after the release.   * After releasing, if there is any regression, create unit tests when fixing the bugs.   * Release more often in smaller chunks after the release, making it easier to release features and repair bugs with a minor priority.


What is the mathematical model of a Python's class?

I understand that the classical model from the lambda-papers is not valid for Python. And the closures are not the mathematical model of the implementation of the Python system. So which model is it?


Should a development machine be inside a VM?

This post by Rob Conery (note the slug) says that development environment should be run inside a virtual machine. I see what he's saying and tend to agree, but still feel a little uneasy. Now that virtualization is so mature that even production systems run inside VMs speed is pretty much a non-issue, but as I say something bothers me here. What's your take on virtualizing your development machine? Have you already done so? If you did, any pitfalls or gotchas along the road?


What should I do to scale out a high-traffic website?

What best practices should be undertaken for a website that needs to "scale out" to handle capacity? This is especially relevant now that people are considering the cloud, but may be missing out on the fundamentals. I'm interested in hearing about anything you consider a best practice from development-level tasks, to infrastructure, to management.


Cheap programmable, portable device

Since a long time I have thrived for being able to program something I can take with me - a very small computer like a programmable calculator, gameboy, pocket PC or cellphone. However, I didn't find anything fitting yet! The thing I'm looking at is the price, because I can't afford to spend too much money on it.   * What are some cheap portable programmable devices? All I'd need is support for uploading assembler code from my computer. I don't care about the display, a simple LCD would be sufficient. Same goes for the buttons I have looked at programmable calculators, portable gaming consoles such as the PSP and more, however didn't find anything that fit :(


What does a "bodyshop" (in context of a programming job /environment) mean

I've kept on coming across the term "bodyshop" in terms of a programming job/environment but despite googling I can't find out what exactly this is referring to? Can someone please enlighten me?


Technique to Solve Hard Programming logic

I have heard about many techniques which are used by developer/software manager to solve hard programming logic or to create flow of an application and this flow will be implemented by developers to create an actual application. Some of the technique which i know, are:   1. Flowchart   2. Screen-Layout   3. Data Flow Diagram   4. E-R Diagram   5. Algorithm of every programs I'd like to know about two facts: (1) Are there any techniques other than this ? (2) Which one is the most suitable to solve hard programming logic and process of application creation?


Entity Framework and layer separation

I'm trying to work a bit with Entity Framework and I got a question regarding the separation of layers. I usually use the UI -> BLL -> DAL approach and I'm wondering how to use EF here. My DAL would usually be something like               GetPerson(id)     {         // some sql         return new Person(...)     }      BLL:               GetPerson(id)     {         Return personDL.GetPerson(id)     }      UI:               Person p = personBL.GetPerson(id)      My question now is: since EF creates my model and DAL, is it a good idea to wrap EF inside my own DAL or is it just a waste of time? If I don't need to wrap EF would I still place my Model.esmx inside its own class library or would it be fine to just place it inside my BLL and work some there? I can't really see the reason to wrap EF inside my own DAL but I want to know what other people are doing. So instead of having the above, I would leave out the DAL and just do: BLL:               GetPerson(id)     {         using (TestEntities context = new TestEntities())         {                 var result = from p in context.Persons.Where(p => p.Id = id)                                     select p;         }     }      What to do?


Advice on JavaScript library for visualizing Yahoo Pipe Output

I'm currently writing a JavaScript library. It is a project for school were I need to make it easier to visualize data from Yahoo Pipes. The data format is a JSON string, which can contain anything, but mostly contains a list of items, with different attributes for each item.   This approach is quite general and now I was wondering which functionality I could insert into this library. Also how I can deal with this general flow of data to make a usable library for all kinds of data.. The data from Yahoo Pipes can be news items (title, description, postdate, images, links,..) Yahoo Pipes also has functionality for parsing CSV files, so "data tables" are also possible.   Also I was thinking about the structure of the library, what the best way is to implement it. In general the library needs to load in the data from the pipe (JSON string) and pass it to a visualization library like Google Chart or D3.js (formerly Protovis)   I would consider my Javascript skill level as 'Rookie' :)      Thanks for the replies, any advice is welcome!


Does a batch of operations violate REST principles?

Does it violate REST principles for a REST API to support a batch of operations (perhaps with transactional guarantees) that can be added to a queue via a POST? This design seems outside the scope of REST architecture but not necessarily in violation of it, but I'm looking for authoritative sources here, and/or supporting explanations when/why to avoid or prefer this approach. For example, the Parse API supports a POST to create a batch of requests, each representing what could be a separate REST request, such as the following (quoting):               curl -X POST \       -H "X-Parse-Application-Id: ${APPLICATION_ID}" \       -H "X-Parse-REST-API-Key: ${REST_API_KEY}" \       -H "Content-Type: application/json" \       -d '{             "requests": [               {                 "method": "PUT",                 "path": "/1/classes/GameScore/Ed1nuqPvcm",                 "body": {                   "score": 999999                 }               },               {                 "method": "DELETE",                 "path": "/1/classes/GameScore/Cpl9lrueY5"               }             ]           }' \       https://api.parse.com/1/batch


Introducing a (new) test method to a team

A couple of months ago I was hired in a new job. ( **I'm fresh out of my Masters in software engineering** ) The company mainly consists of ERP consultants, but I was hired in their fairly small web department (6 developers), our main task is ERP/ecom integration ( **ERP-integrated web shops** ). The department is growing, and **recently my manager asked me to start thinking about introducing tests to the team** , I love a challenge, but frankly I'm a bit scared (I'm the least experienced member of the team). Currently the method of testing is clicking around in the web shop and asking the customer if the products are there, if they look okay, and if orders are posted correctly to the ERP. We are getting a lot of support cases on previous projects, where a customer or a customer's customer have run into errors, which - I suppose - is why my manager wants more structured testing. Off the top of my head, I though of some (obvious?) improvements, like looking at the requirement specification, having an issue tracker, enabling team members to register their time on a "tests"-line on the budget, and to circulate tasks amongst members of the team. But as I see it we have three main challenges:   1. **general website testing**. (javascript, C#, ASP.NET and CMS integration tests)   2. (live) **ERP integration testing** (customers rarely want to pay for test environments).   3. **adopting a method in the team** I like the responsibility, but I am afraid that I'm in a little bit over my head. I expect that my manager expects me to **set up some kind of workshop for the team** where I present some techniques and ideas and where we(the team) can find some solutions together. What I learned in school was mostly unit testing and program verification, not so much testing across multiple systems and applications. **What I'm looking for here, is references/advice/pointers/anecdotes; anything that might help me to get smarter and to improve the current method of my team.** (TL;DR: read the bold parts)


Stereo images rectification and disparity: which algorithms?

I'm trying to figure out what are currently the two most efficent algorithms that permit, starting from a L/R pair of stereo images created using a traditional camera (so affected by some epipolar lines misalignment), to produce a pair of adjusted images plus their depth information by looking at their disparity. Actually I've found lots of papers about these two methods, like:   * "Computing Rectifying Homographies for Stereo Vision" (Zhang - seems one of the best for rectification only)   * "Three-step image rectiﬁcation" (Monasse)   * "Rectification and Disparity" (slideshow by Navab)   * "A fast area-based stereo matching algorithm" (Di Stefano - seems a bit inaccurate)   * "Computing Visual Correspondence with Occlusions via Graph Cuts" (Kolmogorov - this one produces a very good disparity map, with also occlusion informations, but is it efficient?)   * "Dense Disparity Map Estimation Respecting Image Discontinuities" (Alvarez - toooo long for a first review) Anyone could please give me some advices for orienting into this wide topic? What kind of algorithm/method should I treat first, considering that I'll work on a very simple input: a pair of left and right images and nothing else, no more information (some papers are based on additional, pre-taken, calibration infos)? Speaking about working implementations, the only interesting results I've seen so far belongs to this piece of software, but only for automatic rectification, not disparity: http://stereo.jpn.org/eng/stphmkr/index.html I tried the "auto-adjustment" feature and seems really effective. Too bad there is no source code...


A* Algorithm Completeness Proof

The A* Algorithm is the optimal (provided the heuristic function is underestimated), complete & admissible (provided some conditions). I know the proofs of admissibility & optimality. But how do you prove that the A* Algorithm is complete?


What are some feasible ideas for building a smart-device/console development portfolio?

I would like to start getting more contracts in the mobile, smart-device, and console development space and, having little prior work experience in the field, I need to build a portfolio of example projects. Most of my professional experience is based on the .NET stack, so that is helpful in covering Windows Phone, Windows Metro, and XBOX (non-game) development such as Kinect UI development, media applications, etc. But I also need to demonstrate that I can handle Android development, Linux development (i.e. Smart TV apps), possibly Arduino development and so forth. I have the tools and the knowledge to at least knock out some Android and Arduino examples, though iOS and Linux is stretching a bit out of my comfort zone. In any case, what are some ways in which I could demonstrate that I understand and can code for these platforms? Media search and filter apps? Kinect navigation? Android app that gets you the location of the nearest Starbucks based on GPS coordinates? Any ideas would be greatly appreciated.


How can I use JIRA for project management with Green Hopper

I am thinking of using JIRA + GreenHopper for my project management. I have seen that Green Hopper is for making User stories, sprints. I am not able to find how do i need to add tasks, or how to break user stories in to sub stories. Do I first need to create project in JIRA and then use Green Hopper or I can use use Green Hopper standalone for project management? I am thinking of JIRA as issue tracker not project management.


Design Pattern dilemma. Strategy seems wrong?

I would like some help/advice on a design pattern or similar I could use for my problem. I have some shared functionality in my code and I use the Strategy pattern at present. I have a base class named "ProjectSectionBase" and from here I have 2 derived classes, "ProjectSectionStandard" and "ProjectSectionSuperior". Now the problem is that "ProjectSectionSuperior" has a lot of extra functionality than "ProjectSectionStandard" and I'm finding that throughout my code i am calling methods like this: DirectCast(_projectSection, ProjectSectionSuperior).DoSuperiorStuff And I am also wrapping IF statements such as IF typeof(_projectSectio) is superior then. It just feels like bad class design. Both standard and superior share a lot of common functionality but then Superior has so much more functionality. Any advice would be greatly appreciated.


Why would companies allow these practices?

Here's a situation that usually happens in some companies: Announce interesting product X. Promise a release date. Release on the promised released date, ready or not. Users discover and report defects. Send patch after patch after patch after patch after patch. My question is: Ummm, what could be the factors that would lead them to tolerate these undesirable practices? So, in the name of quality, what can be practically and realistically improved in those practicies? I can think of time constraints, user feedback, sponsors pressuring the company, lack of money.


How do you learn Regular Expressions?

I'm not asking **where** to learn. I've found lots of good resources online, and books etc. But how the heck do I tackle them. Where is the start of it, the end? When does the regexp processor advance on the text, when does it hold its stand and tries another match? etc. I feel like trying to figure out hieroglyphs on the Egyptian pyramids.


Common mistakes with javascript arithmetic

I've ran into several oddities using javascripts floating point arithmetic, but I can never recall them off the top of my head! **What are some common mistakes when using JavaScript to do math?**


Preferred way for dealing with customer-defined data in enterprise application

Let's say that we have a small enterprise web (intranet) application for managing data for car dealers. It has screens for managing customers, inventory, orders, warranties and workshops. This application is installed at 10 customer sites for different car dealers. First version of this application was created without any way to provide for customer-specific data. For example, if dealer A wanted to be able to attach a photo to a customer, dealer B wanted to add e-mail contact to each workshop, and dealer C wanted to attach multiple PDF reports to a warranty, each and every feature like this was added to the application, so all of the customers received everything on new update. However, this will inevitably lead to conflicts as the number of customers grow as their usage patterns are unique, and if, for instance, a specific dealer requested to have an ability to attach (for some reason) a color of inventory item (and be able to search by this color) as a required item, others really wouldn't need this feature, and definitely will not want it to be a required item. Or, one dealer would like to manage e-mail contacts for their employees on a separate screen of the application. I imagine that a solution for this is to use a kind of plugin system, where we would have a core of the application that provides for standard features like customers, inventory, etc, and all of the customer's installed plugins. There would be different kinds of plugins - standalone screens like e-mail contacts for employees, with their own logic, and customer plugin which would extend or decorate inventory items (like photo or color). Inventory (customer,order,...) plugins would require to have installation procedure, hooks for plugging into the item editor, item displayer, item filtering for searching, backup hook and such. Is this the right way to solve this problem?


Are RSpec and Cucumber really worth it?

I'm a quite new programmer to Rails (about a year) always trying to discover new gems, new ways of thinking, I just love this framework. The only thing that's kind of disturbing me is testing. I know the major part of the RoR programmers are testing addicts and I understand the advantages of a large testing suite but when I start testing, I never get such a large suite and I always wonder "Am I testing the right way ? Are there really efficient ?". I'm often dealing with integration tests testing only the way the application behave... So I have some questions to improve myself as a Rails programmer. First, is testing really worth it ? I mean, is the time spent on writing tests really worth it ? Then, I use RSpec, I've recently discovered Cucumber, used it for a while but I don't know if writing all these steps is really worth the trouble ? I know I can reuse steps but I never know if these steps are too complete or not : For instance, I've been using a `Given I am logged in as (.+)` but I don't know if I must say in its definition `Given there's a user called $1` because it can duplicate the user if ever created but that's not worthwhile always having a step before `Given I am logged in as (.+)`. It's quite a lot of code that will maybe rarely be useful. I guess there are not new bugs on the parts tested every day... So is Cucumber really worthwhile compared to RSpec ? I really want to thank you for having read me because that's the first message I post that's really long and to thank you in advance for all your answers, hoping it could help other Rails newbies just like me in the future.


Is there any license restriction to avoid binary translation of CIL to custom bytecode?

Prior to actual question, let me summarize what I'm trying to do. I plan to implement a small, JIT-enabled, register-based VM runtime. Instead of making a proper compiler (which is hard IMO) for a super-fancy home-brew language, I decided to implement a binary translator from a appropriate bytecode (much like Dalvik VM approach). Considering CIL vs. Java bytecode, CIL is best for my needs. As a note, I wanted to list some important things to avoid possible confusions:   1. Base Core Library (BCL) or any Microsoft specific assemblies won't be decompiled and translated. Instead, BCL references will be subject to substitution with my VM specific codes at translation phase (much like COSMOS Plugs approach).    2. All CIL opcodes won't be translated. So, directly using CIL is not an option.   3. "Any" .NET executable is not targetted for translation. .NET will be a tool, not target.   4. Dalvik VM is good example what I'm trying to do. In Dalvik case, programs are written in Java, but Java byte codes translated into Dalvik opcodes. In my case, programs will be written in .NET, but CIL will be translated into "fancy" VM opcodes.   5. Custom VM itself will be closed source and it will be in a free software initially. But, in time, it might be used in open source and/or commercial projects. So, is there any license restriction to avoid me doing this? If so, how can I avoid the restrictions? Making only non-profit applications or making it open source? **EDIT:** I won't use **CLI** , **CLR** or any other thing which is distributed from Microsoft. I won't redistribute or integrate **SSCLI** into my applications either. **The question is about translating _CIL_ code into custom byte codes which will be done with my own tools**. So, it's actually decompilation of my own custom .NET executables into a different byte codes to serve my needs in production phase. So, essentially I'll use .NET compilers as a front-end for my decompiler, but I won't redistribute .NET compilers either. **EDIT2: CLI AND CIL ARE DIFFERENT THINGS!**


How to represent a graph with multiple edges allowed between nodes and edges that can selectively disappear

I'm trying to figure out what sort of data structure to use for modeling some hypothetical, idealized network usage. In my scenario, a number of users who are hostile to each other are all trying to form networks of computers where all potential connections are known. The computers that one user needs to connect may not be the same as the ones another user needs to connect, though; user 1 might need to connect computers A, B and D while user 2 might need to connect computers B, C and E. ![enter image description here](http://i.stack.imgur.com/MeLa2.png) _Image generated with the help ofNCTM Graph Creator_ I think the core of this is going to be an undirected cyclic graph, with nodes representing computers and edges representing Ethernet cables. However, due to the nature of the scenario, there are a few uncommon features that rule out adjacency lists and adjacency matrices (at least, without non-trivial modifications):   1. edges can become restricted-use; that is, if one user acquires a given network connection, no other user may use that connection      * in the example, the green user cannot possibly connect to computer A, but the red user has connected B to E despite not having a direct link between them   2. in some cases, a given pair of nodes will be connected by more than one edge      * in the example, there are two independent cables running from D to E, so the green and blue users were both able to connect those machines directly; however, red can no longer make such a connection   3. if two computers are connected by more than one cable, each user may own no more than one of those cables I'll need to do several operations on this graph, such as:   * determining whether any particular pair of computers is connected for a given user   * identifying the optimal path for a given user to connect target computers   * identifying the highest-latency computer connection for a given user (i.e. longest path without branching) My first thought was to simply create a collection of all of the edges, but that's terrible for searching. The best thing I can think to do now is to modify an adjacency list so that each item in the list contains not only the edge length but also its cost and current owner. Is this a sensible approach? Assuming space is not a concern, would it be reasonable to create multiple copies of the graph (one for each user) rather than a single graph?


How to layer if statements when order of logic is irrelevant?

Basically I have a series of logic in my website that can lead to 5 total outcomes. Basically two different if tests and then a catch all else statement. For example:               if cond1:         if mod1:             #do things         elif mod2:             #do things     elif cond2:         if mod1:             #do things         elif mod2             #do things     else:         #do things      I was thinking about rewriting it like this:               if cond1 and mod1:         #do things     elif cond1 and mod2:         #do things     elif cond2 and mod1:         #do things     elif cond2 and mod2:         #do things     else:         #do things      Is there any real difference in these two coding options/a better choice for this kind of logic testing?


If I use MIT-licensed components in my software, can my customers resell it?

My amateur reading of the MIT license suggests that any software is distributed to my customers containing any MIT-licensed components can be freely re-distributed in its entirety. > Permission is hereby granted [...] to deal in the Software without > restriction, including [...] the rights to [...] distribute [...] copies of > the Software. > > The above copyright notice and this permission notice shall be included in > all copies or substantial portions of the Software. It's not clear whether "the Software" refers to the entire application, or just the individual MIT-licensed component. So which is it?


Why returning XML/JSON for API requests, can't we just directly process request and return the modified web page (HTML/CSS/JS)?

Let's say that a user requests for some piece of data. Usually the data is processed via a server and then returned in XML/JSON format. Im guessing another piece of processing happens to convert it into HTML/CSS so that it could be displayed on a browser. Why do we bother returning XML/JSON for API requests? Why can't we just directly process whatever the user wants and just return the modified web page (HTML/CSS/JS)?


What API is required for code completion/syntax highlighting/similar IDE features?

I've been developing a little language in my own time, and I've got a fairly bare-bones prototype that implements some of the most basic features. Now I'm looking at scaling up, and I don't want to make a nasty architectural mistake where I have to massively refactor everything to support these features. So I'd like to know about the key API features required. Right now, I have The lexer can operate on any input buffer using iterators, the tokens are available for inspection before passing to the parser, and I also provide a hook for comments. The parser can operate on any token stream (not hard coded to my lexer at all), and the AST construction can be swapped out. I also annotated my AST with location information. Also, the AST is readily available for inspection prior to analysis. Finally, many of the analysis features are lazily evaluated, so it's easy to get their semantic representation from the AST. But I'm not sure what features those semantic representations need to be readily available for such efforts. Any suggestions as to what is necessary in this regard?


Activity diagram, can merge node have more than 1 output?

There is a simple system, that allows users to do 4 things: ADD, EDIT, DELETE, PRINT data. I am due to model it (I'm entirely new to UML activity diagrams) and from notation, I dont understand whether a decision node can have more than 3 inputs? It should be, otherwise how would I do that. Anyway, the user can perform the action and do it again, so there is a loop needed. But the merge node is said to have only one output, which would not be the case. The picture should be clear what I mean. ![enter image description here](http://i.stack.imgur.com/7FqtI.png)


PHP developer, how to solve javascript related issues in a program with millions of line

I am expert in PHP. There are some JavaScript related bugs in my assignment given by my supervisor. I tried to fix them using Firebug. It is time consuming. Is there any other ways?   1. Are there any good IDE's to tackle this issue?   2. Are there any other developer tools except Firebug?


Logging errors caused by exceptions deep in the application

What are best-practices for logging deep within an application's source? Is it bad practice to have multiple event log entries for a single error? For example, let's say that I have an ETL system whose transform step involves: a transformer, pipeline, processing algorithm, and processing engine. In brief, the transformer takes in an input file, parses out records, and sends the records through the pipeline. The pipeline aggregates the results of the processing algorithm (which could do serial or parallel processing). The processing algorithm sends each record through one or more processing engines. So, I have at least four levels: Transformer -> Pipeline -> Algorithm -> Engine. My code might then look something like the following:               class Transformer {         void Process(InputSource input) {             try {                 var inRecords = _parser.Parse(input.Stream);                 var outRecords = _pipeline.Transform(inRecords);             } catch (Exception ex) {                 var inner = new ProcessException(input, ex);                 _logger.Error("Unable to parse source " + input.Name, inner);                 throw inner;             }         }     }          class Pipeline {         IEnumerable<Result> Transform(IEnumerable<Record> records) {             // NOTE: no try/catch as I have no useful information to provide             // at this point in the process             var results = _algorithm.Process(records);                  // examine and do useful things with results             return results;         }     }          class Algorithm {         IEnumerable<Result> Process(IEnumerable<Record> records) {             var results = new List<Result>();             foreach (var engine in Engines) {                 foreach (var record in records) {                     try {                         engine.Process(record);                     } catch (Exception ex) {                         var inner = new EngineProcessingException(engine, record, ex);                         _logger.Error("Engine {0} unable to parse record {1}", engine, record);                         throw inner;                     }                 }             }         }     }               class Engine {         Result Process(Record record) {             for (int i=0; i<record.SubRecords.Count; ++i) {                 try {                      Validate(record.subRecords[i]);                 } catch (Exception ex) {                     var inner = new RecordValidationException(record, i, ex);                     _logger.Error(                         "Validation of subrecord {0} failed for record {1}",                         i, record                         );                 }             }         }     }      There's a few important things to notice:   * A single error at the deepest level causes three log entries (ugly? DOS?)   * Thrown exceptions contain all important and useful information   * Logging only happens when failure to do so would cause loss of useful information at a lower level. Thoughts and concerns:   * I don't like having so many log entries for each error   * I don't want to lose important, useful data; the exceptions contain all the important but the stacktrace is typically the only thing displayed besides the message.   * I can log at different levels (e.g., warning, informational)   * The higher level classes should be completely unaware of the structure of the lower-level exceptions (which may change as the different implementations are replaced).   * The information available at higher levels should not be passed to the lower levels. So, to restate the main questions: What are best-practices for logging deep within an application's source? Is it bad practice to have multiple event log entries for a single error?


XAML Controls in WinForms

We're considering converting our WinForms application to a WPF application. Part of the reason is that WPF/XAML seem to be the future. We are also using third party controls that we would like to be able to phase out. Making this conversion seems like a pretty big and time consuming undertaking, though. Would it make sense to develop XAML controls that could be used in our WinForms application as a first step in the process? My thinking is that the same controls would then be used in the WPF application and all of the look, feel, and functionality would be built into the controls in either environment.


File Upload Forms: Security

SO I'm building an application for uploading files. We're paying scientists to contribute information on pests, diseases and bugs (for Plants). We need the ability to drag and drop a file to upload it. The question becomes since the users will be authicentated and setup by us, will it be necessarcy to include a virus scanner to prevent the uploading and insertition of malicious files. How important is this?


Purest functional programming language(s)?

I'm interested in better learning functional programming. To do so, it seems obvious that I should force myself to use the purest possible functional programming language. Hence, I'm here asking, more or less, for an ordering of functional programming languages according to their purity. It seems to me that it would be more practical to learn Lisp or Clojure (or Scheme, or Scala, etc.), but for what I've heard recently, Haskell would be very hard to beat at teaching functional programming principles to someone. I'm not sure about this yet, so **I'm asking you:** which is the purest functional programming language? An ordering would be great if several are competing for the magnificent title of the purest functional programming language.


Being prepared for a code review as a developer?

I am looking for some ideas here. I read the article How should code reviews be Carried Out and Code Reviews, what are the advantages? which were very informative but I still need more clarity on the question below. My Question is,   1. Being the target developer, can you suggest some best practices a developer can incorporate before his code is going get reviewed.     * Currently I practice the following methods        * PPT for a logical flow        * Detailed comments. **Issue: Even though I have implemented the above practices, they do not help on the review. The problem I faced is, when certain logic is referred, I keep searching for the implementation and the flow and too much time is wasted in the process and I get on people’s nerve.** I think a lot of developers would be going through what I am going through as well.


Whose responsibility (in term of finances) are regression bugs?

Let's have a scenario like this: There is a medium-size project and you are assigned to it to add new features. The project does not have unit tests or dedicated QA person. You are the one who has to add new features and take care of fixing regression (link) bugs. When a regression bug happens, are you a responsible person (in term of finances) or a client? Or to ask another way, when you are paid to add new features in part-time job and a regression bug occurs, should you fix it for free or you should be paid since the project does not have unit tests or a dedicated QA worker?


Converting large files in python

I have a few files that are ~64GB in size that I think I would like to convert to hdf5 format. I was wondering what the best approach for doing so would be? Reading line-by-line seems to take more than 4 hours, so I was thinking of using multiprocessing in sequence, but was hoping for some direction on what would be the most efficient way without resorting to hadoop. Any help would be very much appreciated. (and thank you in advance) EDIT: Right now I'm just doing a `for line in fd:` approach. After that right now I just check to make sure I'm picking out the right sort of data, which is very short; I'm not writing anywhere, and it's taking around 4 hours to complete with that. I can't read blocks of data because the blocks in this weird file format I'm reading are not standard, it switches between three different sizes... and you can only tell which by reading the first few characters of the block.


What is the best way to handle references in a .NET application

Recently at work we ran into a problem where we tagged/branched a project and had some compiling issues because of dll/project references that was pointing to the old folder structure. We created an 'external bin' folder for each of the projects and copied the referenced dll's to these folders. Is this the best way or is there a specific industry standard to handle this?


Shared QA responsibilities on an Agile team

For many years our IT development group subscribed to the waterfall software development methodology with segregated pods of programmers specializing in database development, logic layer and presentation layer development. Of course we also had a small quality assurance group which handled all testing responsibilities. Requirements, tasks and bugs were handed back and forth electronically, very little conversation took place, and the process ground painfully on. In 2010 we made the monumental shift to Agile with Scrum and after some serious growing pains we've truly began to excel as a whole team. Communication is constant, people are growing and learning from each other every day, and our releases more stable and much more aligned with true business priorities. One area we're still trying to grow in is in sharing software QA responsibilities amongst all development team members to get away from the toss-it-over-the-fence attitude that still seems to persist when it comes time to test a feature. **Does anyone have any advice as to how to grow a development team towards collective application quality ownership?** We currently practice XP so we've begun to do more pair programming between developers and testers when creating unit and integration tests. But it still is challenging to get the whole team to proactively think about testing strategies for each sprint. Inevitably one or two " _Write Test Cases_ " tasks are thrown into the sprint backlog with no forethought as to what will be tested and how it will best be achieved and organized so the entire team is aware of what testing has been completed, what's currently being tested, and what's left to test. Sorry for the long-winded question, but any advice would be much appreciated.


How to make a method synchronized across all instances of an object

Today I was asked this interview question and could not answer. : If you have two instances of a Person Object and each of them have a setAddres method that is synchronized. Now if it was only one object and multiple threads were accessing it, the nsynchronized will make sure that only one method can access it at a time. But if there are different objects, one thread will not wait on the other before entering the method. Now the question is...if I wanted to make the method synchronized across all instances of Person Objects, how to do that?


Do you write common pre-conditions for a large number of unit test cases?

I have heard/read writing common pre-conditions for a large number of test cases is a bad thing, since this dependency may cause large number of test cases to fail if something changes . What are your thoughts on it ? If this is so , then what exactly is the purpose of setUp() method in Junit that runs before each test case ? If the same code inside setUp() runs before each test case , why cant it run only once before running all the test cases together ?


File Processing Times

I have a very simple program in Ruby that opens a dictionary file, `sorted- words.txt` and prints out all the words in pig-latin. I tested its speed, and the first time I ran it, the program finished in about **1.6 seconds**. The second time I ran the program, it took about **2.1 seconds**. Between the two runs, there was maybe about a 10 second wait, me looking at the results and running the program again. I waited a minute, ran it again, and it ran in **1.8 seconds**. Although the variation is slight, it is still there. Why is there this variation?


If a fluent coder disregards good practices, doesn't his fluency work against him?

I am working on a fairly large and buggy application - and due to the way it's written (I'll spare you details, but it violates rules in most areas you can think of), it is next to impossible developing it without major refactoring. Significant part of the app was authored by interns, n00bs etc.; but there has also been a programmer in the rank of Master Developer, and with all humility, the code he left behind is dubious as well, in a different way perhaps but still. Granted, his code tends to get the job done - most of the time - but it's typically cryptic, reinventing the wheel (eg. a big custom method accomplishing a rather ordinary SQL db backup) etc. Basically, needless confusion plus lots of overengineering And it got me thinking that being a highly skilled coder (I deliberately don't use the word "developer", assuming that it indicates a wider set of skills), if not accompanied by other qualities, can actually be sort of poisonous. Assuming that it's true, some of the reasons I could think of are:   * if you're coding with ease, it feels (or actually is, in short run) just quicker to snap out your own solutions on the spot, without turning to libraries, preexistent functionality etc.   * if one is experienced enough to easily maintain a mental image of a complex program, one is less inclined to split it into modules, layers etc. So my point is that if a fluent coder happens to be a bad developer, their fluency not only doesn't compensate for the latter, but it actually does even more harm instead. What do you think of that? Is it true (to what extent if so)?


Have an assesment day for a company and have no clue what to expect and would like any advice please!

I am after some advice in regards to an assessment day I have coming up in 38 days time. I am a computer science graduate who graduated last year and have since been having difficulty finding work. I have had a bit of luck in being accepted (through passing a phone interview) and have now been invited to an 'assessment day'. The company involved is an IT solutions and consultancy company. The job position is titled 'graduate IT consultant'). I was wondering if anyone could give me any advice in what to expect on these 'assessment days'. Will it be a day of tests or would it be a day when we are given tasks (maybe in groups) and then observed to see how we handle those tasks to find a solution? I really haven't the slightest idea and so am wondering through people who have been through a similar experience (even with other companies) what they found. I am after advice in regards to what to study for this position. At university I was exposed to JAVA programming and some design work that was associated with that. This job being an 'graduate IT consultant' position I am after advice in what area to focus in. Would focusing in system analysis & system design be most suited or should I just continue focusing on my programming skills and maybe look into design patterns etc?


Is Morton Code algorithm patented?

Synonyms: Morton Code, Morton Curve, Z-Order Curve, invented 1966 by G. M. Morton according to wiki. Not to be confused with Hilbert Curves which is closely related and have similar name. I was wondering if mentioned algorithm is patented. More generally, is there any place one can browse patented algorithms? I am quite new to all this legal stuff and I am keen to know more. The real question I have, I guess, is: Can I make money off a library that provides Morton Coding, legally?


Possible Damerau-Levenshtein improvement?

I recently implemented the Damerau-Levenshtein distance algorithm from the pseudocode on Wikipedia. I couldn't find any explanation of exactly how it works and the pseudocode uses completely uninformative variable names like `DA`, `DB`, `i1`, and `j1` that left me scratching my head. Here's my implementation in Python: https://gist.github.com/badocelot/5327337 The Python implementation helped me walk through the program and figure out what was happening, renaming the variables to more helpful names. I was familiar enough with the Wagner-Fischer approach to calculating the Levenshtein distance that I had a frame of reference. At the risk of being overly lengthy, here's how I understand Damerau- Levenshtein: **The mystery variables:**   * `DA` (`last_row` in my code) is a kind of map holding the last row each element was seen on; in my code it's an actual Python dictionary   * `DB` (`last_match_col`) holds the last column where the letter in `b` matched the letter in `a` for the current row   * `i1` (`last_matching_row`) is the row number from `DA` for the current letter in `b`   * `j1` is just a copy of the value of `DB`/`last_match_col` before it's potentially updated; in my code I just moved where `last_match_col` is updated and eliminated this variable **The transposition cost:**               H[i1][j1] + (i-i1-1) + 1 + (j-j1-1)      is calculating the cost of swapping the current character in `b` with the last character in `b` known to be in `a` (the last match), treating all characters in between as either additions or deletions. _Components of the cost:_   * `H[i1][j1]` reverts the base cost to the point in the calculations before the transposition, since finding a transposition invalidates previous work   * `(i-i1-1)` is the distance between the current row and last row matching the current character, which is the number of deletions that would be required   * `(j-j1-1)` is the distance between the current column and the last column with a match, which is the number of additions   * The extra `+ 1` is just the cost of the transposition itself If this analysis is incorrect, I'd love to know where I went wrong. As I said, I couldn't find _any_ detailed explanation of how the algorithm works online. **Improved version?** Having figured that out, though, it struck me that by calculating the cost of _both_ additions and deletions between transposed letters seemed flawed: one addition and one deletion is equivalent to a substitution, which this isn't checking for. If all that's correct, the solution should be trivial: the cost of the letters between transposed letters should be the _higher_ of the additions and deletions: convert as many into substitutions as possible and add in any additions or deletions left over. So the cost would be:               H[i1][j1] + max((i-i1-1), (j-j1-1)) + 1      Here's my code for this version: https://gist.github.com/badocelot/5327427 From some simple tests, this seems correct. For example, "abcdef" -> "abcfad" gives an edit distance of 2 (transpose "d" and "f", change "e" to "a"), while the original algorithm gives a distance of 3 (either last three letters are substitutions, or 1 transposition + 1 addition + 1 deletion). Now, I **cannot** be the first person to have thought of this. So, why didn't I run across it? Did I just not search long enough? Or is there some subtle flaw that prevents this from actually working?


how could I interview for a C# position if I master Java

> **Possible Duplicate:**   >  Interviewing a developer who's skilled in a language you don't know I must interview people for a C# position we have. I work on the java side of the project, and master it quite well. When I interview for java position, I ask some technical-questions/programming-problems so I can make sure the candidate has solid skills, not just '5 years experience'. But I don't know C# at all. I could look for some questions online (and their answers), but if I ask them these questions, I might not be able to see clearly if their response is right or wrong, maybe they have a point in some way etc. Also I won't be able to follow up in any side discussion etc. So what I am basically asking is if someone with java/C# knowledge can think of questions that:   1. are deep enough to show the guy is solid   2. I (with java knowledge but zero C#) can discern their reply is good/reasonable/well thought or not.


Is there a way to combat Sales perpetually overcommitting?

I seem to be repeatedly stuck in a situation where release dates are set not based on anything technical, but because someone in Sales has committed to a customer by then. Based on discussions with friends in development at other companies, the same thing seems to happen. "Here is the committed feature set and here is the committed release date", and it's difficult to argue because at this point there is money riding on it, and that trumps everything. **In general, is there a way to push back on this?** If not for this release, what about in future? The problem I have is that the only way I see one way of doing so, and that's by doing the best I can, but release the software 'as is', so to speak. I don't want to release bug-ridden software since it's my name attached, but doing 80 hour weeks for months at a time just vindicates the arbitrarily set release date. edit: for the record, I'm not doing 80 hour weeks now, just that comes to mind as what would be required to cover the expected feature set by the release date.


What scripting language to use for large file transfers on windows xp client machines

I'm a java developer that is tasked with creating some scripts that will handle large xml document file transfers by hitting some web service api's from windows xp client machines. There may be other document formats involved like .pdf, .doc, .xls or .txt, but I'm not sure on that at this point. I've looked into powershell, groovy, perl, but I'm not sure which one would be the best to use as I've not done work with any of those and there may be a better alternative than these three I've listed. So for security, ease of deployment, and maintenance for the script (not overly complicated to write or large), what would fit the best for these requirements?


Are neural networks the best approach to artificial intelligence and machine learning?

I enjoy learning about artificial intelligence techniques What other techniques are useful for AI and machine learning other than neural networks?


Do multiple 'helper' classes conflict with the accepted Apple design scheme?

I have a social location based application and I'm in a bit of design conflict that I can't seem to solve or find good information on. Realizing that I have multiple controllers that will similarly access the user's location and load an array of places to be displayed in a table view, I've made a class that has class methods to provide the users location (coordinates and/or reverse-geocoded address), and populate a variably sized NSArray of locations, and other methods that different controllers will use to form their data. Call it `SpotsManager`. Anticipating future complexity, I have separated `SpotManager`s duties into 2 separate classes, a `SpotLocationManager` for wrapping a `CLLocationManager` and a `SpotNetworkManager` for wrapping AFNetworking. Do all of these managers give off code smell? It seems excessive, especially compared to most of Apple's sample apps but at the same time, it also seems like beneficially strict organization. To contrast my previous approach, I've branched and made a `SpotsList` class that knows how to populate its instances with locations. But I question extending this class without creating some God-class. (And `[SpotList currentCoordinate]` doesn't sound right.) I realize high level design questions provide an opportunity for opinions, so I am specifically asking for an answers that will provide some objectivity and insight into Apple approved design.


Why there is much more support for closed xls format in rails (and ruby) than to an open ods format?

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 more inclined to write SW for open formats). For example for ruby there is a spreadsheet gem.


ReSharper's effect on coding interviews

Anyone who has used R# or CodeRush knows how fast you can put together simple constructs (and refactor complex ones) with a simple keyboard shortcut. However, **do these productivity plugins cause a false evaluation of ability during interviews?** Part of being a productive code writer (and making a good first impression in an interview) is writing good code - fast. If I had two candidates:   1. Doesn't use plugins. She thinks about the problem, sits down at a stock IDE at the interview PC that looks exactly like hers and types out the code in a minute or two, as usual. Done. Pass.   2. Uses plugins. He thinks about the problem, sits down at a stock IDE at the interview PC and realizes "fe + tab" no longer writes a foreach loop automatically, and all the shortcuts are gone. He then bumbles around the keyboard hitting his normal hotkeys and popping up strange windows and getting flustered. It takes him 3 minutes to write what normally would take 30 seconds. Done. Looked like they didn't know their way around the IDE at times. Must be new to this IDE and thus not had much experience with it or maybe the language. Pass, but a 'meh' mark beside their name. In your experience, how do you handle plugins during interviews as the interviewer or interviewee? What are the best practices to getting what the candidate really knows? There can be candidates who don't understand code, and use R# as a crutch. There can also be candidates who know the code in and out and use R# because it's just plain faster than the built in VS or Eclipse templates. Is it best to just not use an IDE at all? Let them bring their own PC? Others?


How should C++ Unit Test code be organized for maximum Unit Test efficiency?

* This question is _not_ about Unit Testing Frameworks.   * This question is _not_ about writing Unit Tests.   * This question is about _where_ to put the UT code written and how/when/where to compile and run it. In Working Effectively with Legacy Code, Michael Feathers asserts that > good unit tests ... run fast and that > A unit test that takes 1/10th of a second to run is a slow unit test. I think these definitions do make sense. I also think that they imply that you have to keep a set of _Unit Tests_ and a set of _Those Code Tests That Take Longer_ separately, but I guess that's the price you pay for only calling something a Unit Test if it runs (very) fast. Obviously the **problem** in C++ is that to "run" your Unit Test( **s** ), you have to:   1. Edit your code (production or Unit Test, depending on which "cycle" you're in)   2. Compile   3. Link   4. Start Unit Test Executable( **s** ) * * * Edit (after weird close vote): Before going into the details, I'll try summarize the point here: How can C++ Unit Test code be effectively organized, so that it's both efficient to edit the (test) code and to run the test code? * * * The **first** problem then is to decide _where_ to put the Unit Test code so that:   * it's "natural" to edit and view it in combination with the associated production code.   * it's easy/quick to start the compilation cycle for _the unit_ your currently changing The **second** , related, problem then is _what_ to compile so that the feedback is instantaneous. Extreme options:   * Each Unit-Test-Test-Unit lives in a separate cpp file and this cpp file is compiled+linked separately (together with the source code unit file it tests) to a single executable which then runs this one Unit Test.      * (+) This minimizes startup (compile+link!) time for the single Test Unit.     * (+) The test runs super fast, because it only tests one unit.     * (-) Executing the whole suite will need to start a bazillion of processes. Can be a problem to manage.     * (-) The overhead of process starts will become visible   * The other side would be to have -- still -- one cpp file per test, but all the test cpp files (together with the code they test!) are linked into one executable (per module / per project / pick your choice).      * (+) Compile time still would be OK, as only changed code will compile.      * (+) Executing the whole suite is easy, as there's just one exe to run.     * (-) The suite will take ages to link, as each recompilation of any object will trigger a re-link.     * (-)(?) The suit will take longer to run, _although_ if all Unit Tests are fast, the time should be OK. So, how are real world C++ **Unit Tests** handled? If I only run that stuff nightly/hourly, the second part doesn't really matter, but the first part, namely how to "couple" the UT code to the production code, so that it's "natural" for developers to keep both in focus always matters I think. (And if developers have the UT code in focus, they'll want to run it, which brings us back to part two.) _Real world stories and experience appreciated!_ Notes:   * This question intentionally leaves unspecified platform and make/project system.   * Questions Tagged UT & C++ is a great place to start, but unfortunately too many questions, and especially answers, are too heavily focused on the details or on specific frameworks.   * A while ago, I answered a similar question on structure for boost unit tests. I find this structure to be lacking for "real", fast Unit Tests. And I find the other question too narrow, hence this new question.


Software Licensing

I have an application and I'm ready to release it into the wild world of the Internet. However, I am a confused of a few things. Keeping in mind that I am not releasing the source code, must I include a license If I don't want my program copied and claimed someone elses? If yes, then which one? Also, note that is a non-commercial freelance programmer's application.


Naming for a REST webservice

I have a rest webservice with an endpoint `www.foobar.com/service.svc/MAC` (migration authorisation code). Posting and getting to that adds and gets one MAC respectively. I now need to impliment a new enpoint for all MACs. What would that be? `www.foobar.com/service.svc/MAC/All` seems wrong. What would be correct and why?


Do private static methods in C# hurt anything?

I created a private validation method for a certain validation that happens multiple times in my class (I can't store the validated data for various reasons). Now, ReSharper suggests that the function could be made static. I'm a little reluctant to do so due known problems with static methods. It would be a _private_ static method. My question is, can private static methods cause similar coupling and testing problems like public static methods? Is it a bad practice? I would guess not, but I'm not sure if there is a pitfall here.


TDD: Am I doing it right?

I'm a new programmer (only been learning for about a year) and in my goal to become better at it I have just recently learned about TDD. I wanted to get into the habit of using it since it seems very helpful. I wanted to check and make sure I'm using it correctly. What I'm doing:   1. Think of a new method I need.   2. Create a test for that method.   3. Fail test.   4. Write method.   5. Pass test.   6. Refactor method.   7. Repeat. I'm doing this for EVERY method I write, are there some I shouldn't bother with? Later on I usually think of a way to test my already existing methods in a different way or situation. Should I make these new tests I think of, or since each method already has a test of their own should I not bother? Can I be OVER testing my code I guess is my main concern in asking this. **EDIT** Also, this was something I was just wondering. When doing something like making a GUI, would TDD be necessary in that situation? Personally, I can't think of how I would write tests for that.


Am I handling my exceptions in a sensible manner?

I'm still restructuring the code I have been given to update on my current work project, and I've come to the point where I'm looking at how the code handles an 'exceptional' input, that doesn't conform to the business logic. In essence, the code stitches together various different excel spreadsheets, tarts them up and lets the user 'download' them to their workspace for later analysis. This is what I have set in the code:   If the code ends up (anywhere) trying to, for instance, import an empty spreadsheet into the final work book (something that should never happen, under the business logic) then write out to a LinkedList variable (ErrorList) in a static class (MyVariables) like so, the error:               MyVariables.ErrorList.add("My Specific Error Text");      Then I throw an exception like so:               throw new PICNICException();      Then in the frame that called the trail of methods, the exception is finally caught and I can write, something like this:               catch(PICNICException Pe){         JOption.showMessageDialog(This, MyVariables.ErrorList.getLast(), "Title Relevant to what Code is Doing", JOption.ERROR_DIALOG)        Pe.printStackTrace();     }      I ~~have~~ feel I have to do this as, I have no way to pop up the Message Dialog (which is the desired behaviour on erroring) from within the method that's thrown this exception. Without _completely_ refactoring the entire code base, and making a singleton that can be accessed anywhere to handle these message dialogues, I don't see any other way of doing this. I can't help but feel this is a gigantic hack, and there is a better method for doing this. Am I handling my exceptions in the best possible manner, _given my situation_? What would the best practice be?


Changing a server centric site to a more JS centric one

First of all, I'm not really a Javascript guy, but more towards PHP.   However, I want to move to the next level, that is taking load off the server and let the client do the processing. Hopefully to be a more JS guy. My first thought is to request of data off the server, and it just returns key-values which the client will generate the HTML and puck in the values. There are 3 problems generally:   1. I find it so much easier to generate the HTML in PHP cause data exchange between the server and HTML is fluid. Unlike returning data in JSON, which I then have to select the DOM that I want, and put in the values eg. `$('.personRecord').html(data['name'])`.   I also find looping through arrays and generating HTML easier than JS?   2. I find myself using so much of jQuery selector to select the element I'm interested to manipulate and I'm not sure if that's the correct practice (going forward to be a JS ninja). But I'm doing it cause it sure saves lots of characters.   3. In order to select the elements easily, I tend to give them unique class names as identifier. Again, I'm not sure if that's what a JS Ninja will do. Going forward (web trend), I would like to know if I should try to put more work to JS?   Also, any ideas or thoughts on how I can overcome my 3 problems stated above?   Is it a sin to return formatted HTML as part of a JSON value? Or should HTML be generated in JS and only read values off the returned JSON when it needs? Putting frameworks aside (I know there's Backbone, Angular, Can.JS and many more) does anyone really do raw JS scripting? I mean, it is possible but seems extremely wordy. Lastly, please advice how one would convert a server centric site to a JS centric one? If what I wrote doesn't make any sense, hopefully you can point some JS centric sites, and explain what approach they are using as an example. Sites that are full featured (say..maybe facebook, twitter, stackoverflow) and not just a TODO web app.


Can the user not manipulate html elements which are disabled for non-permitted user

With todays browser extensions/tools is it not easily possible for a user to edit the html/css settings of a website and so enable some disabled buttons etc... to gain access to not permitted areas?


Is JRuby like RubyMRI but better, or are there some things it lacks?

I am considering using JRuby in a project which would need to talk to some Java. From what I am reading about JRuby I am not noticing that it is missing anything that the standard Ruby has. Is that true? Does JRuby have everything the original Ruby has and also the JVM on top of it? Or is there something missing in JRuby and using it necessitates some benefit trade-off to some degree? Thanks! Alex


Is the Fork/Join framework a bad match for the Java 8 Streams API?

Today I found an article about Java8's Fork/Join-Framework and its usage for the parallel streams implementation. While I do understand the article, I'm not entirely sure what I should think of it. Basically what it says it that F/J in conjunction with streams is next to useless, and especially so in the context of JEE applications. Quite a few specific arguments are listed, such as: >   * it needs a massive volume of easily separable data (aggregate), >   * creates copious threads without regard for others, >   * has a high potential for stack overflows, >   * has a high potential for massive memory usage, >   * has a very, very narrow performance window, >   * is only designed for one request at a time. > Moreover, it gives these arguments against F/J's recursive decompostion approach: > Recursive decomposition has an even narrower performance window. In addition > to the above dynamic decomposition, recursive decomposition optimized for > dyadic recursive division only works well: > >   * on balanced tree structures (Directed Acyclic Graphs) >   * where there are no cyclic dependencies >   * where the computation duration is neither too short nor too long >   * where there is no blocking. > Since this is the only source I could find which complains about FJ, I'm not sure if this can be taken seriously. Are the above-cited, or other similar points a valid concern? More specifically, does Oracle have an official position regarding the limitations of the F/J Framework as applied to the parallelization of streams processing? If so, does it have plans to do something about them?


What is MVC, really?

As a serious programmer, how do you answer the question **What is MVC?** In my mind, MVC is sort of a nebulous topic -- and because of that, if your audience is a learner, then you're free to describe it in general terms that are unlikely to be controversial. However, if you are speaking to a knowledgeable audience, especially an interviewer, I have a hard time thinking of a direction to take that doesn't risk a reaction of "well that's not right!...". We all have different real- world experience, and I haven't truly met the same MVC implementation pattern twice. Specifically, there seem to be disagreements regarding strictness, component definition, separation of parts (what piece fits where), etc. So, **how should I explain MVC** in a way that is correct, concise, and uncontroversial?


How do MySQL joins really work?

In my case joining table inside subquery or outside subquery gives very few difference with `COUNT` **CASE 1:** about 6202 rows.   In this case `table_c` is joined inside subquery, but is only joined (No other actions for the table, not selecting any data or filtering whole query with that table). **CASE 2:** about 6235 rows.   In this case that table is joined outside of subquery but joining key (`groupCol`) is the same. Here is my self-explanatory MySQL query:               SELECT          COUNT(*)     FROM (         SELECT               a.*             , b.some             # no c columns         # main table         FROM table_a      AS a              # no mention this         LEFT JOIN table_b AS b         ON a.col = b.bcol              #### CASE 1 ###         # this is left joined, this is matter         # this is only joined, does nothing more         LEFT JOIN table_c AS c         ON c.col = a.groupCol         #### CASE 1 ###           WHERE          *** SOME statements ***          # c table not participating in WHERE, or GROUP-ing clause      GROUP BY a.groupCol       ORDER BY a.dateCol     ) AS subSelect                #### CASE 2 : table_c is joined outside of subquery ###     LEFT JOIN table_c AS c     ON c.col = subSelect.groupCol     #### CASE 2 ###          WHERE          *** SOME statements ***          # table_c still not participating of course      I also know how does MySQL `LEFT JOIN` works: if data not found on second table, row corresponding fields from that table are set to null. What what actually happens here I can't figure out. Also case 1 is faster than case 2.   Why? Also for sure, that joining in case 1, contains least double amount of rows. In case 2 it's first filtered and then joined.   I thought this should be faster way...


How to handle fired listeners exceptions

This is more of a design question and i was hoping to get pros and opinions on what makes sense. BACKGROUND Imagine something that holds one or more event listeners. Every now and then the thing fires events to its listeners. PROBLEM The problem is of course that listeners that follow after a listener that throws never get to know about the event. THis means that the order of listeners thus is an issue. SOLUTION #1 Execute all listeners catching any thrown exceptions. This means all listeners are fired but in itself introduce other problems. What should be done with caught exceptions ?   * One option is to catch them all and after firing all events throw another exception which holds all the problems. ++   * The other option is to log ~~   * The last is to simply ignore these exceptions. --   * Listeners are executed in isolation which is good. ++ SOLUTION #2 This option is the simplist and simply lets any thrown exception from a listener escape, resulting in remaining listeners never getting fired. Problems with this approach mean that   * the order of listeners is significant(-)   * simple to implement(+).   * before listeners can affect the caller Q Which approach makes sense and causes the least number of problems. Does it really make sense to isolate listeners so they get events but cannot cause a running operation to abort if they throw ?


Loading data for ShoppingCart item

I'm currently trying to cover our shopping cart with unit tests. Class `ShoppingCartItem` has property `Term`. It also loads available terms for this item upon object creation. Currently this is done using call to static class in constructor. **Current state:**               public class ShoppingCartItem     {         private Dictionary<Guid, ShoppingCartTerm> terms;          public ShoppingCartItem(int productID)         {             terms = SKUInfoGopasProvider.LoadAllTerms(productID);         }      }      My question is. How to make data source interchangeable? Should I introduce factory class? Obvious answer is use constructor injection but that doesn't seem somewhat right to me. I am thinking about making something along these lines.               public class ShoppingCartData     {         private readonly ShoppingCartItemFactory _factory;              public ShoppingCartData(ShoppingCartItemFactory factory)         {             _factory = factory;         }              public void AddItem(int productId)         {             var item = _factory.CreateCartItem(productId);             _items.Add(item);         }     }


What trends do you see for your profession in 30 years?

Think of the profession 30 years ago. When one single guy was able to code a whole computer game alone! Will offshoring will finally take over? Will languages be so high level than our added value will be reduced to zero? Will it be a profession like lawyer or doctor? Will you still be a programmer? Please extrapolate and predict based on historical and current trends.


Managing software projects - advice needed

I work for a large government department as part of an IT team that manages and develops websites as well as stand alone web applications. We’re running in to problems somewhere in the SDLC that don’t rear their ugly head until time and budget are starting to run out. We try to be “Agile” (software specifications are not as thorough as possible, clients have direct access to the developers any time they want) and we are also in a reasonably peculiar position in that we are not allowed to make profit from the services we provide. We only service the divisions within our government department, and can only charge for the time and effort we actually put in to a project. So if we deliver a project that we have over-quoted on, we will only invoice for the actual time spent. Our software specifications are not as thorough as they could be, but they always include at a minimum:   * Wireframe mockups for every form view   * A data dictionary of all field inputs   * Descriptions of any business rules that affect the system   * Descriptions of the outputs I’m new to software management, but I’ve overseen enough software projects now to know that as soon as users start observing demos of the system, they start making a huge amount of requests like “Can we add a few more fields to this report.. can we redesign the look of this interface.. can we send an email at this part of the workflow.. can we take this button off this view.. can we make this function redirect to a different screen.. can we change some text on this screen… can we create a special account where someone can log in and get access to X… this report takes too long to run can it be optimised.. can we remove this step in the workflow… there’s got to be a better image we can put here…” etc etc etc. Some changes are tiny and can be implemented reasonably quickly.. but there could be up to 50-100 or so of such requests during the course of the SDLC. Other change requests are what clients claim they “just assumed would be part of the system” even if not explicitly spelled out in the spec. We are having a lot of difficulty managing this process. With no experienced software project managers in our team, we need to come up with a better way to both internally identify whether work being requested is “out of spec”, and be able to communicate this to a client in such a manner that they can understand why what they are asking for is “extra” work. We need a way to track this work and be transparent with it. In the spirit of Agile development where we are not spec'ing software systems in to the ground and back again before development begins, and bearing in mind that clients have access to any developer any time they want it, I am looking for some tips and pointers from experienced software project managers on how to handle this sort of "scope creep" problem, in tracking it, being transparent with it, and communicating it to clients such that they understand it. Happy to clarify anything as needed. I really appreciate anyone who takes the time to offer some advice. Thanks.


How to share a file over multiple projects

I'm using Visual Studio 2010 to amend a C# project. Part of the application requires the user to be able to save and read a settings file (1 Project reads them in (as read only) from a file. The other project reads them in from the file to be shown in the GUI and when saved, the file is to be overwritten). If both of these files were in 1 project, I could share it easily (using Resources.resx for example or any other approach). The issue I have is the project that reads the settings file is different to the project that writes/amends the settings file. The 2 projects are not allowed to be referenced to each other (they apparently have to remain oblivious to each other existence) so I can't share a CONST STRING between them. Now, I may be taking the DRY principal too far, but I am worried about writing code reference the a single file in multiple projects (next OS change may break this logic etc). I'm going to assume that this decision isn't uncommon and that an approach(es) already exist to overcome this issue? Is it just a question of having the same file referenced in 2 locations (and if that file changes, having to update each reference (this seems undesired)) or is there a better way?


How should I go about fixing code from a less-experienced programmer?

**A little background:** I am one of two programmers for our department of 10 people (the rest are artists and management). The two of us do all of the coding required to make things flow well, and develop any projects that come up. I've been programming for about 4 years now, where this is his first "real" job (as he puts it). We generally are working on different projects at any point in time. **A couple months ago** I developed a (by no means perfect) set of classes that were to be used for a later project. A large portion of that project was delegated to him (for billing reasons) to design and program a GUI interface. Since he was new, I helped a bit with the designing, and said to ask for help if he needed it with the rest. He finished up the interface a few weeks ago, which he demo'd to show that it worked, although a little slow. **The next part of that project has started** which I'm working on. I opened up the interface to start with the next steps, and immediately ran into issues (a little slow was a little understatement, errors on common actions, etc.). I looked in to the code for a few issues and am finding `O(n^n)` on calls that should be `O(n)`, type assumptions with no error checking (it's in Python), references to the GUI added to the original code, and so on. Now, I definitely would like to teach him what was wrong and how to fix it, but he's already moved on to his next project, and this was a few weeks ago. I'm afraid me saying "Go back and do it right!" (with help of course) is too harsh, and we still have other projects to get done in the meantime. Should I just fix the code myself for now and try to catch things in the future?


Why is quicksort better than other sorting algorithms in practice?

This is a repost of a question on cs.SE by Janoma. Full credits and spoils to him or cs.SE. In a standard algorithms course we are taught that **quicksort** is O(n log n) on average and O(n²) in the worst case. At the same time, other sorting algorithms are studied which are O(n log n) in the worst case (like **mergesort** and **heapsort** ), and even linear time in the best case (like **bubblesort** ) but with some additional needs of memory. After a quick glance at some more running times it is natural to say that quicksort **should not** be as efficient as others. Also, consider that students learn in basic programming courses that recursion is not really good in general because it could use too much memory, etc. Therefore (and even though this is not a real argument), this gives the idea that quicksort might not be really good because it is a recursive algorithm. **Why, then, does quicksort outperform other sorting algorithms in practice?** Does it have to do with the structure of _real-world data_? Does it have to do with the way memory works in computers? I know that some memories are way faster than others, but I don't know if that's the real reason for this counter-intuitive performance (when compared to theoretical estimates).


Return random `list` item by its `weight`

I have, for example, this table               +-----------------+     | fruit  | weight |     +-----------------+     | apple  |   4    |     | orange |   2    |     | lemon  |   1    |     +-----------------+      I need to return random fruit. But apple should be picked 4 times frequently then lemon and 2 times frequently then orange. In more general case it should be `f(weight)` times frequently. What is general algorithm to implement this behavior? _Or maybe there is some ready gems on Ruby? :)_ **PS** I've implemented current algorithm in Ruby https://github.com/fl00r/pickup


How many programming languages do you work with on a daily basis and how do you effectively manage language specific tasks

Edit: **How do you manage individual tasks when working on multiple languages** In day to day task handling, how many different programming languages do you work with?   * Do you make a mental shift when working on each language?    * Do you Prioritize them and keep each task per language separately.   * Do you code in stages based on progress of each task switching seamlessly between languages/IDE/Environment    * Do you apply the same coding style/conventions on all the languages (not syntax)? Related: Is it normal for programmer to work on multiple projects simultaneously