Introducing functional programming constructs in non-functional programming languages

This question has been going through my mind quite a lot lately and since I haven't found a convincing answer to it I would like to know if other users of this site have thought about it as well. In the recent years, even though OOP is still the most popular programming paradigm, functional programming is getting a lot of attention. I have only used OOP languages for my work (C++ and Java) but I am trying to learn some FP in my free time because I find it very interesting. So, I started learning Haskell three years ago and Scala last summer. I plan to learn some SML and Caml as well, and to brush up my (little) knowledge of Scheme. Well, a lot of plans (too ambitious?) but I hope I will find the time to learn at least the basics of FP during the next few years. What is important for me is how functional programming works and how / whether I can use it for some real projects. I have already developed small tools in Haskell. In spite of my strong interest for FP, I find it difficult to understand why functional programming constructs are being added to languages like C#, Java, C++, and so on. As a developer interested in FP, I find it more natural to use, say, Scala or Haskell, instead of waiting for the next FP feature to be added to my favourite non-FP language. In other words, why would I want to have only **some** FP in my originally non-FP language instead of looking for a language that has a better support for FP? For example, why should I be interested to have lambdas in Java if I can switch to Scala where I have much more FP concepts and access all the Java libraries anyway? Similarly: why do **some** FP in C# instead of using F# (to my knowledge, C# and F# can work together)? Java was designed to be OO. Fine. I can do OOP in Java (and I would like to keep using Java in that way). Scala was designed to support OOP + FP. Fine: I can use a mix of OOP and FP in Scala. Haskell was designed for FP: I can do FP in Haskell. If I need to tune the performance of a particular module, I can interface Haskell with some external routines in C. But why would I want to do OOP with just **some basic** FP in Java? So, my main point is: why are non-functional programming languages being extended with **some** functional concept? Shouldn't it be more comfortable (interesting, exciting, productive) to program in a language that has been designed from the very beginning to be functional or multi-paradigm? Don't different programming paradigms integrate better in a language that was designed for it than in a language in which one paradigm was only added later? The first explanation I could think of is that, since FP is a new concept (it isn't new at all, but it is new for many developers), it needs to be introduced gradually. However, I remember my switch from imperative to OOP: when I started to program in C++ (coming from Pascal and C) I really had to rethink the way in which I was coding, and to do it pretty fast. It was not gradual. So, this does not seem to be a good explanation to me. Or can it be that many non-FP programmers are not really interested in understanding and using functional programming, but they find it practically convenient to adopt certain **FP-idioms** in their non-FP language? **IMPORTANT NOTE** Just in case (because I have seen several _language wars_ on this site): I mentioned the languages I know better, this question is in no way meant to start comparisons between different programming languages to decide which is better / worse. Also, I am not interested in a comparison of OOP versus FP (pros and cons). The point I am interested in is to understand why FP is being introduced one bit at a time into existing languages that were not designed for it even though there exist languages that were / are specifically designed to support FP.


Why would I choose Unity over Autofac

I'm looking to start a new application and I want to use Dependency Injection. I have a lot of "Microsoft is the only way to go guys" in our shop so of course Unity is the way they wanted to go. However I am leaning more towards Autfac because of its speed and its Module feature. I found the speed results on this page. If you use Autofac or Unity can you give me some solid reasons not to use Unity and to use Autofac over Unity? If not, can you point me into a good direction to do some research on bringing back to our next meeting?


Why do computer architecture textbooks prefer MIPS architecture?

I have read a lot of computer architecture textbooks, and I wonder why most of them (if not all) used MIPS as the architecture to teach. Why MIPS and not Intel or AMD or something else? What makes the architecture suitable for teaching?


Is adding in the header the license type enough to say: "my code is licensed"?

I read on various sites about licenses. I did just put the license type in the header file (in my case a javascript file, open-source):               /*      * "codeName" "version"      * http://officialsite.com/      *      * Copyright 2012 "codeName"      * Released under the "LICENSE NAME" license      * http://officialsite.com/LICENSE NAME      */           javascript code      ...      In the same folder I leave a copy of the license. The listing of the folder looks like this:               * codeName.js     * LICENSE      In the file `LICENSE` is the full text of the license my code uses. What I cannot find anywhere that says is this is enough to say _my code is licensed_ (the case of open-source). Is something more required?


Are for loops supposed to be read inward or outward?

for (i = 0; i < 3; i++)      {         for (j = 0; j < 4; j++)         {             cout << arr2d[i][j] << "\t";         }             cout << endl;         .....      Like that for example. Do you read the for loop inward-out (starting from `for (j = 0; j < 4; j++)`) or outward-in (starting from `for (i = 0; i < 3; i++)`) Just wondering. :D


A question about password storage concept

My previous question is here - A question about storing passwords This question is somewhat related to my previous one but with some new doubts. Take for example Windows. I've heard that Windows stores passwords in NTLM hashes somewhere inside the registry (if I'm not wrong). There are programs that crack the NTLM hashes to recover the passwords (brute-force method) in- case you've forgotten them or just want to hack someone's PC. Why don't they just replace the NTLM hashes in the registry with something common like - NTLM hash of 'password'? This was just an example for your understanding. I'm trying to learn, how large programs store, change or verify passwords without any hacker/attacker being able to read them?


Is a large increase in velocity realistic in a Scrum environment?

My manager has recently really been pushing to use velocity as a target and measure of productivity. We are currently working at an average velocity of 50 story points. My manager wants us to increase it by 40% to 70 story points (with no increase in team members). If we don't achieve this increase he wants us to deliver a full break down explaining why. The whole idea of measuring team performance by velocity and using it as a target seems wrong to me, but I am finding it difficult to explain why. Any help? Why isn't this the right way to measure and incentivize productivity?


Implementing User Authentication on an N-Tier Web Application

_I appreciate all help and feedback. Parts bolded are critical parts if this is too verbose. Perhaps it will help to mention I am a green developer. I have found some useful info from related questions posted here and on Stack Overflow but nothing that felt 100%._ ## Background Currently at work we are developing a web application with strict constraints set forth by the client. Normally we are a Rails shop, but the client really wanted to work with us. Thus to fit into their architecture we will be using ASP.NET. We are not very experienced with ASP.NET but some of the team including myself have used .NET for desktop applications. This application is three tiered and includes:   * Public facing server(s)   * Web services server(s)   * Data server(s) The client is expecting high demand and they may have multiple servers in any one of the tiers. There is a firewall between every tier. From my understanding this is a very common set up. **A core goal is to minimize trips over the wire from the public facing server to the database.** ## The Problem **How do we handle user authentication without hampering performance on an N-Tier application with potentially many servers at each layer?** ## What We've Done so Far We toyed with the idea of using view state but ultimately felt like this would be a poor idea. Of course we are not opposed to re-visiting view state, but feel that view state offers no benefits over cookies and simply makes it harder for a user to have multiple tabs of our application open. I have been exploring the path of using the default session state with a custom implemented session store. **The default session state tends to generate multiple requests going over the wire. Logging in and out this is okay, but when the user is using the app we do not want this.** The custom session store helps minimize impact, but not by enough. ## Conclusion & Possible Idea Since trips to the database will be inevitable on almost all requests once inside the application, perhaps giving the user a key on successful login is the best way to go. Then when the user requests a new page, or posts a new page we could send that key with the related SQL transaction for the request and validate the key. I believe this will simplify the code base immensely. So to re-iterate the problem: **How do we handle user authentication without hampering performance on an N-Tier application with potentially many servers at each layer?** Does the idea above sound like a solid implementation? Thanks,   Jonathon


How to lock items when we do check out in commerce applications

I have a specific requirement. Lets say we have 3 items and a user has selected all 3 items to buy. I need to lock the 3 items (meaning the other people who want to buy the same items cannot view it) for around 10 minutes. How do I implement this? I am developing a Java web app using Hibernate and struts.


Use a service layer with MVC

If a controller gets to fat and model instantation starts to add up a service layer could be used.   * If I just wrap the logic inside a service class I will get a bunch of Services with one/two methods. This feels like a code smell. Any best practice regarding this?   * Can a service instantiate models?   * If a service instantiates models the services can't be unit tested. They can only be covered by integration tests?


The best way to store dictionary from file

I'm working on a translator in C++. Basically I want to parse the file with translations and store it in my program, so I can **perform search through the words and simply access the corresponding word**. My file will look like that:               word|translation     second word|second translation      etc. It doesn't have to be `|` as delimiter and the word can contain spaces. So after I store it in my program I want to search for a word and get the corresponding word easily. The question is, what is 'the best' way to store this dictionary? Should I use dynamic structures and link them? Maybe vectors? Or should I use two- dimensional array to store the 2 strings? Could you please propose to me how the structure will look like?


How can one use git-flow effectively on a project in which more than one major version is being maintained?

I've migrated several of my projects over to the git flow work flow, and I'm loving it. However, I haven't found a best practice that keeps things flowing as smoothly when working with a project in which more than one major version is maintained at a time. _Specifically, I'm not maintaining a "free version" and a "paid version" or any other parallel model, I'm talking about a project in which Version 1 gets released, and remains supported with minor versions (1.1, 1.2, etc.) until Version 3 has been released, at which point 2 and 3 would be maintained, until 4 is released...you get the idea._ How have you, or would you, maintain two or more supported versions of a project at once in a gitflow workflow?


Dealing with resistance to testing code

I've recently switched jobs. At my previous job, everyone wrote tests and we were all in a happy place. In my new role, I've been asked to setup CI and testing. I'm experiencing some resistance to testing from some developers and wondered if anyone had experienced this and had strategies for dealing with resistance?


What is meant by "code rot"?

Please say that 'code rots' if you don't clean it. What does that mean? Obviously code is text, not an organism that can change itself. So why does code 'rot' if you don't touch it? What makes it 'rot' and what does it actually mean? Please explain, examples would be welcome.


code review with git-flow and github

With regular git and github I can do a code review by simply creating a pull request of the feature branch I'm working on to the master branch. How would I do code reviews with git-flow? With workflow like "git flow feature finish` I'm confused as to where the code review actually happens and how git-flow or git can facilitate that review.


Are there any empirical studies about the effects of commenting source code on software quality, maintainability and developer productivity?

I am an advocate of commenting on source code and documenting software products. It is my personal experience and observation that working on source code that is rigorously commented has helped me in different ways when I have had to grow software or maintain it. However there's another camp that says commenting is ultimately worthless or its value is questionable. Numerous proponents of coding without commenting argue that:   * If a piece of code is well-written, it is self explanatory and hence does not need commenting   * If a piece of code is not self-explanatory, then refactor it and make it self-explanatory so that it does not need any comments   * Your test suite is your live documentation   * Over time code and comments get out of sync and it becomes another source of headaches   * Agile says working code is more important than piles of documentation, so we can safely ignore writing comments To me this is just dogma. Again, my personal observation has been that software written by teams of smart and experienced developers ultimately end up with a considerable amount of code that is not self-explanatory. Again, the Java API, Cocoa API, Android API, etc. show that if you want to write and maintain quality documentation, it is possible. Having said all these, conversations about pros and cons of documentation and commenting on source code that are based on personal beliefs usually do not end well and lead to no satisfying conclusions. As such I am looking for academic papers and empirical studies about the effects of software documentation, especially commenting source code, on its quality and maintainability as well as its effects on team productivity. Have you stumbled upon such articles and what's been the outcome of them, if any?


How does the ETVDX model fit in with project management?

In a lecture, the lecturer described the following model : E - entry (the preconditions to a task).   T - task - doing the task   V - verifying the tasks quality   D - Delivering the tasks   X - Exit.   or ETVDX If anyone is familiar with this 'generic compliance model', how does it fit into software development exactly? I presume it's equivalent to the waterfall model of negotiating requirements > defining/decompose stage > estimating effort > estimating resources > developing schedule.


Frog crossing N lane road problem

Problem says that: > There are `N` lanes, and the speed of each lane is given. There are many > cars in all the lanes and the start position and the length of each car and > its corresponding lane is given. There is a frog which can do 2 functions: > `wait()` or `jump()`. Find if there is a path for the frog to go from lane > `1` to lane `N` without getting hit by any of the moving cars. I am not able to solve it. I took the data structures `speed[1..n]` to denote speed of cars at `i`th lane, `length[1..n]` denoting length of cars, `start[1..n]` denoting starting position of cars. Then I took starting lane and on the basis of time calculations I decided whether to jump or wait. **My algorithm** : for each lane   1. I will assume that it is safe to jump to the next lane.   2. Then I will calculate the time period within which frog can be hit (time when I will add car length in total distance and time when i will not add car length.)   3. Now if frog will reach to the next lane within that time period then it is good to wait on the current lane.   4. While waiting I will also check whether it will be hit by the car in current lane or not. But in some cases my algorithm will not work. How should I structure my code to solve this problem?


How to start competitive programming?

I have been practicing coding for a while, but the problem is that it takes me a lot of time to write a solution for the problems. I want to ask if competitive programming can help me in improving this. If yes, then how should I start and from which web sites could I use (like TopCoder)? I obviously won't be able to solve very hard problems for now. What should I do? If no, what else should I do? I also have another problem that I want to learn coding but the thing is that I feel that I am not very good at it. What should I do? It's like bugging me from inside. I know some people may not find this question informative but please at least allow me to get an answer.


Why is Invariance, Covariance and Contravariance necessary in typed languages

Ok not really sure if I'm right. I only recently learned that I needed to have contravariant interface to be able to pass that interface as a parameter in C# and this feature was only added in .NET 4.0. So obviously there is some reason you can't do this Covariant or Invariant interfaces and it probably has something to do with passing in, getting out the generic class. I'm not really sure what the limitation here is, and know that I've seen where Contravariant interface can be used where the others can't where can I use Covariant (when is that neccesary?). This is all out of curiosity (I'm very interested in programming concepts surrounding some languages). I would love to see (link would be fine) some examples of why it is necessary to use these features, what would break if you would allow covariant/invariant into contravariant scene and vice versa and where each one shines.


Is it better to use multiple html pages or just change content on the same page using JavaScript?

Is it better to use multiple html pages and link them together with `href` or just change content on the same page using JavaScript? I am thinking of how to layout a page and I don't have a lot of content. It would probably be about three of for pages if I just used all html. If I toggled and swapped bits of html around using JavaScript, I could probably fit it all on one page, and it would be a bit "cooler", in that it's more of an application, dynamic, etc. But I'm just wondering what the best way to go here? Is it horrible to have to much JavaScript "squashed" to one document? How do you know where to draw the line when thinking about this?


Are these steps enough to put my bash script under GPL 3?

I have written a bash script I would like to put under GPL v3. I've read the GNU documentation on How to Apply These Terms to Your New Programs and How to use GNU licenses for your own software. Still, I'm not quite sure what to put there and which artifacts are needed. So far, I did the following:   1. Put a file called `COPYING` (which contains the license) into the project folder   2. At the beginning of my script, I attached the following to my script: > up is a bash function to simplify vertical file system navigation. > > Copyright (C) 2012 Oliver Weiler > > This program is free software: you can redistribute it and/or modify it > under the terms of the GNU General Public License as published by the Free > Software Foundation, either version 3 of the License, or (at your option) > any later version. > > This program is distributed in the hope that it will be useful, but WITHOUT > ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or > FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for > more details. > > You should have received a copy of the GNU General Public License along with > this program. If not, see http://www.gnu.org/licenses/. Is this all I have to do? Is putting the licence into a separate file actually needed, if the notice in the script file links to it?


Applying for job: how to showcase work done for (private) past clients?

I want to apply for my first "real" (read: non-freelance) Ruby on Rails job. I've built several apps already. My best work (also the most logically complicated app) was for a freelance client, and I'd like to show it to potential employers. Only problem is: it isn't online anymore. And I've lost touch with the client. How can I include this work in my portfolio? * * * **About the app:** It's a Facebook game. The client's business idea for this app was not the best. It was never going to make any money. I think it was kind of a vanity side project for him. The logo and graphics are nice-looking, though, and were designed by the client. I've actually spent a lot of time recently recoding most of the app, and adding a full test suite. I want to showcase the BDD / TDD skills I've acquired. * * * I'm not very familiar with the etiquette (/law?) concerning this situation. Can I just put my new version of the app up at a free Heroku URL (perhaps with a "credits" section, where I credit the ideas and graphic designs to my former client)? **NOTE:** Again, this is just to show potential employers. I am **not** trying to market the app as my idea, or attract any users. Can I put some or all of the code on GitHub? What if I don't put the code up publicly, but merely send a tarball to potential employers? Do I need to ask permission from my former client (and what if he says no)? The last thing I want to do is get in any legal trouble, or offend people I'm trying get a job from. But I believe that my work and experience on _this app_ are my highest recommendation for getting a job.


What are the disadvantages of starting an opensource project if one is not an experienced programmer?

I have lots of ideas for products to be built. The problem is that I have less than a year of professional work experience and I am afraid of getting **judged negatively in the future** based on what I produce now. I have no clue if my code is any good. I am not familiar with any of the coding patterns. All I know is to build products that work. I want to have a public profile in github for my future projects and I will try hard to make sure that it is well commented, is optimized and clean. These are the things that I fear getting exposed publicly:   1. My code may not be highly optimized.   2. Wrong usage of certain libraries or functions which coincidentally get the job done.   3. Not knowing or following any coding pattern.   4. Lots of bugs/ not considering corner, edge cases   5. Fundamental lack of understanding and application of certain concepts such as thread safety, concurrency issues in multi-threaded programming, etc. Should I go ahead and get started or continue to stick to building stuff locally and privately till I get more experience. I don't want the mistakes made here to haunt my career prospects in the long run.


What sorts of software patent issues should one be aware of when writing software?

**The scope of this question is intended to be global in nature:** techniques (approaches to solving a problem, such as the use of a layer palette), operations (actions that the software or its user can take, such as using a paint bucket tool to fill in a selection or otherwise bounded area), etc. If the development process comes into play, such as Person A saying "We need to implement this one cool feature in Software X" and perhaps any study of that functionality via decompilation, hex-editing, etc. (vs. a more genuine, independent process of imagining functionality or writing up the spec), then that would be appropriate to mention. I am in the process of creating a substantial application, and I don't know how much of a problem software patents will be. I'm of the impression that no one can patent a "paint bucket" tool (though I wouldn't know the legal justification behind why that can't be patented), but perhaps if you stray much further from that, you'll get hit with a lawsuit? I really have no idea! In my case, I'm not even looking at competitor's software for this very reason. I did sit down with someone who uses software that is currently on the market long enough to know that I can easily demolish it, but I would just consider that market research. The only things that excited me during that little demo session were instances where I would dream up some functionality and his response would be "Yeah, that would be really useful, and no, this software can't do that." There was no "I really need to copy that feature!" because, well, the application was garbage for the most part, despite it price tag.


Add complex customization to form or create two forms?

I'm working in a WPF application that both imports and exports delimited text files. At both ends, there is a UserControl which encapsulates some logic about delimiter configuration. It has some controls for individually selecting delimiters, and a 'Presets' dropdown for quickly selecting certain common combinations such as CSV. I've been tasked with modifying the export configuration dialog. They want the presets feature modified to also cover some text formatting options that aren't related to delimiters. The changes should only appear in the export configuration dialog, because the settings in question aren't applicable to importing. They will involve both adding some new controls, which isn't too bad. But there will also need to be some additional presets which aren't available on the import dialog, and their presence may impact the behavior of the dialog overall. I'm unsure of the best way to do this. Three options come to mind, but of course I might be missing one:   1. Clone the UserControl and make the requisite changes to it. Each dialog now has a separate control. However, both controls will have a lot of logic in common, so I'm uncomfortable with this from a DRY perspective.   2. Keep the single UserControl but throw in a 'mode' property. Based on its setting, show or hide certain controls, swap out the ItemsSource for the 'Presets' dropdown, etc. This is attractive since it involves less copy-and-paste, but at the cost of the single control being more complicated overall, and perhaps more difficult to maintain on down the road.   3. Redo the whole thing's architecture so that the behavior-related aspects are properly managed in a separate ViewModel. This new ViewModel should be programmatically configurable to represent the different working modes (basically by just swapping out the list of available Presets, each represented as an instance of a Preset class). Create two different sets of UI to represent the different layouts, with one simply not having the controls for options it doesn't care about.  My gut instinct is that #3 is the best option. I'm concerned that it's an excessive effort, though, and that I'm just being too picky about one of the first two options. Or that there's some other pitfall with it I haven't thought of. I have a bit of a history with this UserControl and my personal feeling is that it's kind of a PITA to maintain, so I want to be cautious in case I'm overeager for the rewrite for emotional reasons.


Switching between Azure Mobile Services vs my own implementation. Will UIDs change?

I'm looking at Azure Mobile Services, particularly the Authentication part (which I believe relies exclusively on OAUTH 1 or 2). I want to make sure that my application isn't tightly coupled to the service and I can bring authentication back in-house using either of the following methods:   1. I use a version of Azure Mobile Services built for 2012 R2 (which may include support for AMS + OAUTH)   2. I use a local DLL such as .NET Open OAuth to handle the authentication. My theory is that UIDs are portable between all three scenarios (the third being Azure Mobile Services itself), because I manually would be typing in the same secret into each provider. My second gut reaction is that any Windows Live IDs will not have the same URL and aren't portable in these scenarios (based on my Azure ACS and LiveID experience). However since I've noticed OAuth support in .NET OpenID I think I could be mistaken. **Question** Could someone more well versed in authentication, and Microsoft products let me know if authentication can be "moved" to and from Azure Mobile Services if needed? The main contention point I believe will be differing user IDs after the switch which would mean that after migration, users will loose their previous history, etc. in my application.


What arguments can I use to justify the use of either XML or JSON to store and transmit object data?

My project lead considers both of these approaches to be unnecessary overhead. I have been involved in and have witnessed a lot of talk around XML vs JSON, but this is the first time that I have heard an argument against BOTH. We are using c# in .Net 4. We'll be storing data in a sql server database on the server and also on mobile devices. I've heard all the arguments between the two but now I need to understand the arguments for and against the use of any object notation to store data - my project lead prefers csv format.


Which functional language is good for a beginner?

> **Possible Duplicate:**   >  Choosing a functional programming language I am a C++ programmer looking to learn a functional language as a hobby and out of sheer curiosity. I am not looking to be an expert, but just to get a grasp on functional programming. This language should be simple to learn and have good tutorials and resources for beginners. Are there any such languages?


Using visitor pattern with large object hierarchy

**Context** I've been using with a hierarchy of objects (an expression tree) a "pseudo" visitor pattern (pseudo, as in it does not use double dispatch) :                public interface MyInterface      {           void Accept(SomeClass operationClass);      }           public class MyImpl : MyInterface       {           public void Accept(SomeClass operationClass)           {                   operationClass.DoSomething();                operationClass.DoSomethingElse();                // ... and so on ...           }      }      This design was, however questionnable, pretty comfortable since the number of implementations of MyInterface is significant (~50 or more) and I didn't need to add extra operations. Each implementation is unique (it's a different expression or operator), and some are composites (ie, operator nodes that will contain other operator/leaf nodes). Traversal is currently performed by calling the Accept operation on the root node of the tree, which in turns calls Accept on each of its child nodes, which in turn... and so on... But the time has come where I need to **add a new operation** , such as pretty printing :                public class MyImpl : MyInterface       {           // Property does not come from MyInterface           public string SomeProperty { get; set; }                public void Accept(SomeClass operationClass)           {                   operationClass.DoSomething();                operationClass.DoSomethingElse();                // ... and so on ...           }                public void Accept(SomePrettyPrinter printer)           {                printer.PrettyPrint(this.SomeProperty);           }      }          I basically see two options :   * Keep the same design, adding a new method for my operation to each derived class, at the expense of maintainibility (not an option, IMHO)   * Use the "true" Visitor pattern, at the expense of extensibility (not an option, as I expect to have more implementations coming along the way...), with about 50+ overloads of the Visit method, each one matching a specific implementation ? **Question** Would you recommand using the Visitor pattern ? Is there any other pattern that could help solve this issue ?


How do "custom software companies" deal with technical debt?

**What are "custom software companies"?** By "custom software companies" I mean companies that make their money primarily from building custom, one off, bits of software. Example are agencies or middle-ware companies, or contractors/consultants like Redify. **What's the opposite of "custom software companies"?** The opposite of the above business model are companies that focus on long term products, whether they be deployable desktop/mobile apps, or SaaS software. **A sure fire way to build up technical debt:** I work for a company that attempts to focus on a suite of SaaS products. However, due to certain constraints we sometimes end up bending to the will of certain clients and we end building bits of custom software that can only be used for that client. This is a sure fire way to incur technical debt. Now we have a bit of software to maintain that adds nothing to our core product. **If custom work is a sure fire way to build technical debt, how do agencies handle it?** So that got me thinking. Companies who don't have a core product as the center of their business model, well they're always doing custom software work. How do they cope with the notion of technical debt? How does it not drive them into _technical bankruptcy_?


Avoiding ubiquitous language clashes

I have been reading DDD Quickly and wondered about how to avoid naming clashes with technical terms and domain terms. For example, if I commonly used the repository pattern (with classes such as AddressRepository), but a customer also has something called a repository in their domain. How would I best avoid confusing the two?


How to implement isValid correctly?

I'm trying to provide a mechanism for validating my object like this:               class SomeObject {         private $_inputString;         private $_errors=array();              public function __construct($inputString) {             $this->_inputString = $inputString;               }              public function getErrors() {             return $this->_errors;         }              public function isValid() {             $isValid = preg_match("/Some regular expression here/", $this->_inputString);             if($isValid==0){                 $this->_errors[]=  'Error was found in the input';             }             return $isValid==1;         }          }      Then when I'm testing my code I'm doing it like this:                   $obj = new SomeObject('an INVALID input string');              $isValid = $obj->isValid();         $errors=$obj->getErrors();              $this->assertFalse($isValid);         $this->assertNotEmpty($errors);      Now the test passes correctly, but I noticed a design problem here. What if the user called `$obj->getErrors()` before calling `$obj->isValid()`? The test will fail because the user has to validate the object first before checking the error resulting from validation. I think this way the user depends on a sequence of action to work properly which I think is a bad thing because it exposes the internal behaviour of the class. How do I solve this problem?   Should I tell the user explicitly to validate first? Where do I mention that?   Should I change the way I validate? Is there a better solution for this? UPDATE:   I'm still developing the class so changes are easy and renaming functions and refactoring them is possible.


How can I compute the Big-O notation for a given piece of code?

So I just took a data structure midterm today and I was asked to determine the run time, in Big O notation, of the following nested loop:               for (int i = 0; i < n-1; i++) {         for(int j = 0; j < i; j++2) {             //1 Statement         }     }      I'm having trouble understanding the formula behind determining the run time. I thought that since the inner loop has 1 statement, and using the series equation of: (n * (n - 1)) / 2, I figured it to be: 1n * (n-1) / 2. Thus equaling (n^2 - 1) / 2. And so I generalized the runtime to be O(n^2 / 2). I'm not sure this is right though haha, was I supposed to divide my answer again by 2 since j is being upped in intervals of 2? Or is my answer completely off?


Should programmers talk with customers / users according to MSF / agile methods?

I've just read two statements that seem to be very different: > Des Weiteren ist mangelnde Kommunikation zwischen Programmierern und Nutzern > eine nicht zu vernachlässigende Quelle von unzureichenden Produkten. > > Translated: > > A lack of communication between programmers and users is a source of poor > [software] products. Source: de.wikipedia.org I think I have read something similar in CHAOS report of Standish Group. And > Insbesondere bei der Rolle Development ist Kontakt zum Kunden oder zu den > Benutzern nach Meinung des MSF geradezu zu unterbinden. > > Translated: > > According to MSF, especially the role "Development" should not have contact > to the customer or to the user. Source: msdn.microsoft.com This also makes sense, because as a programmer I want to have happy end users. So the user likes to have a new feature, I'll try to implement it. This could lead to feature creep. If I understand it correctly, MSF (Microsoft Solution Framework) tries to avoid this problem by a role that has contact to the customer (this is the product manager, the user experience role and maybe the testing role, isn't it?) and only one role that has contact to the development role (the program manager). **Question 1:** How do agile methods deal with the problem of feature creep? I read that the developers should have very strong contact with customers in agile methods and that one of the main problems in using scrum is to persuade the customer to get involved in the process. Does in SCRUM only the Product Owner have contact with the user / customer? Isn't this a problem, as the programmer might see different problems than the Product Owner? **Question 2:** Who does the requirements engineering in agile methods and MSF? **Question 3:** Do you validate in MSF / agile methods if your product does what the customer wants and the user needs before shipping it? How do you do it?


mind map for programmers

How are mind maps useful for programmers in organizing the way they work?


Spartan programming... What is it good for?

We are being forced to use Spartan programming on a project, to everybody's dismay. So I get it, it makes the methods really short and it handles the simple cases first. But is it really worth the price of the code looking like something out of the Obfuscated C Code contest? Can you see it being useful for something?


best practice: setting up several IDE / frameworks (at file/dir level)

I don't know how to exactly search for this topic, so if there are a lot of answers to that, please just provide a link :) I'm getting a new laptop in a few weeks and am thinking about setting up a logical, easy-to-use and clean folder structure for coding from the beginning.(mixing everything coding related now)   My question is: Does your folder structure look like:   C:\grails   C:\Java\jre-...   C:\JAVA\jdk-...   C:\eclipse   ... etc   or do you always use the default directory?   or do you sort them, like: C:\ide\, C:\framewor and C:\CMS\   Do you put the frameworks and ide on a separate partition? Do you map your projects accordingly? How do you name your projects and how is the saving file structure? Is there a really good way that I've missed? I mean I just have a handful of projects to take care of and I mostly just do some light coding or minor changes, and still I'm confused every time I try to find anything or am often surprised to find several older versions still active... A few information:     * Dual boot to a second partition is out of the question, I do like convenience (#1 reason for me to try programming: make things easier for me.)   * I'll be getting a SSD, so the space is limited.   * Running Windows 7 Prof- 64bit   * I'll need: Eclipse, NetBeans, Grails, Groovy, VisualStudio, Ruby, Perl.  Hopefully anyone has a good idea about that. It really annoys me and since I do have the opportunity to change that it's a good time to think about it.


Result class dependency

I have an object containing the results of a computation. This computation is performed in a function which accepts an input object and returns the result object. The result object has a print method. This print method must print out the results, but in order to perform this operation I need the original input object. I cannot pass the input object at printing because it would violate the signature of the print function. One solution I am using right now is to have the result object hold a pointer to the original input object, but I don't like this dependency between the two, because the input object is mutable. How would you design for such case ?


In developing a soap client proxy, which return structure is easier to use and more sensible?

I'm writing (in PHP) a client/proxy for a SOAP web service. The return types are consistently wrapped in response objects that contain the return values. In many cases this make a lot of sense - for instance when multiple values are being returned:               GetDetailsResponse Object      (         Results Object         (             [TotalResults] => 10             [NextPage]     => 2         )              [Details] => Array         (             [0] => Detail Object             (                 [Id] => 1             )         )     )      But some of the methods return a single scalar value or a single object or array wrapped in a response object:               GetThingummyIdResponse Object     (         [ThingummyId] => 42     )      In some cases these objects might be pretty deep, so getting at properties within requires drilling down several layers:               $response->Details->Detail[0]->Contents->Item[5]->Id      And if I unwrap them before passing them back I can strip out a layer from consumers' code. I know I'm probably being a little bit of an Architecture Astronaut here, but the latter style really bug me, so I've been working through my code to have my proxy methods just return the scalar value to the client code where there's no absolute need for a wrapper object. My question is, am I actually making things more difficult for the consumers of my code? Would I be better off just leaving the return values wrapped in response objects so that everything is consistent, or is removing unneccessary layers of indirection/abstraction worthwhile?


Mobile games: paid vs. ad-supported?

> **Possible Duplicate:**   >  Which has more benefits when selling through mobile app stores: free or > paid? I'm working on a game, and I'm hoping to distribute it through the Android and/or Apple stores. The big decision that I have to make: do I charge money for the game? Or do I put ads in it? I really hate advertising, so I'd prefer not to subject my users to it, but I'll do it if that's the only way to make money. I'd like to hear from anyone who has experience distributing mobile apps. Also, from regular users of the Apple and Android stores; how easy do they make it for you to drop $0.99 on something?


Is there any reason in a Java program for a special naming for a function arguments?

I'd like to know, why would I want to have a special prefixes for a function arguments, like "p_name", "p_age", "p_sex"? On the one hand it helps to distinguish parameter from local variable or field further in the function body, but would it help? On the other hand, I didn't saw such naming recommendations anywhere including official Java language conventions. Please advise any reasons for using such naming policy


Print all values in a value object

I have to debug an issue which requires me to print all the values of a Value Object that is returned by a web service call. The Value object is a complex object in the sense, it has another object as its member which in turn has another object. Printing all the values by using get methods is cumbersome. So I was wondering if there is a way to break down the value object by any way to get to a primitive level like String or int or Date and print them all using one API? I had a look at the below question but my prob is that I don't have access to the source code of the value object. The sources are in obfuscated jar. http://stackoverflow.com/questions/2413001/how-to-print-values-of-an-object- in-java


Keeping up with upstream changes while adding small fixes or even major changes

Often I need to apply some small fixes (to make them run on my environment) or even change some parts of the software (to tailor it to my needs) to software from outside. However this obviously creates problem with updating said software, even when it changes nothing related to my fix. It would be easier when the software provided integration for some kind of plugins but more often than not it doesn't. What would be an ideal workflow regarding that? Most of the projects are git repos I pulled from outside. How should I apply my changes so that I can update painlessly? You can assume that external changes are much more often and larger than my own ones, so reviewing each one of them won't be a solution.


looking for a short explanation of fuzzy logic

I got the idea that basics of fuzzy logic are not that hard to grasp. And I got the feeling that someone might explain it to me in like 30 minutes. Just like I understand neural networks and am able to re-create the famous Xor problem. And go just beyond it and create 3 layer networks of x nodes. I'd like to understand fuzzy till a similar usefully level, in C# language. However the problem is face, I'd like to get concept right however I see many websites who include lots of errors in their basic explaining. Like for example showing pictures and use different numbers as shown in pictures to calculate, as if lots of people just copied stuff without noticing what they write down. While others for me go to deep in their math notation). To me that's very annoying to learn from. For me there is no need to re-invent wheel; Aforge already got a fuzzy logic framework. So what I am looking for are some good examples, good examples like how the neural XOR problem is solved. Is there anyone such a instructional resource out there; do you know a web page, or YouTube where it is shortly explained, what would you recommend me? Note this article comes close; but it just doesn't nail it for me. After that I downloaded a bunch of free PDF's but most are academic and hard to read for me (I'm not English and don't have a special math degree). (I've been looking around a lot for this, good starter material about it is hard to find).


Asking potential developers to draw UML diagrams during the interview

Our interview process currently consists of several coding questions, technical questions and experiences at their current and previous jobs. Coding questions are typically a single method that does something (Think of it as fizzbuzz or reverse a string kind of question) We are planning on introducing an additional step where we give them a business problem and ask them to draw a flowchart, activity, class or a sequence diagram. We feel that our current interview process does not let us evaluate the candidate's thinking at a higher level (which is relevant for architect/senior level positions). To give you some context, we are a mid size software company with around 30 developers in the team. If you have this step in your interview process, how has it improved your interviewing veracity? If not, what else has helped you evaluate the candidates better from a technical perspective.


What should a self-taught/no experience programmer's resume look like?

I asked a question a while back about knowing when you're ready to look for a job and got positive replies. Now I'm working on writing up a resume to begin my job search. The title pretty much sums up the question, what should a self-taught programmer who has nothing but personal project experience put in a resume? PS. What I really want to ask is for someone to take a quick look at my resume(draft) but I know that's too specific here. Is there a place where I can ask this type of question? **EDIT:** Thanks to everyone for the feedback. I've finished a RC version and will hopefully be entering the job market soon.


Why are Oracle directories named /u01 /u02 etc...?

I've been working with the Oracle RDBMS for a few years and today, after installing one for the n-th time, I was left wondering, why do we install it in /u01, /u02, etc.? Of course you could install it somewhere else, but for some unknown reason, this convention is used everywhere and I haven't seen any serious Oracle installation in, for example, /opt Any history lesson I missed?


Returning status code where one of many errors could have occured

I'm developing a PHP login component which includes functions to manipulate the User object, such as `$User->changePassword(string $old, string $new)` What I need some advice with is how to return a status, as the function can either succeed (no further information needs to be given) or fail (and the calling code needs to know why, for example incorrect password, database problem etc.) I've come up with the following ideas:   * Unix-style: return 0 on success, another code on failure. This doesn't seem particularly common in PHP and the language's type-coercion messes with this (a function returning FALSE on success?) This seems to be the best I can think of.   * Throw an exception on error. PHP's exception support is limited, and this will make life harder for anybody trying to use the functions.   * Return an array, containing a boolean for "success" or not, and a string or an int for "failure status" if applicable. None of these seem particularly appealing, does anyone have any advice or better ideas?


Extend the API or use the same name as a class in the API?

I have been running into this problem more and more: I am not happy with the current API, and end up making my own class that does what I wish the API did; however, I don't extend the 'super class' as I don't feel it fully fits. I can't imagine that this is good practice, so should I just extend the 'super class' or should I name the class slightly different than what I feel the original class should have done? For example, in Java you end up writing ten lines of code just to read a file into a List, with each entry being one of the file. So again, in cases like this, should the class be renamed to something similar, or should it go ahead and just extend the class the include the behavior you wanted? It almost seems wrong to me to extend the API classes, but at the same time, by not doing so, you are defeating the point of inheritance in OOP.


Storing lots of large strings with frequent "appends" and few reads

In my current project, I need to store a very long ASCII string to each instance of a given object. This string will receive an 2 appends per minute and will not be retrieved so frequently. The worst case scenario is a 5-10MB string. I'll have thousands of instances of my object and I'm worried that storing all those strings in the filesystem would not be optimal, but I can't think of a better solution. Can anyone suggest an alternative? Maybe a key-value store? In this case, which one? Any other thoughts?


If you have the full spec done, what is left for the developer to do?

I'm working in a small company, started as a developer and coded pieces of a big system being provided with detailed specs. Over five years I moved towards analyst position. I know how existing parts of the system are build, so when we need a new subsystem I know how to connect it to the existing things. So I analyse requirements for a new subsystem to be done, design a new module, then code main parts of it. After that me with my colleagues who are proper analysts write detailed specs for junior developers to finish the module. The problem is that I don't see a new job for myself. I realise that jack-of- all-trades isn't considered to be good, and I don't see getting myself a job exactly like this in a big company. But if I look for a developer job, then I would be somewhat like junior again? Because if I will be provided with detailed description of what software has to do, all that seems to be left for me is merely translating spec to the code, which is plain boring. But developer is considered to solve problems, so which problems are those supposed to be? Only pure technical problems I can imagine is performance optimization. So basically my question is - what problems developers are supposed to face and solve, if all decisions of how application should work to meet customers needs are considered to be an analyst job? What problems do you solve at work?


Is This A Good Example Of Open Recursion?

I understand _open recursion_ as the process of a method on a class calling another method on a class using a keyword such as `this`, but whereby the method call may actually be bound to a sub class at run time. Is this a fair demonstration of open recursion?               class Sup {         go() {             alert('sup');         }              callGo() {             this.go();         }     }          class Sub extends Sup {         go() {             alert('sub');         }     }          var sub = new Sub();     sub.callGo();


Guessing a phone number's country code

This is the problem I'm working with: given a phone number from anywhere in the world and some location information (state, province, possibly country name if I'm lucky, etc.), return the ISO country code for that number. For the purposes of this question, I will not focus on the location information, as that provides an alternative solution to determining the country code which doesn't even need to use the phone number anymore (though, it would be useful for validation purposes) When I first started working on the problem, I was hoping there was a deterministic way to figure this out because there was some sort of international standard out there. It became immediately apparent that one does not exist for phone numbers. There are standards within countries, between countries (NANP for example), but no unified international standard. Playing around with libphonenumbers for a few days, it seems to be able to provide accurate validation of a phone number if I'm given a country code (eg: CA for Canada, GB for United Kingdom, etc). The library provides two methods: `isPossibleNumber`, and `isValidNumberForRegion`. This is the code I'm using               boolean isValid;     PhoneNumber number;     PhoneNumberUtil util = PhoneNumberUtil.getInstance();          String numStr = "(123) 456-7890";     for (String r : util.getSupportedRegions())     {         try {             // check if it's a possible number             isValid = util.isPossibleNumber(numStr, r);             if (isValid)             {                 number = util.parse(numStr, r);                      // check if it's a valid number for the given region                 isValid = util.isValidNumberForRegion(number, r);                 if (isValid)                     System.out.println(r + ": " + number.getCountryCode() + ", " + number.getNationalNumber());             }         } catch (NumberParseException e)         {             e.printStackTrace();         }     }      So for example, if I took an arbitrary phone number like `+44 20 7930 4832` and ran it through the method, I would get the following output               GB: 44, 2079304832      Now, that's assuming I'm given the dialing code (sometimes it's there). If I weren't given the dialing code, I might just get something like `20 7930 4832`, and the results are not as pretty               DE: 49, 2079304832     US: 1, 2079304832     GB: 44, 2079304832     FI: 358, 2079304832     AX: 358, 2079304832     RS: 381, 2079304832     CN: 86, 2079304832     NZ: 64, 2079304832     IN: 91, 2079304832     IR: 98, 2079304832     JP: 81, 2079304832      Given a phone number, I can run it through all of the different rules for every country and filter the list down from 244 to around 20 or less if I'm lucky, but I'm not sure if there's anything else I could do to try and guess the country.


Looking for the recent and powerful upcoming programming languages over net, I came across Ceylon. I dropped in at ceylon-lang.org and it says: > Ceylon is deeply influenced by Java. You see, we're fans of Java, but we > know its limitations inside out. Ceylon keeps the best bits of Java but > improves things that in our experience are annoying, tedious, frustrating, > difficult to understand, or bugprone. What are the advantages of Ceylon over Java?


A weakness of the TDD method?

This is in summary the TDD method:   1. Write a test   2. check if thes test fails   3. write production code   4. run test I think that TDD as presented works only in ideal circumstances. I'll take a simple example: **Specification** : Write a program that calculates the square root of a number, the user must enter a number. If the number is negative, the program should display an error, and if the number is positive or zero the program should display the number whose square is the number entered, or for decimal number whose square is closest to the number entered. **Writing test**               class SquareRootTest {             private SquareRoot squareRoot;             public void testNegativeNumber() {               assertException(squareRoot.execute(-5);           }             public void testIntegerSquareRoot() {           assertEqual(squareRoot.execute(9),3);        }             public void testDecimalSquareRoot() {          assertEqual(squareRoot.execute(3),1.732);        }     }      **run failed test** **writing production code:**               class SquareRoot {           public double execute(Number number) {          if(number < 0)               throw exception;          if(number < 1)              return squareRootLessThanOne(number);           else              return squareRootGreaterThanOne(numner);        }          //private methods....          }      this is when writing production code, I find that I have to deal with the numbers lower than one differently from those numbers greater than 1. So I need to update my tests to reflect this. **Updating test**               class SquareRootTest {             public void testNegativeNumber() {                assertException(squareRoot.execute(-5));           }             public void testIntegerSquareRoot() {            assertEqual(squareRoot.execute(9),3);        }             public void testDecimalSquareRoot() {           assertEqual(squareRoot.execute(3),1.732);        }             public void testNumberLowerThanOne() {           assertEqual(squareRoot.execute(0.04),0.200);        }     }      If I had found a single algorithm to calculate the square root, I would not change my tests. The TDD method focuses solely on tests from specifications, yet there are tests that are derived from the implementation, particularly all conditional instructions and all instructions controlled by loops should normally be tested. These tests case can not be detected at the time of specification. My question: How does TDD will deal with this situation? or is effectivelly a weakness of the TDD?


Repeatability of CPU-intensive benchmarks on NUMA hardware

Consider a benchmark of a C++ application. It does little or no I/O in proportion to its overall runtime -- it is compute-intensive. It is a single- threaded program. It pages/reads in all of its data at the outset, and then runs many iterations of the core task at hand, so as to average out cache or other ephemeral variations. We run it on a large, multi-core, Linux system with far more memory than it uses, which has a NUMA memory hierarchy. We run it on the machine when it is 'idle'. Of course, it has some number of the usual daemons floating around, but there should be plenty of cores and memory to spare to keep them happy. We observe a surprising (to us) range of variation in the wall-clock time that results. Can anyone suggest where to look for an explanation, or what to do to reduce the variation? uname:               Linux perf2.basistech.net 2.6.32-71.29.1.el6.x86_64 #1 SMP Mon Jun 27 19:49:27 BST 2011 x86_64 x86_64 x86_64 GNU/Linux      numactl --show:               ~/ numactl --show     policy: default     preferred node: current     physcpubind: 0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15      cpubind: 0 1      nodebind: 0 1      membind: 0 1           ~/ numactl --hardware     available: 2 nodes (0-1)     node 0 cpus: 0 2 4 6 8 10 12 14     node 0 size: 6144 MB     node 0 free: 2030 MB     node 1 cpus: 1 3 5 7 9 11 13 15     node 1 size: 6134 MB     node 1 free: 144 MB     node distances:     node   0   1        0:  10  20        1:  20  10


Are there tangible benefits to being a Microsoft MVP?

I have several certifications, MCPD, MCTS, MCAD, etc and I've learned that MVP is an award (just a title), not a certification. So if I wanted to get one of these, I'd have to spend valuable time on communities, sharing knowledge and providing answers to others for free, consistently, for _years_ , until finally someone special notices and rewards me. I imagine there'd be some personal benefits along the way, but supposing I achieved this goal and became an MVP, would this pay off financially in any way (career opportunities, higher pay scale, etc.)?


How much difference does experience make?

I see many job adds which require at least x years experience. The question is how do you know when a candidate has the required years of experience? What do you expect from a person with x years experience (edit: effectively how do you check if the CV isn't lying without relying to skill checking)? What can a person with x years experience can do that one with y years (with y < x) cannot do (edit: assuming they have similar skills)? There can be cases with some passionate programmer with y years experience that has vast knowledge and worked on multiple projects and other programmer with x years experience (x > y) that has worked on few projects and doesn't have that much experience. Why can not it be reduced to something like this "if you know this technology and you know how to do that stuff (be it design, communication, estimates etc.) then you are suitable for our job"? I know you cannot hire a fresh graduate with 1 year experience for the post of an enterprise architect but I also see a problem with the facts that almost all ads ask experience. IMHO firstly passion should be taken into account. Firstly I did not know if the question is suitable for this site but since there is a tag for recruiting and experience I believe it has a place here.


Is it just me or is this a baffling tech interview question?

## Background I was just asked in a tech interview to write an algorithm to traverse an "object" (notice the quotes) where A is equal to B and B is equal to C and A is equal to C. That's it. That is all the information I was given. I asked the interviewer what the goal was but apparently there wasn't one, just "traverse" the "object". I don't know about anyone else, but this seems like a silly question to me. I asked again, "am I searching for a value?". Nope. Just "traverse" it. Why would I ever want to endlessly loop through this "object"?? To melt my processor maybe?? The _answer_ according to the interviewer was that I should have written a recursive function. OK, so why not simply ask me to write a recursive function? And who would write a recursive function that never ends? ## My question: Is this a valid question to the rest of you and, if so, can you provide a hint as to what I might be missing? Perhaps I am thinking too hard about solving real world problems. I have been successfully coding for a long time but this tech interview process makes me feel like I don't know anything.


How do we provide valid time estimates during Sprint Planning without doing "too much" design?

My team is getting up to speed with Scrum, but most of us are more familiar with non-agile or "pseudo-"agile methodologies. The part that is the biggest hurdle for us is running an efficient Sprint Planning meeting where we break our backlog items into tasks, and estimate hours. (I'm using the terminology from the VS2010 Scrum Template; apologies if I use the wrong word somewhere.) When we try to figure out how long a task is going to take, we often fall into the trap of designing the feature at the code level -- table layout, interfaces, etc -- in order to figure out how long that's going to take. I'm pretty sure this is not the appropriate place to be doing that kind of design. We should be scheduling tasks for these design meetings during the sprint. However, we are having trouble figuring out how else to come up with meaningful estimates for the tasks. Are there any practical habits/techniques/etc. for making a judgement call about how long a feature is going to take, without knowing how you plan to implement it? If our time estimates are going to change significantly once the design has been completed, how can we properly budget our Sprint backlog ahead of time? EDIT: Just to clarify, since some of the comments/answers are very valid but I think addressing the wrong question. We **_know_** that what we're doing is not right, and that we should be building time into the sprint for this design. Conceptually all of the developers understand that. We also also bringing in a team member with Scrum experience to keep us on track if we start going off into the weeds. The problem is that, _without_ going through this design process, we are finding it difficult to provide concrete time estimates for anything. We are constantly saying things like "well if we design it this way it might take 8 hours but if we end up having to do this other way instead that will take about 32 but it might not be as bad once we start trying to write it...". I also assume that this process will get better once we have some historical velocity to work from, but many of the technologies and architectural patterns we are using are new to us. But if potentially-wildly-wrong estimates are just a natural part of adapting this process then we will just need to recondition ourselves to accept that :)


What makes Instagram so valuable?

If as in the FAQ, that topics about business (computer industry) is allowed here, I'd like to find out why Instagram can be so valuable, that it is acquired for $1 billion dollars (USD). To put it simply, isn't it just a photo enhancement app (such as making a photo vintage look), plus sharing those photos on Facebook? That's because in contrast, PlayFish had superb Facebook games, and many of them, and are so much more sophisticated (such as Restaurant City and Pet Society). And PlayFish was merely acquired for $400 million. Some companies such as RockYou, had the number one app on Facebook, but wasn't even acquired for a low price like $200 million. And now just a photo filter app and sharing photos, and it is a business considered to be worth a billion dollars. Why is that?


Algorithm for fast tag search

The problem is the following.   * There's a set of simple entities E, each one having a set of tags T attached. Each entity might have an arbitrary number of tags. Total number of entities is near 100 million, and the total number of tags is about 5000. So the initial data is something like this:               E1 - T1, T2, T3, ... Tn     E2 - T1, T5, T100, ... Tk     ..     Ez - T10, T12, ... Tl      This initial data is quite rarely updated.   * Somehow my app generates a logical expression on tags like this: T1&T2&T3 | (T5&!T6)   * What I need to is to calculate a number of entities matching given expression (note - not the entities, but just the number). This one might be not totally accurate, of course.  What I've got now is a simple in-memory table lookup, giving me a 5-10 seconds execution time on a single thread. I'm curious, is there any efficient way to handle this stuff? What approach would you recommend? Is there some common algorithms or data structures for this? **Update** A bit of clarification as requested.   1. `T` objects are actually relatively short constant strings. But it doesn't actually matter - we can always assign some IDs and operate on integers.   2. We definitely can sort them.


What factors should be considered before deciding to build a message bus with SOAP services?

It would seem to me that the cost of having a team of developers build and maintain all the components necessary to provide routing, workflow orchestration, durability, security and the other features provided by a commercial ESB would be equivalent to, or even more than, licensing a commercial ESB. Other than up front licensing costs and perhaps architectural preference, what are important factors to consider when designing an integration architecture around building a message bus using SOAP services over licensing message bus software from a commercial vendor and integrating your business components with it?


is it a bad practice to call a View from another View in MVC?

I have some plain Views, they don't have any logic behind them (there is no action or controller behind them), their only propouse is to alert the user about something like "We have sent you an email to confirm your account", "You have no access to this resource", etc... These views are really simple, and calling them through a Controller/Action seems to be too much overhead, but somehow I feel like it is not quite correct. What do you think? How do you handle this kind of situations?? I guess this question will apply to any MVC Framework, but in my case I'm using the ASP.NET MVC 3 framework.


What is the best way to structure workshops for starting programmers?

We are planning to organize programming workshops for Java web developers with basic coding but no design experience. The goal of the workshops is to introduce these programmers to clean code. Focus Areas:   * TDD   * Four Rules of Simple Design      * runs all the tests     * contains no duplications     * expresses the intent of the programmers     * minimizes the number of classes and methods Structure:   * 6 full day coached workshops spread over 3 months using pair programming and pair-switching   * Each workshop contains      * four 15 minute presentations/demos     * four 90 minute problem solving exercises     * 4 minute pecha kucha's by every programmer Planned Katas for first workshop:   * prime numbers   * bowling game   * tennis scoring   * Arabic to Roman numerals conversion   * prime factors Do you think this is a good way to structure a programming workshop? Are there any elements that I could introduce to the workshops to make them more interactive and create more interest among developers? Edit 1: Summary of the feedback   * Create an interest in reading books.   * Have real project examples.   * Have contact with the group during off days.


Version Control based on portable storage?

I develop personal projects on two machines without use of a shared server or a network connection between the two. Do any common version control systems reliably support use of portable storage (such as a USB flash device) as the shared repository?


Why do organizations limit source code access to engineers?

Most organizations restrict access to the source code to engineers, and even at places like Google, the Android source code is kept off-limits to most engineers within the company. Why? Note: I am not talking about write access for everyone in the company, I'm talking about read access.


Plain old struct vs class in this case?

Stroustrup says that you should use structs unless you can specify an invariant for the data structure. I have to represent a physical object which holds things such as position, velocity, mass and inertia (and so on). I also want to render the object, for which I will need setup in the constructor and unloading stuff in the destructor. So I guess that's an invariant, but it feels wrong to put all this physics stuff into it that doesn't really have invariants. The drawing parts are pretty trivial, so it doesn't feel worth it to separate them from the rigid body in this case. Any advice? edit: I suppose I just realized the answer to my own question. Rigid bodies **do** have invariants, namely that it has to follow the physical laws.


How does SSL relate to the Public Key Infrastructure?

This is possibly a stupid question but, how does SSL relate to the Public Key Infrastructure? Cheers, J


Do i need to know how Ajax works since Asp.net provides me UpdatePanel

I am working on Asp.net webform and it already provides me ready to user Ajax solution by using an update panel, so should I invest my time learning how Ajax really work ?


Self-organization during Sprint Planning

During Sprint Planning there are a lot of decisions to be made:   1. How many PBIs should the team commit to?   2. Which tasks should constitute each PBI?   3. How much time should each task take? With no team leader it is not always easy to make all these decisions, since there will be some decision points (sometimes more than a few) in which the team members will disagree. I thought about a few options to deal with such disagreements when a consensus cannot be reached in a short period of time (we don't want endless arguments).   1. Let ScrumMaster decide    2. Let the person who will most likely work on the story decide.   3. Majority vote   4. Let the person who actually writes the tasks in Excel decide (in such case have a different person write the tasks for each story). I have two questions:   1. How to measure consensus? Should the Scrum Master ask each person whether they agree with every decision proposed?   2. When no consensus can be reached shortly, which option from the list that I proposed do you think we should choose, if any? Thank you!


Log within try-catch or after?

Should one log success of an operation within a try-catch-block, or after it? Example:               try         do x         log('successful')     catch         log('fail')     end      or is this better:               try         do x     catch         log('fail')     end     log('successful')      I would say that a logger should never fail, but what if, for some reason, it does anyway? In this specific case, I had a logfile on a network drive which disconnected due to actions of do(x), which however did not fail -- obviously my try failed, but my operation worked. However, I find the latter example harder to read, and I try to keep my code as tight as possible for readability.


Ideal & idomatic javascript interface for RESTful API

I am trying to write an angular service to interface with a RESTful API. For sake of simplicity, lets assume the API is               + Company     |___+ Department     |   |____ Person     |     |____ Person      > Notice how person can be under `Company > Department` or directly > under`Company`. Each of the entities (Company, Department and Person) > support add, edit, list and get_by_id. Which of the following interfaces is more idiomatic? ## Option 1:               // In all cases, get(), put() return $http promise          companyApi().get() // List all companies     companyApi(1).get() // Get company with ID 1     companyApi(1).departments().get() // List all departments     companyApi(1).departments(2).get() // Get department with ID 2     companyApi(1).departments(2).persons().get() // List all persons     companyApi(1).departments(2).persons().put(p) //Add a new person in department 2     companyApi(1).persons().put(p) //Add a new person in company 1     companyApi(1).persons(3).put(p) //Edit person with ID=3 in company 1     companyApi(1).persons(1).remove(p) // Delete a person      ## Option 2:               // In all cases, get(), put() return $http promise          // List all companies     companyApi({         type: 'company'     }).get();          // Get company with ID=1     companyApi({         type: 'company',         companyId: 1     }).get();          // Get department with ID=2 under company 1     companyApi({         type: 'department',         companyId: 1,         departmentId: 2     }).get();          // List persons under department with ID=2 under company 1     companyApi({         type: 'person',         companyId: 1,         departmentId: 2     }).get();          // Get person with ID=3 under department with ID=2 under company 1     companyApi({         type: 'person',         companyId: 1,         departmentId: 2,         personId: 3     }).get();          // Get person with ID=3 under department with ID=2 under company 1     companyApi({         type: 'person',         companyId: 1,         departmentId: 2,         personId: 3     }).get();          // Add person under department with ID=2 under company 1     companyApi({         type: 'person',         companyId: 1,         departmentId: 2,     }).put(personObj);          //Edit person with ID=3 in company 1     companyApi({         type: 'person',         companyId: 1,         departmentId: 2,         personId: 3     }).put(personObj);          // Add person under directly under company 1     companyApi({         type: 'person',         companyId: 1     }).put(personObj);


How do you formulate the Domain Model in Domain Driven Design properly (Bounded Contexts, Domains)?

Say you have a few applications which deal with a few different Core Domains. _The examples are made up and it's hard to put a real example with meaningful data together (concisely)._ In Domain Driven Design (DDD) when you start looking at Bounded Contexts and Domains/Sub Domains, it says that a Bounded Context is a "phase" in a lifecycle. An example of Context here would be within an ecommerce system. Although you could model this as a single system, it would also warrant splitting into separate Contexts. Each of these areas within the application have their own Ubiquitous Language, their own Model, and a way to talk to other Bounded Contexts to obtain the information they need. The Core, Sub, and Generic Domains are the area of expertise and can be numerous in complex applications.   1. Say there is a long process dealing with an Entity for example a Book in a core domain. Now looking at the Bounded Contexts there can be a number of phases in the books life-cycle. Say outline, creation, correction, publish, sale phases.    2. Now imagine a second core domain, perhaps a store domain. The publisher has its own branch of stores to sell books. The store can have a number of Bounded Contexts (life-cycle phases) for example a "Stock" or "Inventory" context.  In the first domain there is probably a Book database table with basically just an ID to track the different book Entities in the different life-cycles. Now suppose you have 10+ supporting domains e.g. Users, Catalogs, Inventory, .. (hard to think of relevant examples). For example a DomainModel for the Book Outline phase, the Creation phase, Correction phase, Publish phase, Sale phase. Then for the Store core domain it probably has a number of life-cycle phases.               public class BookId : Entity     {         public long Id { get; set; }     }      In the creation phase (Bounded Context) the book could be a simple class.               public class Book : BookId     {         public string Title { get; set; }         public List<string> Chapters { get; set; }         //...     }      Whereas in the publish phase (Bounded Context) it would have all the text, release date etc.               public class Book : BookId     {         public DateTime ReleaseDate { get; set; }         //...     }      The immediate benefit I can see in separating by "life-cycle phase" is that it's a great way to separate business logic so there aren't mammoth all- encompassing Entities nor Domain Services. A problem I have is figuring out how to concretely define the rules to the physical layout of the Domain Model. A. Does the Domain Model get "modeled" so there are as many bounded contexts (separate projects etc.) as there are life-cycle phases across the core domains in a complex application? **Edit: Answer to A.** Yes, according to the answer by Alexey Zimarev there should be an entire "Domain" for each bounded context. B. Is the Domain Model typically arranged by Bounded Contexts (or Domains, or both)? **Edit: Answer to B.** Each Bounded Context should have its own complete "Domain" (Service/Entities/VO's/Repositories) C. Does it mean there can easily be 10's of "segregated" Domain Models and multiple projects can use it (the Entities/Value Objects)? **Edit: Answer to C.** There is a complete "Domain" for each Bounded Context and the Domain Model (Entity/VO layer/project) isn't "used" by the other Bounded Contexts directly, only via chosen paths (i.e. via Domain Events). The part that I am trying to figure out is how the Domain Model is actually implemented once you start to figure out your Bounded Contexts and Core/Sub Domains, particularly in complex applications. The goal is to establish the definitions which can help to separate Entities between the Bounded Contexts and Domains.


What kinds of low level knowledge matter?

I realize that this question is similar to Low level programming - what's in it for me, but the answers didn't really address my question well. Part from just an understanding, how exactly does your low level knowledge translate into faster and better programs? There's the obvious lack of stop-the-world from garbage collection, but what else is an advantage? Do you really outperform your optimizing compiler? Do you pack your data structures in as tight as possible and be concerned about alignment? There's extra freedom naturally, but does that really translate into a faster program?


How can I manage a central repository of documentation?

Our team works with a large number of different APIs and services, and we also have our own internal tooling and services we maintain as well. Right now, we do not have a good centrally managed system to list which projects we used a certain API on, or to attach documentation for all of our utilities/apis. I believe what I am looking for is some type of team wiki, but we weren't impressed with the search capability of the the solution we tried (Sharepoint). Are wikis the right way to approach centralize documentation? What types of things should I be looking out for when creating a centralized documentation system?


Visual Studio Express vs. SharpDevelop

I need a bit of input from people who have used both of these programs. I am using Visual Studio Express 2010 right now for creating a project in VB.net and WPF 4. I just discovered a freeware IDE called IC#Develop, which apparently supports both of those formats. Has anyone used both, and if so, what are the advantages and disadvantages of each? Which would you recommend? Is IC#Develop a good alternative to the very expensive Visual Studio Ultimate?


What's the right way to fork/re-use code from an open source project?

Let's say I am working on an open source project and want to re-use a trivial utility function from another open source project (for example, a file search/replace function). Is it legal to copy the function and simply write a small copyright notice in top of the file? Should I include their name as copyright holders of the entire project in the license? Similarly, let's say I fork an open source project. Where and how do I specify that the copyright is shared between both the original copyright holder and myself? I guess the answer must somewhat vary according to the open source license but I'd like a general answer as much as possible. PS: I'm mostly concerned about the legal aspect, but feel free to include your ethical point of view.


Java vs PHP Memory / CPU Consumption

I work in a PHP based company. There is a project where we want to create a backend service. Senior members here are going for PHP, even though it is slower than Java. Their only point of contention, that Java is heavier than PHP in both memory and cpu load standpoint. Jvm is more like a container environment, if u bring in more baggage it will consume that much, but service we are talking here will be of medium complexity. So chances are that it won't be much demanding (or will it?) I understand this question leans heavily towards vagueness, however my point of ponder is, that is it always the same case? That java is more hardware demanding? I would just like to know opinions of all you experienced folks about how the actual scenario looks like.


What kind of bug is this?

My application has 3 shipping methods, the cheapest of which is free. The free shipping option is only available for orders totaling over $100. As soon as I built it, I thought of a way a user could easily circumvent this. Add items to the cart totaling over $100, then select your free shipping, then edit your cart to be less then $100 and maintain the free shipping. I fixed my application to not allow this. I started wondering though, what do you call this sort of design flaw? I know you can call it a bug, but is there a better description that I can use so that someone will understand what I am talking about?


Security through obscurity and storing unencrypted passwords

What exactly does "Security through obscurity" means in the context of stroing unencrypted passwords? I'm using a small program (I won't name it, to not enlarge enough large shame on its author) that uses my Google account for some tasks. I've noticed, that it stores my password in plain-text unencrypted file. Just a string, clearly seen to everyone, that can drag&drop it to Notepad or use `F3` in Total Commander. I have risen a ticket asking program author to fix this ASAP. I haven't got any reply yet, but my issue got one comment, that includes only above mentioned link to Wikipedia's " _Security through obscurity_ " page. How should I understand this comment? Is it pro or con my issue? At first I thought, that it supports my statement of fixing this ASAP. But then I found a Eric Raymond's Fetchmail example (in " _The Cathedral and the Bazaar_ "), who refused to implement config file encryption (passwords are stored in config file for Fetchmail), claiming that it is up to the user to assure security by not letting anyone "from the outside" access that configuration file. This statement (or refusal) is often brought as example of _Security through obscurity_. And looking from this point of view, I'm completely wrong and that program author is right. He do not have to implement encryption of file with my password, it can remain there, stored unencrypted and it is I, who is responsible for assuring security by not giving anyone access to this file or by deleting it each time I stop using that soft. (another question is, how can I achieve this on system as unsecure as Windows itself?) These seems to be in a complete opposition, to what I've been told and learnt for years, so I would like to ask more experienced developers, who is right here and how exactly I should understand "StO"?


C++: calling non-member functions with the same syntax of member ones

One thing I'd like to do in C++ is to call non-member functions with the same syntax you call member functions:               class A { };     void f( A & this ) { /* ... */ }     // ...     A a;     a.f(); // this is the same as f(a);      Of course this could only work as long as   * `f` is not virtual (since it cannot appear in `A`'s virtual table.   * `f` doesn't need to access `A`'s non-public members.   * `f` doesn't conflict with a function declared in `A` (`A::f`). I'd like such a syntax because in my opinion it would be quite comfortable and would push good habits:   1. calling `str.strip()` on a `std::string` (where `strip` is a function defined by the user) would sound a lot better than calling `strip( str );`.   2. most of the times (always?) classes provide some member functions which don't require to be member (ie: are not virtual and don't use non-public members). This breaks encapsulation, but is the most practical thing to do (due to point 1). My question here is: what do you think of such feature? Do you think it would be something nice, or something that would introduce more issues than the ones it aims to solve? Could it make sense to propose such a feature to the next standard (the one after C++0x)? * * * Of course this is just a brief description of this idea; it is not complete; we'd probably need to explicitly mark a function with a special keyword to let it work like this and many other stuff.


How far to go with unit tests

A question asked many times before but with a specific slant twds mvc development. I've been a very good boy and have been coding all my controller actions with corresponding unit tests which has been great (if a little [read a LOT] repetitive at times). To be honest, I've actually created a little T4 template to write most of the bare bones of the intial unit tests and then tweaked as appropriate as per usage. I will admit to not being quite sure how to handle tests in views that contain partialviews - but that's a story for another question. Now, the difficult part for me to decide upon is just how deep the coverage should be in my service layer. The reason being that some of my service methods (for better or worse) actually perform a variety of linq queries which then supply discreet information to subsequent logic within the method. I know i could (should??) break these methods down to only call the required logic for each linq statement and then apply them within the method. However, in many instances, there is never any reuse of the linq 'functions' and therefore it feels that this would refactor the code out a level too far. What I'm asking is, with complex logic occurring within a method, is it 'good enough' to have a test method that simply asserts the required result and/or expected error, or should every logic line be simulted and tested too. the way I'm seeing it, to do the testing correctly, then the method logic (line by line) should be getting some sort of coverage too. That however (in my naive opinion) could lead to a never ending cycle of trying to keep the test and the implemented method so closely aligned (which i know they should be) as to create a cottage industry in the tests themselves. I know my question may offend a few of the TDD devotees who will see this as a no brainer. Not being in the TDD camp, this is a 'yes brainer' for me, hence the question. btw - had checked this out for ideas: http://dotnetslackers.com/articles/aspnet/Built-in-Unit-Test-for-ASP-NET- MVC-3-in-Visual-Studio-2010-Part-1.aspx looking fwd to the steady downvotes now :) **[edit]** \- for the benefit of the single (well at the moment single!!) 'close' voter. this question is **not** subjective. I'm looking for concensus on a very focussed subject. I'm not attempting to stir up negative passions, I'm not looking to expose flaws in the technology - i'm a HUGE fan. So please, drop a polite comment for my benefit if voting to close as it may help me to restructure the question if there's ambiguity or misinformation. this question could benefit a large chunk of the mvc population. thank you!! jim


caching on multiple servers

Because we need to keep response times low, we get tons of requests, and we need to basically process ALMOST the same data (which I'll refer to as X) each request (the inputs are different though, so we can't cache responses), we are using a technique where we grab a new copy of X every 90 seconds from the database and store it locally in memory as a python list of dictionaries, on our application servers (we are using uwsgi). The kink in the machine: There are temporary analytics that we need to keep track of in those 90 seconds to adjust our data each iteration, and each iteration is dependent on what we calculate from the last iteration. The trouble with this is, we have multiple application servers that are storing the same data, X, in memory and each of those servers need to refresh X at the same time to keep calculations consistent for the next interval. I've tried some techniques, like broadcasting a message after each calculation to reload each server's X, but it hasn't been as effective as I would hope, and it just makes things more complicated. I should say, the reason we haven't used memcached or something similar is because we don't want to sacrifice any speed if we can. Maybe I am ignorant on how fast we can retrieve and load the list into python objects from memcached. I understand my explanation isn't the greatest, and will answer any questions to give a better picture of the situation. Edit: we are at about 5000 request/second, the size of the data we process is about 2MB at the moment but will continue to grow, so we'd like to avoid sending it over the wire for each request.


Team member missing? Glue between data producers and data consumers

We're in the business of automated trading and our team consists of two bigger groups, I call them data producers and data consumers. The producers' primary task is to maintain a chain of smaller tools that push some real-time data through an indicator system and out comes an order. All the data that was needed or produced is logged into files, one file per tool per run. The data consumers on the other hand, used to backtests and captured in their backoffice world, want to fragments of the data produced in the different runs, polished to their needs, more specifically one big post-processed chunk of data per day. **Now the problem** that has split our team into two well-distinguishable sides is that the data producers consider it their responsibility to provide comprehensive data without any loss of information and want the consumers to cherry-pick whatever they need in a _pre_ -processing step. The consumers on the other hand want to see live trading as a black-box, to them it shouldn't be different to the backtest which means the data producers in their eyes lack a crucial _post_ -processing step without which they can't start their task. Now clearly there has to be some glue between the two teams, my question is whose task is it? Or is there to be a third group in the middle that provides the glue? What does the theory say about this (can we apply the producer/consumer pattern to `real life')? And just to make the problem a real one: The data producers consider it ugly to boil down the data into consumable chunks, mainly because the consumers' side keeps changing their requirements. The consumers on the other hand are not skilled enough to do the proposed cherry-picking.


Adding unit tests to brownfield applications

I'm working for a company that has been developing a series of products for years with little to no unit testing in place. They want to move to TDD and unit test new code going forward. However, I'm concerned about the lack of testability of the old code and where to draw the line between old and new. Has anyone had experience with layering unit testing onto brownfield software like this? If so, could you recommend some effective approaches?


High resolution graphical representation of the Earth's surface

I've got a library, which I inherited, which presents a zoomable representation of the Earth. It's a Mercator projection and is constructed from triangles, the properties of which are stored in binary files. The surface is built up, for any given view port, by drawing these triangles in an overlapping fashion to produce the image. The definition of each triangle is the lat/long of the vertices. It looks OK at low values of zoom but looks progressively more ragged as the user zooms in. The view ports are primarily referenced though a rectangle of lat/long co-ordinates. I'd like to replace it with a better quality approach. The problem is, I don't know where to begin researching the options as I am not familiar either with the projections needed nor the graphics techniques used to render them. For example, I imagine that I could acquire high resolution images, say Mercator projections although I'm open to anything, break them into tiles and somehow wrap them onto a graphical representation of a sphere. I'm not asking for "how do I", more where should I begin to understand what might be involved and the techniques I will need to learn. I am most grateful for any "Earth rendering 101" pointers folks might have.


How Do You Organize Your Methods in OO Progamming

Whenever I am programming in an object-oriented language, I am always faced with what order and how to group the methods for an object. Are there any standards for this, or any suggestions?


Submit code during interview

I'm interviewing for a position at an internet startup. The position relates to doing data mining on their very large database of user information. As part of the (long-distance) interview procedure which involves examining a subset of their database, they requested that I submit the code I used for analysis. My main concern is that this code is "proprietary", for lack of a better word. I have no problems giving them all my code if I end up working for them, but considering that they could potentially take the code, not hire me, and use it on their larger database to generate revenue, I'm hesitant. Am I being just being paranoid? Is this a legitimate concern?


Can the csv format be defined by a regex?

A colleague and I have recently argued over whether a pure regex is capable of fully encapsulating the csv format, such that it is capable of parsing all files with any given escape char, quote char, and separator char. The regex need not be capable of changing these chars after creation, but it must not fail on any other edge case. I have argued that this is impossible for just a tokenizer. The only regex that might be able to do this is a very complex PCRE style that moves beyond just tokenizing. I am looking for something along the lines of: > ... the csv format is a context free grammar and as such, it is impossible > to parse with regex alone ... Or am I wrong? Is it possible to parse csv with just a POSIX regex? For example, if both the escape char and the quote char are `"`, then these two lines are valid csv:               """this is a test.""",""     "and he said,""What will be, will be."", to which I replied, ""Surely not!""","moving on to the next field here..."


good books about Scrum and XP

I want to know what would you recommend to read for Scrum and XP. I've got Scrum and xp from the Trenches, but I would like to see around some more references that are worthwhile.