title: Storing menu items with user permissions

text: I'm creating a menu system in PHP and MySQL. I will have several different menus and each menu will have a set of menu items connected to it. On the site, I also have different user permissions, some users can see all menu items and some items are hidden from some users. I'm curious on how I could handle the permissions in a clean way that will allow for more types of users in the future to be easily added. What I have thus far is something like this:               -------------------     |Menus     -------------------     |id| |display name|     -------------------          ----------------------------------------------------------     |Menu items     ----------------------------------------------------------     |id| |menu_id| |label| |link| |parent| |sort| |permission|     ----------------------------------------------------------      I'm thinking that the `permission` column could either be a comma separated string that I can match against the current user's permission id. It could also be a reference to some other table that defines all possible combinations of the currently existing permissions. One solution could also be to simply store multiple menu items where the only difference is the permission although this would lead to duplicate storage and perhaps a pain to administer. I'd love to hear some thought on how to structure this and what could be considered clean, dynamic and crappy. Thanks.


title: Testing vs Don't Repeat Yourself (DRY)

text: Why is repeating yourself by writing tests so highly encouraged? It seems that tests basically express the same thing as the code, and hence is a duplicate (in concept, not implementation) of the code. Wouldn't the ultimate target of DRY include elimination of all test code?


title: How to infer my Assumptions I based my time estimate on?

text: In an answer on how to make time estimates it is said to write down all your assumptions you made when estimating a project. Seems like a good plan. Problem is, by assuming I already made an ass out of myself without realizing it. Assumptions are those evil things that like to stay hidden, things I took for granted. So when reviewing my estimate, what techniques can I apply to discover the assumptions I based my time estimate on?


title: Factory design pattern - getting the types from a table

text: I've implemented a generic factory as described here I need to register elements to the factory hard-code like this:               Factory.Register(1, typeof(MyClass));      this factory will have to be correlated with a simple domain data type table [id,Display], in this case id 1 is related to MyClass. I was thinking to add a column to that table with the qualified type, so I can simply retrieve the id to types. table will be [id,Display, typeName] and I will use the factory like this:               Factory.Register(id, Type.GetType(typeName));      I tried it and it's working ok. **is this a good design?** **are there any security flaws?** **is there a better way to do things?**


Mocking the DAL/Repository that I pass to the BLL/ViewModels for testing purposes is not much different than creating an in-memory DAL. Right now I'm using an in-memory DAL in a new project instead of mocking it and it's working very well so far (even easier than setting up the mocks I'd say). Since I haven't seen this done in online/book examples I thought I'd ask. Is there a problem with writing an in-memory DAL for testing the BLL/ViewModels? On my architecture all components share a common library with all the relevant interfaces. Things are late bound which allows me to swap any component for another of the same interface.


title: What happened to Borland Delphi?

text: I have the impression that Delphi isn't very popular anymore. But now at work I had to make some changes to an old Delphi program that we are still using. I used Borland Developer Studio 2006 and it was very pleasant and intuitive to work with, even though I had practically no previous exposure to it. Is Delphi still widely-used and I am simply not aware of it or are there other reasons for its decline?


title: Experience of Python's “PEP-302 New Import Hooks”

text: I'm one of the developers of Ruby (CRuby). We are working on Ruby 2.0 release (planned to release 2012/Feb). Python has "PEP302: New Import Hooks" (2003): > This PEP proposes to add a new set of import hooks that offer better > customization of the Python import mechanism. Contrary to the current > **import** hook, a new-style hook can be injected into the existing scheme, > allowing for a finer grained control of how modules are found and how they > are loaded. We are considering introducing a feature similar to PEP302 into Ruby 2.0 (CRuby 2.0). I want to make a proposal which can persuade Matz. Currently, CRuby can load scripts from only file systems in a standard way. If you have any experience or consideration about PEP 302, please share. Example:   1. It's a great spec. No need to change it.   2. It is almost good, but it has this problem...   3. If I could go back to 2003, then I would change the spec to... I'm sorry if such a question is not suitable for here. I posted here because I'm not sure that I can ask this question at python-dev (of course, the list is not for cruby development). This post is moved from http://stackoverflow.com/questions/11188229/experience-of-pythons-pep-302-new- import-hooks.


title: Why use partial classes?

text: In my understanding, the `partial` keyword does nothing but allow a class to be split between several source files. Is there any reason to do this other than for code organization? I've seen it used for that in generated UI classes. It seems a poor reason to create a whole keyword. If a class is big enough to require multiple files, it probably is doing too much. I thought that perhaps you could use it to partially define a class for another programmer somewhere to complete, but it would be better to make an abstract class.


title: Is implementing an interface defined in a subpackage an anti-pattern?

text: Let's say I have the following:               package me.my.pkg;     public interface Something {         /* ... couple of methods go here ... */     }      and:               package me.my;     import me.my.pkg.Something;     public class SomeClass implements Something {         /* ... implementation of Something goes here ... */         /* ... some more method implementations go here too ... */     }      That is, _the class implementing an interface lives closer to the package hierarchy root than does the interface it implements_ but they both belong in the same package hierarchy. The reason for this in the particular case I have in mind is that there is a previously-existing package that groups functionality which the `Something` interface logically belongs to, and the logical (as in both "the one you'd expect" and "the one where it needs to go given the current architecture") implementation class exists previously and lives one level "up" from the logical placement of the interface. _The implementing class does not logically belong anywhere under me.my.pkg._ In my particular case, the class in question implements several interfaces, but that feels like it doesn't make any (or at least no significant) difference here. **I can't decide if this is an acceptable pattern or not. Is it or is it not, and why?**


title: How do I express subtle relationships in my data?

text: "A" is related to "B" and "C". How do I show that "B" and "C" might, by this context, be related as well? ### Example: Here are a few headlines about a recent Broadway play:   1. David Mamet's Glengarry Glen Ross, Starring Al Pacino, Opens on Broadway   2. Al Pacino in 'Glengarry Glen Ross': What did the critics think?   3. Al Pacino earns lackluster reviews for Broadway turn   4. Theater Review: Glengarry Glen Ross Is Selling Its Stars Hard   5. Glengarry Glen Ross; Hey, Who Killed the Klieg Lights? ### Problem: Running a fuzzy-string match over these records will establish some relationships, but not others, even though a human reader could pick them out from context in much larger datasets. How do I find the relationship that suggests #3 is related to #4? Both of them can be easily connected to #1, but not to each other. Is there a (Googlable) name for this kind of data or structure? What kind of algorithm am I looking for? ### Goal: Given 1,000 headlines, a system that automatically suggests that these 5 items are all _probably_ about the same thing. To be honest, it's been so long since I've programmed I'm at a loss how to properly articulate this problem. (I don't know what I don't know, if that makes sense). This is a personal project and I'm writing it in Python. Thanks in advance for any help, advice, and pointers!


What is the difference between Microsoft.Web.Helpers and System.Web.Helpers? Did one take the place of the other (same thing, different version/name), or are they separate things. If so, how do they differ? What is the raison d'etre of each, and are there scenarios where you might use both of them?


title: Would you show your production code to candidates at the interview?

text: I have seen this happen multiple times: The candidate likes the company, succeeds at the interview. Then comes to work and at the end of the first day he is sure the codebase/project is not what he would like to spend time with. So he leaves quickly. I think that introducing candidates to the codebase at the interview could potentially solve this problem. Maybe even better: mixing this with interview questions like "how would you improve this part of the code?" This way, it would be obvious if the candidate is a "good fit for the codebase". Have you seen this approach applied anywhere? Would you show your own codebase to the candidates at the interview: if they asked/as part of the interview process?


title: Do you contribute to open-source software?

text: Recently John Resig (creator of the jQuery library) wrote on his twitter that "When it comes to hiring, I'll take a Github commit log over a resume any day.". As much as I respect that (motivating developers to give back to the community), it also puzzles me, as not all of us have the opportunity to do so, for a number of reasons (family, employer agreements, etc). How would you make a case for the non-contributor developer? Do you think that developers that do not contribute to open-source software are doomed from certain kinds of organizations?


title: Do you think asking to sign contributor license agreement for a open source project creates a resistance for contributors?

text: I am working on a open-source project which is backed by an organization. Organization pays a team to make this open-source project. This project will be licensed with GPLv3. We are debating on having a CLA for contributors. Do you think mandating a CLA will reduce the number of contributors? I have observed that people have no issues in signing a CLA when the project is really popular. So do you think CLA will create a resistance to contribute?


title: If you were the manager of a team of 25 developers, how would you motivate them?

text: Imagine yourself hired by a new startup backed with few millions coming from venture capitalists. Your mission: `organize the development of the next killer app`. 25 developers is too much to take care of each individually, so **what decision(s) you would make to motivate them?** _I will appreciate any answers from stock options to free cookies ;)_ Of course the trick here (unless you are really a manager of a such startup), is put yourself in the shoes of one of those programmers. EDIT: it's an imaginary context. The purpose of this story is to stimulate your wishes. I want to capture what motivates developers.


title: When programming: How much time is spend navigating/scrolling and how much typing?

text: When your programming you often have to go and look at other pieces of code for reference, search for something etc. I'm looking for some numbers on the ratio of time spend actually typing the code(coding) and the time spend going back and forth between other parts of the system, not even counting browsing the internet, reading documentation. Ofcourse this depends on a large number of factors, probably also on your IDE, programming language etc. I just need some rough estimates, or researches on the subject. Background: I want to investigate how much network latency is tolerable for a programmer to work on virtual machines (if any).


title: Open Source Projects & ITAR/EAR

text: What's the story on contributing to open source projects with respect to the International Traffic in Arms Regulations (ITAR) or the Export Administration Regulations (EAR)? From how the laws read it seems like just working on open source SW could put you in violation of export control laws. Is there any precedence on this? Has there been any court cases involving this?


title: Managing large downloadable content on mobile devices

text: This is a general question of how to best manage large downloadable content on mobile devices. Lets consider a situation whereby a mobile app needs to download a number of very large content items, like HD videos, that are over 500MB but under 2GB. Now, lets assume this content delivery system should be scalable. Would it be a fair assumption that:   * A reputable cloud service would be needed - if so, what is a reliable and cost effective cloud service for mobile devices based on anyone's experience?   * Large content downloads should only be attempted over a wifi connection, so the end user doesn't incur large costs, e.g. when travelling.   * Downloads should carry on in the background if possible, as the user won't want to wait in an app for long periods. If the downloads don't finish, or the OS quits the app, all downloads should carry on when the app is next activated? Are there any other pitfalls anyone may have experienced when managing large content on mobile devices? Thanks.


title: How to test Java web applications

text: So far I haven't been testing or learning how to test my java web applications. If you do, what are the tools you need, and is it really necessary to test a web application if doesn't need scaling or it won't be handling big traffics and multi transactions? What things should I test and what approaches should I take to ensure my application works correctly?


title: algorithm from scientific paper

text: In my application I want to use a mixture of several algorithms described in some recently published scientific papers. But I have some legal questions. **Q1** If an algorithm was published in a scientific paper, and the authors were affiliated with academia not some private company, can it be protected by a patent at the same time? I read somewhere that it is not possible to obtain a patent for something that was described in details in a publicly available source. **Q2** If I use some algorithm described in a paper do I **have** to give credit in "legal" or "about" sections in my program or is it just voluntary and would be simply nice of me? It is **not** that I don't want to give credit. It is rather that I don't want to reveal what the program is based on internally and would like to hold copy- cats off for as long as possible.


title: How should one effectively use time at software conferences?

text: Microsoft (through the Student Insider program) has generously flown me out to Microsoft TechEd North America 2011. It seems like the website suggests that one should just make a schedule of the interesting talks, and that's that. However, it seems like several people don't spend much time in the talks and spend the time "networking" (the people kind, not the software kind) instead. How should one maximize the effectiveness of their time at software conferences?


title: Why does my employer want a list of my past & present side projects?

text: I work in Delaware and live in PA. The law in Delaware is clear: My side programming projects are my property and not my employer's, unless I do something on the side that's very similar to the paid work. (See DE code chapter 19 section 805 here: http://codes.lp.findlaw.com/decode/19/8/805). Nevertheless my employer doesn't want to provide me with a piece of paper recognizing my right to my own side projects or even the legitimacy of that DE statute. Still they wanted a list of all my projects before I started, which is perhaps 20 total. Since then I've put out over 10 iOS apps that I wrote in the evenings. What are they up to? What are my options?


title: Writing algorithm on 2D data set in plain english

text: I have started an introductory Java class and the material is absolutely _horrendous_ and I have to get excellent grades to be accepted into the master's degree, hence my very beginner question: In my assignment I have to write algorithms (no pseudo-code yet) to solve a board game (Sudoku). Essentially, the notes say that an algorithm is specification of the input(s), the output(s) and the treatments applied to the input to get the output. My question lies on the wording of algorithms because I could probably code it but I can't seem to put it on paper in a coherent way. The game has a 9x9 board and one of the algorithms to write has to find the solution by looking at 3 squares (either horizontal or vertical) and see if one of the three sub-squares match the number you are looking for. If none match then the number you are looking to place is in one of the other 2 set of 3 sub-squares (see image to get a better idea). **Note:** The task is not to write a complete solver. Only an algorithm to solve the particular case I have described. I really can't get my head around how to formulate the solution into the terms described above or maybe it's just too simple, here's what I was thinking: **Input:** A 2-dimensional set of data of size 9 by 9 to be solved and a number to search for. **Ouput:** A 2-dimensional set of data of size 9 by 9 either solved or partially solved. **Treatment:** Scan each set of 3x9 and 9x3 squares. For each line or column of a 3x3 square check if the number matches a line (or column). If it does then move to the next line (or column). If not then proceed to the next 3x3 square in the same line (or column). Rinse and repeat. Does that make sense as an algorithm written in plain english ? I'm not looking for an answer to the algorithm per se but rather on the formulation of algorithms in plain english. ![enter image description here](http://i.stack.imgur.com/LWV1I.png) **Note** : Apparently this isn't clear: this is not about solving for all possible solutions. This is about solving only this very particular set of rules. I did not make the assignment. In any case, this is not even remotely relevant as this is not the focus of my question.


title: How to deploy a single website to multiple physical servers ?

text: I want to deploy my website to multiple physical servers. Is there possible methods to save files and setting (and also the user input), on all physical servers, so that servers do the following jobs:   1. Servers used as a network, speeding up the process giving a robust thing to the end user.   2. Data to be stored on all the servers' hard drivers, and   3. Every server have the internet connection from different provider, so for example      1. if any of the internet providers gets down, or     2. there occur any hardware or power failure, the website still runs, without a break and without any data loss. Does anyone know about some online course or some comprehensive tutorials about this topic ?


title: Is this paragraph in Code Complete 2 backwards, or am I misunderstanding it?

text: In chapter 13, when talking about pointers, there is a paragraph: > Sometimes, however, you would like to have the semantics of pass by > reference—that is, that the passed object should not be altered—with the > implementation of pass by value—that is, passing the actual object rather > than a copy. It seems like the author made a mistake and mixed the two up. Is this true, or am I not understanding what he's saying correctly?


title: Is online freelance work viable by American standards?

text: I've always been curious about trying out online freelance sites... it would be nice to work from home, feel independent, get to choose what I want to work on, get to work on different technologies, lose the PHB, etc. However I never really gave them a chance because I'm used to American rates and assumed that I would be competing with people from India, Russia, China, etc. that would severely undercut me, and it wouldn't be viable for me. Am I correct in this assumption or should I give it a shot? What kind of hourly rate would I be able to expect on short-term programming work?


title: Standardized Programming Languages

text: Is there an organization similar to W3C that creates standards for programming languages? If so, are there any programming languages, like browsers would using W3C standards, that implement these standards? I have done my own research and I have been unsuccessful thus far hence the question. The answers and most of the comments so far are very useful but essentially I'm looking for a language or list of languages that have an open and reliable licensing system. I think W3C has been the most successful at this up until now with HTML so I am looking for a language that has a similar licensing structure. Java has certain specifications like the EE servlet specification which has providers like Tomcat implement it but then at the end of the day that is still an Oracle owned standard isn't it?


title: When should I pass setting-like value as class' variable and when as an assoc. array?

text: Following my other question, is there a general rule of thumb, when we should pass a setting-like value, that controls class' behavior (for example displayed texts) as as class' constant or variable, one-by-one, and when it is better to "pack" them to one associative array? Or is it just a choice of the developer? For example -- is this approach better (PHP code):               class SomeClass     {         public $errorIncorrectProtocol = 'Please, don't use GET protocol in this context!';         public $errorMissingId = 'The ID can't be empty or equal zero...';     }      than this one:               class SomeClass     {         public $errorMessages = array         (             'IncorrectProtocol'=>'Please, don't use GET protocol in this context!',             'MissingId'=>'The ID can't be empty or equal zero...'         );     }      and if yes -- then, why?


title: How to use ORM in MVC?

text: If I want to use ORM in MVC system Which is/are correct?   1. Use ORM object to replace Model   2. Encapsulate ORM inside the Model   3. Use ORM outside the Model, use ORM to access DB, and then use one instance to store one record of data.   4. Other better practise Please give me some example


title: Design for an interface implementation that provides additional functionality

text: There is a design problem that I came upon while implementing an interface: Let's say there is a `Device` interface that promises to provide functionalities `PerformA()` and `GetB()`. This interface will be implemented for multiple models of a device. What happens if one model has an additional functionality `CheckC()` which doesn't have equivalents in other implementations? I came up with different solutions, none of which seems to comply with interface design guidelines:   * To add `CheckC()` method to the interface and leave one of its implementations empty:               interface ISomeDevice     {         void PerformA();         int GetB();         bool CheckC();     }          class DeviceModel1 : ISomeDevice     {         public void PerformA() { // do stuff }         public int GetB() { return 1; }         public bool CheckC() {             bool res;             // assign res a value based on some validation             return res;         }     }          class DeviceModel2 : ISomeDevice     {         public void PerformA() { // do stuff }         public int GetB() { return 1; }         public bool CheckC() {             return true; // without checking anything         }     }      This solution seems incorrect as a class implements an interface without **truly** implementing all the demanded methods.   * To leave out `CheckC()` method from the interface and to use explicit cast in order to call it:               interface ISomeDevice     {         void PerformA();         int GetB();     }          class DeviceModel1 : ISomeDevice     {         public void PerformA() { // do stuff }         public int GetB() { return 1; }         public bool CheckC() {             bool res;             // assign res a value based on some validation             return res;         }     }          class DeviceModel2 : ISomeDevice     {         public void PerformA() { // do stuff }         public int GetB() { return 1; }     }          class DeviceManager     {         private ISomeDevice myDevice;         public void ManageDevice(bool newDeviceModel)         {             myDevice = (newDeviceModel) ? new DeviceModel1() : new DeviceModel2();             myDevice.PerformA();             int b = myDevice.GetB();             if (newDeviceModel)             {                 DeviceModel1 newDevice = myDevice as DeviceModel1;                 bool c = newDevice.CheckC();             }         }     }      This solution seems to make the interface inconsistent.   * For the device that supports `CheckC()`: to add the logic of `CheckC()` into the logic of another method that is present in the interface. This solution is not always possible. So, what is the correct design to be used in such cases? Maybe creating an interface should be abandoned altogether in favor of another design?


title: Do markup languages have the equivalent concept of `semantics` that you can find in C or C++?

text: Maybe I miss something, but do the so called markup languages have the equivalent concept of `semantics` that you can find in C or C++? Judging from how you parse the language, you don't really have too many options, there isn't too much context, you just parse your tokens and apply them to the source code. I'm tempted to say that not only semantics doesn't exist in this case, but this only happens in markup languages: am I right?


title: OO Design when using communication

text: I have 2 applications one is written in C++ and one is written in Java. the applications communicate by passing byte arrays which represent a serialized object. each communication object represent a Command and holds the command id and the associated data. I will use an example to describe my problem. Let's say I have 3 components. one is responsible for the data storage and file system, one is responsible for presenting UI , and one is responsible for security and authorizing users. One way to access a specific component is by having one entry point that will do a switch case on all the possible commands ids. pseudo:                   switch(commandId)     {     case SAVE_FILE:     DATASTORAGE::Save();     break;     case LOAD_FILE:      DATASTORAGE::Load();      break;     case AUTHORIZE:      SECURITY_CONTROLLER::authorize();      break;     case DENY_ACCESS:      SECURITY_CONTROLLER::denyAccess();      ...     }      In this case if I need to change the security controller, I need to change this main entry point. so instead I added an extra field to the communication object, that holds the id of the component that need to process the command. In this case if I want to preform authorize I will do the following:               communicationObject.commandId = AUTHORIZE;     communicationObject.target = SECURITY_CONTROLLER_ID;      And the main will switch case on the possible targets and pass the command id to the specfic component which is responsible for that command.                  switch(target)     {     case SECURITY_CONTROLLER_ID:     SECURITY_CONTROLLER::Process(commandId);     break;     case DATASTORAGE_ID:      DATASTORAGE::Process(commandId);           ...     }      I also don't like this new design since it requires that the sender will know the inner structure of the receiver. on the other hand, if I had direct access to the other application classes (not using byte [] for communication) then the second option will be mapped to something like: SECURITY_CONTROLLER::Authorize(); while the first option will be mapped to something like Main.AUTHORIZE(), which is definitely not the way to go! what is the best approach in this case?


title: How to design modular "screen configurator" for database application

text: I am currently working with a product that is effectively a glorified CRUD application. (It is a C# .NET 4.0 desktop application backed by an Oracle 11gR2 database.) The client program presents a list of "screens" that the user can open; each presents a view of some data and a number of buttons used to perform operations on the data. Currently, these screens are configurable to the extent of deciding what data to show on the screen and what each of the buttons should do. However, what I would like to do is to make each control a "module" and allow the user doing the configuration to drag and drop these modules into a wireframe to create a customised screen on-the-fly. For example, I would like a "grid" module (we effectively already have this as a WPF control) such that I could have as many "grids" on a screen as I like, and each could have a different configuration - e.g. what fields are shown, and which fields are editable. Further, each grid could be linked so that selecting an item in one grid would cause related data to load in another grid. How do I approach this design?


title: Intermittent flickering on mouse move

text: We have an internal website that is written in javascript and jquery and is only used in with ie8. Everything is fine but after a certain time, screen flickering starts to occur when the mouse transitions between certain elements (which can be annoying for the users). I can't really put any code up because there is quite a lot but I just wondered if anyone might know what initiate this strange problem or have ever had similar issues!?!? The script makes 4 ajax calls on page load which dynamically loads content and is also within an iFrame. I have looked into a few possible sources, i.e, Memory issues/leaks, jquery/modal, timers, iFrames, but I just don't understand why it is not consistent?


How should code in version control be stored? **Developer friendly**? so that programmer can quickly take the latest and able to run from his editor without doing many changes? (like config files pointing to dev DB..etc) or Should it be **production friendly**? source should be in a manner which is easy to deploy on production environment and when developer takes the latest, he should perform changes as per his development needs.


title: Best approach for a server configuration data collection and reporting solution from a legacy script?

text: I have a project which involves collecting config data from windows servers in our (very large) server estate. My manager wants me to collect over 150 data items across all configuration areas including network config data, disks, registry values, BIOS version, dll versions, you name it. The server support team currently use a nasty vbScript script which is massive, messy and has been passed around and grown organically over time. The script is currently used to collect the data and produce a very basic flat HTML report with a column for each of the 150+ items it collects data for. My job is to tranform it into a proper software solution with new bells and whistles, a website, reports etc. The idea is a sys admin will go to an intranet website, puts the server name in and presses the go button, the solution collects the data and pushes it into the DB for reporting later. My manager wants the solution to collect the data, some of it referencing known desired values (e.g. RAID card drivers for ABC model servers is at v1.2.5.1) to see if they are correct or up to date, store it in a SQL database, and then use the front end web site for producing reports. In the reports, he wants it to be able to compare two datasets; for example, one for server ABC123 and one for server DEF987 in one report, highlighting any differences between the two. It gets messy pretty quick as some data will be collected for on some servers but not others (domain controllers wont have data collected about exchange services running status). There are many miscellanous items which don't fit into a data model area and don't really have a home ... it's a mess. I'm ok with collecting the data (using .Net), but I'm at a loss as to where the best place is to do such things as store and lookup/compare items to good known values (XML, DB?). Should I do it as part of the data collection phase and then push it into the DB. Or should I marry it all up as part of the reporting data? I'm going with a data warehouse (de-normalised) schema for the DB. There will probably be about 20 tables which the data will need to be pulled from, so I have no real idea what the best way to compare the dataset from one server data collection, with another, with such a massive set of fields to compare. What do you guys think my best options are for approaching this project and the architecure of the solution?


title: How do you go from intermediate to expert?

text: Some would say: write a lot of code. That's certaintly true, writing a lot of code has helped me. I seen see the pitfalls. I refactor. I read. I've read countless books and I acknowledge design patterns. However, when it comes to actually using them in real life they escape me. I see code littered with fancy features and elegant solutions and I wonder: gee, why didn't I think of that? How does one go from intermediate to expert? What things should you be reading daily? How can you improve your skill? Your apt for problem solving? Ultimately, how can you bridge the gap from good to great?


title: Will a copyrighted code get into public domain once its copyright expires?

text: Since source code license is protected through the Copyright Law (Berne Convention to be precise), and all copyrighted material will be in public domain for certain number of years, depending on which country.   1. Will a copyrighted source code, closed or open source, be in public domain once its copyright expires?   2. For closed source, can I ask the company for the closed source code once it got expired (just assuming based on what I've understood so far :-) )?   3. Assuming question 1 is true, how can I prevent a source code from getting into public domain once the copyright expires, if it's possible?


title: How can I best manage making open source code releases from my company's confidential research code?

text: My company (let's call them Acme Technology) has a library of approximately one thousand source files that originally came from its Acme Labs research group, incubated in a development group for a couple years, and has more recently been provided to a handful of customers under non-disclosure. Acme is getting ready to release perhaps 75% of the code to the open source community. The other 25% would be released later, but for now, is either not ready for customer use or contains code related to future innovations they need to keep out of the hands of competitors. The code is presently formatted with #ifdefs that permit the same code base to work with the pre-production platforms that will be available to university researchers and a much wider range of commercial customers once it goes to open source, while at the same time being available for experimentation and prototyping and forward compatibility testing with the future platform. Keeping a single code base is considered essential for the economics (and sanity) of my group who would have a tough time maintaining two copies in parallel. Files in our current base look something like this:               > // Copyright 2012 (C) Acme Technology, All Rights Reserved.     > // Very large, often varied and restrictive copyright license in English and French,     > // sometimes also embedded in make files and shell scripts with varied      > // comment styles.      >      >      >   ... Usual header stuff...     >     > void initTechnologyLibrary() {     >     nuiInterface(on);     > #ifdef  UNDER_RESEARCH     >     holographicVisualization(on);     > #endif     > }      And we would like to convert them to something like:               > // GPL Copyright (C) Acme Technology Labs 2012, Some rights reserved.     > // Acme appreciates your interest in its technology, please contact xyz@acme.com      > // for technical support, and www.acme.com/emergingTech for updates and RSS feed.     >      >   ... Usual header stuff...     >     > void initTechnologyLibrary() {     >     nuiInterface(on);     > }      Is there a tool, parse library, or popular script that can replace the copyright and strip out not just #ifdefs, but variations like #if defined(UNDER_RESEARCH), etc.? The code is presently in Git and would likely be hosted somewhere that uses Git. Would there be a way to safely link repositories together so we can efficiently reintegrate our improvements with the open source versions? Advice about other pitfalls is welcome.


title: Proxy to redirect DNS during development

text: I am using Genymotion to test an app. The app is basically a browser that connects to my website. I do not have the app's source. I do the development and testing of the website in a domain like this: dev.mywebsite.com The app connects to mywebsite.com. Genymotion allows me to use an HTTP proxy. My question is, is there any software for windows or linux that would work as a proxy and redirect all requests to mywebsite.com to dev.mywebsite.com ?


title: When a function is called in Javascript, is there then an easy way to find where a function is declared in?

text: It would be great if some IDE offered the way to right mouse click when a function is called and have the immediate option to jump to the function when it is defined. Is this possible in Javascript? Maybe I've just been oblivious - is there a name for this technique?


title: How to implement DDD in a distributed application with NHibernate?

text: I have an ASP.NET MVC web site working in this way: (In the controller)               var user = _applicationService.GetUserById(1);     user.ChangeEmail("mynemail@somewhere.com");     user.ChangeAddress("my new street", "21");      (In a HttpModule)               void EndRequest(){         if (HttpContext.Error is null){             _sessionFactory.GetCurrentSession.Transaction.Commit();          }      This way is possible because the session factory is built in the web site application start. Is posible to call multiple domain methods and call commit once in the end of the request. But in a distributed application isn't posible to use domain objects directly, instead a WCF service must receive a DTO. Now my question is: how you design the methods `ChangeEmail` and `ChangeAddress` for a distributed scenario? Each one must be a distinct operation in the Web service? If so, then when a user changes his email AND his address must be necesary to call two times to the service. Or instead I must model a web service like this:               var userDTO = _wcfService.GetUserDTOById(1);     userDTO.Email = "mynewemail@somewhere.com";     userDTO.Street = "My new street";     userDTO.StreetNumber = "21";     _wcfService.PersistChanges(userDTO)


title: What should I think about when switching from Python to Java?

text: > **Possible Duplicate:**   >  Java dev learning Python: what concepts do I need to wrap my head around? I was a Java developer in the early 2000s, switched to Python in 2008 and now I am working in Java again. How has Java changed since the early 2000s? What are the major updates besides generics? Is there anything special you think I should keep in mind when going back to a Java environment? I used to work with EJB 1.0, I didn't work with EJB 2.0 and now we have JPA instead. I'm comfortable programming in Java and my new job with Java is much better than my Python job even though Python is my favorite language the tools and others things about my Java job makes it much better. I found when I searched jobs that demand for Java developer was much greater than demand for Python programmers - do you have a similar experience?


title: When to stop writing user stories, and start coding?

text: When discovering stories for the first sprint, how do you know when to stop writing and move forward? I've asked a few people I know, and basically the response I've gotten is, it depends on the context the project exists in and how timeboxed the overall project is as well. Is there any standard way for knowing when to stop writing user stories, and if so, what is the basis for this, and how does it apply to future sprints?


title: How do you keep your unit tests working when refactoring?

text: In another question, it was revealed that one of the pains with TDD is keeping the testing suite in sync with the codebase during and after refactoring. Now, I'm a big fan of refactoring. I'm not going to give it up to do TDD. But I've also experienced the problems of tests written in such a way that minor refactoring leads to lots of test failures. How do you avoid breaking tests when refactoring?   * Do you write the tests 'better'? If so, what should you look for?    * Do you avoid certain types of refactoring?    * Are there test-refactoring tools? **Edit:** I wrote a new question that asked what I meant to ask (but kept this one as an interesting variant).


title: What is beautiful code?

text: I often read that developers must write beautiful code, but for a beginner as I am it remains obscure of what is beautiful code and how do you recognize it? The corollary question is: **How to write beautiful code and what are some practical habits to improve your code's quality?** , what should I care about to make the code I write beautiful (and what shoud I learn).


title: Does connection pooling work fine to execute 60 DB queries to load a page?

text: We use Linq2Sql in an ASP.NET application. Unfortunately the eager-loading in Linq2Sql isn't as powerful as in Entity Framework, so a lot of the data has to be lazy loaded as needed. Taking connection pooling into account, is it OK for a web page to execute 60 queries to load a page? Executing a single big query probably won't be much better, as those 60 queries will all those connection pooled connections and not open a new connection each time (which I realize is slow). Any thoughts?


title: How to document business rules

text: I am wondering what would be the formal and the most commonly practiced method of documenting business rules? Also how do you document the UI specifications of development artifacts (e.g. Documenting form fields and how buttons behave on form, info text .. etc)


title: Lost my touch with markup, move into new resources or refresh with old?

text: I haven't touched XHTML/CSS for many months now. I'm no where near efficient coding as I used to be. Creating more complex things is taking me a lot of time lately. What should I do to brush up on my skills? Just work a bunch of tutorials? Go through some old documentation before moving into HTML5 and CSS3?


title: Parallelism implies concurrency but not the other way round right?

text: I often read that parallelism and concurrency are different things. Very often the answerers/commenters go as far as writing that they're two entirely different things. Yet in my view they're related but I'd like some clarification on that. For example if I'm on a multi-core CPU and manage to divide the computation into _x_ smaller computation (say using fork/join) each running in its own thread, I'll have a program that is both doing parallel computation (because supposedly at any point in time several threads are going to run on several cores) **and** being concurrent right? While if I'm simply using, say, Java and dealing with UI events and repaints on the Event Dispatch Thread plus running the only thread I created myself, I'll have a program that is concurrent (EDT + GC thread + my main thread etc.) but not parallel. I'd like to know if I'm getting this right and if parallelism (on a "single but multi-cores" system) always implies concurrency or not? Also, are multi-threaded programs running on multi-cores CPU but where the different threads are doing totally different computation considered to be using "parallelism"?


title: Training a 'replacement', how to enforce standards?

text: Not sure that this is the right stack exchange site to ask this of, but here goes... **Scope** * * * I work for a small company that employs a few hundred people. The development team for the company is small and works out of visual foxpro. A specific department in the company hired me in as a 'lone gunman' to fix and enhance a pre-existing invoicing system. I've successfully taken an Access application that suffered from a lot of risks and limitations and converted it into a C# application driven off of a SQL server backend. I have recently obtained my undergraduate and am no expert by any means. To help make up for that I've felt that earning microsoft certifications will force me to understand more about .net and how it functions. So, after giving my notice with 9 months in advance, 3 months ago a replacement finally showed up. Their role is to learn what I have been designing to an attempt to **support** the applications designed in **C#**. * * * **The Replacement** Fresh out of college with no real-world work experience, the first instinct for anything involving data was and still is listboxes... any time data is mentioned the list box is the control of choice for the replacement. This has gotten to the point, no matter how many times I discuss other controls, where I've seen 5 listboxes on a single form. Classroom experience was almost all C++ console development. So, an example of where I have concern is in a winforms application: Users need to key Reasons into a table to select from later. Given that I know that a strongly typed data set exists, I can just drag the data source from the toolbox and it would create all of this for me. I realize this is a simple example but using databinding is the key. For the past few months now we have been talking about the strongly typed dataset, how to use it and where it interacts with other controls. Data sets, how they work in relation to binding sources, adapters and data grid views. After handing this project off I expected questions about how to implement these since for me this is the way to do it. What happened next simply floors me: An instance of an adapter from the strongly typed dataset was created in the activate event of the form, a table was created and filled with data. Then, a loop was made to manually add rows to a **listbox** from this table. Finally, a variable was kept to do lookups to figure out what ID the record was for updates if required. How do they modify records you ask? That was my first question too. You won't believe how simple it is, all you do it double click and they type into a **pop-up prompt** the new value to change it to. As a data entry operator, all the modal popups would drive me absolutely insane. The final solution exceeds 100 lines of code that must be maintained. So my concern is that none of this is sinking in... the department is only allowed 20 hours a week of their time. Up until last week, we've only been given 4-5 hours a week if I'm lucky. The past week or so, I've been lucky to get 10. * * * **Question** **WHAT DO I DO?!** I have 4 weeks left until I leave and they fully 'support' this application. I love this job and the opportunity it has given me but it's time for me to spread my wings and find something new. I am in no way, shape or form convinced that they are ready to take over. I do feel that the replacement has the technical ability to 'figure it out' but instead of learning they just write code to do all of this stuff manually. If the replacement wants to code differently in the end, as long as it works I'm fine with that as horrifiying at it looks. However to support what I have designed they **MUST** to understand how it works and how I have used controls and the framework to make 'magic' happen. This project has about 40 forms, a database with over 30 some odd tables, triggers and stored procedures. It relates labor to invoices to contracts to projections... it's not as simple as it was three years ago when I began this project and the department is now in a position where they cannot survive without it. How in the world can I accomplish any of the following?:   * Enforce standards or understanding in constent design when the department manager keeps telling them they can do it however they want to   * Find a way to engage the replacement in active learning of the framework and system design that support must be given for   * Gracefully inform sr. management that 5-9 hours a week is simply not enough time to learn about the department, pre-existing processes, applications that need to be supported AND determine where potential enhancements to the system go... Yes I know this is a wall of text, thanks for reading through me but I simply don't know what I should be doing. For me, this job is a monster of a reference and things would look extremely bad if I left and things fell apart. How do I handle this?


title: I have to compromise: DRY, or Command-Query-Separation?

text: I was recently refactoring a method that was both a command and a query method. After separating it into a one command method and one query method, I found that there are now multiple places in the code where I am calling the command then getting the value from the query, which seems like a violation of the DRY principle. But if I were to wrap that common code into a method, that method would be both command and a query. Is this acceptable?


title: New nodes joining distributed genetic algorithm

text: I'm sort of torn on what to do for implementation of my distributed genetic algorithm problem. I would like to be able to have nodes join and part at will and not take down the whole system. But this introduces the problem of mismatch of generations. Often times a genetic algorithm simulation is capped by a certain amount of generations and if I have a node that is on 75 out of 100 generations and a brand new node joins the cluster I'm not sure if I should fake it and start at 75 and copy one of the other nodes as a starting point or have it start out at 0 and potentially have the results delayed until the end of execution of the new node. I was hoping someone had some input on what they could see as problems in addition to a long wait time with this new node if I start at 0, I am struggling to think of what could go wrong in both approaches other than that.


title: Do I have to release source code because I'm using JavaFX?

text: I'm using JavaFX for gui of my app. Its license is GPL+Linking Exception. GPL requires me to release my source code. But what's the linking exception?? (I'm just using it as a library. Not modifying or using its source code.)


title: Copyright notices: What if I change my surname? What if someone else has the exact same name?

text: I'm adding copyright notices to all my source code files:               Copyright (C) 2013 My-First-Name My-Surname        1. But what if someone else is also named _My-First-Name My-Surname_? What does courts think about that? How would they know who is the real author? Is there something I can/should do about this situation? (So they'd know for sure)   2. What if I change my surname. Then, how do other people know that I'm still the copyright holder? Is there something I can/should do, to avoid trouble with copyright, after I've changed my name? **An example** of when the above could be of interest: Someone gets married and change his/her surname and moves to a new address. Then, even if s/he has submitted his/her source code to the U.S. Copyright Office, that was done using his/her old name and address. Now s/he however has a new name and address. But there is perhaps other people that have the old name (but not also the old address). (In my country, for any first + middle + surname, there are usually many people with that full name.) Apparently people think this is a weird question, but I've read about rather many very decisions made in courts, e.g. someone suing for hot coffee and winning millions of dollars.


title: Specifying the format in which I want to get a response through POST

text: It's a good practice to let a client specify the format in Web REST API:               GET /api/items/123.csv      However, not only `GET` can return some answer, but `POST` also can do               Status: 201 Created          {       mgs: "Your item has created successfully",       href: "/example.com/items/123"     }      How should `URI` look like for a `POST` (`PUT` or whatever, but not `GET`) request which returns a response so that a client can specify the format they want the response to be in? Like this?:               POST /api/items/.csv       Or suppose there is an error when a client sends a POST request and the server must inform the client about it:               Status: 400 Bad Request     {       mgs: "this is a bad request",       devMessage: "it's bad because ...."       friendlyMessage: "something bad happened..."     }      What format should it respond in, why and how do I specify it as a client? P.S. - I'm aware about REST - Tradeoffs between content negotiation via Accept header versus extensions


title: Why does java.util.Calendar use static factory methods?

text: It is considered better to have a separate factory class than having static methods in same class. See this question. But the standard API uses both approaches. Separate factory:               DatatypeFactory.newInstance().newXMLGregorianCalendar(...)      Static methods in same class:               Calendar.getInstance(...)      Why is this? In what case would having static methods be better than having a separate factory?


title: Contract Programming - Deposit % and Payment Methods? Any advice is appreciated

text: I'm pretty new to doing contract work and finally landed a decent paying project. The guy actually offered to put down a deposit and I'm just wondering what percentage I should consider asking for. I was thinking around 25% since its not a terribly large project (only about 20 hours). Also, I can't use PayPal (have had a terrible experience with them freezing funds for no good reason) so I'm wondering if anyone can suggest other methods for the client to send the deposit / payment. I want to make it as easy as possible for them.. thanks for any advice


title: How to unit test without mocks and not be tied to a concrete implementations of an interface

text: I consider myself to be a 'mockist' on the 'mockist' vs 'classicist' debate, but I am trying to understand the other point of view. Imagine I have this class, where a concrete instance of `IDependency` is injected by an IoC container. `IDependency` does not access a remote resource like a database or web service (in which case I would definately mock it), it is just another class containing some business logic.               public class UnitUnderTest     {         public UnitUnderTest ( IDependency dependency )         {         }     }      Using this pattern, I am free to change the concrete implementation of `IDependency` by changing the class injected by the IoC container. I am not _tied_ to any particular implementation. If I was to test this class without mocking `IDependency`, wouldn't I have to instantiate my _real_ `IDependency` to pass in to the constructor?               public class My_Unit_Test()     {         IDependency concreteDependency = new ConcreteDependency();         var unitUnderTest = new UnitUnderTest(concreteDependency);     }      In this example, if I write a replacement to `ConcreteDependency`, I would have to not only change my IoC container configuration, but all of my unit tests that use `ConcreteDependency`. Or.. do I use the same IoC container within my unit tests (which seems like it goes against the idea of testing things in isolation)?


title: Keeping documentation / manuals up-to-date in a rapidly changing project

text: ### Background I work on a relatively large project (~570 KLOC) in a relatively small team (formerly 5 developers, now 2). Large amounts of code can appear and then vanish in months; for example, a few years ago an investment bank launched a new stock exchange, then shut it down 7 months later—thousands of LOC were written to support that exchange's interface, then deleted. To help operations and support teams as well as new developers, we have an internal wiki (a modified DokuWiki, if it matters) with things like retrospective specs (we're writing specs as we go, unfortunately) and what various settings, flags, and status codes mean and do. ### Problem Due to the fast pace of development, however, much of our wiki content becomes obsolete in months, if not weeks. And it's not as simple as updating a single wiki section about whatever component is being changed; with numerous interlocking components, changing one thing, like a setting in the algorithmic trading component, might require looking through a hundred references to this setting and/or component in the wiki, many whose sections may need updating. The main issue, I believe, is a motivational one. Developers know that whatever they write has a good chance of becoming obsolete soon, so it's rarely worth it (nor is it practical) to go searching throuh the wiki to update all relevant pieces, especially when 2 or 3 days later there might be a request to change, say, the format of a setting, or even its functionality. This leads to distrust of the wiki—even amongst ourselves, we're never sure whether what we're reading indeed describes the latest functionality. And that, I feel, ultimately feeds a vicious cycle akin to the broken windows theory: the perception of disorder demotivates any action to bring back order. ### Idea My idea was to migrate the wiki to something more like Stack Exchange—for example customizing Question2Answer. For two reasons:   1. I hope that putting all information in Q&A form encourages documentation to be written with the thought in mind, "What question am I trying to answer? Who am I trying to help?" This is unrelated to this post, though.   2. More importantly, my idea is to use tags—a tag for each component, each setting, each business term, etc.—so that it's _easier_ to find _posts_ that need updating, rather than going through every instance of a keyword—and keyword searches are context-less already, on their own. ### Question Before I go through with this idea, though, I thought I might benefit from advice if anyone else has worked in such a context. I'm open to all ideas and alternatives! _How do you keep highly cross-referenced documentation up-to-date in a rapidly changing project?_


title: LLVM case: is the success due to the algorithms?

text: I'm not sure if this is a subjective question, I hope not but I'm not proficient with LLVM so I'm just wondering: how come it's become so popular and so widespread used in the industry? Were the optimization algorithms used in gcc/icc/msvc just worse than the LLVM ones? Is it possible that a university project managed to outperform such known and long-standing compilers? I know that LLVM is modular, but can then a design be the cause of that much success? I can't understand the real reasons behind that, this is also probably related to a subjective question like "is the success of a software always related to a new or semi-new algorithm that speeds something up?" but I'd like to get objective reasons to my first question if possible


title: TFS SQL Deployment Data Script

text: We are using TFS and SQL Server 2005 (looking to upgrade to SQL Server 2012 if that makes a difference). We store our database schema in a Visual Studio Database project (VS 2010). When code is released to live we currently use the Visual Studio Database Project to build a script for all our schema changes. The problem we have been getting is having to alter or add to that script to add/fix data for the deployment. For example if we add a new non-nullable column to an existing table we need to populate that column with data during the insert. Other times we may want to create new records in transactional tables (e.g. assign specific users to a new security access). Do Visual Studio Database Projects have a way to store these scripts that only need to be run once and somehow include them in the build? Does it know which scripts need to be run (for example if we are inserting default data we don't want to do that again a second time)? OR Is there a better way to manage these scripts?


title: Patterns to refactor common code in multi-platform software

text: I have a Django application and a PyQt application that share a lot of code. A big chunk of the PyQt application are copied verbatim from the Django application's views. As this is a game, I have already an engine.py module that I'm sharing among the two applications, but I was wondering how to restructure the middle layer (what in Django corresponds to the largest part of the views minus the return HttpResponse part) into its own component. In the web application the components are those of a classic Django application (with the only exception that I don't make any use of models):   * the game engine   * the url dispatcher   * the template   * the views My PyQt application is divided into:   * the game engine   * the UI definition where I declare the UI components and react to the events (basically this takes the place of the template and the url dispatcher in the Django app)   * the controller where I instantiate the window object and reproduce the methods that map the views in the Django app


title: I need some help creating a non-binary tree (or some other data structure that will better solve my problem)

text: I have about ten lists of numbers and some strings. Each list has about <= 30K lines. Each line on a list has a distinct number. I need to build an efficient way of finding all the lines in each list that has the same 'control' number (or key for dB guys) and comparing what is in their string parts. I am writing this in Java. Let me give an actual example of what I am trying to do..... I have ten lists each containing about 30K records. Each record looks like 901234(key)- 1.0987(float)-kadfnfj(Description String)-01/01/01(date) and all lists have similar records some keys may be available in some lists but not guaranteed!.. I want to find a way to search through all lists for one particular key and compare the attendant float value. Due to the size of the lists, i am worried about the memory usage and due to the number of records, I am worried about the efficiency of the data structure used. I have thought about using trees but my brain cells are about burnt now. I need some help.


title: Are there well-known PowerShell coding conventions?

text: Are there any well-defined conventions when programming in PowerShell? For example, in scripts which are to be maintained long-term, do we need to:   * Use the real cmdlet name or alias?   * Specify the cmdlet parameter name in full or only partially (`dir -Recurse` versus `dir -r`)   * When specifying string arguments for cmdlets do you enclose them in quotes (`New-Object 'System.Int32'` versus `New-Object System.Int32`   * When writing functions and filters do you specify the types of parameters?   * Do you write cmdlets in the (official) correct case?   * For keywords like `BEGIN...PROCESS...END` do you write them in uppercase only? It seems that MSDN lack coding conventions document for PowerShell, while such document exist for example for C#.


title: Why Does F# Contain Both Modules and Namespaces?

text: I've been assuming that F# includes the module keyword in addition to the namespace keyword due to backwards compatibility with OCaml. Is this the only reason for the inclusion of the module keyword or are there other reasons module was included?


title: What are the PHP web server architecture components and the purpose of each one of them?

text: Given below is an image of a basic PHP web server architecture: ![PHP web server architecture](http://i.stack.imgur.com/2H0eh.gif) Would someone please explain the several components available and how they interact?   I'm more concerned of how the **PHP Core** operates and relates to the other components, so feel free to elaborate on this point specifically. This Diagram was taken from here.


title: When to use REST to handle requests vs using AJAX to handle requests

text: On my web page, if I wish to display dynamic dropdowns (e.g city names based on country selected), I can do it using AJAX. But I can also do it using a REST call. So which should I use? My problem is I really don't get the difference between REST and any other HTTP browser request.(a.k.a a form submit). I have looked at the formal definitions of REST and it seems identical to a HTTP request. So how is REST inherently different from AJAX?


title: Organization standards for large programs

text: I'm the only software developer at the company where I work. I was hired straight out of college, and I've been working here for several years. When I started, eveeryone was managing their own data as they saw fit (lots of filing cabinets). Until recently, I've only been tasked with small standalone projects to help with simple workflows. In the beginning of the year I was asked to make a replacement for their HR software. I used SQL Server, Entity Framework, WPF, along with MVVM and Repository/Unit of work patterns. It was a huge hit. I was very happy with how it went, and it was a very solid program. As such, my employer asked me to expand this program into a corporate dashboard that tracks all of their various corporate data domains (People, Salary, Vehicles/Assets, Statistics, etc.) I use integrated authentication, and due to the initial HR build, I can map users to people in positions, so I know who is who when they open the program, and I can show each person a customized dashboard given their work functions. My concern is that I've never worked on such a large project. I'm planning, meeting with end users, developing, documenting, testing and deploying it on my own. I'm part way through the second addition, and I'm seeing that my code is getting disorganized. It's still programmed well, I'm just struggling with the organization of namespaces, classes and the database model. Are there any good guidelines to follow that will help me keep everything straight? As I have it now, I have folders for Data, Repositories/Unit of Work, Views, View Models, XAML Resources and Miscellaneous Utilities. Should I make parent folders for each data domain? Should I make separate EF models per domain instead of the one I have for the entire database? Are there any standards out there for organizing large programs that span multiple data domains? I would appreciate any suggestions.


title: What tools can be used to facilitate code reviews after commits?

text: I've been evaluating a number of code review tools (mostly free ones), but they all seem to be aimed at reviewing patches before they are committed. This wouldn't really fit within our workflow with Subversion, so I've been looking for alternatives that better support reviewing committed revisions instead of just diffs. Any recommendations? I would prefer free or inexpensive tools.


title: Why is C so high in TIOBE index of popularity, while C++ is just under here too, but not as popular?

text: I can't get my head around this. If C is so much used, but C is not C++, can someone explain to me the most important reasons that makes C more used than C++ ? Where is all this C code written for ? Is this about the industrial sector which heavily rely on imperative programming but can't support the cost of implementing or tuning C++ compilers ? Are there that many kernel hackers ? Is tiobe relevant ? I never stumbled into any article or post commenting or explaining how singular tiobe's ranking is, and what it actually says about what the industry likes, and what it can tell about what the industry actually uses, to pinpoint the industry real needs. It's hard to explain. I just find it odd many companies want C#, php, java jobs, and not C or C++ jobs (just relating my unemployment and my interviews here) even if those C/C++ jobs are crap. I would take those instead. Or does this mean language hype plays a strong role here ?


title: What is a manifest and when is it appropriate to use one?

text: I hear the usage of manifests in various ways but never have had the need—to my knowledge—to use one. What are they and how are they used? EDIT: I'm curious about manifests in general with any language.


title: Why should I use the function migration in codeigniter?

text: What is wrong with using database tables with phpmyadmin or mysql? What are the benefits, if I'll use 'migration'?


title: Can we create a program that writes out its source code?

text: Can we create a program that print out its source code what if we (or the program itself) compile than the new program would have the **same exact functionality** what the original program has? So somehow it would reproduce himself in perfect clones that can reproduce too.   The program **shouldn't use any external files** othervise it would be realy easy to implement: we just need to create a program that reads a file than writes it out, than copy and paste the source code to the external file.   My first attempt was to write a program that has a print function than copy- paste the source code to this print function, but this program can reproduce himeself for only once, and doesn't have the same functionality because the second program cant print out the source code.


title: Why should you prevent a search engine from indexing your development server?

text: I've heard that you shouldn't let search engines index your development server. The reasons given were:   * Duplicate content penalties   * Customers making purchases from an unsecured domain (if eCommerce) These issues may seem relatively minor and I'm not sure it would be enough to convince someone to put in the effort to lock down the server. Aren't there broader security concerns? What should be secured and why?


title: C: What is a good source to teach standard/basic code conventions to someone newly learning the language?

text: I'm tutoring someone who can be described as a rank newcomer in C. Understandably, she does not know much about coding conventions generally practiced, and hence all her programs tend to use single letter vars, mismatched spacing/indentation and the like, making it very difficult to read/debug her endeavors. My question is, is there a link/set of guidelines and examples which she can use for adopting basic code conventions ? It should not be too arcane as to scare her off, yet inclusive enough to have the basics covered (so that no one woulc wince looking at the code). Any suggestions ?


title: To be strict or pragmatic?

text: I'm beginning to realize that developing software is (amongst others) a process of constantly asking yourself questions. Questions regarding quality of code, separation of concerns, minimizing dependencies, ... But the main question is: how far can you go without ending up in a mental hospital? I'm applying for a new job. Yesterday I was with a possible future employer who wanted to test my programming capablities. One of the exercises was: explain what this code does. I went through some code of the application (winforms in vb.net) that they develop (it's an administrative application for a hospital). This gave me the opportunity to actually see how they approach things and it was rather disappointing. Some examples:   * I saw somewhere: Call [insert name of subroutine here] -> I was struck: isn't that something from VB6?   * They have a separate datalayer, using ado.net, but one method I had to examine returns a dataset to the calling layer. So separate datalayer or not, the application is tied to ado.net (which could also never be a problem if they never switch to another data access approach).   * That dataset is read as-is, so it still is a data-centric approach (of course, one can argue how much logic/behaviour you can put in classes like "Patient" or "LabAnalysisRequest".   * I also believe to have seen the construction of an sql query by string concatenation.   * They use stored procedures (which, to me, means: scattering of logic)   * no mention of views/controllers: it's all form driven   * The most ugly thing I saw was:                   If TestEnvironment.IsTesting then            someVar = [some hard coded value]         else            someVar = [some dynamically retrieved value]         end if         [remainder of the function here]      It's all so different from what I learned in school: (persistence agnostic) domain layer, persistence layer, presentation layer, unit testing, ... So I rephrase my question: how fundamental or dogmatic should one be? To what extent should a programmer stick to his or her principles or just write code that does the job?


title: What to do when your work colleague doesn't understand the design trying to be maintained

text: A software project that I am working on involves me and another programmer. The project involved an engine backend with an MVC front end. Initially I did alot of the work on the project and so setup some simple design methodologies mainly surrounding abstraction and template strategy. For quite a while I have been off the engine backend and working on the website. However I have still maintained an interest in the engine as I was informed that I might be back on it at some point. The project is under a very tight deadline so we are all rushing like made to get it finished on both the front end and back end. I don't consider myself to be a great programmer and so I never try and enforce any particular design or set of methodologies on people as I'm not always sure I'm right and like to have other people offer their opinions to try and come up with better solutions. However I have noticed changes being made to this engine code that is really starting to irk me. When I confronted the developer to suggest he do the work another way he said he didn't see the point as there seemed little benefit considering the tight deadlines. I had to try and explain that the haack he had put in could mean further development after release and I didn't think it was fair to make others pick up the slack when we could fix it now. I spent about 30mins going through what I had done and at the end of it he asked me to pretty much write the code so he could just copy it. The basis of what was I had initialy setup was:   * An abstract class x   * An abstract factory class to create concrete instances of x What had happened was he had put a couple of if statements that could easily have been put as virtual/abstrace methods on the abstract class and then implemented accordingly as the new change followed the same principle of other methods on the abstract class already. This seems trivial to me, however he couldn't even grasp this even when I showed him the classes involved. Now my question is:   1. Is this unfair to assume he should have grasped this concept. I realise that we are on tight deadlines but I thought it was trivial. The programmer is supposed to be at least an intermediate level.   2. This has happened in a number of places and I have constantly tried to get him to change but he doesn't seem to. Should I just ignore it?   3. Should I raise this issue elsewhere, or just suck it and when I'm put back on the project just go around changing all these things. His part of the project is not going to be finished which is why I will have to go back on and help him out. I really don't want too, as he has taken a project with not great, but ok architecture and really put in alot of messy code that more than often didn't follow what was trying to be achieved. If the question is too vague or ranty, please let me know and I'll try and edit accordingly. EDITED: The project is expected to continue after the initial deadline as there is already follow up work planned and work that we did not fit in and has been agreed to be implemented later.


title: How to visually document interactive user interfaces for fast consumption

text: I'm writing documentation for some interactive Ajax user interface but instead of writing everything in words I would rather provide diagrams that are faster consumed than whole paragraphs of text. I did provide page navigation flow diagram but that's very high level before you drill down to individual pages and their inner workings. ## Example Suppose I have to document a typical search panel:   * is collapsed by default and can be expanded on click   * has basic search fields that provide basic search criteria over my model entity   * has advanced fields as well that show when one clicks a particular link which expands search with additional fields   * has two actions Search and Reset that are pretty much self explanatory, but have particular behaviours attached to them I know you will say that this already is documentation, but it's usually not this simple and trivial. Search panel is just an example. I can see that most of my interfaces (or interface components) need two types of documentation:   1. **properties** related to contained controls (i.e. drop down field with these and those values of which that particular one is selected by default)   2. **actions and behaviours** that describe what happens when user interacts with controls related to those properties ### What would be the best diagram or documentation format to describe these kind of interactive interfaces so that it's easy and quick to consume by implementers?


title: do asp.net mvc tools let you make sites faster than php frameworks

text: I generally use cakephp but after watching some MS videos of MVC3 it seemed to go fairly quick. I understand the intellisens in VS2010 works classes and for databases. It seems like once you know the editor and framework basics this would be very handy. My question is, do things like intellisense actually speed things up noticeably?


title: Too much to learn, dealing with overwhelming varieties of technologies

text: I am about to graduate, and I am already working as a web developer in our library IT department. When I look at job postings I am absolutely overwhelmed by the sheer variety of technologies out there. Some companies care about math + algorithms + data structures. Some care about experiences in technology stack XYZ. SQL, css, html, frameworks, javascript, design patterns etc.. etc... etc... At some point I realized I just need to start at mastering a foundation to become employable at a better place and go from there. But the skill-set to get me in the doors varies and I just don't have time to learn everything. How do you deal with this issue? What is the essential stack to become employable? Say in php or ror arena. Perhaps a smarter move would be to move to a technology stack with less variety like .net?


title: Should I pay my developers for bugs fixes for a project or work that's still in progress?

text: We are working with a group of developers on a project. The project is still in progress (not completed) and these developers charge us for time spent on fixing bugs on codes that were not written valid in the first place. I understand that we should pay for changes/new requests if any, but not bugs fixes for a work in progress. We also understand that once the assignment is being deployed to the live site, we may be liable for bugs fixes that may arise after a support period is being exhausted. The question now is, is it appropriate for such charges to be levied upon us while the project is still in progress?


title: How can I correct html for missing closing tags in c# ?

text: I have html stored in database received from text editors and because of some mistakes in the code the html is not valid, it is missing some closing tags. and due to this I am not able to process this html for some other operations like generating pdfs. So I need to write some code in c# that can check for tags that are missing closing tags and insert a closing tag at the correct place.


title: Is this RabbitMQ / sockjs pub/sub connection setup a comet solution?

text: My company is attempting to set up a pub/sub connection using RabbitMQ and sockjs, on Windows servers. I have two questions:   1. My supervisor is calling this setup a comet solution, I was wondering if that is the right terminology?   2. Is there a better solution stack for having a data server asynchronously ship data to a client without the client requesting data (besides the initial subscription)?


title: Can all code be represented as a series of Map / Filter / Reduce operations?

text: I have recently been refactoring large chunks of code and replacing them with Linq queries. Removing the language bias - Linq is essentially a set of Map / Filter and Reduce operations that operate on a sequence of data. This got me thinking, how far would I theoretically be able to take this. Would I be able to rewrite the whole code base into a series (or even a single) of Map / Filter and Reduce operations. Unfortunately I get paid to do useful stuff, so I haven't been able to experiment much further, but I can't think of any code structure that couldn't be re structured as such. Side effected code can be dealt with via monads.. Even output is essentially mapping memory addresses to screen addresses. Is there anything that couldn't be (theoretically) rewritten as a Linq query?


title: Windows Azure vs Amazon EC2 vs Google App Engine

text: From a developer point of view which platform would you consider for a large social web application? If you could provide some details on what you consider to be the strengths of which alternative it would be great.


title: MVVM, DDD, and WPF Layered Application Project Structure Guidance

text: I am trying to setup my application's structure in VS and I want to "try" and future proof it to a reasonable level. This application will be a WPF re-write of an old Winform app that had followed no conventions. No Layers, Tiers, Acronyms, etc... It is a fairly largish Enterprise Application. I planned to use Linq To SQL as my DB's are and will most likely always be MS SQL. Also I have an existing skill set with it. I want to follow MVVM and DDD the best I can but I get confused on the structure of my application when combining these. Let me try and illustrate with some examples. When I follow MVVM my folder structure may look like this:               Views     Models     ViewModels     Helpers      but how does that fit into a simplistic DDD layered approach where my Project Structure might resemble this:               MyApp.UI     MyApp.Domain     MyApp.Data      Do I put the `Models` in the Domain layer or do I have 3 versions of say `Person`? This leads to another question of where would I put my Repository and mappings of DB Object to Domain Object? I would assume Data... `Views` I get would go in UI but would `ViewModels` also? Finally, where would I be embedding my Business Logic? I found the following on CodePlex,DDD Example ,and it has been some help but seems to be for a Web App though that may not matter and is my ignorance shining through. Don't get me wrong, I know I can have as many folders and call them whatever I want. I am trying to figure out where to place things so that this will be scale-able, not what those places necessarily are called. The heart of my question might be shown like this.   I have `tblPerson` object generated by `*.dbml`. This is obvious and would belong in my "Data" layer.   Now I would have Model, DTO, Domain Model, or whatever it's called in a seperate Layer(project?) called `Person`. I would need a `Mapper` for `Person` to `tblPerson` that I'm not sure where to put.   Then, I'll have a ViewModel for, say, `EditPerson` that would have it's own properties that it pulls from `Person` but possibly more as well.   Finally I'd have a View that was bound to that ViewModel.... To be clear that paragraph is FILLED with my assumptions and guesses and I am hoping someone will help clear the air for me or offer there insights so that 6 months to a year from now I am not kicking myself more than I need to.


title: Safest way (i.e. HTTPS, POST, PGP) to send decryption keys through the web?

text: I am in the final stages of development for my Revit plugin. This plugin is programmed in C#, and distributed via a DLL. One of the DLLs is an encrypted SQLite database (with proprietary data) that is in the form of a DLL. Currently, in development stages, the decryption key for the SQLite database is hardcoded in my main DLL (the program's DLL). For distribution, since DLLs are easily decompilable, I am in need of a new method to decrypt the DLL. My solution is to send our decryption keys from our servers securely to the host's computer. I was looking in POST, thinking it was more secure than GET, but upon research, it appears it's similarly insecure, only more "obscure" than GET. I also looked into HTTPS, but Hostgator requires extra money for HTTPS use. I am in need of some advice - are there any custom solutions I can do to implement this?


title: How can I be most productive in Visual Studio when limited to small screen space?

text: I'm a student, and I do a lot of code on a small (12.5", 1366x768) laptop screen that I carry from class to class. Most programming environments are designed with the idea that someone has large screen size available, because most programmers do in fact have access to large screens. However, large screens are difficult to carry to class all day, and my previous laptop (15", 1920x1200) often got left in the dorm just because it was so friggin heavy. I'm pretty much locked in to Visual Studio at this point; no program I've ever used is as productive for the kind of code I work with (after installing Whole Tomato's Visual Assist and Jared Par's VsVim, of course :) ) (I've seen other questions about small screens but they all pretty much go with "leave Visual Studio" -- which is hard given some of the kinds of development I've been doing....


title: Considerations for accepting contributed code to an Open Source project

text: I’m working on a "for fun" project in my spare time. I may end up making it Open Source and this makes me wonder what I need to think about if someone cares enough to contribute to it.   * Do I need to have some sort of legal mumbo jumbo about “if you give me yer code, it accepts the same license as the project, bla bla bla” (what is the norm here?)    * Is there a way to check contributed code to make sure it is not plagiarized or would that liability fall on the contributer?    * Are there any other gotchas, standard/common practices I should follow, recommendations, things I need to think about?


title: Mercurial release management. Rejecting changes that fail testing

text: Researching distributed source control management (specifically mercurial). My question is more or less **what is the best practice for rejecting entire sets of code that fail testing?** **Example:** A team is working on a hello world program. They have testers and a scheduled release coming up with specific features planned.               Upcoming Release:        Add feature A        Add feature B        Add feature C      So, the developers make their clones for their features, do the work and merge them into a QA repo for the testers to scrutinize. Let's say the testers report back that "Feature B is incomplete and in fact dangerous", and they would like to retest A and C. ![Repo Doodle](http://i.stack.imgur.com/DteiT.png) **End example.** What's the best way to do all this so that feature B can easily be removed and you end up with a new repo that contains only feature A and C merged together? Recreate the test repo? Back out B? Other magic?


title: Ergonomics of Apple keyboard for long programming hours

text: I am programming with an apple keyboard (the one all aluminium with flat keys). it's quite some time I observed I occasionally mistype, and I feel pain in my hands. Is it the keyboard's fault, or am I just getting old ? Does any of you have experience with hours of programming with the apple keyboard ?


title: How do OSes work on multiple CPUs?

text: Assumption: "OS es (atleast in some part) should be written in assembly.Assembly programs are CPU specefic." If so how can one os run on different CPUs ? For example: how is that I can load Ubuntu on different systems having different CPUs (like intel i3,i5,i7, amd a8,a6,etc) from the same bootable disk?   1. Does the disk contain seporate assembly programs for each CPU?   2. Are these CPUs 'similar' enough to run the same assembly program?   3. Is my assumption wrong?   4. Something else.... Thanks for responding.   1. I tried to find out in what way are the CPUs that I mentioned 'similar'. I came across the concepts of Instruction Set Architecture and Microarchitecture of CPUs.A CPU will understand a program if it is combatible with its ISA. Even if CPUs are 'wired up' differently (different microarchitecture) , as long as the ISA implemented on top is same ,the program will work. ARM and x86 have different ISA ( that why there are 2 windows 8 versions, right?). And if an app program is written in an HLL with compilers for both platforms we will saved from wasting time writing 2 programs. Did I understand anything wrong?   2. Are there programs that can take a compiled program as input and produce a program executable on another CPU as output? Is it possible? (Virtualisation?)   3. 32 bit windows programs do install on 64 bit windows ,dont they? Arent 64 bit CPUs 'differerent' from 32 bit CPUs? They do get seporate OS versions, right?   4. Is this backward combatibility achieved using programes mentioned in (3) ?


title: Are multi-line comments a critical facility in a modern language?

text: I'm trying to convince the designers of a language that multi-line comments with an arbitrary start and end are important, and should be included. Currently there is only a "comment-to-end-of-line" primitive. Their line of argumentation reminds me of what some say about why you should use spaces instead of tabs. Basically that editor features can pick up the slack and remove the requirement for a different construct. _(So if you wanted to comment out more than one line, you'd select what you wanted and run a macro of some kind...to add or remove a to-end-of-line comment to each line. I just read thatthis feature exists in Visual Studio, despite C/C++ offering a multiline comment.)_ Other suggestions about removing blocks of code from execution wind up being things like "cut the code out, try it, and use the redo queue". I think this is not a very easy way to keep track of "invisible" information you might want back, and redo queues are quick to lose information the moment you hit even a stray key on accident. So this does not sway me. I can live with the space vs. tab thing and putting that on the editor, and it's now pervasive. But to me this is different, and I'm dissatisfied with these answers. For me, being able to comment out code with just a start and end marker like `/*` and `*/` is extremely useful. Passing the buck to editor magic doesn't let you position your starts and ends arbitrarily _(how would you comment out the middle of a line if all you had was`//`?)_ And I also don't like leaning that much on editor features. Sorry to ask a question with overtones of an opinion poll, or about something subjective. But what I'm looking for are any more objective arguments I am not thinking of, which could provide more ammunition backing this feature I think is important. _(Or I guess I could accept a powerful argument favoring NOT having a multi-line comment format, which overrides my strong desire to have it... I'm not putting high odds on that, though.)_


title: Thoughts on refactoring a generic DAO

text: I have designed a generic DAO in Java and am having confusion about whether to refactor it to different design or not. **PS** Don't say to use already existing 3rd person framework. I know there are some present but I am learning Java and design patterns so I need all the practice I can get. If there's any confusion then please ask and I'll clarify. **The current Architecture** * * * **DAOFactory.java**   * Contains the `abstract` methods for creation of `DAODelete`, `DAOUpdate` and 2 other interfaces to be implemented by concrete implementation classes   * `public` Class method for creating the concrete Factories for producing the concrete implementaton of the interfaces mentioned before. **DAORead.java**               public abstract <T> T getPojoForPrimarKey(Connection con,             TableName tableName, String primaryKey) throws SQLException;      Similarly in my other interfaces I have generic methods.   * Here `Connection` is passed by the service layer and closed there for transaction management.    * `TableName` is a enum that I am using to have a switch case in lower layer of DAO for calling Table Specific functions. Also using an enum is helping me in type checking. **OracleRead.java**               @Override         public <T> T getPojoForPrimarKey(Connection con, TableName tableName,                 String primaryKey) throws SQLException {             T currentPojo = null;             PreparedStatement ps = null;             ResultSet rs = null;             try {                 String queryString = OracleSpecifics.queryString(tableName,                         primaryKey, QueryType.READ);                 ps = con.prepareStatement(queryString);                 rs = ps.executeQuery();                 if (rs.next()) {                     currentPojo = OracleSpecifics.getPojoFromResultSet(tableName, rs);                 }             } finally {                 DAOFactory.closeAll(ps, rs);             }             return currentPojo;         }      This is how I have implemented the `deleteFrom` function from the interface in concrete class. Here `OracleSpecifics` is the lower layer of DAO that I was talking about. It basically contains `switch` cases to check for specific Table. **OracleSpecifics.java**               // These functions call table-specific functions         @SuppressWarnings("unchecked")         static <T> T getPojoFromResultSet(TableName tableName, ResultSet rs)                 throws SQLException {                  switch (tableName) {             case ASEEM_MASTER:             case ASEEM_MASTER_TEMP:                 return (T) SpecAseemMaster.getPojo(rs);             case AUTHENTICATE_TABLE:                 return (T) SpecAseemRole.getPojo(rs);             default:                 return null;             }         }      Here `SpecAseemMaster` and `SpecAseemRole` are Table Specific (specifically schema specific) layer producing the required fields **SpecAseemRole.java**               public static AuthenticationDetails getPojo(ResultSet rs)                 throws SQLException {             AuthenticationDetails cur = new AuthenticationDetails();             cur.setUserName(rs.getString(1));             cur.setPassWord(rs.getString(2));             cur.setRole(rs.getString(3));             return cur;         }      * * * **In service layer** The type by which the DAO's method is called is the Pojo representing the schema's data fields. e.g.               myFactory.getDAORead().<AuthenticationDetails> getPojoForPrimarKey(con, CUR_TABLE, primaryKey);      Here `AuthenticationDetails` is my Pojo aka DTO for communicating between my Controller and service layer (in Model). * * * **Please Note** that I am giving just a overview in the simplest way. There are 4 interfaces in the abstract DAOs containing total of 8 `abstract` methods implemented by 4 concrete classes. All these generic classes depend on a lower layer in DAO for getting specific queries, `PreparedStatement`s etc. which further calls functions in auxiliary utility class's functions depending on the `tableName` passed down this hierarchy. The bottom layer is schema- specific. **My Confusion about refactoring**   * I am satisfied with the upper layers of DAO but I think that at the the lower level specifically at the `OracleSpecific` the things which should have strong coupling has weak coupling. e.g. there are different methods for getting `PreparedStatement` for insert and update. Each of these in turn have `switch` case for calling the functions in lower utility class.    * **Although** the `schema-specific` methods are tied together in different utility classes the method call themselves in `OracleSpecifics.java` do not have any coupling.   * I am thinking whether I should change the enum `TableName` to contain a _specific state_. The state I am thinking for the schema-specific lowest level utility classes.   * These `specific states` contained in enums can be used to change the state of DAO and the DAO can then call the specific functions based on an interface implemented by all such states. Thus depending on the state the behavior can change automatically.   * Is this design decision correct or would it be meaningless?   * Any other thing that I might have overlooked?    * Any thoughts about the design itself?   * Would I lose type safety introduced by generics due to this change?


title: What is a web API? (Application Programming Interface)

text: What is a web Application Programming Interface? Many common sites provide APIs. Why are they needed, and what function do they provide? How does one access a web API?


title: Best way to re-platform MS access application to java application

text: I have a requirement where MS Access application needs to be re-platformed to java application.The MS access app has about 45,000 records and 53 columns with SQL connectivity.These record data need to be edited,data used to send email with pdf report attachment.Report is designed using SQL reporting services.I need to create UI to call the reporting service and generate reports.The customer wants all the 45000 records to be loaded in the single stretch in the datatable. Can anyone please suggest which is the best way to mimic this in java.Do i need to go with swing app or a web app.