How to use a switch statement with enum efficiently?

I would like to know how I can use a `switch` statement with `enum` values for the following scenarios: I am making a small program for a flight reservation system. The program is meant to enter certain details about the passenger. The program also restricts the user to choose destinations other than the following 3 destinations. Once destination is chosen, the flight number is supposed to be automatically assigned. The user will choose one of three destinations and program will assign an appropriate Flight No for the passenger. The Flight No will be assigned as below:                    Destination                    Flight No.           London                            201           Frankfurt                         233           Berlin                            241      So let's say I make an `enum` of destinations, then how can I use switch statement here? This isn't a homework. I am doing it just for the sake of exploring.


Clarity over Python and Jython

I'm a Java programmer, but I want to program in Jython. I've never coded in Python before, but have been looking through some tutorials and I'm fairly confident I can grasp it. My question is clarity over Jython. I understand with Jython you have the joys of writing Python code with the added bonus of accessing Java libraries. Does this mean, all aspects and coding practices of Python can be applied, such as creating animation, input out structures, or is there a whole new structure which needs to be learned to code Jython?


What is the Meaning of Return False in a Php Function

i wanted to know what is the meaning of return False in an function. go Through this function:               function reset_password($password,$user_id)     {         $sql="UPDATE user SET password='$password' WHERE user_id='$user_id'";              if(!mysql_query($sql,$this->mycon))         {             array_push($this->err_msg,"Error in Inserting - ".mysql_error($this->mycon));             return false;         }         else         {             //Reset Password code.         }        }      in this function i wanted to know what is the meaning of return false.


Restructuring a large Chrome Extension/WebApp

I have a very complex Chrome Extension that has gotten too large to maintain in its current format. I'd like to restructure it, but I'm 15 and this is the first webapp or extension of it's type I've built so I have no idea how to do it. **TL;DR:** I have a large/complex webapp I'd like to restructure and I don't know how to do it. **Should I follow my current restructure plan (below)? Does that sound like a good starting point, or is there a different approach that I'm missing? Should I _not_ do any of the things I listed?** While it isn't relevant to the question, the actual code is on Github and the extension is on the webstore. The basic structure is as follows: **index.html**               <html>         <head>             <link href="css/style.css" rel="stylesheet" /> <!-- This holds the main app styles -->             <link href="css/widgets.css" rel="stylesheet" /> <!-- And this one holds widget styles -->         </head>              <body class="unloaded">             <!-- Low-level base elements are "hardcoded" here, the unloaded class is used for transitions and is removed on load. i.e: -->                  <div class="tab-container" tabindex="-1">                            <!-- Tab nav -->             </div>                  <!--                 Templates for all parts of the application and widgets are stored as elements here.                 I plan on changing these to <script> elements during the restructure since <template>'s need valid HTML.             -->             <template id="template.toolbar">                 <!-- Template content -->             </template>                  <!-- Templates end -->                  <!-- Plugins -->             <script type="text/javascript" src="js/plugins.js"></script>                  <!-- This contains the code for all widgets, I plan on moving this online and downloading as necessary soon. -->             <script type="text/javascript" src="js/widgets.js"></script>                  <!-- This contains the main application JS. -->             <script type="text/javascript" src="js/script.js"></script>         </body>     </html>      **widgets.js**               (initLog || (window.initLog = [])).push([new Date().getTime(), "A log is kept during page load so performance can be analyzed and errors pinpointed"]);          // Widgets are stored in an object and extended (with jQuery, but I'll probably switch to underscore if using Backbone) as necessary     var Widgets = {         1: { // Widget ID, this is set here so widgets can be retreived by ID             id: 1, // Widget ID again, this is used after the widget object is duplicated and detached             size: 3, // Default size, medium in this case             order: 1, // Order shown in "store"             name: "Weather", // Widget name             interval: 300000, // Refresh interval             nicename: "weather", // HTML and JS safe widget name             sizes: ["tiny", "small", "medium"], // Available widget sizes             desc: "Short widget description",             settings: [                 { // Widget setting specifications stored as an array of objects.  These are used to dynamically generate widget setting popups.                     type: "list",                     nicename: "location",                     label: "Location(s)",                     placeholder: "Enter a location and press Enter"                 }             ],             config: { // Widget settings as stored in the tabs object (see script.js for storage information)                 size: "medium",                 location: ["San Francisco, CA"]             },             data: {}, // Cached widget data stored locally, this lets it work offline             customFunc: function(cb) {}, // Widgets can optionally define custom functions in any part of their object             refresh: function() {}, // This fetches data from the web and caches it locally in data, then calls render. It gets called after the page is loaded for faster loads             render: function() {} // This renders the widget only using information from data, it's called on page load.         }     };      **script.js**               (initLog || (window.initLog = [])).push([new Date().getTime(), "These are also at the end of every file"]);          // Plugins, extends and globals go here. i.e. Number.prototype.pad = ....          var iChrome = function(refresh) { // The main iChrome init, called with refresh when refreshing to not re-run libs         iChrome.Status.log("Starting page generation"); // From now on iChrome.Status.log is defined, it's used in place of the initLog              iChrome.CSS(); // Dynamically generate CSS based on settings              iChrome.Tabs(); // This takes the tabs stored in the storage (see fetching below) and renders all columns and widgets as necessary              iChrome.Status.log("Tabs rendered"); // These will be omitted further along in this excerpt, but they're used everywhere              // Checks for justInstalled => show getting started are run here              /* The main init runs the bare minimum required to display the page, this sets all non-visible or instantly need things (such as widget dragging) on a timeout */         iChrome.deferredTimeout = setTimeout(function() {             iChrome.deferred(refresh); // Pass refresh along, see above         }, 200);     };          iChrome.deferred = function(refresh) {}; // This calls modules one after the next in the appropriate order to finish rendering the page          iChrome.Search = function() {}; // Modules have a base init function and are camel-cased and capitalized          iChrome.Search.submit = function(val) {}; // Methods within modules are camel-cased and not capitalized               /*       Extension storage is async and fetched at the beginning of plugins.js, it's then stored in a variable that iChrome.Storage processes.            The fetcher checks to see if processStorage is defined, if it is it gets called, otherwise settings are left in iChromeConfig     */     var processStorage = function() {         iChrome.Storage(function() {             iChrome.Templates(); // Templates are read from their elements and held in a cache                  iChrome(); // Init is called         });     };          if (typeof iChromeConfig == "object") {         processStorage();     }      ### Objectives of the restructure   1. **Memory usage:** Chrome apparently has a memory leak in extensions, they're trying to fix it but memory still keeps on getting increased every time the page is loaded. The app also uses a lot on its own.   2. **Code readability:** At this point I can't follow what's being called in the code. While rewriting the code I plan on properly commenting everything.   3. **Module interdependence:** Right now modules call each other a lot, AFAIK that's not good at all since any change you make to one module could affect countless others.   4. **Fault tolerance:** There's very little fault tolerance or error handling right now. If a widget is causing the rest of the page to stop rendering the user should at least be able to remove it. Speed is currently not an issue and I'd like to keep it that way. ### How I think I should do it   * The restructure should be done using Backbone.js and events that call modules (i.e. on storage.loaded => init).   * Modules should each go in their own file, I'm thinking there should be a set of core files that all modules can rely on and call directly and everything else should be event based.   * Widget structure should be kept largely the same, but maybe they should also be split into their own files.   * AFAIK you can't load all templates in a folder, therefore they need to stay inline.   * Grunt should be used to merge all modules, plugins and widgets into one file. Templates should also all be precompiled. ### Question: **Should I follow my current restructure plan? Does that sound like a good starting point, or is there a different approach that I'm missing? Should I _not_ do any of the things I listed?** Do applications written with Backbone tend to be more intensive (memory and speed) than ones written in Vanilla JS? Also, can I expect to improve this with a proper restructure or is my current code about as good as can be expected?


Architecture for dashboard showing aggregated stats

I'd like to know what are common architectural pattern for the following problem. Web application A has information on sales, users, responsiveness score, etc. Some of this information are computationally intensive and or have a complex business logic (e.g. responsiveness score). I'm building a separate application (B) for internal admin tasks that modifies data in web application A and report on data from web application A. For writing I'm planning to use a restful api. E.g. create a new entity, update entity, etc. In application B I'd like to show some graphs and other aggregate data for the previous 12 months. I'm planning to store the aggregate data for each month in redis. Some data should update more often, e.g every 10 minutes. I can think of 3 ways of doing this.   1. A scheduled task in app B that connects to an api of app A that provides some aggregated data. Then app B stores it in Redis and use that to visualise pages. Cons: it makes complex calculation within a web request, requires lot's of work e.g. api server and client, storing, etc., pros: business logic still lives in app A.   2. A scheduled task in app A that aggregates data in an non-web process and stores it directly in Redis to be accessed by app B.   3. A scheduled task in app A that aggregates data in a non-web process and uses an api in app B to save it. I'd like to know if there is a well known architectural solution to this type of problems and if not what are other pros/cons for the solution I've suggested?


Should cucumber step definitions in Java be static methods or instance methods?

We are new to using cucumber with selenium to write automated test suites. Our initial approach was to have one java class per feature file. Now we added instance methods in each class for corresponding step definitions. Now if we need to re-use a step definition in some other feature file we are facing problems as we can't re-use same annotation with same regex pattern with any other method of other class and neither can we use the existing step definition which is in some other class. These methods are sharing instance variables like the reference to the driver. Now to re-use an instance method as a step definition is also a problem because these methods are not re-usable outside the class and I can't put all step definitions inside one class. I looked at some samples of ruby, I found that they write some sort of blocks that don't have access to shared state. They just execute steps. So in Java should I always make static methods that will just execute steps one by one and share no state ?


Is committing/checking in code everyday a good practice?

I've been reading Martin Fowler's note on Continuous Integration and he lists as a must "Everyone Commits To the Mainline Every Day". I do not like to commit code unless the section I'm working on is complete and that in practice I commit my code every three days: one day to investigate/reproduce the task and make some preliminary changes, a second day to complete the changes, and a third day to write the tests and clean it up^ for submission. I would not feel comfortable submitting the code sooner. Now, I pull changes from the repository and integrate them locally usually twice a day, but I do not commit that often unless I can carve out a smaller piece of work. **Question:** is committing everyday such a good practice that I should change my workflow to accomodate it, or it is not that advisable? _**Edit:_** I guess I should have clarified that I meant "commit" in the CVS meaning of it (aka "push") since that is likely what Fowler would have meant in 2006 when he wrote this. ^ The order is more arbitrary and depends on the task, my point was to illustrate the time span and activities, not the exact sequence.


Are there deals (free or low cost) to license Visual Studio for open-source developers?

I have several open-source projects, but I no longer have a license for Visual Studio. I heard that Resharper has some kind of deal for open-source project contributors. Is there something similar for Visual Studio? Thanks. * * * **EDIT**   ps: The main project I'm concerned about is DotNetZip. I use an open-source text editor now to modify the code and project files; and the project is hosted at CodePlex, which I can get to via the "free" Visual Studio TFS command-line tools. My main problem is that I can no longer design or run the tests I've put into the code. I know there is Nunit and other alternative testing frameworks, but the code is already instrumented for MSTest (I guess that's what it is) and I'd like to keep the testing stable if possible. **EDIT2** I know about DreamSpark but I am not a student. Just a developer of an open- source project. **EDIT3** I guess a better question might be, _what's the lowest-cost option for me, an individual open-source developer, to license Visual Studio so that I can run tests on my project?_


Old programmer disappeared. About to hire another programmer. How do I approach this?

After spending over one year working on a social network project for me using WordPress and BuddyPress, my programmer has disappeared, even though he got paid every single week, for the whole period. Yes, he's not dead as I used an email tracker to confirm and see he opens my emails, but he doesn't respond. It seems he got another job. I wonder why he just couldn't say so. And I even paid him an advance salary for work he hasn't done. The problem is that I never asked for full documentation for most of the functions he coded in. And there were MANY functions for this 1+ year period, and some of them have bugs that he still didn't fix. Now it seems all confusing. What's the first thing I should do now? How do I proceed? I guess the first thing to do will be to get another programmer, but I want to start on the right foot by having all the current code documented so that any programmer can work on all the functions without issues. Is that the first thing I should do? If yes, how do I go about it? What's the standard type of documentation required for something like this? Can I get a programmer that will just do the documentation for all the codes and fix the bugs or is documentation not really important? Also, do you think getting another "individual" programmer is better or get a company that has programmers working for them, so that if the programmer assigned to my project disappears, another can replace him, without my involvement? I feel this is the approach I should have taken in the beginning.


How to analyze a scenario where a bug didn't get caught and adjust development workflow to prevent similar errors

I had a bug that was really difficult to track down, because all the unit tests were green, but the production application didn't work properly. Here's what happened: I had a filter class that set my application to ignore data that was not in some specified time windows.   * The unit test, which seemed thorough to me, turned green.   * Additionally, my integration tests also produced results as expected.   * Production, however, did not work.      * As a result of the first two bullets, this problem was very difficult to find. It turned out the problem was that my test dates were using my time zone (America/Chicago) but the production data was providing dates in UTC, which I did not realize, and the logic for the filter wasn't correct for UTC dates. (I was using joda time `DateTime` objects).   1. **Where did my workflow break down?**     * Did I fail to produce a spec that specified that the logic needed to handle dates in any time zone?     * Did I fail to thoroughly consider all cases at the unit test level?     * Did I fail to insure the integration test was sufficiently similar to production?     * Other?   2. **What changes can I make to my workflow to better prevent this sort of mistake in the future?**   3. **How can I more effectively debug a problem when there is an issue in production but not in testing?**


Is it smart to store application keys, ids, etc directly inside an application?

I have heard some say it isn't but they never suggest an alternative. Is this true? **UPDATE** Is it possible to store this external from application and have it called?


Is it OK to partially change a collection with PUT or DELETE?

I have a collection of products in a product group e.g.:               product-groups/123/products        1. If I need to **add** to the collection, is it OK that I pass only **some** products with PUT?   2. If I need to delete **some** products from the collection, is it OK that I pass **filter data** (an array of ID's) with DELETE? What's the best way to implement the functionality in the spirit of ReST? Edit: the items are links to separate entities, basically ID's of products.


How do I cleanly design a central render/animation loop?

I'm learning some graphics programming, and am in the midst of my first such project of any substance. But, I am really struggling at the moment with how to architect it cleanly. Let me explain. To display complicated graphics in my current language of choice (JavaScript -- have you heard of it?), you have to draw graphical content onto a `<canvas>` element. And to do animation, you must clear the `<canvas>` after every frame (unless you want previous graphics to remain). Thus, most canvas-related JavaScript demos I've seen have a function like this:               function render() {        clearCanvas();        // draw stuff here        requestAnimationFrame(render);     }      `render`, as you may surmise, encapsulates the drawing of a single frame. What a single frame contains at a specific point in time, well... that is determined by the program state. So, in order for my program to do its thing, I just need to look at the state, and decide what to render. Right? Right. But that is more complicated than it seems. My program is called "Critter Clicker". In my program, you see several cute critters bouncing around the screen. Clicking on one of them agitates it, making it bounce around even more. There is also a start screen, which says "Click to start!" prior to the critters being displayed. Here are a few of the objects I'm working with in my program:               StartScreenView  // represents the start screen     CritterTubView   // represents the area in which the critters live     CritterList      // a collection of all the critters     Critter          // a single critter model     CritterView      // view of a single critter      Nothing too egregious with this, I think. Yet, when I set out to flesh out my `render` function, I get stuck, because everything I write seems utterly ugly and reminiscent of a certain popular Italian dish. Here are a couple of approaches I've attempted, with my internal thought process included, and unrelated bits excluded for clarity. ### Approach 1: "It's conditions all the way down"               // "I'll just write the program as I think it, one frame at a time."          if (assetsLoaded) {       if (userClickedToStart) {         if (critterTubDisplayed) {           if (crittersDisplayed) {             forEach(crittersList, function(c) {               if (c.wasClickedRecently) {                  c.getAgitated();               }             });           } else {             displayCritters();           }         } else {           displayCritterTub();         }       } else {         displayStartScreen();       }     }      That's a very much simplified example. Yet even with only a fraction of all the rendering conditions visible, `render` is already starting to get out of hand. So, I dispense with that and try another idea: ### Approach 2: Under the Rug               // "Each view object shall be responsible for its own rendering.     // "I'll pass each object the program state, and each can render itself."          startScreen.render(state);     critterTub.render(state);     critterList.render(state);      In this setup, I've essentially just pushed those crazy nested conditions to a deeper level in the code, hiding them from view. In other words, `startScreen.render` would check `state` to see if it needed actually to be drawn or not, and take the correct action. But this seems more like it only solves a code-aesthetic problem. The third and final approach I'm considering that I'll share is the idea that I could invent my own "wheel" to take care of this. I'm envisioning a function that takes a data structure that defines what should happen at any given point in the `render` call -- revealing the conditions and dependencies as a kind of tree. ### Approach 3: Mad Scientist               renderTree({       phases: ['startScreen', 'critterTub', 'endCredits'],       dependencies: {         startScreen: ['assetsLoaded'],         critterTub: ['startScreenClicked'],         critterList ['critterTubDisplayed']         // etc.       },       exclusions: {         startScreen: ['startScreenClicked'],         // etc.       }     });      That seems kind of cool. I'm not exactly sure how it would actually work, but I can see it being a rather nifty way to express things, especially if I flex some of JavaScript's events. In any case, I'm a little bit stumped because I don't see an obvious way to do this. If you couldn't tell, I'm coming to this from the web development world, and finding that doing animation is a bit more exotic than arranging an MVC application for handling simple requests -> responses. * * * What is the clean, established solution to this common-I-would-think problem?


What changes can I make to my IDE to minimize the effect of my dyslexia?

I program and I am dyslexic. My vision is excellent. I do poorly processing symbols and am a visual thinker. When I code, I'm slower than normal people because I am unpredictably unaware of the errors I make. I am learning python and the text only development environments cause me a lot of visual stress; I am using Wingware which is somewhat helpful, but cant complete assignments in the time given. Can you suggest an accommodation that would help me? What adaptations would be helpful to me? Is there any way I can automatically find, highlight and fix these kinds of errors? Proofreading, I see what I expect to see or something familiar. I don't notice typos, skip lines etc and the bugs turn up in testing. Even copy & pasting I can miss lines and cause errors. Blocks of text from margin to margin give me headaches as do some color combinations I do not process text as symbols, rather as objects that can be rotated, transposed so that the digits in a number move to different places, I may perceive "123" AS "132", THE LETTERS "pddq", look the same to me. I think of these as tricky - the same shape rotated and reflected.


Is the term "web portal" obsolete?

My boss uses the term "portal" for the project I work on all the time. To me, the word makes me think of Yahoo in the late 90s. Does the word "portal" have old-school connotations, or is it just me? Do you think it's ok to use it or will it drag our client's perception of the product down into the middle-ages?


Interpolation search vs Binary Search

When should I used interpolation search instead of binary search? For example, I have a sorted dataset, in what situations would I use binary search to find an item in this dataset or in which situation should I used interpolation search? What properties of the dataset would be the determining factor?


Differences between programming in school vs programming in industry?

A lot of students when they graduate and get their first job, feel like they don't really know how to program even though they may have been good programmers in college. What are some of the differences between programming in an academic setting and programming in the 'real world'?


HTTP events? Is there a standard / precedent for this?

Our architecture is HTTP servers (custom written) which whereby custom clients send a HTTP request for some information and information is returned just as HTTP works. But we need a special custom 'extension' which is a request which is a subscription for receiving asynchronous 'events' on a resource. For example the client sends an http request subscribing for events on some entity. As the 'entity' generates events they are passed to the http server and the http server must then lookup subscriptions for that entity and send the event message to all subscribed clients. Hope that makes sense. So my questions are:   * Has this been done before / or is there a standard I should be looking at?   * If no standard, any suggestions on how to implement?   * How does a http server send an unsolicited 'message' to a client?


To implement registration page with Vaadin or not?

This is a tactical implementation question about usage of Vaadin or in some part of my application. Vaadin is a great framework to login users and implement sophisticated web applications with many pages. However, I think it is not very well suited to desgin pages to register new users for my application. Am I right? Am I am wrong? It seems to me that a simple HTML/CSS/Javascript login + email registration + confirmation email with confirmation link cannot be implemented easily with Vaadin. It seems like Vaadin would be overkill. Do you agree? Or am I missing something? I am looking for feedback from experienced Vaadin users.


How to parse different number types with LALR(1)

Consider a LALR(1) parser for a file format that allows integer numbers and floating point numbers. As usual, something like `42` shall be a valid integer and a valid float (with some automagic conversion in the background). There might be parsing rules where a floating point number or an integer number is expected, and other rules where _only_ an integer number is expected, e.g.:               foo1         : bar FLOAT buzz         | bar INT buzz         ;          foo2         :  some INT other stuff         ;      Now consider something like               foo3         : bar FLOAT xyz FLOAT abc FLOAT buzz         ;      but at each position in this rule, instead of `FLOAT`, also `INT` shall be allowed.   * Turning this rule into 8 rules (one rule for each combination of `FLOAT` and `INT`) isn’t an option. (Consider a rule having 4 or 5 numbers...)   * Using a rule like              float_or_int : FLOAT | INT;      won’t help, because in general, this rule will reduce all `INT` to `float_or_int`, and rules like `foo2` no longer can be parsed. (Because with a grammar large enough, the one token lookahead cannot avoid the shift-reduce- conflicts resulting from this rule.)   * When the lexer sees a number without a decimal point, it cannot decide whether the parser currently expects an int or a float-or-int. How can this be handled in an elegant way?


How can we integrate use of a foreign language into an internship?

We have a few interns here that have orders from college to integrate speaking, reading, and writing French into their internship.   All of them are working on developing their own web application, and I'm wondering how we can integrate French into their projects.   Here are some things I've come up with:   * Translate the whole project front-end to French   * Write French documentation for the project   * Promote the application in a French community   * Speak French (exclusively?) to our project managers Any other ideas or suggestions? Does anyone else have experience with this?


How do I make a license an open source license?

I have been granted permission to reduce the rules from our custom license used in Advanced Electron Forum project. I am not sure what exactly is needed to make the license above an open source license for the product but I think that third term is the one that should be removed/changed. Best regards.


What graphics engine is used in Photoshop

I am wondering what is the default graphics engine used in Photoshop? It's great tool. And I don't know how they make it? I mean, if I want to create a simple tool like it, I will use MFC/GDI+. So, what is core to make Photoshop being great tools?


When should I use or not BooleanUtils.isTrue(...) and BooleanUtils.isFalse(...)?

About this function: `org.apache.commons.lang3.BooleanUtils.isFalse(Boolean bool)` and the similar `isTrue`, my co-work (less experienced) use it for **every** boolean in the code. I am trying to convince him that it is not a good practice because make the code confusing. In my POV, it should be used ONLY if the boolean to be tested is a type of non-primitive `Boolean` and it can be `null`. Actually, even this I think it is unnecessary, because the implementation of this function is simply `Boolean.TRUE.equals(bool)` or `Boolean.FALSE.equals(bool)`. Anyway, I think it is totally crazy do something like:               boolean isReady = true;          if (BooleanUtils.isTrue(isReady)) {        // ...     }      when you cold simply do               if (isReady) {        // ...     }      or `(!isReady)` for the opposite. His only argument to use this is "it is easy to read". I just can't accept this argument. Am I wrong? What arguments can I use to convince him that no useless code is better than useless code in this case? Thank you guys.


NoSQL Modify operations performance

I am working on the application which in near future (hopefully) will have to process tens or hundreds of thousands of items (item is currently one row in relational database table) per second. If I understood it right NoSQL databases are superheroes of data retrieval thanks to map-reduce magic. But will NoSQL databases provide extra performance in comperatison to relational ones in my case?


What to do if the task is too difficult ? Internship/SummerTraining

I conducting my summer training or internship for 2 months in an IT company as a a Sysadmin and Web developer. This is my first week. My mentor assigned me to work on an existing Flash/AS3 project(alone) to improve it and add new features. ( I think this wasn't part of my training plan) The problem is that I have never worked on AS3, so I took my time this week to learn as much as I can, about it. Today, I saw the source code of the project and it was outsourceed with 3500 lines of code plus no comments or any documentation included. I am panicking . The company has no one with AS3/Flash experience nor my mentor. I'm not sure if I can accomplish the task with their requirements. As it definitely needs an experienced developer in this field , plus I have only 2 months - so it's short. Hence , I'm asking here and looking for advice and suggestions on what to do next. Should I ask him and explain ? or should I risk and (try) working on it? what if I fail? Thanks advance! EDIT: I'm not sure if I have to accomplish the task in 2 months. I'm sure less so that I work on other projects. I haven't really asked. Since I'm not living in the US , I'm not sure if an Intern is the proper word to use. Every university student is required to conduct his/her summer training for 2 months in a company. At the end , either he/she passes the course or fail.


Are captchas worth the decreased usability?

When is it useful to use a captcha? When is it an unnecessary hindrance? Is a captcha just a quick fix for the lazy/unexperienced programmer, or are they really the best way to prevent spam and bots?


Is there a clean alternative to WTF that communicates to coders?

> **Possible Duplicate:**   >  Another term for common code smell Programmers know immediately what I mean if I talk of finding a 'WTF' in the code base. In particular, it is a noun that refers to an extremely wrongheaded approach/implementation, and not typically an exclamation (though it can be used also as an exclamation). I don't want to use expressions that thinly veil obscenity, but I can't think of any substitute that communicates this idea quickly and succinctly. Any ideas?


How to calculate the cost of a course I will give?

I am going to give a javascript course to some developers in a local company, I know all the subjects I will teach and estimate duration, also note that the course will be for experience developers so it will contain a lot of advanced subjects. I don't know how to calculate my cost, anyone there have experience and can advice me?


Separate Action from Assertion in Unit Tests

## Setup Many years ago I took to a style of unit testing that I have come to like a lot. In short, it uses a base class to separate out the Arrangement, Action and Assertion of the test into separate method calls. You do this by defining method calls in [Setup]/[TestInitialize] that will be called before each test run.               [Setup]     public void Setup()     {        before_each(); //arrangement        because(); //action     }      This base class usually includes the [TearDown] call as well for when you are using this setup for Integration tests.               [TearDown]     public void Cleanup()     {        after_each();     }      This often breaks out into a structure where the test classes inherit from a series of Given classes that put together the setup (i.e. GivenFoo : GivenBar : WhenDoingBazz) with the Assertions being one line tests with a descriptive name of what they are covering               [Test]     public void ThenBuzzSouldBeTrue()     {        Assert.IsTrue(result.Buzz);     }      ## The Problem There are very few tests that wrap around a single action so you end up with lots of classes so recently I have taken to defining the action in a series of methods within the test class itself:               [Test]     public void ThenBuzzSouldBeTrue()     {        because_an_action_was_taken();        Assert.IsTrue(result.Buzz);     }          private void because_an_action_was_taken()     {        //perform action here     }      This results in several "action" methods within the test class but allows grouping of similar tests (i.e. class == WhenTestingDifferentWaysToSetBuzz) ## The Question Does someone else have a better way of separating out the three 'A's of testing? Readability of tests is important to me so I would prefer that, when a test fails, that the very naming structure of the tests communicate what has failed. If someone can read the Inheritance structure of the tests and have a good idea why the test might be failing then I feel it adds a lot of value to the tests (i.e. GivenClient : GivenUser : WhenModifyingUserPermissions : ThenReadAccessShouldBeTrue). I am aware of Acceptance Testing but this is more on a Unit (or series of units) level with boundary layers mocked. _EDIT_ : My question is asking if there is an event or other method for executing a block of code before individual tests (something that could be applied to specific sets of tests without it being applied to all tests within a class like [Setup] currently does. Barring the existence of this event, which I am fairly certain doesn't exist, is there another method for accomplishing the same thing? Using [Setup] for every case presents a problem either way you go. Something like [Action("Category")] (a setup method that applied to specific tests within the class) would be nice but I can't find any way of doing this.


Implementing set of processes in a stored procedure or through the code?

I want to know what's the suitable method to implement the following case (best practice). If i make a set of processes like this:   1. select data from set of DB tables.   2. loop on the selected result.   3. Make some checks on each iteration.   4. Insert the result in another table. * * * Implementing the previous steps in a stored procedure or in a transaction through my code (asp.net)? Concerning the performance, security and reliability issues.


What is the best way to handle similar functionlaity in separate user stories / Product back Log Items?

I am using the TFS 2010 SCRUM template. So, let's say I have these user stories: As a user I want the ability to add contacts directly from the Partner page. As a user I want the ability to add contacts directly from the Project page. Design wise the contact forms should be the same and so should the functionality. So, if a user clicks the add contact button from either page, a pop up window will appear allowing the user to add a new contact. Should both those stories share similar tasks since the development and design are similar? Should I break up the features into separate stories? Update: So, is it more acceptable to write this: As a user I want to add contacts from any area in the site so that I don't have to keep going back to a speicifc contact entry page. Then I could supply the features we need for that story?


How would you manage development between many Staging branches?

We have a Staging Branch. Then we came out with a Beta branch for users to move whenever they wanted to from old Production branch to the new features. Our plan seemed simple, we test on Staging, when items get QA'd, they get cherry-picked and deploy to Beta. Here's the problem! A bug will discreetly make its way on to Beta, and since Beta is a production environment, it needs fixes _fast_ and _accurate_. But not all the QA's got done. Enter Git hell.. So I find a problem on Beta. No sweat, it's already been fixed on Staging, but when I go to cherry-pick the item over, Beta barely has any of the other pre- requisites of code to implement this small change. Now Beta has a little here and a little there, and I can't imagine it as a code base being as stable as Staging. What's more, is I'm dealing with some insane Git conflicts, and having to monkey patch a bunch of things to make up for what Beta hasn't caught up with Staging. Can someone polite or non-polite terms, tell me what we're doing wrong here as far as assembling this project? Any awesome recommendations or workarounds or alternatives to the system we came up with?


What guidelines should be met for something to be called a webapp

In my mind a webapp is any website that has some complicated features and that's served from the web, but I know there are people who are a lot smarter than me here and they'll point out other features that I'm not noticing. For example:   * If it doesn't have a login system, can I still call it a webapp? (because most webapps end up being user-based).    * Should I think of a CMS as a webapp? and how about the sites that are built with it? probably they're not webapps, right?    * Is Gmail a webapp? I think so.   * Is twitter a webapp? Yes, though the functionality is rather simple. So what conditions need to be met to call a website a webapp? P.S. StackExchange's tag system defines web-applications as > applications that are accessed over the "web", which can mean the Internet, > or an internal network (an intranet).


Should each method have a seperate JUnit test class?

I am writing JUnit unit tests for my classes. Is it better to have a separate class for each method, or have just one test class for every actual class?


Need help understanding a recursion example in Python

Python is my first programming language, and I'm learning it from "How to Think Like a Computer Scientist". In Chapter 5 the author gives the following example on recursion:               def factorial(n):        if n == 0:          return 1        else:          recurse = factorial(n-1)          result = n * recurse          return result       I understand that if n = 3, then the function will execute the second branch. But what I don't understand is what happens when the function enters the second branch. Can someone explain it to me?


Data Scraping - One application or multiple?

I have 30+ sources of data I scrape daily in various formats (xml, html, csv). Over the last three years Ive built 20 or so c# console applications that go out, download the data and re-format it into a database. But Im curious what other people are doing for this type of task. Are people building one tool that has a lot of variables and inputs or are people designing 20+ programs to scrape and parse this data. Everything is hard-coded into each console and run through Windows Task Manager. Added a couple additional thoughts/details:   * Of the 30 sources, they all have unique properties, all are uploaded into individual MySQL tables and all have varying frequencies. For example, one data source is hit once a minute, another on 5 minute intervals. Majority are once an hour and once a day.  At current I download the formats (xml, csv, html), parse them into a formatted csv and put them into staging folders. Within that folder, I run an application that reads a config file specific to the folder. When a new csv is added to the folder, the application then uploads the data into the specific MySQL tables designated in the config file. Im wondering if it is worth re-building all this into a larger complex program that is more capable of dynamically adding content+scrapes and adjusting to format changes. Looking for outside thoughts.


What algorithm(s) can be used to achieve reasonably good next word prediction?

What is a good way of implementing "next-word prediction"? For example, the user types "I am" and the system suggests "a" and "not" (or possibly others) as the next word. I am aware of a method that uses Markov Chains and some training text(obviously) to more or less achieve this. But I read somewhere that this method is very restrictive and applies to very simple cases. I understand basics of neural networks and genetic algorithms(though have never used them in a serious project) and maybe they could be of some help. I wonder if there are any algorithms that, given appropriate training text(e.g., newspaper articles, and the user's own typing) can come up with reasonably appropriate suggestions for the next word. If not (links to)algorithms, general high-level methods to attack this problem are welcome.


How do other people keep code current accross multiple machines? (something other than DropBox)

I am a hardware/infrastructure guy going back to school to get my degree (FINALLY...) and am taking some low level intro programming classes. On top of the JAVA I am working on at school, I am also tinkering around in some other languages. I work in a shop with some very talented developers and am attempting to learn as much as I can from them. Basically, learning a bunch on my own to write code that will make my infrastructure job easier, so I have more time to learn. With that said, I spend 90% of my time using eclipse, and 8% in BlueJay (blah, I know) and 2% in VS Express. Because I have 5 different machines between work and home, I am having a big issues keeping my code for various projects up to date when working on different machines. I tried using Dropbox, and setting the local folder on all my machines to my workspace in Eclipse, and that worked great for a week. Then I found out that the company was getting on users for Internet Usage, because their Dropbox was keeping a live connection to the web 100% of the time that it was running. I have tried the old school thumb drive approach, and I keep forgetting to save most recent to the thumb drive. So, basically, what I am looking for is advice on how users keep their code up to date? Are there any similar utilities like DropBox, and only attempt to sync when stuff is changed? Are their any other suggestions for an online repository that I can do this with, without logging 50+ hours a week of time on our Firewall report?


Which online/hosted bug tracking tool do you use for your own work and projects?

I've accumulated a lot of side projects over the years, which I slowly improve on over time. Whenever I return to one, I take some time reading over text files that include design, recent bugs, next features, etc... that I should be working on - it's not pretty. I'm looking to switch to something more formal. Ideally, this would be a full featured, online, bug tracking system, which allows for free or nearly free bug tracking for my own projects. Also, ideally this would be doable in a private manner - I don't really want everyone to see my side projects and what a mess I've made of some of them.


Distribution Licensing for Windows XP Junction tool

My application needs to create a directory symbolic link in Windows XP to get around the file path length limitation of ~256 characters. Windows XP does not have this functionality built-in. I had chosen Junction from Sysinternals as a candidate to solve this issue. However, now legal is telling me that I cannot distribute Junction to my users; they would have to download it themselves. My problem is that my users are not connected to the internet and probably have too many bureaucratic hurdles to go through to get approval to download and transfer this software.   1. Has anyone found an exception and legally distributed Sysinternals software like Junction?   2. What free/open/libre alternative do I have for creating directory symbolic links in Windows XP?


How should ability be distributed through teams?

After reading this, I saw that there seems to be a lot of disagreement over how agile teams should be structured within a group of developers with varying ability (aka almost all teams). Should all the best developers be put on their own teams and be given the highest priority work? This will pretty much ensure that the most important tasks will get done. At the same time, you are then left with the "less than perfect" teams elsewhere racking up technical debt, even if it is only on low priority tasks. On the other hand, evenly distributed teams could have the benefit of making your lagging developers a bit better, but has the potential to demotivate your heaviest hitters. Also, if you mix in a bunch of good design patterns with a bunch of terrible anti- patterns, you can really end up with something that might as well be a bunch of anti-patterns. All teams have their strong coders and their not so strong coders, so how should this be dealt with?


How to deal with colleagues refuse to follow practices?

I was discussing with another colleague about what we should be used when an DB entity is referring to another. I don't think there is any good reason to break the practice of putting the Primary Key in the referring entity. However, one of my colleague says: "You should use a surrogate key in the entity, but it is better to put the human-readable natural key in the referring entity. As long it is unique, it is fine and it is easier when you are doing support or maintenance job" I know it will works, but obviously it is not a good practice you are putting a non-PK unique column as "foreign key", just for gaining a bit of ease in writing SQL during support as we can have less table join. Though I mentioned the his approach is conceptual incorrect, and causing problem too practically etc, he seems rather trade off correctness in data model in exchange of ease of ad-hoc support jobs. And he said: "I know it is not good practice, but good practice is not golden rule" Honestly I feel frustrated when dealing with something like this. I know there are always case that we should break some rule or practice, but doubtless it is not such case now. What will you when you are facing situation like this? Please assume yourself being a senior developer which is expected to contribute in misc development direction and convention.


What is So Unique About Node.js?

Recently there has been a lot of praise for Node.js. I am not a developer that has had much exposure to network application. From my bare understanding of Nodes.js, its strength is: we have only one thread handling multiple connections, providing an event-based architecture. However, for example in Java, I can create only one thread using NIO/AIO (which is non-blocking APIs from my bare understanding), and handle multiple connections using that thread, and I provide an event-based architecture to implement the data handling logic (shouldn't be that difficult by providing some callback etc.)? Given JVM being a even more mature VM than V8 (I expect it to run faster too), and event-based handling architecture seems to be something not difficult to create, I am not sure why Node.js is attracting so much attention. Did I miss some important points?


Integration of advertisement into WP7 apps: Any experiences?

Has anyone of you guys integrated or is thinking about integrating either admob, MS pubCenter, adwhirl or any other advertising provider into your apps? Please share your experience...   1. Who pays best?   2. Any regulations?    3. Any problems with getting the app approved by Microsoft Market?   4. If you chose Admob: Which plugin do you suggest? This or that or another one?   5. Any experiences in Europe or Germany? (MS pubCenter is US only so far) **Edit:** I think we discussed enough about acceptance of mobile advertisement. **Let's focus now on the questions I asked.** **Edit 2:** Hmm, maybe Stackoverlfow is a better place to discuss question 2-5. Could somebody migrate this one?


Is there any benefit of using one language over the other for competitive programming websites like SPOJ or TopCoder?

I know a bit of C++, Java and Ruby. I want to be proficient in one of these now and I don't know how to pick. I was wondering if picking one over the other would be advantageous in any way for competitive programming?


iOS object instance accessible from three separate classes, or load 3 nib files with one class?

I've got three nib files in my project, each of which is driven by its own class (.h and .m files). Each nib has a stylized design with a full screen background image and a few overlay images acting as buttons. Each button has its own button-click sound, and most of the buttons on each nib file will play a different video per button. To play the videos, each of my three .m files have a couple of methods similar to this:               -(IBAction) videoButtonClicked: (id)sender{         if([sender tag] == 1) {             AudioServicesPlaySystemSound (buttonClick1);             [self loadMoviePlayer:[[NSBundle mainBundle] pathForResource:@"Video 1" ofType:@"mov"]];         } else if ([sender tag]  == 2) {             AudioServicesPlaySystemSound (buttonClick2);             [self loadMoviePlayer:[[NSBundle mainBundle] pathForResource:@"Video 2" ofType:@"mov"]];         } else if ([sender tag]  == 3) {             AudioServicesPlaySystemSound (buttonClick3);             [self loadMoviePlayer:[[NSBundle mainBundle] pathForResource:@"Video 3" ofType:@"mov"]];         } else if ([sender tag]  == 4) {             AudioServicesPlaySystemSound (buttonClick4);             [self loadMoviePlayer:[[NSBundle mainBundle] pathForResource:@"Video 4" ofType:@"mov"]];             }     }          - (void)loadMoviePlayer:(NSString*) movieURL     {           // Play movie from the bundle         NSURL *url = [NSURL fileURLWithPath:movieURL];              player = [[MPMoviePlayerViewController alloc]                   initWithContentURL:url];              [[NSNotificationCenter defaultCenter]          addObserver:self          selector:@selector(movieFinishedCallback:)          name:MPMoviePlayerPlaybackDidFinishNotification          object:player];              [self presentMoviePlayerViewControllerAnimated:player];         [player release];     }      My code works now because the videos are embedded in my resources folder. However, together, the videos are too big to be bundled with the app and downloaded from the App Store. I'll therefore have the app download them from a server, so I want to create one video-management class to keep track of which videos have been downloaded. I think I should have one instance of the object, but then how can my three controllers talk to the one instance? I am pretty sure if I have one class that loads the correct .nib file, I can have that one instance talk to my one video-management instance. But would I be unnecessarily wasting memory by loading all three nibs at once?


How prototypal inheritance is practically different from classical inheritance?

Inheritance, Polymorphism, and Encapsulation are the three most distinct, important features of OOP, and from them, inheritance has a high usage statistics these days. I'm learning JavaScript, and here, they all say that it has prototypal inheritance, and people everywhere say that it's something **far different** from classical inheritance. However, I can't understand what's their difference from the point of practical usage? In other words, when you define a base class (prototype) and then derive some subclasses from it, you both have access to functionalites of your base class, and you can augment functions on the derived classes. If we consider what I said to be the intended result of inheritance, then why should we care if we're using prototypal or classic version? To clear myself more, I see no difference in the usefulness and usage patterns of prototypal and classic inheritance. This results in me having no interest to learn why they are different, as they both result in the same thing, OOAD. How practically (not theoretically) prototypal inheritance is different from classical inheritance?


What is a good pattern for multi language in MongoDb?

Say I want to build a website that support multiple language and use MongoDB datastore. I wonder what is a good approach to have multiple versions of the body and title of an article, one for each language. Should I keep all versions in the same article document? Like a collection of key-value pairs of language code and text in the body field of the article. This way I'd get no more than 1 request for viewing articles, but I'd also get more data than I might need so the response is larger. Is there a better solution? How and why?


Does Clojure have the continuation?

I started programming with Python. When using python, concepts like coroutine, closure made me really confusing. Now I think I know them some superficial level, but I want to get the "enlightement" so, I choose to learn Clojure, the dialect of Lisp. I bought the book of Stuart Halloway and it's good. But when I looked the index of that book, there's no words like coroutine, continuation. I googled it, but there's anything, too. So, my question is, Does Clojure have continuation or coroutine (which greenlet or stackless serve) to do the jobs like the Ping-pongs without stack overflow? Python style (though Python standard does not serve full-feature of this symmetric coroutine):               def ping():       while 1:        print "ping"        function to switching to pong          def pong():       while 1:        function to switching to ping        print "pong"      If not, as for learning the functional concepts, is it better to learn Scheme instead?


PHP and SQL, together or individually?

I am done with HTML and CSS. Now I want to know whether I should study PHP and SQL together or individually. Basically, I have this book, `O'Reily Head First PHP and MySQL`. Should I take this book or start with a book for PHP only? And is there any difference?


Algorithm to determine fastest route?

Let's say we're going from 1 to 5. The shortest route will be 1-4-3-5 (total: 60 km). ![Graph](http://i.stack.imgur.com/w0SnS.png) We can use Dijkstra's algorithm to do that. Now the problem is, the shortest route is not always the fastest one, because of traffic jams or other factors. For example:   * 1-2 is known to have frequent traffic jams, so it should be avoided.    * Suddenly a car accident happens along 4-3, so it should be avoided too.   * Etc... So probably we can speed on the route 1-4-5, because of no traffic jams/accidents, so will arrive at 5 faster. Well that's the general idea, and I haven't think about more details yet. Is there any algorithm to solve this problem?


Researching the growth of functional languages

In recent years it seems that functional programming languages have had a real popularity increase. Languages like Erlang, Haskell, Scala, F# and Clojure seem to be pretty well known and many popular programming sites (such as Stack Overflow) seem to be full of questions and discussions on them. The question is how would you go about researching the growth of these languages in real terms. Of course I know about the TIOBE index but is that really the best source to measure the popularity of a given programming language? Hopefully this question will be allowed since it is something that many programmers look towards to decide whether a given technology is likely to last for a long time or not (although this is not my personal goal).


Why is C++ still preferred to build heavy GUI apps over the latest dynamic languages?

I see that most of the apps that include heavy GUI content are usually developed in C++. Most of the games/browsers are coded in C++. Can't we just develop better GUI apps with the latest dynamic languages? I know java wouldn't be a great choice. But what about languages like python which are natively built on C? Aren't the latest languages supposed to be better than their ancestors? Why do we still have to prefer the age old C++ over the latest languages? And I would also like to know, what is it that is responsible in C++, for the better speed of processing GUI? On the other hand what is it that the other latest languages lack?


How do you pronounce technical English words around non-natives?

I'm working as a developer back in my home country, where English is not a first/second language. However, I consider myself a native speaker since most of my schooling has been in an American environment. Everyday I have to talk to my colleagues about technical stuff and English words obviously come up all the time. My colleagues pronounce English words very differently than how it's supposed to be (well most of the times) and I feel weird trying to correct them or speaking the 'right way' because it makes it seem like I'm a dick and often takes the focus away from the real subject. How do you guys deal with this kind of 'problem?'


Merging branches where the same code was worked on

If there are two unrelated tasks, except that the changes are in the same project, and end up touching at least one of the same classes/methods, how do I manage that? Two different developers could each pick up one task. Each dev will create a new branch off of Integration, work in it, then need to Merge. When Merging two branches, most of the time "Take Source Branch" is proper for Up-Merging, and "Take Target Branch" is proper for Back-Merging. But when Back-Merging, or dual-merging up, there could be conflicts which overwrite the code of the previously merged project if they both changed the same class/method. One answer is: "So only let one dev work on both tasks sequentially." Except that we're in SCRUM and any dev can pick up any task. We don't want to start assigning. Another answer is: "Have the devs get together and hash out how to manually merge some stuff." But that's work! Lol. Is there a method I'm missing?


GPLed Library (EXT JS) Licensing Issue

Good Day Everyone, I am realy out of option for interpreting the GPL for EXTJS for my work/idea/personal project. I can see that this is an active forum I realy hope, I have a closure on this. First let me explain my project, Iam creating this website which is like a webportal which is intented for End-User, now this webapps uses an EXTJS library which is GPL'ed as with my understanding on this GPL Any application uses GPL license libray should be released to as Open Source a a GPL compatible Linsence, this is when I or my application is a derivework or I have modified the Library and released it. or destribute it. But EXTJS has this dual license which is typically giving me the rights to do what I want. without giving out my code. If my application is intented for end user only, not a derive form of work, not a library, not a development tool, I will not distribute it because it is on the web. with this also the Libraries i will use will remain untouch as it is. and I will have list of library I use and thier respective license to credit them Given this can I not close-source my application and not violate the GPL? is it ok for me to use GPL library so long as the above is meet? The question in short is can i used GPL'ed Library, do not released my code as OPensource compatible License and still NOT violate the GPL'ed terms? Thanks in Advance Nick Ace


How does fair use apply to code snippets?

Is there a size where you can copy under fair use for code you don't have a license for the purpose? For example, what if I copy a snippet that is (normally) 3 lines of code? Is that fair use? If it is fair use, what length is required before I need a license?


What should a Python developer know while learning Ruby?

I have been a Python programmer for about 18 months, consisting of one internship and a few side projects, and I consider myself pretty comfortable in the language. However, there seems to be a lot of attention on Ruby in the programming field, but not a lot on Python anymore. So in learning Ruby, are there going to be Pythonic things that are just bad practices in Ruby? What should I watch out for, and what should I avoid?


Career advice: PhD in theory of programming languages

I'm very interested in the theories of programming languages and going to apply a PhD in this topic, but I want to know more about the career after the graduate education. besides being a professor, but also what occupation can I get?


Advancing Code Review and Unit Testing Practice

As a team lead managing a group of developers with no experience ( and see no need) in code review and unit testing, how can you advance code review and unit testing practice? How are you going to create a way so that code review and unit testing to naturally fit into the developer's flow? One of the resistance of these two areas is that "we are always tight on dateline, so no time for code review and unit testing". Another resistance for code review is that we currently don't know how to do it. Should we review the code upon every check-in, or review the code at a specified date?


Arguments for development environment being the same as production

Intuitively it seems appropriate that the development environment (and all test environments) be as close to the production build as possible. Are there any documented arguments in support of this intuition?


How the cross programming language compiler or translator works

These days there are more cross programming language compilers (specially from some 'X' language to JavaScript). I wonder how these are developed? What are the general steps to be taken care to write algorithms if I were to develop one? Do I need to be completely thorough in Lexical Analysis? As far as my knowledge is concerned they should follow the same steps of translating some 'X' language to Assembly language (basic compilation). Is that how they actually been developed? OR there is some different way? Thanks


What are the differences between AppMobi and PhoneGap?

I am new to the cross platform application development. I came across the very similar cross platform frameworks AppMobi and PhoneGap. I want to know   * Is there any differences between apk/ipa created using Appmobi and apk/ipa created using PhoneGap?   * Is there any difference in native features that can be used ?   * What are the advantages of appmobi over phonegap or PhoneGap over Appmobi? Also other differences between these two.


What to do when your colleagues don't value code maintainability

I've been working in the same software development department for a few years now. In that time, the average stay of a developer has been 6-9 months. A handful have been around for over 2 years, but the majority of our 20 or-so developers come and go at a relatively high rate. As a result, the majority of our projects have become maintenance nightmares. Contractors will come in, code a few patch releases, and leave. Our department has development guidelines (we do TDD) but they aren't enforced. Recently, I've been pushing for our department to produce more maintainable code. I've been asking for mandatory code reviews and mandatory TDD. Management fully agrees with me... in theory. In practice TDD always goes out the window. The justification is always that, in our domain, we need to deliver NOW. I keep going on and on to colleagues that we're just digging a hole for ourselves, and that our current approach to software development is costing our department a lot of money... but it seems to fall on deaf ears. What can I do to get my colleagues to see the value of code maintainability? How can I explain that short-term wins without a long-term vision is not sustainable?


How to effectively cooperate in a team having mixed background/mindset regarding OOP?

I've been recently assigned for a new high-performance C++ project (finance) together with 3 other guys who, like, me, refer to themselves as "primarily C/C++ programmers", meaning, all of us have also done Java & other stuff, we all have comparable experience (8 to 10 years) and have successfully collaborated for the making of other projects (not C/C++). I soon found out we have such different mindsets when it comes to our "mother programming tongue" that it risks not only the good delivery of the project but also the general well-being of the team/office. Specifically: They come from an electrical engineering/automation/polytechnic type of background, so their reasoning is intimately related to how hardware works, how bytes move around, processor workings, instruction caching, generally everything at the lower layers. They did embedded programming, ARM programming (I barely know what those are). I soon found out their practical experience is with mostly C, not C++. They think procedurally, not OOP. I, on the other hand, have trained myself to think in a more abstract way, to apply principles such as encapsulation, low coupling/high cohesion for creating reusable, modular software. My speciality is the C++ programming language, with an accent on language constructs that help you get both fast and reusable, generic code. I think design patterns, idioms, concepts. Throughout 9 years of developing software I consistently witnessed how poor maintainability of software systems is by far the #1 burden of teams. I generously document my code, write careful interfaces. I embrace template meta-programming as a way to obtain fast and reusable products. I embrace the new C++11 standard features. Where I see reusability and loose coupling, they see "complication". They want to "see it all there". They want to see `char*`, not some buffer class in interface methods. At one point one even said "I don't care how simple your interfaces are if your implementation looks complicated". The trouble is, we really are trying to transition from a monolithic style of systems to a reusable one - we are writing a library. Yet they don't wish to see their C-style structs being polluted with templated methods, typedefs and c-tors, even if neither makes their structs non-POD. They also don't wish to see static_assert(std::is_pod<...>). They love memcpy and pointers and generally stay away from references. They tend to think typedefs are somehow evil. I really tried to make them see an abstraction for what it is. It is code together with data it operates on. By necessity, a library needs to define some interfaces for the user to be able to plug it into a larger product. They tend to see these interfaces as ways in which my code _requires their code behave/look as I wish and doesn't allow them to do things their way_ , but without actually telling me a specific functionality they can't obtain. Make no mistake, I'm no ignorant when it comes to performance. I know about cache lines, branch prediction, the overhead of method virtualization, heap allocation, hash lookups. I'm good with complexity of algorithms (though that doesn't matter so much here), data structures, inlining and some other compiler optimizations such as RVO. I believe with a modern compiler a reusable, layered OOP C++ product can get within 10% of the performance of a C-only monolithic product, when carefully written and optimized. I honestly believed we would complement each other in our thinking. What are your thoughts? Please don't be too harsh, we need to make this work.


Which programming guidelines for a chess network application?

I'd like to implement a simple chess peer to peer network application : one instance of the program may register friends player, and when one friend is "connected" (I mean both available by another program instance and registered as friend), I can ask him to play a game. As I know J2SE language, as well as Swing framework, I tried to start coding, using Sockets. The problem is that I need a way to   * register my friends (or other accounts)   * get the friend ip, for creating a socket (it will be the same problem on the other side) : with the problem of dynamic ip adresses.I mean that a serialized adress may not be valid anymore   * be informed that the other side has "connected" I think that first and third point can be resolved if I use a PHP server which will have all informations for all registered users. This is how the application should work :   1. First, before trying to connect each other, the users must register an account on a PHP server that I'll have to implement (with MySQL database)   2. When launching the application, the user logins by giving its username and password. So that the application will be able to retrieve friends (and stats for example) thanks to the server   3. When two friends are ready to play together, the server give all needed informations (such as ip adress) to both player application instance. My main difficulties will be for the (de)serialization of dynamic IP Adresses, and for retrieving informations about a user on the PHP server. What do you suggest ?


When is a glue or management class doing too much?

I'm prone to building centralized classes that manage the other classes in my designs. It doesn't store everything itself, but most data requests would go to the "manager" first. While looking at an answer to this question I noticed the term "God Object". Wikipedia lists it as an antipattern, understandably. Where is the line between a legitimate glue class, or module, that passes data and messages from place to place, and a class that is doing too much?


Approaches to reduce cyclomatic complexity

I was running our code through JSHint, and decided to switch checks against cyclomatic complexity, and then went on long refactoring sprint. One place though baffled me, here is a code snippet:               var raf = null //raf stands for requestAnimationFrame          if (window.requestAnimationFrame) {       raf = window.requestAnimationFrame;     } else if (window.webkitRequestAnimationFrame) {       raf = window.webkitRequestAnimationFrame;     } else if (window.mozRequestAnimationFrame) {       raf = window.mozRequestAnimationFrame;     } else if (window.msRequestAnimationFrame) {       raf = window.msRequestAnimationFrame;     } else {       raf = polyfillRequestAnimationFrame;     }      Not surprisingly, in this implementation CM is 5, first attempt was to use solution from MDN:               var requestAnimationFrame = window.requestAnimationFrame || window.mozRequestAnimationFrame ||                               window.webkitRequestAnimationFrame || window.msRequestAnimationFrame;     window.requestAnimationFrame = requestAnimationFrame;      Which simply looks like a hack to me (yes I know, majority of full time javascript programmers won't agree with me, however this is a prevalent opinion within our team). Doodling around my code, I found another hacks I could employ to full code-linter, among ones I was proud for about 5 second was usage of array comprehensions:               var rafs = [                  window.requestAnimationFrame,                  window.webkitRequestAnimationFrame,                  window.mozRequestAnimationFrame,                  window.msRequestAnimationFrame,                  polyfillRequestAnimationFrame                ].filter(function (rafClosure) {                  return rafClosure !== null && rafClosure !== undefined;                });     return rafs[0];      However I'm curios whether there is more or less standard practice of refactoring long branching code (that's not trivial to reduce)?


Advice: The first-time interviewer's dilemna

I've been working in my first job for about 2 years now, and I've been "asked" to interview a potential teammate (whom I might have to mentor as well) on pretty short notice (2 days from now). Initially, I had been given a free rein(or so I thought, and hence agreed), but today, I've been told "not to pose _bookish_ questions" - implying I can only ask basic programming puzzles and stuff similar to the 'fizbuzz' question. I strongly believe that not knowing basic algorithmic notations(the haziest ideas of space/time complexities) or the tiniest idea of regular expressions would make working with the guy very difficult for anyone. I know i'm asking for a lot here, but according to you, what would be a comprehensive way to test out the _absolutely basic_ requirements of a CS guy(he has 2 yrs of exp) without sounding too pedantic/bookish etc ? It seems it would be legit to ask C questions/simple puzzles only....but I really do want to have something a bit different from "finding loops in linked lists" that has kind of become the opening statement of most techie interviews !! This is a face-to-face interview with about an hour or more of time - I looked at Steve's basic phone-screen questions, and I was wondering if there exists a guide on "basic face-to-face interview questions" that I can use(or compile from the community's answers here). EDIT: The position is mostly for a kernel level C programming job, with some smattering of C++ required for writing the test framework.


I've never interviewed anybody before... HELP?

There were 3 developers at this GIS tracking company, but now there's 2. Last week my boss was fired. Today, new developers will be coming in for interviews. They'll be coming in from a placement agency. I don't really know how to be on this side of a hiring interview. Any advice or sample questions I can ask? Company Background: The 2 of us wear many hats. We are the MySQL DB admins, we write C# web services including APIs, there's C# back end processes that generate reports and issue alerts, and we also have a few VB6 projects that I personally am hoping to replace. Our web app is just under 10K lines of javascript, almost 2K lines of HTML and just under 4K lines of CSS. We don't use a lot of frameworks or libraries aside from jQuery and Bing Maps. I've been here a year as just a developer and at no place have I ever worked with any sort of management responsibilities. What kinds of questions can I ask that can really show me that somebody knows how to develop in these languages? I'm really drawing a blank here.


What are the problems with a relatively large common library?

As long as the code in the base library is as loosely coupled as splitting it up into separate libraries, what's the problem? In general, having a lot of assemblies composing a .NET solution is painful. Plus, when code in one solution needs to be shared, it can just be added to the common library, rather than deciding which common library it should be added to or creating yet another library. edit: the question comes to me after using Smalltalk for a bit, where all the code is available to use, all the time.


Is there a good reason to use Java's Collection interface?

I've heard the argument that you should use the most generic interface available so that you're not tied to a particular implementation of that interface. Does this logic apply to interfaces like _java.util.Collection_? I would much rather see something like the following:               List<Foo> getFoos()      or               Set<Foo> getFoos()      instead of               Collection<Foo> getFoos()      In the last case, I don't know what kind of data set I'm dealing with, whereas in the first two instances I can make some assumptions about ordering and uniqueness. Does _java.util.Collection_ have a usefulness outside of being a logical parent for both sets and lists? If you came across code that employed _Collection_ when doing a code review, how would you determine whether its usage is justified, and what suggestions would you make for its replacement with a more specific interface?


How to evaluate Java skills

I was asked to make a table in which developers in team could use to evaluate their Java level (Maybe from 1 to 5). And then they will know what they are lacking so they could focus to learn on that technique. I think about Skill Matrix but don't know how to start. Could you please help me some hint? Thank you in advance. * * * As Paul commented, i would like to update some information. our software is just related to Web-Application using Core Java, JSP, JSF, Struts, Spring, Hibernate. Desktop application is using Core Java, Swing to develop


Book on Information Technology Concepts for Developer

Is there a good book and/or series of articles that explains IT concepts such as networking, windows domain, security (SSL certs), cryptography, IT infrastructure, etc? I'm a mid level developer who would like to build a good foundation on these topics as it would help me see how my system fits in.   Now, I realize that these topics are vast and have great deal of resources available on individual topics. My goal, at this point in my career, is not to necessarily gain the depth of the information, instead I'm looking for a good overall working knowledge and when required I'll resort to those special topic books. I'm certain you folks had to overcome this bump in your career as enterprise software developer. What did you do? What resources did you resort to? How does one go about bridging the gaps in knowledge and gaining the necessary understanding that is essential to your success. I'm very interested in reading about your experiences. Thanks for the comments so far. Thanks in advance!


What does it mean to perform an operation "In Place" for Interpreted Languages?

Programming question: > Reverse words in a string (words are separated by one or more spaces). **Now > do it in-place**. What does "in-place" mean in the above context for an interpreted language like PHP or JavaScript?


Are code screening services worthwhile?

I've seen websites that screen programmers by their ability to write code. It's a service that you enter a programming question into and then send out a link. Job candidates program their solution to the question as they are timed and recorded. The person who posted the question can then playback a video of their candidate programming the script. This video allows them to see how quickly and neatly their job candidate can code. Are these types of services worth it? What caveats and hangups are there to using such things to screen potential hires?


How to fulfill requirements of AGPL on my web service?

We want a simple tool to parse PDF forms, retrieving just the associated field names and user values. PDFSharp would be a good option for us, as it is under the MIT license, but it is a few versions of Acrobat behind - so not going to work. The most popular library (from what my searches have revealed) seems to be iTextSharp. Thus I am introduced to the intricacies of the AGPL. Now, for the structure of our app. We want something simple and re-usable among any apps we may want to use later that require the same functionality. My plan was to design a simple web service, that takes in the PDF file, and simply returns the Fields and Values in a list of key-value pairs. It looks like, as long as this is an intranet service, there is no concern from the AGPL, as described in this question: Can I safely use an open source library in an internal closed-source project? That is our most likely scenario, but I wanted to be aware ahead of time in case we need to expose our service externally (such as for some of our Silverlight clients, for example). If the service were exposed externally, then, under AGPL, would we simply need to provide the source for the service itself? Or, would the source of any consumer of the service also need to be provided? So, I am looking for 1) confirmation that in the intranet scenario there are no further considerations, and 2) what is necessary if the web service is publicly visible?


Sharing authentication methods across API and web app

I'm wanting to share an authentication implementation across a web application, and web API. The web application will be ASP.NET (mostly MVC 4), the API will be mostly ASP.NET WEB API, though I anticipate it will also have a few custom modules or handlers. I want to:   1. Share as much authentication implementation between the app and API as possible.   2. Have the web application behave like forms authentication (attractive log-in page, logout option, redirect to / from login page when a request requires authentication / authorisation).   3. Have API callers use something closer to standard HTTP (401 - Unauthorized, not 302 - Redirect).   4. Provide client and server side logout mechanisms that don't require a change of password (so HTTP basic is out, since clients typically cache their credentials). The way I'm thinking of implementing this is using plain old ASP.NET forms authentication for the web application, and pushing another module into the stack (much like MADAM - Mixed Authentication Disposition ASP.NET Module). This module will look for some HTTP header (implementation specific) which indicates "caller is API". If the header "caller is API" is set, then the service will respond differently than standard ASP.NET forms authentication, it will:   1. 401 instead of 302 on a request lacking authentication.   2. Look for username + pass in a custom "Login" HTTP header, and return a FormsAuthentication ticket in a custom "FormsAuth" header.   3. Look for FormsAuthentication ticket in a custom "FormsAuth" header. My question(s) are:   1. Is there a framework for ASP.NET that already covers this scenario?   2. Are there any glaring holes in this proposed implementation? My primary fear is a security risk that I can't see, but I'm similarly concerned that there may be something about such an implementation that will make it overly restrictive or clumsy to work with.


When should the presentation model design pattern include one or more controllers?

I have been researching the usage of the Presentation Model design pattern for an application I am preparing to build. The specific technology I will be using is Flex though I doubt that it matters for this question. In general most of the Presentation Model examples I have run across are pretty consistent in the basic implementation. More or less they follow Martin Fowler's Presentation Model description to a T when it comes to the three basic concepts: View, Model, Presentation Model. I think that I understand this. However, I have seen some other examples that extend this further by including controller, event, and service objects in addition to the three basic constructs I listed above. The examples I have seen are (note these are both using Swiz for DI and event handling):   * CafeTownsend   * Swiz Presentation Model Example I understand the reasoning for a service layer. You may want / need to retrieve your data from a SOAP interface one day, a REST interface the next, and a SharedObject on the third day. The service layer interface makes it easy to swap out retrieval and persistence logic. However, I am not sure that I understand why the addition of the controller is an advantage? In the examples linked above some logic within the presentation model is dispatched and handled within the presentation model itself while other logic is dispatched and addressed within a controller. My guess is that logic that is view specific is captured within the presentation model. This supports the notion that the presentation model is simply an abstract representation of the view. Further, I suspect that the controllers are used to capture common business logic and events that are not view specific and are not performed by the service layer (e.g., persistence). This should support reuse across the application and help to make the application more testable.   * Is this conclusion right?    * Are there other advantages I am missing?    * What are the disadvantages (besides more code)?   * How do you know when logic should be in the presentation model and when it should reside in a controller?


Android Card Game Database for Deck Building

I am making a card game for Android where a player can choose from a selection of cards to build a deck that would contain around 60 cards. Currently, I have the entire database of cards created that the user can browse. The next step is allowing the user to select cards and create a deck with whatever cards they would like. I have a form where the user can search for specific cards based off a few different attributes. The search results are displayed in a List Activity. My thought about deck creation is to add the primary key of each card the user selects to a SQLite Database table with the amount they would like in the deck. This way as the user performs searches for cards they can see the state of the deck. Once the user decides to save the deck. I'll export the card list to XML and wipe the contents of the table. If the user wanted to make changes to the deck, they would load it, it would be parsed back into the table so they could make the changes. A similar situation would occur when the eventually load the deck to play a game. I'm just curious what the rest of you may think of this method. Currently, this is a personal project and I am the only one working on it. If I can figure out the best implementation before I even begin coding I'm hoping to save myself some time and trouble.


How do I develop database-utilizing application in an agile/test-driven-development way?

I want to add databases (traditional client/server RDBMS's like Mysql/Postgresql as opposed to NoSQL, or embedded databases) to my toolbox as a developer. I've been using SQLite for simpler projects with only 1 client, but now I want to do more complicated things (ie, db-backed web development). I usually like following agile and/or test-driven-development principles. I generally code in Perl or Python. Questions:   1. How do I test my code such that each run of the test suite starts with a 'pristine' state? Do I run a separate instance of the database server every test? Do I use a temporary database?   2. How do I design my tables/schema so that it is flexible with respect to changing requirements?    3. Do I start with an ORM for my language? Or do I stick to manually coding SQL? One thing I don't find appealing is having to change more than one thing (say, the CREATE TABLE statement and associated crud statements) for one change, b/c that's error prone. On the other hand, I expect ORM's to be a low slower and harder to debug than raw SQL.   4. What is the general strategy for migrating data between one version of the program and a newer one? Do I carefully write ALTER TABLE statements between each version, or do I dump the data and import fresh in the new version?


Should documentation be a company policy or every programmer's responsibility?

I have been struggling lately with the whole subject of documentation at my current position. I am at a point in my programming career in which I feel I have just been birthed into the whole world of proper and effective documentation. Currently there is very little to be found in any database or source code at the company. User spec documents are generally developed in email threads, on a good day. I wonder, am I to blame for having not been strict with myself on this issue? Is it the responsibility of the programmer to maintain this and update where needed or found lacking? I have come to the realization that the best way to approach documenting is to pretend that you have one foot out the door, and another soul will have to take over your work. Thoughts?


Is there a way to check if redistributed code has been altered?

I would like to redistribute my app (PHP) in a way that the user gets the front end (presentation) layer which is using the API on my server through a web service. I want the user to be able to alter his part of the app but at the same time exclude such altered app from the normal support and offer support on pay by the hour basis. Is there a way to check if the source code was altered? Only solution I can think of would be to get check sums of all the files then send it through my API and compare them with the original app. Is there any more secure way to do it so it would be harder for the user to break such protection?


Reporting Solution in PHP / CodeIgniter - Server side logic vs client side

I'm building a report for an end user. They would like to see a list of all widgets... but then also like to see widgets with missing attributes, like missing names, or missing size. So i was thinking of creating one method that returns json data containing all widgets... and then using javascript to let them filter the data for missing data, instead of requerying the database. Ultimately, they need to be able to save all "reports" (filtered versions of data) inside a csv file. These are the two options I'm mulling over: **Design 1** Create 3 separate methods in my controller/model like:               get_all_data()     get_records_with_missing_names()     get_records_with_missing_size()      And then when these methods are called, I would display the data on screen and give them a button to save to csv file. **Design 2** Create one method called get_all_data() and then somehow, give them tools in the view to filter the json data using tables etc... and then letting them save subsets of the data.   The reality is, in order to display all data, I still need to massage the data, and therefore, I know which records are missing attributes. So i'd rather not create separate methods by each filter. I'm not sure how I would do that just yet but at this point, i would like to know some pros/cons of each method. Thanks.


Does the (A)GPLv3 allow people to contibute code anonymously?

Does AGPLv3 or GPLv3 allow people to contribute code without specifying author of contributed code ? Does it allow people to fork an (A)GPL-project without specifying authors of forked code ?


How long should I practice a code kata?

I recently found out about the idea of code katas at Dave Thomas's blog and was really interested in it. I'd like to hear the opinions of people who have experience with code katas; is it assumed that I should practice one kata until I find a solution to the problem, or there is another explanation?


Running cherryPy on apache or not?

seems the cherryPy have a standalone web server, is this suggested to deploy the application on Apache Server? or just use the standalone one? If so, any pros and cons between these decision? Thanks.


developing an android app that include a C++ toolkit

I'm a java developer and I want to develop an android app that capture a photo and extract its bags of visual words. To extract those bags of words I use the TOP-SURF toolkit which is written in C++ I'm new to C++ development and I want to know how to develop an android app that use this toolkit I read about the NDK. It's the solution?


Commercial Apps with an Open Source on github

I am going to be launching a small web service soon and was wondering if it's a good idea to upload the code to a public github repo. The code will not be licensed for commercial use but the public could download the code and hack around with it. Is this a good idea? Would it help produce more secure/bug-free code? Or would it run my startup into the ground? Thanks, Ben


How do I read the Entity Framework Model and validate it against a given connection?

I have a Entity Framework Database First Model. I want to write a MSTest/nUnit test to verify that all the stored procs, tables and views that are defined in my edmx model are still valid on the database.


Dual Inspection / Four Eyes Principle

I have the requirement to implement some kind of dual inspection or four-eyes principle _as a feature of my software_ , meaning that every change of an object done by user A has to be checked by user B. A trivial example would be a publishing system where an author writes an article and another has to proofread it before it is published. I am a little bit surprised that you find nearly nothing about it on the net. No patterns, no libraries (besides cibet), no workflow solutions etc. **Is this requirement really so uncommon? Or am I searching for the wrong terms?** I am not looking for a specific solution. More for a pattern or best practice approach. **Update:** the above example is really trivial. Let's add some more complexity to it. The article has been published, but it now needs an update. Putting the article offline for the update is not an option, but the update has to be proof read, too.


About ANSI C++ 2003 standard

I would like to ask for your help. I searched a lot on Internet, but I found mismatched informations. **My questions:**   1. I tried to buy the "ISO/IEC 14882:2003(E) Programming Languages - C++" standard on the ansi.org, but i have not found it. However, I found this standard on nssn.org: www.nssn.org/search/DetailResults.aspx?docid=338353&selnode= But unfortunately this standard has been deleted or replaced with an another one. webstore.ansi.org/RecordDetail.aspx?sku=INCITS/ISO/IEC%2014882-2003 On the iso.org, it's also the same situation: www.iso.org/iso/catalogue_detail.htm?csnumber=38110 Yes, I know that the actual standard is C++11, but I'm need the C++03 standard. From another sources, I heard that, the C++03 standard has become an open standard, so I can download it from the Internet for free, THE FULL, OFFICIAL standard, for example: code.google.com/p/openassist/downloads/detail?name=C%2B%2B%20Standard%20-%20ANSI%20ISO%20IEC%2014882%202003.pdf cs.nyu.edu/courses/spring13/CSCI-GA.2110-001/downloads/ Is this true? And it's the full, official C++03 standard, not just a draft?   1. Is that true, the C99 (C programming language, 1999) has also become an open standard? If yes, this is the full C99 standard?: cs.nyu.edu/courses/spring13/CSCI-GA.2110-001/downloads/C99.pdf


Communication/Updates between units of works/entity framework contexts, colliding with user changes

I'm developing a WPF application using Entity Framework for my database communication. The application has a hierarchy of tabs where each tab has a db context. Each tab allows the user to view some particular object, make changes, save, update, close or open tabs for related objects. My crux is that some tabs contain information that depends on other objects as well, an object O of type A may be related to other A objects (o_1,...,o_n) in a parent-children relationship, where I have a graphic indicator showing wether property P in O has the same value as P in all the children of O, for example. Red indicator means they are unequal, green means they are equal. The "overlap" in information between contexts will only be presentation-wise, the different tabs will not be stepping on each others toes by changing each others data. Now if I have Tabs for O and o_3 opened, change P in o_3 and save, the indicator in the tab for O might need to change as well, but since that tab has its own (now outdated) db context, the indicator still shows the old value, which might be confusing to the user. This seems like a very general and common problem considering how many application has this architecture. How would you solve the problem? I see a few different but flawed/problematic solutions. A. Make the user aware of the fact that tabs can become "obsolete" when saving others. _This feels like a forfeit to technological troubles._ B. Force updates of related tabs when saving. _This would either overwrite user changes or I would have to build some system (repository pattern?) that maintains information of user changes and mediates what to update and what to keep, what to tell the user and so on._ C. Indicate outdated:ness of related tabs. _This seems like the pragmatic solution, but the user is left to wonder what would be affected if updating the tab manually, and any changes made would have to be dismissed_ D. Communicate the change to the other tab without involving the db context. _This would sort of work, but could lead to complicated problems by introducing state that is not related to the db context, overall it would increase complexity_