title: Is it an anti-pattern to use void* and enums to enable type-checking?

text: Say in a game engine, you have `Object`s that composited of different components. One of these is a `RenderComponent` which can be either a `Mesh`, a `Sprite` or a `Light`. Now, all these are vastly different classes with non-complatible interfaces, so deriving them all from `RenderComponent` makes little sense. Also, an `Object` can only have one `RenderComponent` at a time, so you saving three pointers in `Object`, two of which must always be `nullptr`, seems wasteful. So what I came up with is using `RenderComponent` to store a `void*` pointer and the type.               class RenderComponent{     public:         enum class RenderType{             Mesh, Sprite, Light         };              RenderType getType(){ return type_; }              Mesh* asMesh(){              if(type_ == RenderType::Mesh)                 return static_cast<Mesh*>(pointer_.get())              else                 return nullptr;          } /* the same stuff for Sprite and Light */              RenderComponent(unique_ptr<Mesh>&& pointer) :             pointer_(std::move(pointer)),             type_(RenderType::Mesh)         {} /* the same stuff for Sprite and Light */          private:         unique_ptr<void> pointer_;         RenderType type_;     }      It should work as intended, but I feel like this is an anti-pattern. I'm basically discarding all typesafe aspects of C++ and then reimplement them myself. This can't be right. So, is this an anti-pattern? What are common workarounds for this problem? Am I missing something obvious? Or is this a known, but (for good reason) only rarely used pattern?


title: Using Twitter share and Facebook share

text: Hi I m trying to use **Social Plugins** in my website For a Tweet on Twitter   `<a id="twitter-link" href="https://twitter.com/share" class="twitter-share- button" data-lang="en" data-size="large">Tweet</a>` I have included the above line my url is something like this   localhost:3000/#a=abc `to give it a faster response i used a location.hash instead of changing params so to avoid reloading the webpage` so when any user clicks on any image the url changes to localhost:3000/#a=def but the twitter share button tries to shares the url `localhost:3000/#a=abc` How can i solve this?   Thanks in advance!!


title: Async function iterated calls

text: I'm new to using async calls in ajax. My problem is that I have two server "tasks": one that just checks if session is set (fast), and another that sets the session (slower). I want to check if the session is set and if not, set it. And I want to try X number of times (I'm unsure if I really need to but that, but that is another question). If I just do it with a “while” or a “for” and not do think about that it is async, I will generate problems like to many calls, and it will not be check session then set session. I could to it on the server, but I do not want to send the request data if session is set, only if it is not set. Below is the way I'm trying to do it now, but I'm unsure if there is a better way of doing it? The code below just implements the idea and is not tested. The idea is that send the counter back and forth between checking and sending session in the success function. What I do not like about the code is that the set session really is just understandable in context of checkSession. If I in some time come back to the code and just want to setSession, I would have a magic number of X to make sure it does not check the session also. Is there a smoother way of doing this? If the code smells even worse, please tell me.               self.start = function() {         self.checkSession(0);     };     self.checkSession = function(count) {         server.CheckSession(function(returnValue){             if(returnValue == false && count < 4){                count++;                self.setSession(count);             }},function(err){});};     self.setSession = function(count) {           var sessionData = someData;           server.SetSession(sessionData, function(d){               self.checkSession(count);     }, function(err){});};


title: Populate date to jList in netbeans (Java)

text: I created a jFrame using netbeans, Here is a screenshot on how i want the data to be added in to jList, From A to B. ![enter image description here](http://i.stack.imgur.com/LyTxa.png) Can you show me how i can do it?


title: Use of Abstract Syntax Notation (ASN.1)

text: The problem of Electronic Data Interchange over networks is well known and understood. Today, the most common formats for data interchange are things like XML and JSON. There are various pros and cons of using one format over the other, and certain formats lend themselves better to certain data-sets. I've been programming for quite some time now, and I've only just NOW come across the **ASN.1 (Abstact Syntax Notation)** format, which is apparently used in certain Internet protocols such as LDAP, and is actually quite old (in Internet years). I read a bit about the format. Like JSON, it provides primitive data types (boolean, integer, etc.) and also sequence and set types. It's a bit different from JSON or XML in the sense that, while the notation itself is human readable, the encoding is usually not human readable (it is usually encoded in a binary format.) Is there some reason why this format is so rarely used? (Or am I totally wrong, and it is actually used often?) I've only just now heard of it for the first time, and I've never heard it come up in any of the various discussions I've read about the merits of JSON, YAML, XML or whatever interchange format. Is there some major drawback to ASN.1 that prevented it from being more widely used?


title: Brainstorming questions to elicit features in new software version?

text: Because of a change in technologies, we are doing a major version change in our in-house enterprise software. I am going to be doing the usual of interviews, observations and brainstorming sessions. What general (and fun!) questions do you recommend/use in a first pass to elicit the discovery or remembrance of new functionality or changes to existing functionality? (Too much literature on requirements gathering tells you the easy part: how to get details on functionality. Nobody seems to have much on actually eliciting the function at first!) Examples:   1. You have a magic wand. You can wave it and change one thing about General Software v1.0. What would you change, how and why?   2. Have you used any software where you wished something in it was also in General Software v2.0?   3. What functionality is too complicated in General Software v1.0?


title: Model-View-Controller and client-side concurrency responsibility

text: In a web application that has a significant ajax component, where is the best place for the client-side concurrency responsibility to lie? We're trying to use MVC on both the server application (LAMP stack) and the client application (ajax, mostly jQuery and unobtrusive js). On the server-side, our model throws an exception if it finds a concurrency conflict that it can't solve on it's own. Essentially, the model tracks a revision number and date/user of creation and update. If the object being saved is out of date (older revision than in the data store), it attempts a merge. If it fails, the controller handles the exception and initiates some kind of resolution workflow. The issue is with the client application; since ajax runs requests asynchronously, the model doesn't necessarily have the latest version of the data, but only the controller would know that--it is responsible for handling the queue/polling. The original idea was to pass all the updates fetched from the server directly to the javascript models for handling the concurrency-- problem being that the lack of exceptions in javascript limits us to making flow-control decisions in the model that way. Is it a bad idea to move the merging/model-conflict-resolution into the javascript controller? Is there a better way to handle this without the controller getting to far into model land? Flow of the page:   1. User loads page(ajax application) with initial models--the models are numerous and have many attributes.   2. Page polls server for updates every 10-15 seconds--this is for auto-save and getting updates from other users.   3. User edits models.   4. Any conflicts that arise after initial entry are resolved when the user clicks the "save" button at the bottom of the page.


title: Bare minimum on the Joel Test

text: From the Joel Test, of the 12, which do you think are the absolute must-haves to at least have a decently running software department/company? I realise there is no absolutely right answer. I'm just trying to get opinions of others out there. My own organization only manages a measly 5 of 12. If you check listings on Careers 2.0, most companies don't score a full 12 either but I'm sure they're doing fine. Does SO publish the stats for those anywhere? Or has anyone tried scrapping the results? Would be interesting to know which are practised the most. And whether because they are easier to implement or whether they actually have the most impact. Thanks. EDIT: These are the ones practised by my company and for the given reasons   1. Having source control. - Have to agree with one of the answers that that is the one I would not negotiate about.   2. Fix bugs before writing new code. - Matter of principle but not a must-have.   3. Have a spec. - In a small software house with tight margins, specs save life. But I could see it done away with in other companies without affect.   4. Candidates write code during an interview. - Saved us hiring the wrong candidate many many times over. This is the other non-negotiable must-have for me.    5. Hallway usability testing. - Easy for us. Our whole office is a hallway. It's really easy to grab people anytime. But that also means we don't have a quiet working environment for developers.


title: Should I make a variable readonly when I modify it, but I don't actually set it outside of the constructor?

text: ## Background: I was writing some code. It looked something like this:               class X     {         private List<int> _myList = new List<int>();         public void MyMethod(int x)         {             _myList.Add(x);         }     }      R# suggested that I make `_myList` readonly. I wasn't so sure, as though I technically could make it readonly, I think it would be slightly confusing to do so, as I'm still modifying the list, just not reassigning it. So while I could make it readonly, I'm not sure if I should. ## Question: Should I make variables like this readonly? **Why?** If not, why does R# suggest this?


title: Designing Algorithm Flowchart Application

text: I need to develop an GUI application in C# where users can freely add conditional/statement blocks on the algorithm flowchart like the one shown below. By freely, I mean users can add a block on wherever the arrows are. I'm having some problems brainstorming how to approach this problem, especially what to choose for my datastructure to store the blocks. I was thinking LinkedList since everything follows a linear fashion and every node always has a head and tail, but the If/Else block (b>a) has two branches (heads) to store, so this complicates things a little bit. How would a smart one approach problems like this? My apologies if this question isn't suited for Programmers stackexchange, but this is more of a conceptual problem rather than implementation problem so I figured this place was appropriate for the question. ![enter image description here](http://i.stack.imgur.com/FSS4W.png)


title: Shortest Common Superstring: find shortest string that contains all given string fragments

text: Given some string fragments, I would like to find the shortest possible single string ("output string") that contains all the fragments. Fragments can overlap each other in the output string. Example: For the string fragments:               BCDA     AGF     ABC      The following output string contains all fragments, and was made by naive appending:               BCDAAGFABC      However this output string is better (shorter), as it employs overlaps:               ABCDAGF     ^     ABC      ^      BCDA         ^          AGF      I'm looking for algorithms for this problem. It's not absolutely important to find the strictly shortest output string, but the shorter the better. I'm looking for an algorithm better than the obvious naive one that would try appending all permutations of the input fragments and removing overlaps (which would appear to be NP-Complete). I've started work on a solution and it's proving quite interesting; I'd like to see what other people might come up with. I'll add my work-in-progress to this question in a while.


title: ASP.NET MVC - Dynamic Views with many similar controls

text: I have a main View which has several sections and a main dropdown at the top which defines how the rest of the view looks like. All these sections have some data that is visible all the time, and some that need to be hidden when certain values are chosen in the main dropdown. As of now, I have partial views for each section, and I am having lots of if/else statements in my view to show/hide the specifics, which is getting clumsier by the day.


title: Documenting higher-level concepts

text: I will be leaving my current project in a few days, and as part of securing my knowledge I have been asked to add comments to the code wherever I feel that can add value. The problem I am running into now is that the comments I want to write are not really suitable as comments, because they do not pertain to a single entity in the code (a few lines, a function, a class or even a file), but they are more about how two or more entities interact with each other or about a feature whose implementation is spread over multiple entities. So, how do you go about documenting the stuff that does not belong to a single entity but is important to know to understand the bigger picture? And also: Where do you document it? In the source file or in an external document? As an example, we have a client-server architecture in C (with the client and server both running on the same embedded device). To avoid flooding the server, the client has a mechanism to throttle the sending of similar requests to the server such that a request can only be sent if the previous one has been answered. The innards of this mechanism are spread over multiple functions. Where would you place the documentation of such a feature, especially if the file with the functionality also has some other, unrelated, functions? **Edit** : Extended the question a bit.


title: Web Service REST clarification

text: I'm new to web-service programming, and I'm unsure of a few things. I know that REST web-services can be used to interact with the system like this:   * to retrieve a user: GET /user?id=1   * to retrieve all users: GET /user   * to insert a user: PUT /user?{all user data} When I need to do an update action for some tables using a JSON object can this be done with a REST API or does it need to be some other interface? If is REST, what is the right method (GET, POST, DELETE, etc) to use? Is it correct to have two type of patterns in the same web-service?


title: Some Insight on the Field of Knowledge Representations and Reasoning

text: I started following an MS in computer sciences after about two years of work for a software company. I worked primarily in data warehousing and business intelligence related software development during my previous occupation. There is a high chance for me to select a research in knowledge representations, ontologies and reasoning, as there are no other research available in any other interesting fields, such as pattern recognition and navigation. I developed an interest towards knowledge representation with what I learnt from the courses I am taking currently. But I do not have a deep understanding of it in terms of which areas such a field would have an impact in a real life scenario, and how it will help me when I am hunting for a job in the near future. Some thought about this would be greatly appreciated.


title: When to do Code Review

text: We have recently moved to a scrum process and are working on tasks and user stories inside of sprints. We would like to do code reviews frequently to make them less daunting. We are thinking that doing them on a user story level but are unsure how to branch our code to account for this. We are using VS and TFS 2010 and we are a team of 6. We currently branch for features but are working on changing to branching for scrum. We do not currently use shelvesets and don't really want to implement if there are other techniques available. How do you recommend we implement code review per user story?


title: I'm hoping to start an online supermarket and needs advice on open source shopping cart software and applications

text: I have been researching on both open source software and off-the-shelf software for an online supermarket project in Africa. I have now narrowed by search to X-cart and the PHP based PrestaShop shopping carts. My plan is to acquire an open source shopping cart either by purchasing or as a free open source cart and hire a local developer to customize it to our local needs. I have been doing the demo for x-cart for three weeks now and had thought it might work best for us but after going through the 600 page manual and I'm concerned with how far it can be localized. Yesterday I was looking at the possible Prestashop free open source cart and I seem to like the back-end. Didn't like the back-end for Magento much but from reviews conducted by third- parties they seem to recommend it. I'm now wondering whether I should have a developer start the whole project from scratch, or use an open source software such us PrestaShop or get x-cart which can then be customized? Note that my store will have thousands of products and services including groceries and so I want something that can handle up to 500,000 products and over. * * * Thanks guys for your thoughts and advice. I have indeed looked at the other shopping carts and from a store managers point of view i like PrestaShop back- end and the fact that more modules can be added. You have raised a red flag for me though about the capacity to host that many products. Whats the point then of marketing the software as 'Unlimited Products' when it really cant. Perhaps someone can refer me to a website that has that many products and is PrestaShop? I agree though it has to be customized. Am just worried about asking someone to start from scratch since i believe open source software have been worked on by many minds and been tested enough something that a scratch project may not have.


title: Is there any open source code analyzer for java which I can adopt my software metrics algorithm on it?

text: I am doing my masters dissertation and I have conducted a software metrics. I need to adopt my metrics on an open source tool. I have found PMD and check style on sourceforge.net but there is not adequate explanation about their codes. However, I couldn't to find their source code to customize them. I will be appreciated, if you introduce one open source tool for java which I can customize it's code.


title: Is this Java Compiler error message incorrect? (byte loss of precision)

text: The following IMHO valid java program doesn't compile because the Oracle 1.7 javac compiler thinks there's a possible loss of precision in lines 5 and 6. If you uncomment line 3 and comment out line 4, it compiles fine. Would someone explain why the compiler believes there is a loss of precision on the assignment to either byte `b2` or `b3`?               public class BUG {         public static void main( String[] args ) {             //final byte b1 = 9;             byte b1 = 9;             final byte b2 = -b1;    // fine if line 3 is uncommented and line 4 is commented             final byte b3 = 0 - b1; // fine if line 3 is uncommented and line 4 is commented         }     }      If my sample code is correct, then I'd like to report this as a bug but I can't find out where. Would someone explain what the compiler error message is saying in this case and why it's correct?


title: Liability for software framework

text: If I ask money for a software product (php famework) instead of offering it for free, does it make me more liable for problems caused by my product?


title: Recommend resources for development team leaders

text: I was recently made the team leader of a database (95% MS SQL Server, 5% misc- Oracle, Sybase, Access) development team that manages and develops a large number of databases in a corporate environment. I'm looking for resources (checklists, utilities, best practices, procedures, websites, books, etc) that will help me to implement fundamentals which have been lacking in this development group in the past, such as code reviews, cross training, documentation, enforcing standards, knowledge sharing, mentoring and so forth. Most of what I'm finding is general management skills resources, but I would like to find anything that might be specific to leading a team of developers. Corporate processes are "standard" waterfall type SDLC, so resources geared towards Agile are not nearly as relevant.


title: Minimizability or readability?

text: I am authoring a lot of plugins for the content management system that I am writing. I believe it to be of utmost importance that script files (especially if they're plugins) should load quickly, which leads to me to the question that I've asked today? **What's more important for plugins, minimizability or readability?** Let's imagine that we live in an ideal world where code is always perfect. Should a plugin (which being perfect, the author doesn't expect the end user to read) be designed so that it takes up as little space as possible, or so that it readable by the end user. For example, I'm writing a piece of code that spits out HTML and appends it to the body. I have replaced every instance of the tag 'div' with '!' and then used `String[replace](/\!/g, 'div')` to save four characters (therefore bytes?) for each declaration of a div element. _NB,`[replace]` is also a declared variable so that when it is minified it will read something to the effect of `String[r](/\!/g,'div')`_ Am I caring too much about download speed or should care a bit more about readability. (IMO, most minifying techniques are easily reverse-engineered, but is it bad practice?) * * * **Edit** Thanks for all the answers, you guys are great!


title: What precisely do I/my company need to do "make available/publish" source code changes and satisfy GPL/LGPL

text: This seems like a basic question, but I have not found a definitive source. I need to modify the source for an LGPL application for my employer to plug a security hole. Longer term we will upgrade to a later version of this application, but for now, this is the quickest solution. (specifically: I will change a 2005-era version fork of Apache Tomcat'--jboss- web 2.0.1--to add allow "httpOnly" and 'secure' JSESSIONID cookie). **The question** What exactly must I/my company do to "make available" or "publish" the source code? Must it be accessible from the company's own website or github repository? Or can I have it on my own private github account and simply have the company link to it? thanks


title: Encode Optimal Huffman code

text: I have given message encoded with non-optimal Huffman code. I need to decode the message and encode it again, but this time with optimal Huffman code, so after that I can find `average_number_of_bits_per_symbols = num_of_bits_in_message / num_of_characters_in_message`   **Example:** **_input:_**               6     A 11     B 10     C 01     D 0001     E 001     F 0000     101100000001000010001001100011000000010001010010000000100001000110001100011000000010000000000000100110001000100000000000000011011111010100100101011001010000111001010110000100000010010000000111010000001100100100001010001000100000000001      **_output:_**               2.469      Here is what I got from decoding:               // Third column is occurrence of the letter     A 11 5     B 10 19     C 01 12     D 0001 8     E 001 18     F 0000 19          BAFDFBEEBEBFEDCEFDFBEBEBEBFEFFFCEBEDFFFDBAABBBCECCBCCFABCCCBDFEEFDACFEBCEFBBEDFFE          num_of_characters: 81      So now I have to find optimal codes for these letters. I've tried tree like this one:               19      19     18     12      8     5       B      F      E      C      D     A        \     /       \     /      \     /        0\   /1       0\   /1      0\   /1          \ /           \ /          \ /           \             \            /            \             \          /             \            0\        /1              \             \      /               \             \    /                \             \  /               0 \             \/                  \            /                   \          /                    \        /1                     \______/      And with this I will get:               A 111 => 3 * 5  = 15     D 110 => 3 * 8  = 24     C 101 => 3 * 12 = 36     E 100 => 3 * 18 = 54     F 01  => 2 * 19 = 38     B 00  => 2 * 19 = 38     num_of_bits     = 205          So 205 / 81 = 2.530 => which is not equal with the example output...      So what I am doing wrong?


title: Is it a bad sign that I am often redesigning as I develop a project?

text: When I first started programming, I assumed that I would one day get to the point where I would start a project by sitting down and sketching a UML diagram of all the classes, then pretty much stick to that. I have now been programming for a couple years and it is not turning out that way. As I go through a project, I am often saying   * "Hey, I need a class to do ___ _. I didn't think of that before."   * "Wait, this function should really be in that class instead of this one. I'll move it over."   * "This should actually be two classes instead of one. I'll split it up."   * "I should make these three stand-alone classes all inherit from one abstract class."   * Etcetera, etcetera. Is it a bad sign that I am often redesigning like this as I go along? Does this mean I'm a poor programmer or is this normal?


title: Passing notifications between programs written in different programming languages

text: I work in a team of people with experience in varied programming languages. Recently we were required to build a report when an order is placed in our system. Our ecommerce store runs on PHP and the program to send the report was written in Java. The major challenge we faced was setting up a way so that the Java process is triggered as soon as the order placed. In the same vein, we have plenty of programs written in Python, Scala etc that need to be coordinated and be aware of when to do a task X when task Y happens. As of now, our go to solutions to this problem is to setup a cron to routinely check whether a file or value in DB exists and THEN run (simple polling). I believe a task queue is a right way to solve this problem. However, I'm not sure how to setup one, and how will the Java process know that a task is waiting for it? Also, would a lot of change be required in my PHP program to put something in task queue? Thanks a lot!


title: From a high level programming perspective, where does the 'different-paradigm' barrier between C# and F# really kick in?

text: I'm aware that they both use different programming paradigms, but from a high level perspective apart from differing syntax it seems most basic tasks can be achieved in similar fashion. I only say this because when I've previously touched functional programming languages such as Haskell, writing code for basics tasks was (at first) difficult, frustrating, and required a completely different mindset. For example the following took some time to get to grips with using recursive syntax:               loop :: Int -> IO ()     loop n = if 0 == n then return () else loop (n-1)      Where as an F# loop is recognisable and understandable almost immediately:               let list1 = [ 1; 5; 100; 450; 788 ]     for i in list1 do        printfn "%d" i      When C# programmers start learning F# they are advised to completely re-think their thought pattern (which was definitely required for Haskell), but I've now written several F# programs dealing with conditions, loops, data sets etc to perform practical tasks, and I'm wondering where the 'different-paradigm' barrier really kicks in?


title: Dev environment different from testing environment

text: I'm working on a .net web app project where we develop on our personal machines, but our testing and production environments are in a corporate intranet. The problem is I run into bugs that only present in the testing/production environment, but not in dev. I find this makes it really difficult to track down the cause of the problem. Are there any tips/strategies to deal with this issue? **Please note I have no control or options when it comes to setting up new servers or modifying the test environment. I can only make changes to my local machine. I also do not have access to a company image file to image my PC.


title: More requirements in a single use case - correct?

text: I have been arguying with a developer who insists that 1 FR=1 UC. I think that is a non sense as there are requirements often describing situations arising from the same point - for this the use cases have alternate flows. For example: FR01 - User can log in FR02 - User's account will be locked after 3 incorrect passwords. FR03 - Logged user can log out I believe all these can be nicely captured within a single use case, describing the interaction between the user and the system. But maybe I am missing something? EDIT: According to the book "Use Case Modeling" from Bittner, Spence: > a use case contains a set of description of requirements, the requirements > are presented in the form of narrative rather than an itemized list... ...   So I would say definitely more requirements can be captured within a single use case.


title: I found free software project whose executables are spreading a virus. What is the correct couse of action?

text: Today I found a GPLed project on SourceForge whose executables are spreading a virus. This fact has been pointed out several times in reviews of the project and the infected executable is still available for download. Apparently, older executables are not infected, so the project itself does not seem to be made with malicious purpose in mind. There is no preferred way to contact developers and forums for the project are dead. What should I do?


title: Why is the cyclomatic complexity equal to two for a simple Hello World?

text: I would have two questions related to cyclomatic complexity:   1. Can I use this metric for a whole app? I guess I cannot, as it would be incredibly large number, considering functions calling functions etc. Is it just for module/method/unit?   2. In Visual Studio, for starting app with just calling the `Main` method, the cyclomatic complexity value is 2. Why? There is just one possible way if I run the program - it ends.


title: How to implement loose coupling?

text: I want to implement loose coupling in a project. I know two examples of successful loose coupling designs:   1. On a Unix workstation, shell scripts realise a loose coupling between basic utilities. The loose coupling relies on the shell's ability to _blindly_ redirect data flows between utilities, without having any knowledge on the structure. Utilities agree on a common form to cooperate like a _pipe-separated format_ for sort, cut, paste, awk, etc., a svn dump or a _trivial dump_ of a normalised SGML document (with onsglmls).   2. On a Mac OS X system, Applescripts can be regarded as a loose coupling. In these two examples, I see that cooperating components agree on a common protocol to serialise and deserialise data that needs to be exchanged. Thus components depend on the serialisation protocol rather than on internal representation of data. Is the implementation of a stable communication protocol between application components a winning strategy to implement loose coupling (and good encapsulation)? To solve ties, I also ask what would be a nice name for the protocol artefacts: “data” is a bit vague and there is a lot of them at various places in a software!


title: Is there such a thing as a super programmer?

text: Have you come across a super programmer? What identifies him or her as such, compared to "normal" experienced/great programmers? Also. how do you deal with a person in your team who believes he is a super programmer? Both in case he actually is or if he isn't? **Edit** : Interesting inputs all round, thanks. A few things can be gleaned: A few definitions emerged. Disregarding too localised definitions (that identified the authors or their acquaintance as super programmers), I liked a couple definitions:   1. Thorbjørn's definition: a person who does the equivalent of a good team consistently for a long time.   2. Free Electron, linked from Henry's answer. A very productive person, of exceptional abilities. The explanation is a good read. > A Free Electron can do anything when it comes to code. They can write a > complete application from scratch, learn a language in a weekend, and, most > importantly, they can dive into a tremendous pile of spaghetti code, make > sense of it, and actually getting it working. You can build an entire > businesses around a Free Electron. They’re that good. Contrasting with the last definition, is the point linked to by James about the myth of the genius programmer (video). The same idea is expressed as egoless programming in rwong's comment. They present opposite opinions as whether to optimise for such a unique programmer or for a team. These definitions are definitely different, so I would appreciate it if you have an input as to which is better. Or add your own if you want of course, though it would help to say why it is different from those.


title: Visual Studio versions and Team Etiquette

text: I have a project on CodePlex that I have opened to basically anyone to join and help out on. I am mostly an enthusiast coder, although I have done some programming work as part of my job it has always been solo projects that my team uses for IT support. With my CodePlex project, I got my first new fork yesterday. I cloned it to see some of the changes and realized he had upgraded the package to VS 2012 from my 2010. What is team etiquette for Visual Studio in a team environment? I can see the benefit of using the latest and greatest, but forcing the hand of a team to upgrade seems a little off too. My assumption is this developer did not consider it. Is it considered good etiquette to maintain a standard, even if outdated like with VS 2010? Or is the best etiquette to use the latest stable Visual Studio, and those with out an upgrade can use the Express versions of the latest? Or is there a standard way to make a solution IDE agnostic between VS versions? * * * **Edit** A ton of great input. And the verdict seems to be there is no universal or established etiquette. That it really boils down to my own preferences for the project and what affect the change has on the project.


title: Dictionary of objects

text: I have a dictionary of Objects of a class Columns               Dictionary<double, Columns>      Columns is a class of columns, i.e. name, post code, etc, mobile phone. I would like to make Columns class as much open for extension as possible, so it will be no trouble to add more classes. I need to set few of the columns to be there always, and would like the user to be able to define which columns to display from the remaining, and also add custom columns. Each columns has to have a method getValue() My idea is to create an abstract class Column and derive specific columns from it. Make each child class implement the getValue() method by making it abstract what should force it to be overridden (am I correct?). I will define enum which will list all available column types. Finally, a class Columns would keep all the available columns in dictionary               Dictionary<enum, Column>      My question is: is my thinking process correct? Is there any room for improvement? Would it be a better idea to use interfaces? Finally, is this design going to be efficient and fast for rapidly changing values in columns, i.e. within a second I might have to update 50 different records in this dictionary.


title: how to create a new "Custom Conditional Statement" in programming language

text: Is it possible to create a new "Custom Conditional Statement" in java. Here i am planning to create a new custom component for the switch statement to give better performance. The custom Switch control which i am planning to create will have only integer operators: example:               int i = SOMEVALUE;     Switch(i)     {     Case 1:      //Some Statement     Break;     Case 2:      //Some Statement     Break;     Case 3:      //Some Statement     Break;     ....     ....     ....     Case 10000000:      //Some Statement     Break;     Default:     //Some Statement     Break;     }      According to my knowledge the Switch condition will check in a particular order. If the actual value of the "i" variable is 9999999 then it has to check the case for 9999999 times but if we check it with some algorithms similar to binary search then its performance will be improved. Am I Right ?? If right then why don't we add this functionality to our programming language ? So why don't we create a "Custom Conditional Statement" something like "OrderedIntegerSwitch statement" , in which the value passed inside that switch should be an integer.


title: Is it a good idea to use width and height properties with the < td > tag?

text: I am new to HTML and Im working on a self made project and I have to use < table > and < fieldset > tags in my html files. I need to set the width and height properties to the tables like               <td width="100" height="200" > </td> <!-- something like that -->      But Im afraid of these reason because as the Monitor size changes with the computers some have large screens and some have small screens like notebook pc's. The table dimensions looks small for the big screen computers and big to the small screen computers.How do I manage them. How do I fit it to all types of screen sizes. I mean when it goes to the right most part of the screen it jumps to the next line, if I use width property to the < td > tag? and also using Padding like these is a bad idea ?               < span style="padding-left:100"> </span>      It looks exactly what i want on my browser. Does it look same on all types of monitor sizes? or does it vary? Is there any standard way to follow it? I love your answers but answer these original question too, does it matter to the monitor sizes using width and height properties in < td > tag ?


title: What's the most important, useful or enlightening thing you learnt in the last 12 months?

text: A lot of people in the coding community talk about continuous improvement, deliberate practice and so-on - but when they talk about their current practices it's almost like they 'sprang fully formed from the loins of Zeus' because you don't hear about how their opinions changed over time or what they learnt recently. Every now and then though I go to a talk, or read a book, or talk to someone and they open up a bit more and I find that I learn a lot from these insights. So, if you had to pick **one** thing from the last 12 months that you learnt what would it be?


title: git repo structure with post-receive hook

text: I plan to use git/gitolite to provide managed read/write access for approximately 30 developers and project managers to a shared SAN with the following file structure:                   base/          clients/           clientA/            dirA/              xxx-config.xml-app1              xxx-config.xml-app2            app1/              conf/              deploy/              app1.tgz            app2/            app3/            ...           clientB           ...      I can use gitolite to to configure R / RW access for different groups of devs. The files the developers need to read / modify are the xxx-config.xml-appX and the files in the conf/ and deploy/ folders. Further, whenever anything in conf/ or deploy/ are modified (via "git push"?), I need a git hook script to recreate the appX.tgz file containing all the new contents of the appX folder. I'm assuming each developer could do a "git clone" to their local computer and do periodic "git fetch" to refresh or "git push" whenever they make changes. The "git hook" requirement has me wondering whether I should have one git repo for each client folder: /base/clients/clientA, .../clientB, etc. or one repo for each clientX/appX folder. The following comes from the gitolite samples:                   repo    clientA           RW+     =   @clientA-grp           option hook.post-receive    =   deploy      If there is one repo for each client folder, how would the "deploy" script know which appX.tgz file needs to be recreated? Or would it just recreate them all indiscriminately? The second option clearly doesn't scale.


title: How to address, "Is anyone even using this feature?" questions

text: My team will regularly make code changes that break a unit or integration test for a feature hidden deep in the dark corners of our application. When the test breaks there is a frequent question, "Who is even using this feature!?". We generally un-break the code and make the test pass because, as developers, we cannot determine if a feature is still in use and still needed. How can my team and I effectively address obscure or seemingly strange features? I think what we want to know is if any customer is using them and if not can we remove the feature. With several hundred users and the nature of our app it would be hard to put a logging or reporting feature in our app to phone home whenever a 'feature' is used. I think that makes this a management process rather than a technical process.


title: Finding the best practice for a game simulating tool

text: I'm studying Java right now, and I'm thinking of this tool as my practice project. The game is "League of Legends" in case anyone knows it, I'm not actually simulating the game as in simulating game play, I'm just trying to create a tool that can compare different champions to each other based on their own abilities and items bought inside the game. The game basics are:   * Every player has a champion in a team of 5 players playing against another team.   * Each champion has a different set of abilities (usually 4) that s/he uses to do damage to opposing champions.   * Each champion gets stronger by buying different items, increasing the attack it deals or decreasing the damage received. What I want to do is to create a tool to be used outside the game enabling players to try out different builds for their champions and compare the figures against other champions they usually fight against. The goal is to enable players get a deeper understanding of the different item combinations (builds) that can be used during the games, instead of trying them out in real games which can be somehow very time consuming. What I'm stuck at is the best practice I should follow to make this possible using Java, I can't figure out which classes should inherit from which, should I make champions and items specs in the code or extracted from other files, specially that I'm talking about hundreds of items and champions to use in that tool. I'm self studying Java, and I don't have much practice at it, so I would really appreciate any broad guidelines regarding this, and sorry if my question doesn't fit here, I tried to follow the rules. English isn't my native language, so I'm really sorry if I wasn't clear enough, I would be more than happy to explain anything that's not understood.


title: Is there a clear leader amongst JVM-based languages?

text: What is the current status of these projects, and has any one (or two) emerged as a clear leader? To demonstrate my motives for asking this question, cast your mind back several years. Prototype and jQuery were going head-to-head with other players like MooTools fighting to survive as well. Fast forward to today, and the general consensus is that jQuery is the best general purpose JavaScript library. Has something similar happened in the last several years with these JVM-based languages? Have certain languages fallen into disrepair and abandonment? From what I've read, it seems that Scala is certainly well-prepped to become the favorite, but then again, nearly everything I've read is several years old. * * * I've done a bit more research - I had the idea to check out search volume through the years by using Google Trends. It seems that Jython and JRuby have relatively little interest while Groovy's volume is decreasing and Scala's volume is constant (at worst) or increasing slightly (at best). Is this an accurate assessment? * * * And yes, I'm referring to non-Java languages on the JVM such as Jython, JRuby, Groovy, Scala, Clojure, etc.


title: Is it a good practice to create a list of definitions for all symbols and words in a programming language?

text: After arriving at this point in Learning Python The Hard Way I am wondering if this is a good practice to create a list of symbols and define what they do as noted in bold below, for every programming language. This seems reasonable, and might be very useful to have when jumping between programming languages? Is this something that programmers do or is it just a waste of effort? > Exercise 22: What Do You Know So Far? There won't be any code in this > exercise or the next one, so there's no WYSS or Extra Credit either. In > fact, this exercise is like one giant Extra Credit. I'm going to have you do > a form of review what you have learned so far. > > **First, go back through every exercise you have done so far and write down > every word and symbol (another name for 'character') that you have used. > Make sure your list of symbols is complete.** > > **Next to each word or symbol, write its name and what it does. If you can't > find a name for a symbol in this book, then look for it online. If you do > not know what a word or symbol does, then go read about it again and try > using it in some code.** > > You may run into a few things you just can't find out or know, so just keep > those on the list and be ready to look them up when you find them. > > Once you have your list, spend a few days rewriting the list and double > checking that it's correct. This may get boring but push through and really > nail it down. > > Once you have memorized the list and what they do, then you should step it > up by writing out tables of symbols, their names, and what they do from > memory. When you hit some you can't recall from memory, go back and memorize > them again.


title: How is leaving on time perceived in software companies?

text: What are the consequences of leaving work on time in software companies? What's the professional way to deal with this? [Editorial addition] The question is about working standard hours and not putting in extra hours without being explicitly asked to. Is working extra hours a norm or an expected work attitude in software companies and/or for a software developer role? How is one going to be perceived by colleagues and peers if one only worked the standard hours specified by local laws or the contract?


title: How to document the high-level structure of a Java program?

text: **Background:** My collaborators and I are writing an article for an academic journal. In the course of our research, we wrote a simulation program in Java. We want to make the simulation program freely available for others to use. We have decided on hosting the code on a GitHub repository. In order to make it easy for others to use, we want to write good documentation for our program, including:   * Javadocs for each class and method   * How to use the code   * Describing the high-level structure of the code My high-level question is: **Could you provide a good example of the words and diagrams that can be used to describe the high-level structure of a program?** This includes as sub-questions:   1. How do we show what classes are contained in which packages?   2. How do we show what packages depend on other packages?   3. How do we show how the objects/classes in the program work together?   4. We have tried to use domain-driven design principles in the design of my code. How do we show the correspondence between the objects in the domain and the particular source code files encoding these objects? (See my "ubiquitous language" description of the project below.) # What I have done so far ## Ubiquitous language We put a "ubiquitous language" description of the code in a file `ubiquitous- language.md`, contents below. The purpose of this project is to study how well a replenishment policy performs in a simple supply chain with a single facility, under different lead time models, report delays and demand models. In each period, the following events occur:   1. If a **shipment** is scheduled to arrive at the **facility** at the current period, then the inventory level of the facility is incremented by X units.   2. If the **schedule** indicates that the current period is a reporting period, then the **facility** submits a **report** to the **supplier**. The **supplier** may receive the **report** instantaneously, or with a delay of several weeks, as specified by the **schedule**.   3. If the **supplier** has received a **report** , then based on the **replenishment policy** , it will calculate a replenishment quantity of X units. A **shipment** of X units of the product will be scheduled to arrive after a lead time of l periods.   4. Customers arrive at the **facility** and demand X units of the product. Any unmet demand is lost. ## Source Code Structure We put an incomplete "high-level" description of the code in a file `structure.md`, contents below. ### Package Level Structure At the highest level, the source code is organized into three packages   * `com.gly.sfs` The main class with the `main` method resides in this package.   * `com.gly.sfs.model` The domain model classes reside in this package.   * `com.gly.sfs.util` Helper classes reside in this package.


title: Which one to choose: XML attribute or Sub node?

text: We want to export some data from our data base as XML. For example, a `Person` can have `age`, `name` and some other properties. We have two choices to define the XML format. Choice #1:               <Persons>        <Person>            <Age>16</Age>            <Name>Richard</Name>        </Person>        <Person>            <Age>34</Age>            <Name>Eric</Name>        </Person>        ...     </Persons>      Choice #2:               <Persons>        <Person Age="16" Name="Richard"/>        <Person Age="34" Name="Eric"/>        ...     </Persons>      So what's the difference between definition of sub node or attribute? And what's the benefit of each choice?


title: When to use tools vs custom development?

text: To learn dependency injection in a current side-project, I am writing my own dependency injection container. But this has lead me to wonder, at what point is it worthwhile to use a third party product vs "roll my own"? What would be the kind of questions you would ask to figure this out?


title: Maintaining code-style conventions for large projects

text: For a while I've been maintaining an ad-hoc script to check code style against our project's guidelines. I'm aware of AStyle/Uncrustify and have used them, but they are best for once- off code-style cleanups, but impractical to just run all code through some automatic process after every commit. To explain the issue a little more, yes - we have code-style documentation, but devs don't always follow exactly, and it's not really great to give them personal mail every time they make some tiny change that goes against some convention. So I took the approach to deal with this like compiler warnings, report inconsistencies but leave it up to the developer to resolve (some of you may be familiar with Python's pep8 style checker). Once every so often we do style cleanups. In general I'm very happy with the outcome (unlike most style checking tools), you get to get a lot of flexibility - so you can choose where to be strict and where to be relaxed about conventions (avoid too many false positives is important too). Currently I'm using Python and Pygments to parse C source code (some C++ also but mainly C) and then my own script to check the tokenized results meet our conventions. This works fairly well, I don't need the full AST you can get with GCC or Clang for example, simply knowing if text is a comment, string, punctuation, preprocessor... etc. is enough (what you would get from syntax highlighting, or a source tokenizer). But I did end up having to write quite a few utility functions for the source:   * extract the body of a block between brackets.   * find matching brackets.   * identify casts.   * inspecting whitespace around punctuation. ... nothing really advanced. The exact conventions are probably not so important, but for an example here are some checks:   * Placement of braces for 'if' statement checks broken into multiple lines.   * Placement of `break` in a `switch` statement.   * Spaces around operators, braces, function calls, after commas.   * Indentation for multi-line if statements.   * Indentation consistency. At this point I would be interested to move away from my own utility functions but still have a script which checks code-style, if there is something else well maintained solving similar problems. I'd be surprised if there is not some other people doing similar projects to maintain consistent source style in this way, so I'm interested to know of any alternatives available. # Question: Considering the workflow I have described, can anyone cite their experiences using a similar workflow, are there projects that already do this, I'm interested to see a precedent.


title: Is it good practice to create convenience delegate methods?

text: Suppose I have design like this:               class Corpus:         def something1(self):             pass         def something2(self):             pass         def serialize_to_stream(self, stream):             _CorpusJsonSerializer().serialize(self, stream)          class _CorpusJsonSerializer:         def serialize(self, corpus, stream):             .             .             .         .         .         .       I think that the serialization process should be in a separate class for various reasons. That makes the method `serialize_to_stream` in `Corpus` unnecessary. I would however like to have it there because I think it makes it easier for the users of the Corpus, because they do not have to know anything about another class `CorpusJsonSerializer`. Do you think it is reasonable? Or shall I just expose the `CorpusJsonSerializer` and let the user do the work?


title: SOA in .NET 4.5 with MSMQ Durability

text: I have been doing some investigation regarding ASP.NET Web API. I have enjoyed using the WCF REST template to create new RESTful web services, and Web API seems to be a cleaner iteration on that. However, I like the flexibility of WCF in allowing http, TCP, MSMQ. This aspect seems to facilitate a distributed and scalable architecture. Is it correct for me to conclude that WCF would continue to be my best bet when it comes to fire-and-forget durable message queueing?


title: What methodology to use for planning/developing a Language conversion project?

text: I am trying to help my friend by creating a part of his on-going project. What I'm going to do is create a Java parser to break up the Java code into operators, parameters etc to build XML representation. Next I want to create a code generator to convert the parsed java code to XML conforming to the schema I've created. Finally I want to use an XML style-sheet to transform the XML into another programming language type. Basically I just wanted some advice on which methodology/model I should use for planning and developing this project. Is there some benefit to using Agile etc for instance?


title: How can I get non-programmer colleagues on board with bespoke software rather than Dynamics CRM + Sharepoint?

text: I am working with a company which designs and builds one-off machines. They have been 'dabbling' with hosted Dynamics CRM and Sharepoint (on different servers!) in an attempt to centralise their data and help colleagues collaborate more effectively across projects. They haven't used either system to their potential. Now we are looking at the engineering department who already use a form of version control software for the various CAD files (Autodesk Vault) however it is becoming increasingly necessary to implement more of a generic file version control system as they use many more files than can be managed in Vault (sometimes just photos or scans of paper documents), hence why they were looking at using Sharepoint. However... as the 'programmer' of the bunch, I can see several scenarios which don't seem to fit well with the Dynamics + Sharepoint approach; simple reports based on cross-table queries, exporting certain metrics as a spreadsheet, defining project hierarchies and many-many relationships, and as such I have been pushing for an in-house developed 'ECM' / 'ERP' software package (perhaps in .NET or php). Some colleagues seem to attach a greater value to the MS software (perhaps becuase it has a logo!) but don't see that it's just a framework, not a solution. Can anyone provide a good example of when custom software would actually be better than using Dynamics + Sharepoint and how do I relate that to non- technical staff?


title: Can I start learning C# immediately?

text: I've got my BSc in Computer Science 4 years ago and I feel like I've forgotten everything I learnt. I still know the basics such as CPU, mohterboard, RAM, software, hardware, etc but I forgot how they work exactly. In general, I know what a programming language is and I have worked with Java when I was at Uni. To be honest I was just trying to solve the assignments in that time and now I've found I have some interest in programming and I chose C# because I can use it for web and for desktop applications. Now, I want to learn C#. Is there any prerequisites for that? I mean do I need to come back to all the materials that I did study on my BSc? Or can I srart learning immediately?


title: SVN code review tool

text: I would like to do some code review on the SVN repository used by our team. For now, I've used Eclipse: show log on trunk, click on a revision and "Compare" to see the changes. The diff renders great, but the navigation isn't practical IMO. I'm looking for a tool that could enable code reviewing with "diffs", but with an **easy navigation in the changes**. For example, being able to **filter/exclude commits** based on their names/patterns, show commits of a user, **show changes since last tag** , maybe watch commits on sensitive files, etc... An Eclipse plugin would be the best, as I could still use functionalities such as Ctrl+click on methods/classes. But any suggestion in welcomed.


title: Formatting code a bad thing when using a VCS?

text: I almost always format my code before I commit to make sure it's done properly. Most of my team don't really care and don't always format their code properly (minor things that don't affect the code but affect readability when trying to maintain it). I recently installed the VS power tools that has an option "Format on save", and made a change to a file that wasn't formatted prior. The development VP just came to me and reprimanded me for formatting since it shows up in the merging tool as having almost the entire file changed, instead of just a line or two (so he can't see exactly what I modified easily), and told me to disable the format on save in the future. While I understand that concern, I find it difficult sometimes to sort through the code that is unformatted, and IMO it should be formatted properly all the time anyways. Note that I'm not just reformatting things on a whim., but as I write code I'll either use the power tool or hit the key command to format the text to make it easier to read, and in SVN this shows up as a modification. So I ask, is always formatting the code actually a bad thing? Are his concerns more valid than making sure the code is readable?


title: Are there any real-world cases for C++ without exceptions?

text: In When to use C over C++, and C++ over C? there is a statement wrt. to code size / C++ exceptions: Jerry answers (among other points): > (...) it tends to be more difficult to produce truly tiny executables with > C++. For really small systems, you're rarely writing a lot of code anyway, > and the extra (...) to which I asked why that would be, to which Jerry responded: > the main thing is that C++ includes exception handling, which (at least > usually) adds some minimum to the executable size. Most compilers will let > you disable exception handling, but when you do the result isn't quite C++ > anymore. (...) which I do not really doubt on a technical real world level. * * * Therefore I'm interested (purely out of curiosity) to hear from **real world examples where a project chose C++ as a language and then chose to disable exceptions.** (Not just merely "not use" exceptions in user code, but disable them in the compiler, so that you can't throw or catch exceptions.) Why does a project chose to do so (still using C++ and not C, but no exceptions) - what are/were the (technical) reasons? * * * Addendum: For those wishing to elaborate on their answers, it would be nice to detail how the implications of no-exceptions are handled:   * STL collections (`vector`, ...) do not work properly (allocation failure cannot be reported)   * `new` can't throw   * Constructors cannot fail


title: Solo .NET Programmer moving to a team

text: I've been a solo .NET programmer for a small startup for the last 8 years. I've put together some pretty decent software, and I always strived to better myself and conform to best practices, including source control (SVN/TFS). I worked very closely with a team of engineers of other disciplines, but when it came down to the software I was the only one programming. I love the craft of programming and love learning new things to sharpen my tools. In 2 weeks I will be starting a new job in a team of 20 .NET developers. My position will be mid-level, and I will be working under some programmers with incredibly impressive backgrounds. Again, the team aspect of development will be new to me, so I'm looking for some general "new guy" tips that will help me be as effective and easy to get along with as possible from the get-go. Anything goes, including high level tips, and small day-to-day things about communication.


title: Single Identity for Desktop and Web

text: I'm building a system has both a WPF desktop application as well as an Asp.net MVC application. I need a common user identity component so that user can log on to either one with the same credentials. Is ASP.NET Identity appropriate for this task? Has anyone used ASP.NET Identity with a WPF application? Are there any alternatives?


title: Looking for statistics on automated testing, continuous integration and refactoring usage

text: Are there any credible sources of information on the adoption of agile techniques like automated testing, continuous integration and refactoring? Of those that are using unit testing, how many follow test first or test driven development. I'm trying to determine how widespread these practices are.


title: Do privacy concerns prevent us from accessing location-based user data?

text: Every time my team begins to explore the scenarios that are possible with mobile device location data, location data that is part of user data, or even location data that may be retrieved or inferred from IP address or browser cookies, we are stopped dead in our tracks by the risk of violating a user's privacy. It's frustrating, because working with location data creates whole new areas for providing a great user experience. I have taken a look at the Mobile Device Privacy Act, related online opinions, such as the ars technica article, and the Electronic Frontier Foundation's recent Mobile User Privacy Bill of Rights, but there isn't really an authoritative (or even de facto) standard and opinions differ. Is it as simple as obtaining a user's permission to make use of location-based data and then safeguarding the data? I would like to know how others are addressing or even skirting this issue. Do you obtain user permission before utilizing location data? Are you just riding it out for now and waiting to see if a national law is passed?


title: Are DDD Aggregates really a good idea in a Web Application?

text: I'm diving in to Domain Driven Design and some of the concepts i'm coming across make a lot of sense on the surface, but when I think about them more I have to wonder if that's really a good idea. The concept of Aggregates, for instance makes sense. You create small domains of ownership so that you don't have to deal with the entire domain model. However, when I think about this in the context of a web app, we're frequently hitting the database to pull back small subsets of data. For instance, a page may only list the number of orders, with links to click on to open the order and see its order id's. If i'm understanding Aggregates right, I would typically use the repository pattern to return an OrderAggregate that would contain the members `GetAll`, `GetByID`, `Delete`, and `Save`. Ok, that sounds good. But... If I call GetAll to list all my order's, it would seem to me that this pattern would require the entire list of aggregate information to be returned, complete orders, order lines, etc... When I only need a small subset of that information (just header information). Am I missing something? Or is there some level of optimization you would use here? I can't imagine that anyone would advocate returning entire aggregates of information when you don't need it. Certainly, one could create methods on your repository like `GetOrderHeaders`, but that seems to defeat the purpose of using a pattern like repository in the first place. Can anyone clarify this for me? **EDIT:** After a lot more research, I think the disconnect here is that a pure Repository pattern is different from what most people think of a Repository as being. Fowler defines a repository as a data store that uses collection semantics, and is generally kept in-memory. This means creating an entire object graph. Evans alters the Repository to include Aggregate Roots, and thus the repository is amputated to only support the objects in an Aggregate. Most people seem to think of repositories as glorified Data Access Objects, where you just create methods to get whatever data you want. That doesn't seem to be the intent as described in Fowler's Patterns of Enterprise Application Architecture. Still others think of a repository as a simple abstraction used primarily to make testing and mocking easier, or to decouple persistence from the rest of the system. I guess the answer is that this is a much more complex concept than I first thought it was.


title: What's the proper hand position for the movement keys in Vim?

text: I've recently started using Vim and am working to replace Notepad++ as my go- to. However, I'm running into an issue where I keep hitting u instead of i because my right hand is on HJKL instead of the usual JKL;. So, Vim users: Is there a preferred right hand positioning for the editor, or should I just get used to moving my hand back and forth for normal and insert modes?


title: Maintaining a list of nodes with challenging requirements

text: This is a question regarding the design of a collection of ordered nodes which have some requirements that I am struggling to satisfy. In the problem area that I am dealing with we have routes which are an ordered collection of nodes. A route will be between 1000 and 25000 nodes. A node itself is a complex object. I need to be able to persist the nodes, ideally to a relational database (as the wider application is currently delivered using an architecture that uses a relational database for persistence). I have two separate requirements which present a difficultly in how to model the data.   1. I need to be able to insert nodes (or pointers to nodes) into the middle of the list and reorganise the list on the fly.   2. I need to be able to retrieve the list in it's correct sequential order with both an efficient index and the ability to random access. The only way I think that I can satisfy the first requirement is to model the data as a linked list where every node points to the next node in the list, which would allow the list to be edited and reorganised on the fly. The only way I think that I can satisfy the second requirement would be to sequentially order the list so each node has a reference to it's position in the list and order/access the list by the position. Is there any other method that I could use that can satisfy the two requirements or am I stuck with building a hybrid that employs both methods at various times depending on operational context and that keeps the two referencing types in synch?


title: What are the different ways  for performing authorization in a web application other than role-based authorization?

text: The most common approach used for authorization which I know is role based authorization. Instead of directly storing the access rights against the user ids you create roles and store the access rights against them. Then assign the users the roles. Though I find the role based method quite flexible and easy to maintain I am still interested to know whether there are any better methods for storing authorization details. I am using Spring Security for securing JSF web applications. Along with solutions for Spring Security I would also appreciate general solutions (not specific to a particular security framework).


title: Usage of "Multi-Paradigm Languages" in commercial applications

text: I am currently learning the two languages F-Sharp and Scala. These two languages are, in my opinion, both quite comprehensive to grasp. Nonetheless, what seems to make Scala and F-Sharp similar, is that both of them try to offer a conglomeration of programming paradigms (OO, functional), in order to solve real-world tasks and to make them applicable as general-purpose languages. While both languages seem to get the most attention in academia, there is comparable little mention of their usage in commercial software projects. Considering the different platform philosophies behind these two languages, which is -in your subjective opinion- more promising to become widely used for commercial purposes in the near future?


title: What Are Some Advantages/Disadvantages of Using C over Assembly?

text: I'm currently studying engineering in Telecommunications and Electronics and we have migrated from assembler to C in microprocessor programming. I have doubts that this is a good idea. What are some advantages and disadvantages of C compared to assembly? The advantages/disadvantages I see are: **Advantages:**   * I can tell that C syntax is a lot easier to learn than Assembler syntax.   * C is easier to use for making more complex programs.   * Learning C is somehow more productive than learning assembler cause there is more developing stuff around C than Assembler. **Disadvantages:**   * Assembler is a lower level programming language than C,so this makes it a good for programming directly to hardware.   * Is a lot more flexible alluding you to work with memory,interrupts,micro-registers,etc.


title: WHere do I put my update class and handle request / response from HTTP web request?

text: I don't know how to organize my code. Right now I just dumped everything in MainPage for testing. But what is the proper way to handle getting data from REST web service in Windows Phone 8? I have multiple pages that need to utilize the data that is returned.                   /// <summary>     /// State information for our BeginGetResponse async call     /// </summary>     public class UpdateState     {         public HttpWebRequest AsyncRequest { get; set; }         public HttpWebResponse AsyncResponse { get; set; }     }               public partial class MainPage : PhoneApplicationPage     {         // Constructor         public MainPage()         {             InitializeComponent();                  // Sample code to localize the ApplicationBar             //BuildLocalizedApplicationBar();         }              private async void test()         {                  var handler = new HttpClientHandler();             if (handler.SupportsAutomaticDecompression)             {                 handler.AutomaticDecompression = DecompressionMethods.GZip |                                                  DecompressionMethods.Deflate;             }                  // form the URI             UriBuilder fullUri = new UriBuilder("http://test/GetData?");             fullUri.Query = "format=xml&param=test&dateFrom=20071225&dateTo=20080101";                  var httpClient = new HttpClient(handler);             var str = await httpClient.GetStringAsync(fullUri.Uri);             string test = "";         }              private void Button_Click(object sender, RoutedEventArgs e)         {                       test();                            // form the URI             UriBuilder fullUri = new UriBuilder("http://test/GetData?");             fullUri.Query = "format=xml&param=test&dateFrom=20140124&dateTo=201425 ";                  // initialize a new WebRequest             HttpWebRequest request = (HttpWebRequest)WebRequest.Create(fullUri.Uri);                  // set up the state object for the async request             UpdateState state = new UpdateState();             state.AsyncRequest = request;                  // start the asynchronous request             request.BeginGetResponse(new AsyncCallback(HandleResponse),                 state);         }              /// <summary>         /// Handle the information returned from the async request         /// </summary>         /// <param name="asyncResult"></param>         private void HandleResponse(IAsyncResult asyncResult)         {             // get the state information             UpdateState forecastState = (UpdateState)asyncResult.AsyncState;             HttpWebRequest forecastRequest = (HttpWebRequest)forecastState.AsyncRequest;                  // end the async request             forecastState.AsyncResponse = (HttpWebResponse)forecastRequest.EndGetResponse(asyncResult);                  Stream streamResult;                  string newCredit = "";             string newCityName = "";             int newHeight = 0;                  string XMLresult = string.Empty;                  try             {                      // get the stream containing the response from the async call                 string type = forecastState.AsyncResponse.ContentType;                  streamResult = forecastState.AsyncResponse.GetResponseStream();                      XMLresult = getXMLData(streamResult);                      // load the XML                 XElement xmlData = XElement.Parse(XMLresult);                      string t = "";                  }             catch (FormatException)             {                 // there was some kind of error processing the response from the web                 // additional error handling would normally be added here                 return;             }              }


title: Etymology of “throw an exception“

text: Why do we use the expression “throw an exception“ and not something like “generate“? Where was that term born and in which language?


title: With ASP.NET MVC actions, should I use web services?

text: In ASP.NET Web Forms if you want to use jQuery and call a method directly, you should either implement a web service, or use Page Methods. Also you can use Generic Handlers (.ashx files). However, in ASP.NET MVC, a controller action (a method in nature) can be called directly from jQuery. What web services has to offer in ASP.NET MVC world? In other words, seems that I can fulfill of my requirements via MVC's clean URLs, controllers and actions. Should I bother using Web Services?


title: Which version management design methodology to be used in a Dependent System nodes?

text: This is my first question so please indicate if my question is too vague and not understandable. My question is more related to High Level Design. We have a system (specifically an ATCA Chassis) configured in a Star Topology, having **Master Node (MN)** and other **sub-ordinate nodes(SN)**. All nodes are connected via Ethernet and shall run on Linux OS with other proprietary applications. I have to build a recovery Framework Design so that any software entity, whether its Linux, Ramdisk or application can be rollback to previous good versions if something bad happens. Thus I think of maintaining a State Version Matrix over MN, where each State(1,2....n) represents Good Kernel, Ramdisk and application versions for each SN. It may happen that one SN version can dependent on other SN's version. Please see following diagram:- ![enter image description here](http://i.stack.imgur.com/dh1pv.jpg) So I am in dilemma whether to use Package Management Methodology used by Debian Distributions (Like Ubuntu) or GIT repository methodology; in order to do a Rollback to previous good versions on either one SN or on all the dependent SNs. The method should also be easier for upgrading SNs along with MNs. Some of the features which I am trying to achieve:- 1) Upgrade of even single software entity is achievable without hindering others. 2) Dependency checks must be done before applying rollback or upgrade on each of the SN 3) User Prompt should be given in case dependency fails.If User still go for rollback, all the SNs should get notification to rollback there own releases (if required). 4) The binaries should be distributed on SNs accordingly so that recovery process is faster; rather fetching every time from MN. 5) Release Patches from developer for bug fixes, feature enhancement can be applied on running system. 6) Each version can be easily tracked and distinguishable. Thanks


title: Why '42' is the preferred number when indicating something random?

text: I have seen this on the SO on many times. Whenever a question is vague and the question is asking some magical answer somebody or the other leaves a comment saying answer is 42. Even a book I am reading right now uses '42' as the number whenever it wants demonstrate some basic concept using an integer. So is there any history behind it or it is just a coincidence?


title: What's the first thing you write when trying out a new language?

text: I think everyone has their own program or set of features beyond "Hello World!", that they use when trying out a new language. Mine is a guessing game:               I'm thinking of a number 1-10, guess what it is!     Guess: 3     Nope, too low!     Guess: 7     Nope, too high!     Guess: 5     Yes, You win!     Play again (Y/N)? N      What do _you_ write?


title: When does pair programming work for you? When should you avoid it?

text: Rather than slavishly pair program all the time, we use pair programming selectively on our team. I think it works best in the following circumstances:   * Ramping up brand new team members on a project (instead of letting them wade through documentation or code on their own).   * Having junior and senior people work together (helps to show some of the skills and tricks of the more experienced developers, plus it allows the old dogs to learn new tricks sometimes).   * When someone is trying to track down a defect, it often helps to pair with a fresh set of eyes. When do you pair program and why? When do you avoid pair programming? Why?


title: What syntax element do you hate most in a programming language you use frequently?

text: No matter how much you love a programming language, there are always a few details in it that aren’t quite as nice as they could be. In this question, I would like to specifically focus on **syntax elements.** In a programming language that you use frequently (perhaps your favourite programming language, or perhaps the one you are forced to use at work), which syntax element do you find most unreadable, unclear, inconvenient or unpleasant?


title: Should accessible members of an internal class be internal too?

text: I'm designing a set of APIs for some applications I'm working on. I want to keep the code style consistent in all the classes I write but I've found that there are a few inconsistencies that I'm introducing and I don't know what the best way to resolve them is. My example here is specific to C# but this would apply to any language with similar mechanisms. There are a few classes that I need for implementation purposes that I don't necessarily want to expose in the API so I make them `internal` whereever needed. Generally what I would do is design the class as I normally would (e.g., make members `public`/`protected`/`private` where necessary) and change the visibility level of the class itself to `internal`. So I might have a few classes that look like this:               internal interface IMyItem     {         ItemSet AddTo(ItemSet set);     }          internal class _SmallItem : IMyItem     {         private readonly /* parameters */;         public _SmallItem(/* small item parameters */) { /* ... */ }              public ItemSet AddTo(ItemSet set) { /* ... */ }     }          internal abstract class _CompositeItem: IMyItem     {         private readonly /* parameters */;         public _CompositeItem(/* composite item parameters */) { /* ... */ }              public abstract object UsefulInformation { get; }         protected void HelperMethod(/* parameters */) { /* ... */ }     }          internal class _BigItem : _CompositeItem     {         private readonly /* parameters */;         public _BigItem(/* big item parameters */) { /* ... */ }              public override object UsefulInformation         {             get { /* ... */ }         }              public ItemSet AddTo(ItemSet set) { /* ... */ }     }      In another generated class (part of a parser/scanner), there is a structure that contains fields for all possible values it can represent. The class generated is `internal` too but I have control over the visibility of the members and decided to make them `internal` as well.               internal partial struct ValueType     {         internal string               String;         internal ItemSet              ItemSet;         internal IMyItem              MyItem;     }          internal class TokenValue     {         internal static int EQ(ItemSetScanner scanner) { /* ... */ }         internal static int NAME(ItemSetScanner scanner, string value) { /* ... */ }         internal static int VALUE(ItemSetScanner scanner, string value) { /* ... */ }         //...     }      To me, this feels odd because the first set of classes, I didn't necessarily have to make some members `public`, they very well could have been made `internal`. `internal` members of an `internal` type can only be accessed internally anyway so why make them `public`? I just don't like the idea that the way I write my classes _has_ to change drastically (i.e., change all uses of `public` to `internal`) just because the class is `internal`. Any thoughts on what I should do here? It makes sense to me that I might want to make some members of a class declared `public`, `internal`. But it's less clear to me when the class is declared `internal`.


title: Is it legal to release GPL version project into FreeBSD?

text: I could not differentiate between FreeBSD and GPL liecense. Can anyone tell me the in what respect these two liecense are different. Is it legal to use some source based on GPL license and release the new product as FreeBSD license? In particular, I have following scence: I would like to follow some of the implementation module of some implentation for my use. The implementation is standard algorithm implementation. So basically i am taking some reference to implement in my own way. I am not making use of verbatim copy, some module matches with the original one. The one which i am taking reference is in FreeGPL V3 license. The new product which i will release with FreeBSD license. Is it legal to do this or I should relase my product in FreeGPL license? [EDIT] Moreover, my case is, I am implementing some standard algorithm. Lets say here a data structure linked list. I think,whoever implements it, he/she will have same structure and similar kind of functions for search, delete and insert.Even the operations will be seen. I saw some code in internet and i got the influence of that of code my implementation which was so unavoidable. In this case how can a programmer can claim that the particular code is his own original code?


title: What languages are used by professional mobile app designers?

text: I've recently done some Java programming for an android app (though my question is not android specific), and was wondering if what I was doing was just a lot less complicated, but generally the same as what a professional mobile app designer would do. I kind of asssumed that an app designer working for, say, the BBC would use an expensive software package, and maybe a different language. So my question is **what language would they be using?** Maybe they would use one that would work for both Android and iOS?


title: What mathematics should I review & master before enrolling in CS program (early 40s student, 20 years dev exp, no degree)

text: I am in my early 40s and plan to enroll in university this fall to pursue a long-postponed CS degree. I have been working as a developer for almost 20 years, but have found further advancement at this stage of my career difficult without a degree. Plus, I've always wanted to get one, I have a hunger for learning, and I'd still have 20 years ahead of me after graduation before retirement. I started at a junior college out of high school, but only completed about 16 hours, so I'm basically starting from scratch. I'm excited, but apprehensive. In high school, I was very good at math - took Trig/Pre-calc, etc. and did well. I scored high in math on the ACT/SATs. However, 20 years of database- driven application development has not required any higher math, and I know I am quite rusty. **What specific topics/areas in mathematics do I need to review and master over the next 6 months to give me a fighting chance in Calc I (and beyond) come fall?** Your help is greatly appreciated. Thank you for your time.


title: What is the optimal minimum time to work on tasks for a single project?

text: As I'm getting more organized, and getting more projects, I'm starting to wonder how to best manage time between them. Especially in regard to how I give estimates to the PHBs. So if the project is broken up into small tasks, say 2-3 hours each, then is it just as productive to work on one task per day as opposed to spending 6 hours a day and working through a good portion of 3 tasks. I realize that to a certain extent this depends on the project, but I also think that it might be better in general to work on components together so that things stay fresh in your mind. That said, it means pushing back other projects a week or two in order to devote 6 hours a day towards those tasks. Just trying to think this through, and thought I'd get some input.


title: What has research shown about the effectiveness of comments?

text: I have been arguing with a friend about the necessity of comments, and the efficiency of different comment styles. The argument ended quite fast, as we could not find any research - or essay - that support either claim. Has any serious research been conducted regarding the efficiency of different commenting styles? If so, what has it shown? I'm mainly interested with:   * Length (I think that comments longer than a tweet are never read)   * Type (I strongly favor comments that are actual code samples, explaining how to call a method)   * Location (As a separate line? at the end of the line?)


title: Does functional programming ignore the benefits gained from the "On the Criteria To Be Used in Decomposing Systems into Modules" (data hiding)?

text: There's a classic article named On the Criteria To Be Used in Decomposing Systems into Modules that I just read for the first time. It makes perfect sense to me, and is probably one of those articles that OOP was based on. Its conclusion: > We have tried to demonstrate by these examples that it is almost always > incorrect to begin the decomposition of a system into modules on the basis > of a flowchart. ... Each module is then designed to hide such a decision > from the others In my uneducated and inexperienced opinion, functional programming takes the exact opposite advice of this article. My understanding is functional programming makes data flow idiomatic. Data gets passed from function to function, each function being intimately aware of the data and "changing it" along the way. And I think I've seen a Rich Hickey talk where he talks about how data hiding is overrated or unnecessary or something, but I can't remember for sure.   1. First I want to know if my assessment is correct. Does the FP paradigm and this article philosophically disagree?    2. Assuming they disagree, how does FP "compensate" for its lack of data hiding? Perhaps they sacrifice data hiding but gain X, Y and Z. I'd like to know the reasoning for why X, Y and Z are considered more beneficial than data hiding.    3. Or, assuming they disagree, perhaps FP feels that data hiding is bad. If so, why does it think data hiding is bad?   4. Assuming they agree, I'd like to know what FPs implementation of data hiding is. It's obvious to see this in OOP. You can have a `private` field that nobody outside the class can access. There's no obvious analogy of this to me in FP.   5. I feel there are other questions I should be asking but I don't know I should be asking. Feel free to answer those, too.  # Update I found this Neal Ford talk that has a very relevant slide in it. I'll embed the screenshot here: ![enter image description here](http://i.stack.imgur.com/esjl0.png)


title: Why do so many programmers absolutely hate object prevalence layers?

text: Prevalence is a simple technique to provide ACID properties to an in-memory object model based on binary serialization and write-ahead logging. It works like this:   * Start with a snapshot. Serialize the object model and write it to a file.   * Create a journal file. For every call into the object model, serialize the call and its arguments.   * When the journal gets too big, you're shutting down, or it's otherwise convenient, perform a checkpoint: write a new snapshot and truncate the journal.   * To roll back or recover from a crash or power hit, load the last snapshot and re-execute all the calls recorded in the journal. The precautions needed to make this work are:   * Don't let mutable object references escape or enter the prevalence layer. You need some sort of proxy or OID scheme, as if you were doing RPC. (This is such a common newbie mistake it's been nicknamed the 'baptism problem'.)   * All the logic reachable from a call must be completely deterministic, and must not perform business-logic-meaningful I/O or OS calls. Writing to a diagnostic log is probably OK, but getting the system time or launching an asynchronous delegate is generally not. This is so that the journal replays identically even if it's restored on a different machine or at a different time. (Most prevalence code provides an alternate time call to get the transaction timestamp.)   * Writer concurrency introduces ambiguity in journal interpretation, so it is prohibited. Is it because ...   * people developed a bad taste for them after trying to use one on a project that wasn't well suited* to it?    * Klaus Wuestefeld's strident advocacy turned people off?   * people who like the imperative programming model dislike separating I/O from calculation, preferring instead to interleave computation with I/O and threading calls?   * prevalence layers are so conceptually simple and so intimately bound to the characteristics of the framework they inhabit that they're usually custom-rolled for the project, which makes them too alien/nonstandard/risky?   * it's just too hard to keep straight what you have to be careful not to do?   * newbies' heads just seem to explode when faced with something that isn't the same kind of two-tier database-driven app they learned to write in school? ;) * * * *The entire data set fits in RAM, you don't need writer concurrency, and you don't need to do ad-hoc queries, reporting, or export to a data warehouse. With apologies to SQLite, prevalence is an improvement on save-files, not a replacement for Oracle.


I read a question in one book: Numbers are randomly generated and stored into an (expanding) array, How would you keep track of the median? There are two data structures can solve the problem. One is the balanced binary tree, the other is two heaps which keep trace of the biggest half and the smallest half of the elements. I think these two solutions has the same running time as O(n lg n), but I am not sure of my judgement. In your opinions, What is the best way to keep track of the median? ————————————————————————————continue In this question，I think the heaps is the best way to keep track of the median. There are two heaps, the big heap and the small heap, which need not to be sequential. First, we calculate the mean value of the elements in the array. If the element is less than the mean value, we put the num to the small heap. On the contrary, we put the num to the big heap. If the number of the big heap is equal to the number of the small heap, the biggest one in the small heap and the smallest one in the big heap are the median. If the two heaps have different size, we just pop the root element from the heap with bigger size and push it to the root of the smaller size heap. For big heap, the root element is the smallest one, and for small heap, the root element is the biggest one. In this way, if the two heaps have the same size or a digital difference, we find the medium in the root. I think this solution has the running time as O(m*n), m means the times we adjust the unbalance heaps. Is this the best way to keep trace of the median?


title: Under what conditions does it make sense to break code into many files, or merge them?

text: Just finished merging seven scripts into one, but got me thinking that I really don't have a formal logic for breaking scripts into pages, or why I'd merge them. Suggestions?


title: How to implement a Weighted shuffle

text: I recently wrote some code that I thought very inefficient, but since it included only a few values, I accepted it. However, I'm still interested at a better algorithm for the following:   1. A list of X objects, each of them are assigned a "weight"   2. Sum up the weights   3. Generate a random number from 0 to the sum   4. Iterate through the objects, subtracting their weight from the sum until the sum is non-positive   5. Remove the object from the list, and then add it to the end of the new list Items 2,4, and 5 all take `n` time, and so it is an `O(n^2)` algorithm. Can this be improved? As an example of a weighted shuffle, an element has a greater chance at being at the front with a higher weight. Example (I'll generate random numbers to make it real): 6 objects with weights 6,5,4,3,2,1; Sum is 21 I picked 19: `19-6-5-4-3-2 = -1`, thus 2 goes in the first position, weights are now 6,5,4,3,1; Sum is 19 I picked 16: `16-6-5-4-3 = -2`, thus 3 goes in the second position, weights are now 6,5,4,1; Sum is 16 I picked 3: `3-6 = -3`, thus 6 goes in the third position, weights are now 5,4,1; Sum is 10 I picked 8: `8-5-4 = -1`, thus 4 goes in the fourth position, weights are now 5,1; Sum is 6 I picked 5: `5-5=0`, thus 5 goes in the fifth position, weights are now 1; Sum is 1 I picked 1: `1-1=0`, thus 1 goes in the last position, I have no more weights, I finish


title: What is the best wrapping strategy?

text: I'm planning to integrate an external tool (ffmpeg in my particular case, but it could be anything, in fact, as lolng as its tasks are long running ones). This tool has a lot of command-line parameters. For now, I've done to simple things with it, already requiring me a good bunch of class writing, to embed all the information it can return to me. I now face the even more complex task of having to send it a bunch of parameters _and_ to handle possible errors. So, what is a best way for that ?   1. Create classes containing all possible options   2. Relying upon a reverse equivalent of commons-cli / CliBuilder / OptionParser   3. Directly write all options from user input   4. Obiwan Kenobi powers (or anything I don't even know about) Please notice I do it in an uncommon language (for the sake of me, don't ask me what it is, as it looks like a desperate and sterile union between CoffeeScript and lua), as a consequence, there can be no framework doing what I want in the language I use.