title: Function pointers to object instance returned by function pointer

text: Im new to c++. I want to make a std::map with strings of get-method names mapped their respective get-method. These are to be looped over and present the value obtained by the get-methodtogether with the method name. I will loop over several instances of the type A. I have found that boost/function is very useful for storing the get-methods in A. However, A also has an instance of type B, with its own get-methods. How do I access the get-method in B? Here is my current code (The line `mapping["B_Nine"] = &B::(&A::getB)::nine` is wrong, but my best guess so far)...               #include <boost/function.hpp>     #include <boost/bind.hpp>     #include <boost/ref.hpp>     #include <iostream>     #include <map>     #include <string>     #include <functional>          class B     {     public:         B();         ~B();         int nine() {return 9;}     };          B::B()     {          }          B::~B()     {          }          class A      {     public:         A();         ~A();        int one () {return 1;}        int two () {return 2;}        B getB() {return b;}        B b;     };          A::A()     {           b = B();     }          A::~A()     {          }               typedef std::map<std::string,boost::function<int (A*)>> str_func_map;          int main()     {              str_func_map mapping;              mapping["One"] = &A::one;         mapping["Two"] = &A::two;          mapping["B_Nine"] = &B::(&A::getB)::nine //This line is wrong - how should                                                    //it be done correctly??              A* a = new A();              for (str_func_map::iterator i = mapping.begin(); i != mapping.end(); i++)         {             std::cout<< i->first << std::endl;             std::cout<< (i->second)(a) << std::endl;         }              system("pause");     }


title: Using the same keyboard shortcuts in every editor

text: I want to configure each IDEs/editor I use to have exactly the same key shortcuts. By default each IDE/editor has slightly different set of key bindings - even simple "close current tab" is bound either to CTRL+W or CTRL+F4. Is there already a set of config files (one for each IDE, editor, etc) with the same key binding configured?


title: Where does jQuery fit-in with frameworks like JavaScriptMVC, BackboneJS, SproutCore and Knockout?

text: I have been happily using **JQuery** for the last 2 years and have been quite sucessful creating some really cool functionality with it...so I am very comfortable with it. I also beleive the future of the web will continue on the current client-side path. **However...** The next challenge seems to be coming in the form of various controller frameworks: **KnockoutJS**, **BackboneJS**, **SproutCore**, **JavaScriptMVC** (the list goes on). Additonally, there are some great **AMD Loader** tools for use like **RequireJS** or **LabJS** etc. However, jQuery now has `define` and `then` capabilities baked-in. **It's getting harder-and-harder to keep track of it all...**   And now, my task seems to be to evaluate/decide-on a strategic-direction for using some form of either an MVC or MVVM framework client-side...but I have so many questions.   * Where does **JQuery** **fit-in** with the various controller-frameworks mentioned above?   * Is **JQuery** **used alongside** each or do some of them have their own ' **JQuery**-styled version' baked-in?   * Are tools like **RequireJS** **still needed** if you implement one of the various controller-frameworks mentioned above?   * Does the `define` and `then` capabilities baked-into **JQuery** **now supercede** the AMD Loader mentioned above?   * Which one seems most modular? (see notes below) **NOTES:**   One thing I don't want in any future-framework is the requirement of having to take-in vast amounts of functionality that I don't use. Meaning, I would rather use a framework that is truly modular. For example, to use jQuery UI you have to take-in a lot other core libraries that you might not actually use. I will be experimenting with each one, but some REAL feedback would be great. I've seen some 'similar' questions, but none have really answered the above skew. Thanks in advance!


title: Workflow for obfuscated PHP code with PHP protect

text: Let's say I have a database-driven web application written in PHP. After obfuscating the code with PHP protect it will be copied to a web hosting server. And here is the question. What is the workflow of a programmer when there is a bug in an application and he needs to edit the PHP code to repair it? It's clear, that he can't debug (and edit) directly the obfuscated code.


title: Mobile cross-platform SDK for computationally intensive apps

text: I am aware of the PhoneGap toolkit for creating mobile applications for virtually all mobile platforms with a significant market share. However, the code in PhoneGap that is shared between the different platforms is written in JavaScript. While I like JS, I think it's hardly appropriate for computationally intensive tasks. The situation with Titanium is pretty much the same. **So, is there any way that I can create a cross-platform mobile app that has the computationally intensive code shared between the platforms?** Some context: Obviously, I don't want to implement the time consuming algorithm in many different languages, since this violates DRY, increases the chance for bugs slipping in at least one version and require boilerplate code to work. I've looked at Xamarin's MonoTouch and Mono for Android tools, but while they cover iOS and Android, they're not nearly as versatile for deployment as PhoneGap. On the other hand, (IMO) the statically typed nature of C# is more suited for intense computation than JS. Are there any other SDK/tools appropriate for the task that I don't know about or a point about the mentioned above that I've missed? Also, uploading data to a web service for processing is not an option, because of the traffic required.


title: memory and time intensive php task

text: Sorry if this question has been asked before, but I couldn't find anything usable. I'm working on a project for a client and currently I have to loop through the users table which is about 3000 records and still growing. I have to do some calculations on a nightly basis which I am going to be using cron/php. The calculations script uses about 3.5mb of memory and takes about 1 second to run. When loading individual users my current php setup handles this fine, but if I try and loop through the user list my php script execution time runs out. I've read after doing some searching that I can make the page reload itself after each user calculation and just keep my previous place in the loop and this sounds like a good idea, but I wanted to hear some opinions from others that have handled similar situations and how you handled these types of tasks. Thanks.


title: Why some Javascript code needs to be written in different tags and not embedded within the same

text: When I was using the modernizr file, I came across this problem where in I need to source a file and call the script.               <script src="js/modernizr-min.js"></script>     <script>     if (!Modernizr.input.placeholder){           $('input[placeholder], textarea[placeholder]').placeholder();     }     </script>        Why is that the script does not work when embedded within the same script tag. I have across this situation many time, but failed to understand what causes this problem. Is that the scripts have to be written in two different script tags to make it work or else what fails it.


title: What is the most inspiring speech from a developer you ever watched?

text: _Please put a direct link to it._ **Required** :   * Still available online (please put a direct link to it)   * Must be a speech from a current or former developer   * Speaker's popularity doesn't matter   * Target audience should be other developers   * It is not required that the topic is programming (the task). I'm more looking for subject generally developing here within P.SE rather than SO.   * Explain why it was inspiring _(please, native english speaker, edit my question)_


title: Can Windows Phone development be done remotely?

text: Can Window Phone 7 or 8 development be done remotely, such as on an Amazon EC2 instance or a rented VPS running Windows, via using an RDP or VNC client from a PC running Linux (or OS X, or maybe even an iPad)?


title: What are the best practices for phasing out obsolete code?

text: I have the need to phase out an obsolete method. I am aware of the `[Obsolete]` attribute. Does Microsoft have a recommended best practice guide for doing this? Here's my current plan: A. I do not want to create a new assembly because developers would have to add a new reference to their projects and I expect to get a lot of grief from my boss and co-workers if they must do this. We also do not maintain multiple assembly versions. We only use the latest version. Changing this practice would require changing our deployment process which is a big issue (have to teach people how to do things with TFS instead of FinalBuilder and get them to give up FinalBuilder) B. Mark the old method obsolete. C. Because the implementation is changing (not the method signature), I need to rename the method rather than create an overload. So, to make users aware of the proper method I plan to add a message to the `[Obsolete]` attribute. This part bothers me, because the only change I'm making is decoupling the method from the connection string. But, because I'm not adding a new assembly, I see no way around this. Result:               [Obsolete("Please don't use this anymore because it does not implement IMyDbProvider.  Use XXX instead.")];             /// <summary>             ///              /// </summary>             /// <param name="settingName"></param>             /// <returns></returns>             public static Dictionary<string, Setting> ReadSettings(string settingName)             {                 return ReadSettings(settingName, SomeGeneralClass.ConnectionString);             }                  public Dictionary<string, Setting> ReadSettings2(string settingName)             {                 return ReadSettings(settingName);// IMyDbProvider.ConnectionString private member added to class.  Probably have to make this an instance method.             }


title: WWDC 2012 announced features on iOS 5?

text: I am relatively new to iOS development, so after watching a bunch of WWDC videos announcing new awesome features for the iPhone SDK, I still got a few questions regarding their support for older devices. Specifically:   * Do the new compiler features (such as literals support, auto-synthesize, etc) require iOS 6 on the target device, or can the new style code be deployed to iOS 5 devices?   * Auto-layout for iOS, same question. Will it only be supported on iOS 6, or 5 as well? If it's 6 only, what kind of fallback are we expected to implement? Would really appreciate if someone could clarify this for me, as I'm thinking about rewriting my older unfinished project and I would love to use some of that improved SDK functionality.


title: Turning a problem into a data

text: OK, I have an app that I'm creating but I'm just really not sure about how to approach the problem. The idea is fairly simple. I'm just not sure how to wrap it in a data model (or even if I should). TBH I feel like I'm making it more complicated than it needs to be. How it works. The app will have circles along the top in a row that need to be connected to circles along the bottom in a row. 10 circles at the top. 10 at the bottom. One connection per pair of dots. Anyway, I can get the dots to connect I'm just not sure how to wrap it in a data model so that I can analyse what has been connected and see if it is right or not. The circles will be questions and answers. I can make an array of `question` objects with a `question` and `answer` properties. I can then display these as the dot pairs. I'm just not sure how to record which questions have been connected to which answers. It is valid for a user to connect a wrong answer as they all get checked at the end. I was thinking of using SpriteKit but this isn't a restriction. I could use UIKit or something else. TBH, this question is fairly language free as I'm just after a way of modelling it.


title: How to present a stable data model in a public API that allows internal data structures to be changed without breaking the public view of the data?

text: I am in the process of developing an application that allows users to write C# scripts. These scripts allow users to call selected methods and to access and manipulate data in a document. This works well, however, in the development version, scripts access the document's (internal) data structures directly. This means that if we were to change the internal data model/structure, there is a good chance that someone's script will no longer compile. We obviously want to prevent this breaking change from happening, but still want to allow the user to write sensible C# code (whilst not restricting how we develop our internal data model as a result). We therefore need to decouple our scripting API and its data structures from our internal methods and data structures. We've a few ideas as to how we might allow the user to access a what is effectively a stable public version of the document's internal data*, but I wanted to throw the question out there to someone who might have some real experience of this problem. NB our internal document's data structure is quite complex and it could be quite difficult to wrap. We know we want to expose as little as possible in our public API, especially as once it's out there, it's out there for good. Can anyone help?   * How do scripting languages / APIs decouple their public API and data structures from their internal data structures?    * Is there no real alternative to having to write a complex interaction layer?  If we need to do this, what's a good approach or pattern for wrapping complex data structures that include nested objects, including collections? I've looked at the API facade pattern, which looks like it's trying to address these kinds of issues, but are there alternatives? *One idea is to build a data facade that is kept stable across versions of our application. The facade exposes a set of facade data objects that are used in the script code. These maintain backwards compatibility and wrap access to our internal document's data model.


title: Should you always pass the bare minimum data needed into a function in cases like this

text: Let's say I have a function `IsAdmin` that checks whether a user is an admin. Let's also say that the admin checking is done by matching user id, name and password against some sort of rule (not important). In my head there are then two possible function signatures for this:               public bool IsAdmin(User user);     public bool IsAdmin(int id, string name, string password);      I most often go for the second type of signature, thinking that:   * The function signature gives the reader a lot more info   * The logic contained inside the function doesn't have to know about the `User` class   * It usually results in slightly less code inside the function However I sometimes question this approach, and also realize that at some point it would become unwieldy. If for example a function would map between ten different object fields into a resulting bool I would obviously send in the entire object. But apart from a stark example like that I can't see a reason to pass in the actual object. I would appreciate any arguments for either style, as well as any general observations you might offer. I program in both object oriented and functional styles, so the question should be seen as regarding any and all idioms.


title: What are some Java patterns well-suited for fast, algorithmic coding?

text: I'm in college, and I've recently started competing in programming competitions with my friends. These competitions involve solving algorithmic problems quickly. It's a lot of fun, but there's one problem: I'm forced to use Java. (My teammates use Java.) **Background:** I'm a self-taught JavaScript programmer, and it hurts to write Java code. I find it very verbose and inflexible, and I feel slowed down when having to declare types and decide which of the eighty list data structure to use. I'm also frustrated about the lack of functional programming features and how verbose using regular expressions, arrays, and dictionaries are. As an example, consider the problem of finding the length of the longest string of consecutive characters in a given string. So the string `XX22BBBBccXX222` would give `4`, for the string of four `B`s. In Java, I'd have to loop through and manually count characters and manually keep track of the maximum. (That's at least as far as I'm aware -- I'm not as familiar with Java as I am with JavaScript.) In JavaScript, I'd find it like this:               var max = Math.max.apply(Math, str.match(/(.)\1*/g).map(function (s) { return s.length; }));      Much quicker and simpler, in my book. **The question:** what are some Java features, techniques, or patterns well- suited for fast, algorithmic coding?


title: Is there a Design Pattern for preventing dangling references?

text: I was thinking about a design for custom handles. The thought is to prevent clients from copying around large objects. Now a regular handle class would probably suffice for that, but it doesn't solve the "dangling reference problem"; If a client has multiple handles of the same object and deletes the object via one of them, all the others would be invalid, but not know it, so the client could write or read parts of the memory he shouldn't have access to. _Is there a design pattern to prevent this from happening?_ * * * Two ideas:   1. An observer-like pattern where the destructor of an object would notify all handles.   2. "Handle handles" (does such a thing even exist?). All the handles don't really point to the object, but to another handle. When the object gets destroyed, this "master-handle" invalidates itself and therefore all that point to it.


title: Storing documents in Database vs CMS in JSF, Seam, Hibernate application on cloud

text: I am about to start with an application using JSF 2, Seam 3, Hibernate and Hibernate search with the following characteristics:   * Users will be uploading documents (pdf, doc).   * There can be millions of documents.   * The application will be deployed in the cloud. Here are my questions:   1. What will be the best place to store the documents: a database or a content management system (CMS)?   2. If choosing a database, should I go with document oriented db?   3. Is there any integration between Hibernate and document oriented databases or CMS to fetch the documents and index it in Lucene? Basically I am looking for an approach that will be good for storing documents in the cloud, easy accessibility of documents for indexing and keeping performance in mind. Any suggestions / experience or link on this will be good.


title: Should I follow an open source project's documentation patterns even if they are bad?

text: I've considered making modules and the like for various languages and other open source things. Where documentation is not specified but rather is communal de facto standard or entirely ad hoc; should I try to improve from that standard in my code if it is not in-line with what I've learned to be good documentation from reputable sources ( _Code Complete_ et al)? Or should I maintain consistency over all, regardless of quality?


title: How to write a command interpreter/parser?

text: Problem: Run commands in the form of a string.   * command example: `/user/files/ list all;` equivalent to: `/user/files/ ls -la;`   * another one: `post tw fb "HOW DO YOU STOP THE TICKLE MONSTER?;"` equivalent to: `post -tf "HOW DO YOU STOP THE TICKLE MONSTER?;"` Current solution:               tokenize string(string, array);          switch(first item in array) {         case "command":             if ( argument1 > stuff) {                // do the actual work;             }     }      The problems I see in this solution are:   * No error checking other than nested ifs-else inside each case. The script becomes very big and hard to mantain.   * Commands and responses are hardcoded.   * No way of knowing if flags are correct or missing parameters.   * Lack of intelligence to suggest "you might wanted to run $command". And the last thing I can't address is synonyms in different encodings, example:               case command:     case command_in_hebrew:         do stuff;     break;      The last one might be trivial, but well, what I want to see is the solid fundations of this kind of program. I'm currently programming this in PHP but might do it in PERL.


title: Forward and backward fourier transform image in java

text: Can anyone suggest a java library to perform forward and backward Fourier transform on images? Either RGB or gray-scale or binary , that doesn't matter since I've converted the image to all these ;) I do searched but most of the image processing libraries like marvin, JAI etc don't have Fourier transform. So I thought anyone who have done this earlier could suggest me one


title: How to : Nextag and such other dynamic data pulling website

text: Yesterday, I came across Nextag which is a website for comparing prices of various products from different retailers. **Is this site automated?** Can the process of data pulling from various sites can be automated for comparison with each other. I tried understanding a hell lot, but could not realize this fact and now think that they ought to be manually managed because on every other retailer site, the product name was different and it was very hard to recognize a similarity for a specific product. I have made such a system in which one can add a product and then add the respective retailers and their pricess. Every thing is manual in here. Today, I will be entering the data into the system, but thought it would be better to know if there is a way to automate this thing. Or I am going the right way as there can't be an automation for such system, because the data has no similarities.


title: Design RESTful API to update a resource that belong to another resource

text: I'm developing an ASP.NET MVC Web Api with C#. I have the following two resources. Group:               public class Group     {         public int GroupId { get; set; }         public string GroupName { get; set; }              public User Owner { get; set; }              public List<User> Members { get; set; }              public List<Message> Messages { get; set; }     }      Message:               public class Message     {         public int MessageId { get; set; }         public string Body { get; set; }         public DateTime DateSent { get; set; }         public Group ToGroup { get; set; }              public User Sender { get; set; }         public User Recipient { get; set; }              public List<Link> Links { get; set; }     }      And I also have these two URIs. This one to expose `Message` resource:               "api/messages/{id}"      And this one to expose Group's Messages:               "api/groups/{groupId}/messages/{messageId}"      I use the second one to access directly to a group's message (I don't know if it is a good design). Now, I'm thinking which URI do I have to use to add a new message for a group. I think that I have to use the second URI to get a group's messages. And the first URI to add new messages. What do you think?


title: Confusion of the "stack" in Assembly-level programming

text: What is the "stack" exactly? I've read articles, tried comprehending it through my understanding, experience, and educated guessing of programming and computers, but I'm a bit perplexed here. The "stack" is a region in RAM? Or is it some other space I'm uncertain of here? The processor pushes bits through registers on to the stack in RAM, or do I have it wrong here? Also, the processor moves the bits from the RAM to the register to "process" it, such as maybe a compare, arithmetic, etc. But what actually can help understand, in some visual or verbal description or both, of how to implement the idea of a "stack" here? Is the stack actually the same in terminology with a "machine stack" meaning it's in RAM? * * * I know what a software stack is. I know about LIFO, FIFO, etc. I just want to gain a better understanding of the assembly level stack, what it is, where it is, how exactly it works, etc...


title: Storing IEnumerable as instance variable - is it a code smell to expect it to change?

text: I have something that works like a fixed size list - it's actually called `FixedSizeStack<T>` in my program. I will use it to represent the X last occured events. This event list will then be examined by different observers, and if they detect patterns they will trigger some action. Naturally, I see no reason for them to know of `FixedSizeStack<T>` \- to me it makes sense to present it to the actions as IEnumerable. I am considering giving them this event list in their constructors, then calling something like `PreviewEvent(Event e);` and `EventOccured();` and they will iterate over this IEnumerable. I feel a little queasy enumerating this IEnumerable multiple times, and making it part of the contract that the enumeration changes - do you think this is a reasonable method?


title: Should I put calculation logic in an Entity or in the Business Layer?

text: Recently I was faced a question about whether a simple calculation should be put in the Entity layer, or should the Entity be pure for just storing the raw data and leave the calculation logics in the business layer. So my question is whether it is sensible to encapsulate simple calculations in the properties in an entity class?


title: What is the difference (if any) between (null != $object) and ($object != null) when using PHP?

text: I am used to Java and therefore always think conditions are interpreted from left to right, i.e. there is a vital difference in `null != $obj` and `$obj != null` Now this seems not to be the case with PHP. Can I do something wrong in PHP when I always start with `null` on the left- hand side? Can I keep my behaviour from Java or do I need to train myself to do something else when dealing with PHP conditions?


title: What languages are the kids of today actually programming in? Does anyone have real data?

text: Back in the 80s colleges were teaching Pascal because it is easy to learn, while myself and many others like me were learning BASIC because it was not only easy to learn but accessible and also fashionable (for an extremely liberal definition of fashion) It has just occurred to me that empirical data on the actual programming languages kids are choosing to use should be a good indicator of which language would be the ideal first choice for educators. Please note that this question is not "what do you think is a good programming language for kids?"


title: Where do you optimize?

text: There are two areas to possibly optimize for speed in:   * Where the most time is spent   * The code that is called the most Which is the best place to start optimizing? Often code that is called the most often has low execution times already. Do you optimize the slower, less called areas or spend time optimizing the faster, heavily used areas?


title: Worst coding standard you've ever had to follow?

text: Have you ever had to work to coding standards that:   * Greatly decreased your productivity?   * Were originally included for good reasons but were kept long after the original concern became irrelevant?   * Were in a list so long that it was impossible to remember them all?   * Made you think the author was just trying to leave their mark rather than encouraging good coding practice?   * You had no idea why they were included? If so, what is your least favorite rule and why? * * * Some examples here


title: Is it good to review programs with seniors and boss even if it is working fine?

text: In my company, before delivery of any project, my boss asks my seniors to review programs written by me or other team members or sometimes boss also sits with us for review. I think it is a good way of getting knowledge, but sometimes when programs are working fine, they don't work same after review and I need to look again into my program. They says that review helps to optimize program and query execution, but can we prefer optimization over actual functioning of program?


title: Are "customizable" programming languages more widely used than not as "customizable" ones?

text: Are languages which are very customizable, like Python (see for example goto in Python, lightweight Python type-checking) and Javascript (see jQuery for one example of this) more widely used than languages which cannot be customized very much?


title: What is a widely accepted term for a string variable that would probably contain a file path and file name?

text: For functions that need to index files in a directory and rename them FileName0001, FileName0002, etc... I often need to write a function that splits the file name from the file path and rename the file. When I put the file name and file path back together, I don't have a very good name for the variable that contains both of them and I usually just wind up concatenating them every time I want to use them (usually using them as parameters for functions labeled either filename or filepath) so I never really know what I'm doing until I notice a lot of files being written in the same directory as my binaries. Anyway, what do I call a file name and a file path? I don't want to call it File, because that usually means the binary information behind the file. I don't want to call it URI because that usually means I've got some sort of protocol, which I don't. I just want a good way to denote "c:\somedir\somedir\somedir\somefile.txt" so as to deconfuse this mess I've just realized I'm in. * * * Please don't just list your personal preference. I think an excellent answer should "'site its sources". (as in, provide a link to a repository with a good example of the code being used as I described)


title: Approach on working with many programmers on one module/feature

text: How can 2 or more developers code a certain feature/module of a software? Let's assume that the module is big and feature rich. How would they prevent each other from overlapping their code? Say, we have the same method but is implemented in a different way. Do you think it might be better to have one focused at a specific feature only? Is a version control system like Git would help solve the problem? Is it correct that it allows developers to have these "branches" and then merge it later on? What's your take on this?


title: What applications for self-adaptive programs can you think of?

text: Hey everyone! By self-adaptive programs, I mean the programs which are able to adapt to specific situations. For example they are able to repair them selves or are able to change their behavior according to user's needs. Obviously they need some sort of A.I modules like Intelligent Agents or so on. My question is, what applications for these programs can you think of/exist? An obvious destructive (!) application could be a malicious program/virus which can change its strategy in attacking its victim based on some factors. The reason for this question is that I want to do some research on this topic as a university project and I want to know about different stuff and uses that could come into mind! Any response is greatly appreciated! :-)


title: Which is better: for valid buffer length?

text: This is a basic question. But, I think understanding this would be helpful to play with buffers in 'C'. Thanks. ## Scenario Just a sample snippet               char *test_buff = (char *) malloc(512); //allocate 512 bytes in heap memory.     bzero(test_buff, 512); //Reset buffer instead of Junk/garbage.     /* random code here to fill-in the buffer called "test_buff"...*/     ...     /* Send data to another host/system [this doesn't matter though]      * using buffer "test_buff".      */      sendto(sock_descriptor, test_buff /*buffer to send data*/, sizeof(*test_buff) ,...,...);  // option-1     /* OR */      sendto(sock_descriptor, test_buff /*buffer to send data*/, 512 /* actual malloced size*/ ,...,...); // option-2      ## Question   1. Which one of the two is better [between option-1/option-2] way of using buffer? I hope option-1 makes sense, as it has length/size of valid data bytes of send buffer or "test_buff" in this case. Thanks for your time and input.


title: What and all the areas of Linux a PHP developer should know about? (Like just commands of it or something advanced)

text: I've developed a website using PHP but I implemented it on Windows OS and hosted it on Windows server. I just searched the PHP job market to know the on-going technology requirement and to keep my knowledge up-to-date accordingly with the job market. I see more are asking for LAMP stack. I understand the sort of skills required for a developer in PHP and MySQL. But coming to the Linux and Apache what kind of the skills exactly companies expect from a developer? On what should I be focusing in case of Linux, Apache whilst developing my website using these LAMP stack? I am going to develop a new website and want it to be using LAMP. But I want to know what difference it makes? Why LAMP stack got more demand in the job market compared to WAMP ? Edit: Sorry I thought my question is creating confusion ... so I put my question in different words as What and all the areas of a Linux a PHP developer should know about? (Like just commands of it or something advanced) Note: I am Linux newbie


title: Is it wise to ask about design decisions made on a product during an interview?

text: I've been thinking about interview questions lately and I've been reflecting on bad interview experiences I've had in the past. One of particular note is where I had asked the interviewer why the team chose to use EJB 3 over Spring in their product. The interviewer pretty much tore my face off, yelling "Because Spring is not the be all and end all of Java software development, do you want this job or not?". In response to this, I told him that this probably wasn't the job for me and I promptly walked out of the interview. I was informed at the beginning of the interview that the company had high staff turnover, the product they were working was initially created in Modula-3 then ported to Perl and finally to Java. I was handed a 10 page booklet of technical questions covering Java, EJB, SQL and JDBC and I was asked questions about the technology stacks I've worked with. When prompted to ask questions, I felt it was reasonable to ask them about their technology stack and and get reasonable answers back, not to send the interviewer into flames. **Question:** Is it a good idea to probe on architectural choices taken in an interview? If not, why? From my own point of view, an interview is a two-way process. If the interviewers are testing me on my technical skills, I've got every right to ask them the same questions to: 1) Figure out what their mindset and attitudes towards developing software are. 2) Determine if their approach is in line with how I would approach problems of that kind. It's possible that the interviewer who got angry had poor interviewing skills and forgot that an interview is a two-way exchange. If I was asked this, I would have given a reasonable answer, but I certainly wouldn't have tried to put an interviewee in a state of meek capitulation where the head just bobs up and down with no conversation.


title: anyone familiar with these analytic questions?

text: So...my recruiter just called me to confirm my interview on Thurs. He also mentioned that I am going to be asked to answer for two analytic questions. He gave me a little bit about those questions.   1. There are eight balls. One of them is defective.    2. There are three incandescent light bulbs inside a room, but switches are placed outside. These are all he said. I think that these are not completed question. Anyone knows what questions these are?? Does my question belong to programmer.stackexchange.com? I thought it would because it is related to interview questions.


title: Syntax extension in weakly typed lanuages?

text: I like languages that give me the ability to extend the syntax of the language. At the same time, all the languages that I know will let me extend the syntax have relatively heavy type systems. Are there lighter-weight languages that allow the same sort of syntax extensibility? Or does flexible syntax require that you would be able to define new data types (and operations on those types)? Basically, I want the syntactic flexibility of Haskell without Haskell's type system. Is there a way to get this, or does that syntactic flexibility require the assistance of a type system? Examples of languages where I know the type system can be used to create new syntax are Haskell, C++, and Python. Possible examples of where syntax could be modified without a strong type system maybe Scheme, Forth, and Common Lisp. However, while I can see how to overload operators in the first list to generate new syntactic constructs, I don't know enough to know how to do it in the second list. Maybe the answer is for me to go read up on macros in Common Lisp. What I would like is a language with the conceptual simplicity of C, Lua or Erlang, but with the ability to create additional syntactic operators as desired. TLDR - basic summary of question: Is it possible for weakly typed language to support syntax extension, or does the ability to extend the syntax of a language (from within the language itself) require a type system to implement?


title: Working as a contractor--questions part II

text: This is a follow-up to this discussion: Working as a contractor--questions I still would like to get more info on the following points, when working as a contractor as opposed to direct employee:   * Housing: for short-term contracts (let's say 6 months or less) that are not in your home area, where and how do you search for short-term, flexible housing? Especially since an employer would typically want you to start immediately, so you don't have the time to go out and explore. Also, would you typically look for furnished apartments because the cost transporting your own furniture for a few months is not justified?   * Work hours and pay: are contractors more strictly supervised (as far as getting specified work done) because they get paid by the hour? There are also supposed to get overtime pay (at a higher rate) if they work more than 40 hours per week, does this really happen? Or do they work unpaid extra hours just like many regular employees?   * Some potential employers have mentioned paying the "per diem", which is essentially a non-taxable daily allowance, which is supposed to be used for living expenses. This money gets subtracted from you per-hour rate, but the advantage is that you pay less tax. However, from the information I have seen, the per diem can only be paid if you maintain a "permanent" residence you intend to return to. Is this checked in practice, and if yes, how?


title: Will adopting a DVCS mean there will be a positive impact on development speed?

text: I was wondering how safe is to say that —because developers are free to version and have better and more organic workflows— code will be delivered faster. A big factor here is team size of course, and I'd say the team is big enough to see this benefit (10-15 core devs, and maybe 5 to 15 more contributors to the common codebase). **Edit** : How development speed can be affected:   * Merging hell could be one of the cases that slow down people (DVCSs are much better at merging).    * Better workflows that ~~can pretty much only work~~ work more naturally on a DVCS **Integration Manager** ![Integration Manager](http://i.stack.imgur.com/IxVc7.png) **Dictator & Lieutenants** ![enter image description here](http://i.stack.imgur.com/63H5O.png)   * Ability to use version control (i.e. committing) without inflicting potentially unstable changes to everybody  I just want to know if anyone has seen such things help the overall speed of teams/projects as a whole.


title: Can I (reasonably) refuse to sign an NDA for pro bono work?

text: A friend of mine (let's call him _Joe_ ) is working on a promising project, and has asked me for help. As a matter of friendship I agreed (orally) not to discuss the details, but now he has a potential investor who wants me to sign a non-disclosure agreement (NDA). Since thus far all my work has been pro bono I told Joe I am not comfortable putting myself under documented legal obligation without some kind of compensation for the risk. (It needn't be strictly financial. I would accept a small ownership stake or possibly even just guaranteed credits in the code and documentation.) Is my request reasonable, or am I just introducing unnecessary complexity?


title: My colleague doesn't understand things he works with. What to do?

text: I've spent 3 days debugging one very obscure bug in a library made by my colleague, this bug happens very infrequently. After all I found that this bug happens due to cross-thread access to an object without any lock. Actually this is not a first bug of this kind, there were similar bugs before. He just runs his unit tests, and if something fails puts somewhere a lock. And if nothing fails, ughm, then his code is perfect. It seems he has no idea about threading safety. I'm 100% sure there are many similar bugs that just haven't surfaced yet. It seems PM doesn't understand threading stuff too.   The problem is, he works much more time in the company than I do. Anyway, I can't just say "this guy is incompetent in this area", because this always shows you as a "bad team player", etc.   Any ideas, what I can do?


title: Don't structure data all the way down

text: In the blog post Don't structure data all the way down, the author discusses different ways to structure a circle datatype and how to implement the parameters to a Radius function.               area({circle, {point,0,0}, 17.4})      Kind of messy. What about a function to build a circle for us? Then we could do this:               area(make_circle(0, 0, 17.4))      We could also have a shorter version of make_circle that only takes a radius, defaulting the center point to 0,0. Okay, stop, we're engineering ourselves to death. All we need is a simple function to compute the area of a circle:               area(R) -> math:pi() * R * R.      He is talking about the functions in the Erlang language, which is functional and not object oriented (OO). My question is, does this argument hold for OO languages, and does it hold for functional languages?


title: Release Planning in Agile/Extreme Programming

text: I've been studying couple of books of how to exactly implement agile. I am confused about release planning. Our application is a Insurance System consisting of different modules (Quoting, Policy Management, Claims management etc). During the first phase we are just planning to release Quoting and we are estimating approximately 4 months for it. Now my question is, do we have to identify user stories for overall system (including all the other modules) first before start working on our first release (i.e quoting)? Or is release planning is an iterative process too?


title: Flow Chart - While Loops process

text: I'm having difficulties understanding whether or not this is the right process to use for a flow chart which illustrates the processes involved in an algorithm. For this, assume the following: A 1D `X = [0, 1, 2, 3,........]` data block is split into 2D blocks:               x = {[0 1]}          {[2 3]}      For each of these blocks, the total energy is counted, if the total energy is less than the threshold value the block is removed. If the energy is higher, then it is kept and the algorithm moves onto the next block. Here's my flow-chart: ![enter image description here](http://i.stack.imgur.com/B2mcq.jpg) Now the way I look at this is that, I start the algorithm split the signal into frames, calculate the energy for each signal (2D) if the energy < theshold remove the frame AND THEN end the algorithm. If the energy is higher than the threshold, then, it looks that the signal block (2D) is passed back into the algorithm, the energy for the signal is re- calculated. My questions:- 1) Should there be a while loop that says "If at the end of the block"? 2) Should I specify that blocks of `x[n][n]` could be passed into the calculate energy? Alternatively, does this look fine and I should apply some description of how the process works in written text? Any help would be greatly appreciated :)


title: Scanning a billion rows in an ultra-fast database

text: ## Background A local database contains nearly 1.3 billion unique rows. Each row is indirectly associated with a specific latitude and longitude (location). Each row has a date stamp. ## Use Case The problem is as follows:   1. The user sets a starting/ending date, and a range of values (e.g., 100 to 105).   2. The system gathers all the rows that match the given date, grouped by location.   3. The system performs determines the locations that, during those dates, have a statistical likelihood of falling into the given range of values.   4. The system displays all matching locations to the user. This is a problem of speed and scale. ## Question What is the least expensive solution architecture you can imagine that would allow such a system to retrieve results for users in under five seconds? ## Current System The environment is currently:   * PostgreSQL 8.4 (upgrade is possible; switching databases is not an option)   * R and PL/R   * XFS   * WD VelociRaptor   * 8 GB RAM (Corsair G.Skill; 1.3 GHz)   * Quad core GenuineIntel 7 (2.8 GHz)   * Ubuntu 10.10 Hardware upgrades are acceptable. ## Update - Database Structure The billions of rows are in a table resembling:               id | taken | location_id | category | value1 | value2 | value3        * id - Primary key   * taken - Date assigned to the row   * location_id - Reference to the latitude/longitude   * category - A description of the data   * value1 .. 3 - The other values the user can query The `taken` column is typically consecutive dates per `location_id`, sometimes each location has data from 1800 to 2010 (about 77,000 dates, many of them duplicated as each location has data in the same date range). There are seven categories and the tables are already split by category (using child tables). Each category contains ~190 million rows. In the near future, the number of rows per category will exceed a billion. There are approximately 20,000 locations and 70,000 cities. The locations are correlated to city by latitude and longitude. Assigning each location to a particular city means finding the city's boundaries, which is not a trivial task. ## Ideas Some ideas I have include:   * Find a cloud service to host the database.   * Create an SSD raid stripe (great video).   * Create a table that amalgamates all the locations by city (pre-calculation). Thank you!


title: After 15 years of programming, how does one get out of it?

text: > **Possible Duplicate:**   >  I no longer want to be a developer This might seem like an odd question, but I think I've just about had it with programming. I used to enjoy back when I was 11 years old (I'm 31 now), and I actually got to be really great at it at an early age. In high school, I had already knew c++, design patterns and all sorts of things and was building fairly sophisticated stuff. Then web development became all the rage, and like a lot of people, I sort of got sucked into that - to the point where that's all anyone really wanted. To be honest, I've never liked it. After learning so many technologies and languages year after year, I'm a little sick of relearning the same sorts of things that I knew how to do before but differently. I am sick of learning the new bugs, design errors and idiosyncrasies of the new technologies over and over again. Sometimes it seems like we are regressing rather than progressing. The amount of languages you need to know just to get a web application up and running now is just disgusting. It's way more bloated then it should be. Things have just gotten a lot more complex now too. While I appreciate a lot of the frameworks out today that _try_ to make your life easier, it seems that debugging and knowing what's going on has become a lot harder. I've never come across more bugs in other people's code than I have in the last 1.5 years in my entire 15 years of programming. It is annoying, it sucks out a ton of my energy. I am just not passionate about this anymore. Learning and working with the technologies for their own sake is just a means to an end - it's not fun. I actually don't care about any of it anymore. Despite how simple things some things have gotten, it is amazing how trivial problems blow up into solutions that require 4 or 8 hours to fix... and these things have nothing to do with your actual application requirements - it's just fixing crap that other people got wrong. We're also in a era where frameworks and libraries need to hype their tools and they need to prove to you how easy they are compared to things that have come before... but they almost always make you jump through a billion hoops to doing something complicated. By the time you figure out how to achieve the complex requirements in the new tool, you've lost a lot of time that was more- or-less equivalent to the time it would have taken in the old technology. So what was the point of learning the new technology in the first place? While the old technology required more code, it was more generic and flexible. You could argue that learning the new quirks for these complex requirements build intellectual capital that can be used later, but by the time you need to utilize this knowledge a second time, there comes yet another new technology that makes this knowledge obsolete. With websites basically needing to be super rich client applications now, these beasts have become extremely hard to test. No longer can you just write the bulk of your code in a single language, and getting amazingly good at Javascript seems like a monumental task all on its own. We are in the era of mass specialization now, and that doesn't interest me because any projects I want to work on, I have to do by myself. How do I get out? I have decided that I'm just done with it all. I really want out. I have just invested so much time and energy into being a great software developer for most of my life, it seems sad that I'm basically going to throw it all away. **EDIT** After reading some of the comments, I think these are also problems. 1) Burnout. Regardless of how long I take a break, I have no interest in working on programming stuff when I need to start back again. 2) Not caring about writing "good" software anymore like I used to. You don't get rewarded for doing a job better than 99% of the programmers out there. Nobody cares if you do it well either. It's actually kind of amazing that skill and craftsmanship and care is not a value to most people in this industry. 3) Boredom. Writing mindless queries, business logic and pumping data to a view for so many years is just not interesting. After working on 1500-2000 database tables and the application logic that worked on them, I don't find any of this kind of stuff interesting or challenging. 4) Producing value. Nothing I work on really matters. Sure, it matters for the clients, but it doesn't really matter to me.


title: Need advice on making the transition from a .NET development shop to a Java shop

text: For almost all of my professional development career (15+ years) I have been working on or managing development teams that primarily use Microsoft technologies (VB6, ASP, ASP.NET, C#, SQL Server, etc.) I've recently been approached by a company that seems very interested in me for a job managing their development team, which happens to be a Java shop. Although I did recently take some college level Java courses, it was the typical programming academic environment, that is, lots of theory,excessive focus on syntax, and mostly console type apps, with only a trivial app at the end of the course with anything remotely resembling a modern Windowed UI. I'm not worried at all about the syntax elements, picking up new programming languages isn't all that difficult and C# is so similar to Java that I think it should be fairly seamless in that respect. However, thinking back over all the tools, frameworks and platform specific knowledge, lingo that I have amassed for MS development, I worry about how quickly I can get up to speed enough to be productive in that environment and earn the respect I will need to manage effectively a team of veteran programmers, who potentially may have biases against MS developers. Have any of you made the transition from a .NET shop to a Java shop? If so what were the toughest aspects of making the shift? Also, did you find it harder to get street cred on the team based on your experience in another platform? For those of you who already work on a Java team, how would you feel if a veteran .NET programmer/manager took over the reins of the team? What could that person do or say to make you feel more comfortable trusting them?


title: How do you keep track of your past projects?

text: After having hard time trying to remember details of my past projects several years ago I was wondering how programmers usually keep track of that? This kind of information comes handy with job interviews etc. Do you write down technologies used, challenges faced etc to some kind of "jumbo CV"? Or do you just trust your memory?


title: Objective-C As A First OOP Language?

text: I am just finishing the second semester of my CS degree. So far I learned C, all the fundamental algorithms and data structures (e.g., searching, sorting, linked lists, heaps, hash tables, trees, graphs, etc). Next year we'll start with OOP, using either Java or C++. Recently I got some ideas for some iPhone apps and got itchy to start working on them. However I heard some bad things about Objectice-C in the past, so I am wondering if learning it as my first OOP language could be a problem. Not to mention that I think it will be hard to find books/online courses that teach basic OOP concepts using Objective-C to illustrate the concepts (as opposed to books using Java or C++, which are plenty), so this could be another problem. **In summary** : should I start learning Objective-C and OOP concepts right now by my own, or wait one more semester until I learn Java/C++ at university and then jump into Objective-C? **Update** : For those interested in getting started with OOP via Objective-C I just found some nice tutorials inside Apple's Developer Library -> http://developer.apple.com/library/mac/#documentation/Cocoa/Conceptual/OOP_ObjC/Introduction/Introduction.html


title: How to appear very professional on my first freelance project?

text: I need some help on appearing very professional on my first freelance project. How / What should you do to achieve this? * * * **Background** : I started as a full time web developer 18 months ago, two promotions later I am now a senior software engineer. I've never had any problems with designing / developing / coding a complicated system. I thought I could use some help for Christmas and I started bidding for a project and now I have one - from a very reputable lawyers association in London. _I have no problem dealing with the actual implementation of the system, but I have no idea how to appear professional throughout the whole process._ **About the project** : This lawyers association are starting a distant training courses and in addition to having a website to show off all their clients etc, they want a students area where their students would log in, download course materials allocated to them etc.. and an admin section where they assign courses to students / create new ones / upload materials etc.. * * * ## Questions breakdown: 1) How should I start with the requirement gathering? Is using scrum a good idea, or should I use something like Volere Template - and what should I do with it? should I submit a copy to the client etc.. 2) How often should I meet the client? Would once a fortnight would be good? 3) What are the processes / protocols that I need to follow so that they would be satisfied with me and think that I am very professional 4) How much should I charge for the product? 5) How should I get a quote / contract / receipt for the whole project? **6) What are the steps that professional freelancers go through, during the life cycle of a project?** * * * **My Research so far** Looking at How much should I charge doesn't help.. I live in London, zone 1, though I have no idea how much a project of this size would cost. Help on this would be appreciated. How to be professional articles talks about the work / time management etc and not the actual process, what would real people do etc.. it's like academia theory, but not practical. * * * If this needs revising, please let me know, do not close it because of whatever reason, I will edit the question or details to fit the needs. Thanks for reading a lengthy question.


title: What modern alternatives to Numerical Recipes exist?

text: In the past, the Numerical Recipes book was considered the gold standard reference for numerical algorithms. The earliest Fortran Edition was followed by editions in C and C++ and others, bringing it then more up-to-date. Through these, it provided reference code for the state-of-the-art algorithms of the day. Older editions are available online for free nowadays. Unfortunately, I think it is now mostly useful only as a historic tome. The "software engineering" practices seem to me to be outdated, and the actual content hasn't kept pace with the literature. What similarly comprehensive yet approachable references should the modern programmer look at instead?


title: Why does HashMap allow only one null key?

text: A `HashMap` allows only one `null` key. Is it because it allows only unique keys? Or is there another reason?


title: What is the rationale behind entering email twice for registration?

text: Many web sites ask users to enter their email address twice, sometimes taking the trouble to disable copy-pasting. What is the logic behind this? Is this e.g. a security measure?


title: Is there a resource that explains the benefits of layered programming?

text: Let's say we have a winform application with a buttonclick event. The buttonclick handles everything from the UI configuration to the database call and data manipulation. So you end up with a method that is 100's of lines of code long. Outside the fact that this code can't be considered test-able for various reasons, this style of programming is fragile to change. I can talk bout OO, Anti-patterns, etc. The problem is that any distinct topic I can dream up requires a great deal of explanation to understand the potential benefits. Outside of finding a new job ( **lots** of businesses program this way), how can I teach these kinds of developers how to write better code? Obviously we can't sit around a round table and discuss pro's and con's all day due to time constraints and real work that has to be done. Although, training and intense training is the only thing I can think of to fix these problems. Not to say I write perfect code, I most certainly do not. I do believe there are certain best practices that should be followed as a rule E.G. OO in the context of .NET. The most common excuse I hear is "we can't write code fast enough if we do it like that".


title: Looking for a distributed locking pattern

text: I need to come up with a custom recursive object locking mechanism\pattern for a distributed system in C#. Essentially, I have a multi-node system. Each node has **exclusive write** permissions over _n_ -number pieces of state. The same state is also available in **read-only** form on _at least one_ other node. Some writes/updates must be atomic across all nodes, while other updates will eventually become consistent thru background replication processes, queues, etc... For the atomic updates I'm looking for a pattern or samples that efficiently allow me to mark an object as locked for **writes** which I can then distribute, commit, rollback, etc... Since the system has high-levels of concurrency, I'm assuming I'll need to be able to stack-up locks which will either timeout or be unrolled once the locks are released. The transaction or messaging pieces are not the focus of this question, but I've provided them for some extra context. With that said, feel free to articulate what messages you think would be needed if you like. Here is a vague sample of what I was envisioning although I'm open to any new ideas aside from implementing whole new products               thing.AquireLock(LockLevel.Write);          //Do work          thing.ReleaseLock();      I was thinking of using extension methods, which might look something like this               public static void AquireLock(this IThing instance, TupleLockLevel lockLevel)     {          //TODO: Add aquisition wait, retry, recursion count, timeout support, etc...           //TODO: Disallow read lock requests if the 'thing' is already write locked         //TODO: Throw exception when aquisition fails         instance.Lock = lockLevel;     }          public static void ReleaseLock(this IThing instance)     {         instance.Lock = TupleLockLevel.None;     }      To clarify a couple details...   * All communications are TCP/IP using a binary request/response protocol   * There are no intermediary technologies such as queues or databases   * There is no central master node. In this case, the locking arrangement is defined by the initiator of the lock and the partner which will honour the request with some form of timeout to govern its behaviour Anyone have any suggestions?


title: How to implement gestures to a toolbar made from custom view in Android or is it recommended approach?

text: I would like to develop a re-usable component of horizontal Slidable tool bar. I would like to try to develop a custom view instead of ActionBar.   My Custom-View extends VieGroup contains and custom image button class as child views. The custom-view contains multiple tool buttons. Is it recommended approach please? or do we have any better approach without using ActionBar. Minimum android version should be 4.0 and target is 4.x and one of the screen resolution is 480X640 in 4.7 inches screen. The re-usable toolbar would be used in different screens/views with in same and multiple apps. I understand that Action bar comes with many standard features of a tool bar including various gesture features.


title: Algorithm for pinning joints for use with inverse kinematics

text: I'm part of the development team for a 2D animation program. One of the key features of the program is the ability to pose figures using Inverse Kinematics. Although we have that part down, we need to be able to pin joints in their place so moving another joint won't move the pinned one, or any past it. This is currently working for single joint pinning with the current algorithm we're using. However it's a necessity for us to be able to pin multiple joints at once and the algorithm we're using just isn't designed to work with it, and everyone on the team is stumped as to a solution. Are there any algorithms out there for joint pinning for use with inverse kinematics, while keeping in mind that it will have to work for any kind of non-closed figure?


title: Strategy for code review before merge to master from feature branches

text: Me and my team use feature branches (with git). I'm wondering which is the best strategy for code review before merge to master.   1. I checkout a new branch from master, lets call it fb_#1   2. I commit a few times and than want to merge it back to master   3. Before I merge someone is supposed to make a code review Now there are 2 possibilities: 1st   1. I merge **master to fb_#1** ( **not** fb_#1 to master) to make it as up-to-date as possible   2. A teammate reviews changes between master head and fb_#1 head   3. If fb_#1 is ok we merge fb_#1 to master   4. Pros: no obsolete code in review   5. Cons: if someone else merges something between "1." and "2." his changes appear in the review, though they belong to another review. 2nd   1. A teammate reviews changes between the point of checkout (git merge-base master fb_#1) and fb_#1 head   2. Pros: we see exactly what was changed during working on the feature branch   3. Cons: some obsolete code may appear in the review. Which way do you think is better and **why**? Maybe there is another more suitable approach?


title: Should if/else statements be arranged by rareness of cases or difficulty of dealing with them?

text: In some code I'm writing right now, I have something like this:               if (uncommon_condition) {         do_something_simple();     } else {         do();         something();         long();         and();         complicated();     }      Part of me thinks "It's fine the way it's written. Simple cases should go first and more complicated cases should go next." But another part says: "No! The `else` code should go under the `if`, because `if` is for dealing with unusual cases and `else` is for dealing with all other cases." Which is correct or preferable?


title: Should I Aggregate Web API Errors?

text: ### The Situation We are writing a REST API that performs validation up-front. The code is written such that it tries to find as many errors as possible. However, each error might correspond to a different HTTP status code. Additionally, the client (the HTML) doesn't have a convenient way to parse/display the errors. ### The Question Is it better to just throw as soon as the first error occurs? Or should we do our best to aggregate the errors somehow? By the way, there is no requirement to try to handle as many as possible at once. I am not looking for an opinion. I was curious if there was a standard practice in REST. ### Why It Matters The current code is really complex. Some validation can only be run if other pieces are valid. So there is this explicit dependency between tests. It is complex enough that it warrants using a 3rd-party library. But I would rather just eliminate the cause of the complexity if I am going to spend time on it.


title: Why do so many hashed and encrypted strings end in an equals sign?

text: I work in C# and MSSQL and as you'd expect I store my passwords salted and hashed. When I look at the hash stored in an nvarchar column (for example the out the box aspnet membership provider). I've always been curious why the generated Salt and Hash values always seem to end in either one or two equals signs. I've seen similar things while working with encryption algorithms, is this coincidence or is there a reason for it?


title: Is there a name for the 'break n' construct?

text: In a conversation earlier this week I was discussing certain language features, and I realized I don't have a good word / phrase to describe a particular feature. Some languages, such as PHP, have a language construct which allows `break` and `continue` statements to accept a numeric parameter indicating which block should be affected. For example:               for ($i = 0; $i < 10; $i++)         for ($j = 10; $j > 0; $j--)             if ($j == $i)                  break 2;     echo $i;      Because `break 2;` causes the outer loop to break, the output is `1`. If this were `break 1;` or just `break;` the output would be `10`. C# does not have any such construct. The equivalent would something like this:               for (i = 0; i < 10; i++) {         bool broken = false;         for (j = 10; j > 0; j--) {             if (j == i) {                 broken = true;                 break;             }         }         if (broken)             break;     }     Console.WriteLine(i);      But of course, this could also be accomplished using a `goto`. So my question is, what do you call this? Is there a specific name for this "break _n_ " construct? I'd like to be able to say " _Language X has parametric break and continue statements_ ", or something like that.


title: What is your favourite/ideal development environment?

text: If you could describe your ideal development environment, what would it be? There are numerous things to take into consideration, including but not limited to:   1. Hardware   2. Software ( _Operating System of Choice_ , Paid vs. Free Software, ...)   3. Physical Environment (lighting, open-plan, location, ...)   4. An endless supply of coffee...   5. ... In other words, if you could tell your company what they could do to make your development experience there better, what would it be?


title: When interviewing programmers, are algorithm problem solving skills relevant for a job were solving such algoritm problems isn't normally needed?

text: Software created for some business domains don't require heavy use of algorithm problem solving skills on the job from the programmers working there. For example, a JEE developer might most of the time only need to move data from system to system, doing data transformations, then crunch that data for various reports, designing systems with well defined boundaries etc. As a programmer you are a problem solver and you should know how to solve algorithm problems. But some programmers haven't really been doing that since school if their domain of expertise hasn't required that skill, so the skill isn't up to date. For such domains, does it still make sense to have an interview selection that requires candidates to solve algorithm problems (like math problems, string manipulations, sorting arrays etc) or should the interview be focusing only on the skills needed for the particular domain?


title: How would you want to see software intellectual property protected?

text: Reading answers to this question \- and many other discussions of software patents - it seems that most of us as programmers feel that software patents are a bad idea. At the same time we are in the group most likely to lose out if our work is copied or stolen. So what level of Intellectual Property Protection does code and software need? Is copyright sufficient? Are patents necessary? As software is neither a physical object nor simple text, should we be thinking of a third path that falls somewhere between the two? Do we need any protection at all? If you had the facility to set up the law for this, what would you choose?


title: Unit testing best practices for a unit testing newbie

text: In recent years, I have only written small components for people in larger projects or small tools. I have never written a unit test and it always seems like learning how to write them and actually making one takes a lot longer than simply firing up the program and testing for real. I am just about to start a fairly large scale project that could take a few months to complete and whilst I will try to test elements as I write them (like always), I am wondering if unit testing could save me time. I was just wondering if anyone could give good advice:   1. Should I be looking at unit testing at the start of the project and possibly adopt a TDD approach.   2. Should I just write tests as I go along, after each section is complete.   3. Should I complete the project and then write unit tests at the end.


title: Algorithm Correctness and Complexity Analysis

text: If given an algorithm to traverse a graph (say with a breadth first traversal algorithm). And say you code it in the same manner described in this video tutorial shows (starting at 04:30 for breadth first). Then you were asked to do an Analysis of the correctness and complexity of the code. What things will you set your mind to think about in analysing the algorithm? I mean let us start with Correctness Analysis .. is it simply a matter of setting my algorithm to work on 100s and 1000s of different graphs and if the traversal of all of them is a success I say "Yep, I have analysed this and it is correct!" Or is there more to it? **How would you analyse the correctness of a piece of code?** Also complexity .. there are so many parameters to complexity, but I'm guessing with it being an Algorithm, it'll be useful to talk about that n metrics stuff, n to the power of 2 and so on .. that is complexity is it not? The higher the power of n, the more complex the algorithm. How can I figure out the power of n for some code? **How do you determine the complexity of an algorithm?**


title: Looking for good practices on managing branches and developers in Git

text: I a little while ago I joined a new development team and recently we had our first major release. We've used Git since the beginning of the project and by now are somewhat comfortable with it. However, now that the product is in the field, we are discovering new issues/processes that need to be established. Up to this point, everything we've done was by referencing the very popular successful branching model post, which indeed has been very helpful Currently we have the following branches, all live and all being updated:   * master - only released, stable code (tagged every time release is cut)   * develop - wide open. used for long term development   * hotfix-1.0.1 - branched off master's 1.0.0 tag for small, very targetted fixes which are already lining up   * release-1.1 - This is a small incremental release that we want to push relatively soon so we wanted to manage it separately from develop and to limit scope of changes. These are the merging rules we are establishing:   1. If a code change is made in release-1.1, it must be merged up to develop.   2. If a code change is made in hotfix-1.0.1, it must be merged up to release-1.1.    3. Nobody except for one team member should merge anything into master and that merge only happens when a product version is about to be shipped. My questions are:   1. When should the merges take place? As soon as the fix is applied in lower-level branch? Or periodically in chunks of changes? If periodically, how do you typically determine merge period?   2. Who should do the merges? Person making the original code change? Or one individual who would be designated as "Director of Git Services"? Reason I'm asking all this is because it seems that while Git is very flexible (and I do love that part about it), it also allows you to easily shoot yourself in the foot. With just few commands, someone could easily, and hopefully not on purpose, merge new development right into hotfix that should ship out in 2 days. Many of us are new to Git and we are still feeling our way around the tool. I was thinking how my other companies/teams handled such concepts in the past and I think the biggest difference is that most other source control products that I've used, work with individual commits, so each developer could be responsible for making sure his fixes are applied to the correct places. But with Git, when one developer runs:               git checkout release-1.1     git merge hotfix-1.0.1      ... after his commit, those commands will end up merging an entire branch including code that he has never seen before and may not be the best person to resolve, if there are any conflicts.


title: Shared context: good or bad?

text: RSpec allows users to share context across tests / examples, which would reduce the number of code lines in my app by a significant amount. On the other hand, somehow related to the question of sharing codebase between tests, one of the reasons why I'm using Factories and not Fixtures is because I don't want tests to be dependent on code stored outside the tests. Ryan Bates explains it better: > There’s a heavy dependency between the tests and the fixtures and we can > cause the tests to fail just by changing the fixtures. External dependencies > that are this strong aren’t a good idea and make the tests brittle. What's best practice here, to share context across tests or to have an independent context for each test?


title: Using node.js, how to serve content without using a framework like express?

text: I'm trying to learn node.js and create a web application, and although I'm doing my best to just use only node.js to create it, I'm having a very difficult time finding resources and examples that describe the process without using other frameworks or libraries. Specifically, how can I serve HTML and CSS content without using hard-coded string variables, but serving up HTML and CSS files dynamically using just node.js?


title: Are `break` and `continue` bad programming practices?

text: My boss keeps mentioning nonchalantly that bad programmers use `break` and `continue` in loops. I use them all the time because they make sense; let me show you the inspiration:               function verify(object) {         if (object->value < 0) return false;         if (object->value > object->max_value) return false;         if (object->name == "") return false;         ...     }      The point here is that first the function checks that the conditions are correct, then executes the actual functionality. IMO same applies with loops:               while (primary_condition) {         if (loop_count > 1000) break;         if (time_exect > 3600) break;         if (this->data == "undefined") continue;         if (this->skip == true) continue;         ...     }      I think this makes it easier to read & debug; but I also don't see a downside. Please comment.


title: Is "continue" and "break" in loops antipattern/bad practice in Java?

text: I see the main purpose of `continue` in programming, it can get you out from the rest of loop steps like:               while(condition1){       ... code ...       if(!condition2){         continue;       }       ... code ...       if(condition3){         break;       }       ... code ...     }      I understand that condition2 and condition3 might depend on the inner code so it makes handy to make a separate escape route from loop step. But does it mean the code should be refactored instead building escape routes, like rethinking the original condition1? I would say if I need several `continue` and `break` parts, I feel bad about my code, usually I am working without `continue` and I don't really miss it. An another use of `continue` and `break` which I can accept is optimalization, but I still have the same feeling about it like I told above. For some reasons I have feeling "using GOTO". **Am I right, if I am not, why?**


title: what are the advantages and disadvantages of putting code for an unfinished project on github

text: I'm stating to work on a project that I intend to release as open source via the githubs. What are the advantages of putting the code on github from the outset, as opposed to waiting until the project is in a working state before publishing. If it matters, this particular project is a C# app/service, and I have only a free github account (so I can't make it private and then pull back the covers later)


title: Better OOP in Javascript - multiple methods or methods with options?

text: Let's say I have an object like this:               function Foo() {       this.parser = new DataParser();     };      Within Foo I have a method that does something like this:               Foo.prototype.getResponse = function(message, callback) {       var payload = {data: message, type: 'normal'};       var response = this.parser.parse(payload, function(data){         callback(data);       });     }      Now, let's say that somewhere else I need to call `foo.getResponse()`. Most of the time I want it to run just like this, but on occasion I need the format of the `payload` to be slightly different - let's say I need to specify a different type. Would it be better to make a different method for this slightly different kind of request, like so...               Foo.prototype.getSimilarResponse = function(message, callback) {       var payload = {data: message, type: 'other'};       var response = this.parser.parse(payload, function(data){         callback(data);       });     }      ... or to take an option on `getReponse`, like so...               Foo.prototype.getSimilarResponse = function(message, type, callback) {       var payload = {data: message, type: type};       var response = this.parser.parse(payload, function(data){         callback(data);       });     }      ... or to do something else entirely? Using a `type` option in the example above is a lot more DRY, but I don't like the way it requires the caller to know about payload type, which is really the concern of `Foo` and doesn't need to be exposed anywhere else. How would you recommend approaching a situation like the above?


title: Training materials - books vs webcasts

text: I'm in process of selecting some training materials for our team. We mainly focus on C# (Silverlight and ASP.NET) I thought it would be a good idea to get some books (to keep us up to date) but also I ran into some websites that offer webcasts/workshops with annual subscriptions fees. I much prefer following some video and actually trying out some code rather than reading C# bible, hence I liked the idea. **Has anyone had any experience with those video/webcasts/workshop learning? Are there any good ones out there?**


title: How do you assign error codes?

text: How, when developing a medium sized project, do you identify, create and maintain error codes? I for the life of me can't think of a simple and clean method of doing so. Some of my ideas convert class names and method name into an integer string, but that is way to long to display to the user on top of the fact that method names and class names may change (hopefully not!). Others are just using an incrementing log system (ie. when ever I create a new error message, just add 1 to the last error message id). But that is just completely unorganized. **Edit 1:** To be more specific I am talking about error code such as: `Error 401 Unauthorized.`


title: How to get to level where one can charge $300/hr?

text: I've been a developer for financials/hedgefunds in the Northeast for about 9 years now. I'm a consultant and would like to stay that way. What do I need to do to get to around $300/hr? I've been a pure dev my entire career so it seems like doing more management would be required. Is this goal even possible?


title: What is the size of a reference variable in java. Can it be calculated?

text: As pointers in C require 2 bytes of memory size irrespective of the size of the data type they are pointing. So does the same thing applies to java references also ?


title: Wrapping constructor arguments

text: Given a base class with around 25 or so subclasses, I have found that adding an argument to the base constructor is painful.               protected AbstractController(Service1 s1, Service2 s2, Service3 s3){ ... }     public Concrete1Controller(Service1 s1, Service2 s2, Service3 s3) : base(s1, s2, s3)     public Concrete2Controller(Service1 s1, Service2 s2, Service3 s3) : base(s1, s2, s3)      Now that I need yet another object passed to my base controller, I am debating introducing a wrapper class and refactoring so that only a single parameter is required in the constructors of (most) concrete instances.               public class ServiceLayer     {         public Service1 S1 {get; private set; }         public Service2 S2 {get; private set; }         public Service3 S3 {get; private set; }              public ScheduledReportServices(Service1 s1, Service2 s2, Service3 s3)         {             S1 = s1;             S2 = s2;             S3 = s3;         }     }      Which will allow me to clean up quite a bit.               protected AbstractController(ServiceLayer sl){ ... }     public Concrete1Controller(ServiceLayer sl) : base(sl)     public Concrete2Controller(ServiceLayer sl) : base(sl)      Given the amount that this reduces clutter, I'm either a dope for not doing this to begin with or there's a valid argument against this kind of approach. I'd be interested in a) knowing what this "pattern" is called and b) if I'm going to regret it and if so, why?


title: The most important advice to a non-professional programmer

text: As an adjunct to my regular job (teaching) I have taken on the task of developing an appointment booking system to be deployed on the school's server (SQL Server 2008 R2 / IIS 7.5). I have been writing and programming web pages since the very beginning, so I have a good knowledge of the client-side (including jQuery). I also have some knowledge and experience in database programming (Access and mySQL). For the last several months I have been been teaching myself server-side programming (mainly via the Apress books on MVC3, ASP.Net and C#, as well as through the tutorials on Pluralsight.) I shall be developing the system in Visual Studio 2010, and have written one or two basic practice solutions in MVC3 that work fine on my local development system. My question: What is the single most important thing I should know or do as I embark on this project? (PS. I am committed to using MVC3, Entity Framework 4.1, C# and Visual Studio.)


title: How are the forwarding of requests normally managed in the Chain of Responsibilty pattern?

text: I was just experimenting with the **Chain of responsibility** pattern, implementing my own version. I'm currently reading Design Patterns, but I'm not really sure whether DP tells to stop your forwarding of requests when a single action is accomplished, or just continuing to the end of the chain. What I'm interested in is how this feature of the COR pattern is managed in most of cases. In my example below, I let the forwarding continuing to the end of my chain. I don't think you need any source, but you can anyway find it here. If **I missed some DP paragraphs** telling about this, please provide its location!


title: Has Little Endian won?

text: When teaching recently about the Big vs. Little Endian battle, a student asked whether it had been settled, and I realized I didn't know. Looking at the Wikipedia article, it seems that the most popular current OS/architecture pairs use Little Endian but that Internet Protocol specifies Big Endian for transferring numeric values in packet headers. Would that be a good summary of the current status? Do current network cards or CPUs provide hardware support for switching byte order?


title: What qualities does an "average" programmer have?

text: There's a lot of talk around this site and elsewhere about comparing the productivity of excellent programmers to "average" programmers. Likewise, there's talk of how to become a great programmer instead of an "average" one. Everyone can agree there are definitely some amazing coders out there, and lots more (very) subpar programmers. These are easy to define (designed and wrote a text editor in Assembly on a Nintendo DS over a weekend vs checks in copy-and-paste code that doesn't compile on a daily basis). But what qualities does an average coder have? This I think is important beyond just an academic discussion, such as making hiring decisions and sizing up where you are on the crappy-amazing scale. So what qualities does an "average" programmer have or should have?


title: What is the benefit of multiple return values

text: I feel as if a return statement should only return one value. When it returns multiple, things get confusing. I know since the return type in Java has to be declared, this is difficult to do, but in languages like Python it is a snap. Are multiple return values a sign of bad design or coding style? Python example                    def get_name():        # you code        return first_name, last_name


title: Should I structure my DBs based on the data's true form, or how I plan to use that data?

text: This is mostly a hypothetical question, but it's something I've been tossing around and I wondered what other people though. Here's a contrived example to illustrate: Let's say I'm building an app that lets users pick a few keywords and then shows them photos that are tagged with those keywords. On one hand, I could create `user`, `keyword` and `photo` tables which store the data entities as they exist. This would let allow me to easily change the function of the app without needing to change the underlying data structures, but it also requires several queries to fetch the data I need for the app. Or, I could just have a single `user-photos` table, and somehow stuff all the data in there. This would make it easier to pull the data I need for the app, but it would be harder to perform any other type of querying on that data. After all, a `user-photo` isn't really a _thing_ \-- it's just a convenient data structure for this one purpose. This might be a bad example, but the main thrust of my question is: should your database structure be based on the actual underlying entities they're storing, or can you use shortcuts to make it easier to use the data for your purposes?


title: Time complexity implications when designing shell scripts for large data/high number of files?

text: There are many questions about the performance of commands or scripts on the _U+L_ SE asset. As time is of the essence, this is often evaluated using the `bash` time _reserved word_ or the external `time` command and a subset of the target data, under average or no load. Yet there are scenarios which are either about a large number of files or just operations on very big files. In some instances a careful examination of what happens in the shell, intricate knowledge of command behavior, even hardware considerations, provide insight into efficiency. But benchmarking remains no simple affair. In one instance recently a community member made a comment about the _time complexity_ of a command, implying that since there was no _sorting operation_ \- and not merely no `sort` command - it would ultimately scale better with more data. The solution involved `awk`, whereas another solution involved for instance a combination of the `grep`, `sort` and `head` commands.   * Is this just an instance of "the simpler the better" - what are main implications of _time complexity_ when designing shell scripts which operate on huge data sets(number or size)?    * Beyond common sense and _sorting_ (an operation for which there is a seemingly high level of intuition about performance costs, even for a non expert), is there a well known _common time complexity_ example which would showcase how the concepts apply in practice to shell scripting?


title: Is Java instanceof operator considered reflection, and what defines reflection?

text: I had a discussion with a coworker today, whether usage of using the Java operator `instanceof` is a kind of reflection. And the discussion quickly evolved into what actually defines reflection. **So, what is the definition of reflection?** **And is the usage of`instanceof` considered "using reflection" ?** And in addition, if `instanceof` is considered reflection, then is polymorphism not also "using reflection"? If not, what is the difference?


title: How do you write unit test cases?

text: Sometimes I end up writing unit test cases for the code other developers have written .There are occasions when I really didn't know what the developer was trying to do (the business part) and just manipulated the test case to get the green line . Are these things normal in the industry ? What is the normal trend ? Are the developers who wrote the code supposed to write the unit test cases ?


title: Is there a name for a testing method where you compare a set of very different designs?

text: "A/B testing" is defined as "a method of marketing testing by which a baseline control sample is compared to a variety of single-variable test samples in order to improve response rates". The point here, of course, is to know which small single-variable changes are more optimal, with the goal of finding the local optimum. However, one can also envision a somewhat related but different scenario for testing the response rate of major re-designs: take a baseline control design, take one or more completely different designs, and run test samples on those redesigns to compare response rates. As a practical but contrived example, imagine testing a set of designs for the same website, one being minimalist "googly" design, one being cluttered "Amazony" design, and one being an artsy "designy" design (e.g. maximum use of design elements unlike Google but minimal simultaneously presented information, like Google but unlike Amazon) **Is there an official name for such testing?** It's definitely not A/B testing, since the main component of it (finding local optimum by testing single-variable small changes that can be attributed to response shift) is not present. This is more about trying to compare a set of local optimums, and compare to see which one works better as a global optimum. It's not a multivriable, A/B/N or any other such testing since you don't really have specific variables that can be attributed, just different designs.


title: vim (or other text editor) ability as a metric for potential tech job candidates

text: Not sure if this is a "subjective" question or not. I'm thinking about hiring a mid level java programmer and came to the realisation that all the competent programmers that I've worked with had a very strong knowledge of their chosen editor. My chosen editor is vim (sometimes I use it as a plugin in IntelliJ IDEA). So in the case that someone puts that they use vim to program with I was considering giving them a couple of quick tasks to see how they go about it. Something that you could do in varying different ways. For example today I had a xml file with placeholder strings of the form               <?xml version="1.0"?>     <root-element>        ....xml....        ${placeholder.here} some text ${placeholder.there}         and some more text ${placeholder.everywhere}        ....xml....     </root-element>      and wanted to convert it into a string that I could then paste as a java string array literal, sorted alphabetically. e.g.               ["placeholder.everywhere", "placeholder.here", "placeholder.there"]      Has anyone used this kind or metric in their interview process and if so what were the results? If you did use editor ability as a metric, what editing tasks did you set? Any problems with using this as a indicator (obviously amongst other criteria) of ability?


title: Why has the rate of programming language popularization slowed down in recent decades?

text: If I understand correctly, there was a huge birth of programming languages during the early decades of computing, but then things have stabilized. Basically, why are many universities and industries still using languages such as C and C++ (which were created decades ago), when there have been plenty of decades since then to improve upon and create more effective (and human- friendly) languages?


title: Restrictive routing best practices for Google App Engine with python?

text: Say I have a simple structure:               app = webapp2.WSGIApplication([         (r'/', 'pages.login'),         (r'/profile', 'pages.profile'),         (r'/dashboard', 'pages.dash'),     ], debug=True)      Basically all pages require authentication except for the login. If visitor tries to reach a restrictive page and he isn't authorized (or lacks privileges) then he gets redirected to the login view. The question is about the routing design. Should I check the auth and ACL privs in each of the modules (`pages.profile` and `pages.dash` from example above), or just pass all requests through the single routing mechanism:               app = webapp2.WSGIApplication([         (r'/', 'pages.login'),         (r'/.+', 'router')     ], debug=True)      I'm still quite new to the GAE, but my app requires authentication as well as ACL. I'm aware that there's `login` directive on the server config level, but I don't know how it works and how I can tight it with my ACL logic and what's worse I cannot estimate time needed to get it running. Besides, it looks only to provide only 2 user groups: `admin` and `user`. In any case, that's the configuration I use:               handlers:     - url: /favicon.ico       static_files: static/favicon.ico       upload: static/favicon.ico     - url: /static/*       static_dir: static     - url: .*       script: main.app       secure: always      Or I miss something here and ACL can be set in the config file? Thanks.


title: Useful versioning scheme for a git project?

text: I have a small github project, which I need to add an option to to output some version number on the commandline. The problem is I have no idea how to "compute" the version number. Is this some random process? Should I just start at 1.0 (probably creating a tag or something), and put a number after `.` for fixes? I know this question is a bit vague... I just had never to deal with this, and want to use some sane versioning scheme. **EDIT** Im also interested into how to update this version number automatically, maybe using something like a git hook.


title: Best advice for game programmer who wants to go indie?

text: So. I'm working right now as an intern in a mobile game development company. I've used Unity quite a lot for 1 year now but, that's about all the experience I have with game design/development. Here's the things. I wanna go indie, the main reason is for fun, I really enjoy games and by making indie games I believe I can let my imagination fly and make personal personal stuff. Unfortunately I...I just don't know where to start! I'm interestes in making mobile and web games so what...should I download Stencyl? Construct 2?...XCODE for iOS, maybe a great plugin for Unity would be fine? What whould be your single best advice for someone like me? (programmer and interestes in design) :)


title: Efficient Data Structure for holding a graph

text: Problem Link - http://opc.iarcs.org.in/index.php/problems/NUMTRIPLE In my opinion, the problem can be solved by a data structure, that shows how each number is connected to another, and via recursion find the smallest possible value. But my question is, what data structure (most efficient) can hold/represent such data? Also, is there a better (faster) way of solving this problem. Thanks