How to implement proper identification and session managent on json post requests?

I have some minor messaging connection to server from website via json requests. I have single endpoint which distributes requests according to identification data. I am using asynchronous server and handle data when it comes. Now I am thinking about extending requests with some kind of session. I tried using REST/JSON approach, passing single id in json. For example I register on page, get some kind token id as response and used that token with each post request. Post request has three simple parts: type, data, token_id. My problem is I am not sure how to cache token on browser side. I am using Tornado as webserver and saving token via cookies like this(http://technobeans.wordpress.com/2012/08/07/tornado-cookies/). Problem is I am not sure how long set expire time and how I should force to renew cookie. For example, should I when cookie expires (I really do not know proper way to detect it) to launch event on client side to register. Also I tried to drop requests and use socket like interfaces (sock-js) to transfer data. There I find that handling was way more easier: login open socket post data, close. Where I could implement it, I was happy with it. However I feel that having open connection is not solution to all problems, specifically to rare irregular data transfer events. I am searching for ideas how to have post requests properly identified and how to handle irregular json connections. To sum up:   1. **What is the best way to define post requests session?** Get cookie when registered and use token as long as session runs with each request? Should I implement timeout for token? Is there alternative methods? Can I cache tokens to same origin requests? What could I use on client side (Web browser)?   2. **How about safety?** What techniques I should use to throw away requests with malformed data, to big data, without choking server down? **Should I worry?**


Low impact refactoring and code cleaning of sloppy code while waiting for requirements

I inherited an existing code base for a product that is reprehensibly sloppy. The fundamental design is woefully inadequate which unfortunately I can do little about without a complete refactor (HIGH coupling, LOW cohesion, rampant duplication of code, no technical design documentation, integration tests instead of unit tests). The product has a history, high exposure to critical "cash-cow" clients with minimal tolerance for risk, technical debt that will make the Greeks blush, VERY large codebase and complexity, and a battle-weary defeatist approach to bugs by the team before me. The old team jumped ship to another division so that they have the opportunity to ruin another project. It is very rare that I experience a Technical Incompetency Project Failure as opposed to a Project Management Failure but this is indeed one of those cases. For the moment I am by myself but I have a lot of time, freedom of decision and future direction and the ability to build a team from scratch to help me. My question is to gather opinion on low impact refactoring on a project like this when you have some free time during the functional requirements gathering phase. There are thousands of compiler warnings, almost all of them unused imports, unread local variables, absence of type checking and unsafe casts. Code formatting is so unreadable and sloppy that it looks like the coder suffered from Parkinsons disease and couldn't control the amount of times the space bar was pressed on any given line. Further database and file resources are typically opened and never closed safely. Pointless method arguments, duplicate methods that do the same thing, etc.. While I am waiting for requirements for the next feature I have been cleaning low-impact low risk things as I go and wondered if I am wasting my time or doing the right thing. What if the new feature means ripping out code that I spent time on earlier? I am going to start an Agile approach and I understand this is acceptable and normal to constantly refactor during Agile development. Can you think of any positive or negative impacts of me doing this that you would like to add?


How to explain that it's hard to estimate the time required for a bigger software project?

I'm a junior developer and I find it hard to estimate how much time it takes to finish a bigger software project. I know how to structure the architecture in general, but it's hard for me to know what details I have to do and what problems I have to solve. So it's hard to estimate how much time it will take to finish a bigger project, because I don't know what problems I need to solve and how long it takes to solve them. How do I explain this to a person that is **not a software developer**?


Sales Manager: "Why is time-estimation so complex?"

A few days ago a sales manager asked me that question. But at this moment I didn't know a answer which he can understand. He isn't a programmer! At the moment I work on a product which is over 8 years old. Nobody thought about architecture or evolvability. I have a swamp of code in front of me every day which is not tested. Because of that, time estimates are very difficult for me. How I can describe that problem to an **salesman**? Not only my swamp-code- problem, but general!


Setting Deadlines in software development

I have been working on a system alone for about two years. I inherited the system from a contractor who spent about two years working on it before me (alone). The system is not particularly well designed because there is business logic, presentation logic and data logic mingled together. It is a very complex system, which I am trying to refactor as I go along and this takes time. A new developer was recruited but he seems to be taking more of a Project management role. He is very direct asking exactly how long things will take; questioning all my assumptions and predictions, which is difficult because of the complexity and because I am the only expert at the moment. I am very organised in my personal life. For example, I was asked what time I would arrive in Manchester last week so I provided an exact time catering for accidents and road works on the way. I find it difficult to apply the same principles at work in software development at the moment. Don't get me wrong. I have worked with project managers on less complex projects in the past and have had a good relationship, but then the projects were less complex and I always delivered before schedule. I am struggling with this particular project manager and it is causing stress. How do other developers deal with project managers who want answers and accurate deadline dates?


Network application framework/API/etc

With all the web2.0 hype and webapps being all the rage, the only advantage from a corporate POV that I can think of webapps having is that it is easier to service your user base: upgrades become easier among several things. It's just that the browser is not a good platform. I've been mulling this over for a while now. My original idea was to use python, then I found out about QSA. I like QT. It's widgets are excellent for most purposes, and it's cross platform. A generic QT application is installed on the clients machine. They point it to a URL to begin executing the signed/encrypted application at that location. The actual application could be written in Qt script. It could be developed very much like a traditional MVC application. Or it could, and probably should, be developed like WT, so that a "web" application can be coded the same way as a "desktop" application. Before I go reinventing the wheel, are there any such platforms/frameworks in existence? If I do go inventing this wheel, what are some things I should be aware of?


What does Douglas Crockford mean when he says jQuery doesn't scale?

In the Q&A section of this talk, Douglas Crockford says that jQuery doesn't scale as well as some other popular libraries. What does he mean by that, and what is it about the other libraries that makes them more scalable?


When returning from a period of not programming, do you find you've improved?

It seems as though whenever I take an extended break from programming--whether to pursue other interests or simply because I fall out of the habit for a while--I invariably find that when I return to a project and set to coding, I come with an abundance of new ideas, novel approaches, and just plain better code. It may be because I have a lot of other creative interests besides programming, and my mind likes to find correlation and crossover between them, so while I'm doing one thing, in the back of my mind I'm usually also applying it to another. So what's your experience? Do you ever return from a break (whether intentional or not) feeling not only refreshed, but also somehow _noticeably improved?_ Is it actually the norm?


What is a uniform way to express Country, City, State? (ISO standard, etc)

I need to encode data into a user token that describes the user's Country, State, and city. I understand that different descriptors apply to different government hierarchies, but am looking for a standard of some type that has already sorted this out. What ISO standard, binary format, etc is best at describing a user who may be from any country?


Getting rid of Massive View Controller in iOS?

I had a discussion with my colleague about the following problem. We have an application where we need filtering functionality. On any main screen within the upper navigation bar, there is a button in the upper right corner. Once you touch that button, an custom written Alert View like view will pop up modally, behind it a semitransparent black overlay view. In that modal view, there is a table view of options, and you can choose one exclusively. Based on your selection, once this modal view is closed, the list of items in the main view is filtered. It is simply a modally presented filter to filter the main table view.This UI design is dictated by the design department, I cannot do anything about it so let accept this as a premise. Also the main filter button in the navbar will change colours to indicate that the filter is active. The question I have is about implementation. I suggested to my colleague that we create a separate XYZFilter class that will   * be an instance created by the main view controller   * acquire the filtering options    * handle saving and restoration of its state - i.e. last filter selected   * provide its two views - the overlay view and the modal view    * be the datasource for the table in its modal view.  For some unknown reason, my colleague was not impressed by that approach at all. He simply wants to do these functionalities in the main view controller, maybe out of being used to do this in the past like that :-/ Is there any fundamental problem with my approach? I want to   * keep the view controller small, not to have spaghetti code   * create a reusable component (for use outside the project)   * have more object oriented, decoupled approach.   * prevent duplication of code as we need the filtering in two different places but it looks the same in both.. Any advice?


Anyone knows good references for Machine Learning Algorithms and Image Recognition?

I need it for my thesis and for some reason I am having a hard time finding decent books or websites for it. My thesis topic is "Classification of Modern Art Paintings using Machine Learning Approach". My goal is to classify examples of modern art paintings to its respective modern art movement(expressionism, realism,etc..) using machine learning approach. Also, suggestions and comments about my thesis are greatly appreciated.


Looking for the tool that generated JSON Rail-Road grammar descriptions

I am currently working on a little language, and I'd like to express its grammar more rigorously. I know about EBNF and it's great to generate parsers (Bison/Yacc), however it's not that easy to visualize. The Wikipedia page on Syntax Diagram points out that one of the success of JSON is due to the display of its grammar as a Rail-Road diagram. Indeed if one goes to the JSON webpage, one can see nice diagrams, that are easily accessible and (I find) visually attractive, for example: ![http://json.org/object.gif](http://i.stack.imgur.com/raLaZ.gif) It easily conveys the structure of an `object` in JSON, dealing with multiple alternatives and repetitions easily. A very similar way of expressing the grammar can be found on SQLite (though I prefer the JSON one). ![http://www.sqlite.org/images/syntax/delete- stmt.gif](http://i.stack.imgur.com/Oiv6H.gif) Does anyone know if there was a tool used to generate the JSON diagrams ? (and if so, where I can find it). The wikipedia page reference some generators but none seem to generate such nice diagrams.


What are some easy techniques to scan books for new information?

I find it irresistible to keep purchasing cheap programming and technical e-books in fields such as Drupal, PHP, etc., and also compulsively download free material made available such as those from Microsoft's developer blog... The main problem with the large library I've developed is that there are many chapters (especially the first few) in these books packed with information I already know, but with helpful tidbits hidden in between. The logical step would be to skip those chapters and read the ones I don't seem to know anything about, but I'm afraid I may lose out on really important information this way. But naturally it is tedious to have to read about variables, functions and objects all over again when you are trying to know more about the Registry pattern, for example. It's hard to research on the net for this, because my question itself seems vague and difficult to formulate into a single search query. I need people- advice - what do you do in this situation?


What do you think about JavaFX script retirement?

Oracle will no longer develop JavaFX script ( the language ) and now the applications would be coded through the API. I think JavaFX script was kind of neat. Does it seem reasonable to stop the development of the language, and use it only through the API? Links: http://jonathangiles.net/blog/?p=916 http://java.dzone.com/articles/javaone-2010-alternative-jvm


Is it bad practice to store metadata information in file names? Better solutions?

I have noticed where I work people are keen on storing information in file names, and parsing the file names. To me this doesn't seem to be especially good practice. I already see the occasional issues with scripts globbing for a file, and getting the wrong one because another file matches first.We are also discussing how to get around problems with separators for the fields. Is it considered bad practice or not? What are other accepted solutions for retrieving files from a file system based on some type of metadata?


Load all templates at startup?

I am developing a jQuery mobile app. In this app, i often use Mustache.js templates in separate html files. Actually, every template is needed by the user, but my app loads a template (via GET method) only when it is needed. For now, all the templates are small and they're all used by the client at runtime. But obviously this won't be the case for long, in case I add extensions that will be needed or not by the users. I could load every template at once, but I'm afraid this could become a blocking point in the future. Based on your experience, what is the best thing to do? Load all templates at once, or load them one by one, when needed?


Is there any standard for design document

This question is purely from academic point of view. As part of the software engineering lab, a design document is to be created after generating the SRS. Is there any standard for creating the design document. Since we followed IEEE standard for creating the SRS. What all things can be included in the design document from the academic point of view? I am thinking of including different UML diagrams.


How should I test my application?

I have made a simple application which searches for files and folders on users computer. Since, I am a student currently in my 1st year and don't have any formal training and have made my application while I was still learning C# and .Net framework, I didn't have knowledge about unit tests and other good testing methods used by professionals. Although, most of my code is working fine, sometimes it throws exceptions or some other unexpected situation occurs and the code breaks. Keeping the above experiences in mind, I don't think my application is ready for deployment and so , I would like to test my application in a professional way, and be assured that my application is bug free. Therefore, I want to ask professionals here, that keeping my situation in mind, how should I start testing my application.   What are the steps that I should follow, to ensure the quality of my application.


Unit Testing in iOS -- Should I split out my Data Model into it's own class?

I'm attempting to try out using unit test in for the first time in new iOS activity for work. I love the idea of unit testing, but always find the specifics to be... messy. I get the general principals -- I have read a lot about it so I wanted to ask a specific question. My situation:   * I have a UITableView that can have anywhere from 10 to 10,000 items. I would like to do partial loading. Load the first 100 or so, and then when the user scrolls down half way, load the next 100. Or something like that.   * My calls to the DB are asyc (I do not control this, although I guess I could block and wait on the main thread if I really wanted to). My first thought is to have an NSMutableArray and a function to load/update the data in my UIViewController. I also need to keep track of if the data is finished loading and if the data is currently being reloaded (because it's an async call). However, I'm wondering if it's better to split this into it's own class for testability? Let's call it SmartMutableArray? My concerns are   1. If I do this, it requires more selectors then before. I already need to create a call back for my call to the database, and now I need to create another one for my UIViewController to be notified when SmartMutbleArray is completed loading. I would think this makes my code harder to read.   2. Because my new array is updated in the background, I think I need to use `self performSelectorOnMainThread:@selector(addObjectsFromArray:) withObject:response.balances waitUntilDone:YES];` to update the new array in my new SmartMutableArray class. Which seems weird to me, that this class needs to know it's a data source for a UI element.   3. If I don't break it up, I have to test all this loading indirectly by calling my UITableView delegate commands. I've plowed ahead with creating the new class for this list... but I'm curious what people with more experience think of something like this. Is it overkill? Thanks for any input, sorry for the length. Please let me know if I'm missing any details that would be useful though.


Using multiple Git repositories instead of a single one containing many apps from different teams?

I am migrating a 10-years-old big CVS repository to Git. It seemed obvious to split this multiple-projects repository into several Git ones. But the decision-makers are used to CVS, therefore their point of view is influenced by CVS philosophy. To convince them to migrate from one CVS repo to different Git repositories I need to give them some arguments. When I speak with mates working on Git repo for years, they say that using multiple Git repo is the way to use Git. I do not know really why (they give me some ideas). I am a newbie in this field so I ask here my question. **What are the arguments to use multiple Git repositories instead of a single one containing different applications and libraries from different teams?** I have already listed:   * branches/tags impact the whole Git repository files => pollutes other team projects   * 4GB limit Git repo size but this is wrong   * git annotate may be slower on _bloat_ Git repo...        **EDIT:**   * Eamon Nerbonne has noticed the related question:    Choosing between Single or multiple projects in a git repository?   * The reason the team managers finally have accepted the split: the single Git repo (550 MB) was requiring 13 minutes to be cloned on Windows.    * The _bloat_ CVS repo split in 100 Git repositories:      * each dead apps in one repo     * each stabilized library in one repo (source code almost never changed any longer)      * related apps/libs kept together in one repo     * moved large files not used for compilation (config...) to other repos (Git does not like large files)     * skipped other unrelevant files (`*.jar`, `*.pcb`, `*.dll`, `*.so`, `*.backup` ...)    * Successfully installed the `repo` tool used by Android Open Source Project in order to handle all these Git repos:      * easy installation on Linux      * more difficult on Windows because of Cygwin and NTFS native symlinks requirements


Where to put entity model classes in case of using a dataservice layer?

If my solution has both a "dataservice" project and a "business logic" project, where do the entity models, which represent database tables, belong? At first i thought putting them in the dataservice layer, but then i would need duplicate models in the business logic layer, if i wanted to provide reusable logic dealing with or being dependant of database data. Putting models in the business logic project, would force the dataservice layer to be dependant on the core project.


Custom PHP Template Engine

I've been developing a custom PHP template engine to suit just my needs and also to get a little more practice with PHP. What I did was to create a Template class that simply receives as constructor parameter a path to a template file and a string that should be the placeholder for the contents of the pages. In that case, the template file is an HTML file with some placeholders written as [placeholder]. These will be filled with real content by another class. So for instance, [title] should be filled with the title, [content] with the content of the selected page and so on. I've created also a Page class that receives as constructor parameter the directory of the pages and then has methods to set which name of file it should use (this is filled in as we like in the initialization, when working with friendly URL's the most common way I use this is setting as the first piece of the URL) and methods to set more data as pairs of placeholder string and real content. My only problem is with how to deal with titles and meta tags. For each page there's a title and a collection of meta tags. My only way to deal with this was to create in different files one array with titles and one array with meta tags. Both of them receives as index the name of the page file. So for instance $titles["home"] should be the title of the home page and $meta_tags["home"] should be the html code for the meta tags of the home page. The problem is that as soon as there are lots of pages this will have one unecessary cost of memory: the system would be loading for every requests all the titles and all meta tags, while it must load only the required one. I thought on using database, but it seems like killing one ant with an atomic bomb. So the next best thing I thought of was XML. Now, what's the best solution for this kind of situation? Use XML, use a MySQL database, or some other method? As I've said, I know that the recommended is that we use the template engines that are already out there since they are tested lots of times, are already stable and so on, but I'm struggling with those things as a way to get more practice developing with PHP. Thanks very much in advance for the help. Also, I didn't think it was needed to post any code I've written, but if some of the code will help, please ask and I'll post it.


C++ class with only pure virtual functions: what's that called?

So i'm looking for some input/consensus on what terminology we should be using to describe something that looks like this:               class Printable     {       public:         virtual void printTo(Printer *) = 0;         virtual double getWidthInPoints() = 0;         virtual double getHeightInPoints() = 0;     };      So this is a class that only has pure virtual methods. Any class that inherits it needs to implement the whole thing, i.e. there is no partial implementation. So what is this called? I have mostly seen two different names: 1) _Interface_ Used in Windows COM programming (perhaps it came from the IDL), it's a keyword in both C# and Java and also a compiler directive/keyword in Objective-C (but isn't the same thing). I've heard engineers using the phrase 'interface' synonymously with 'API', but, at least in this scenario, it's a single thing whereas an API could comprises more than one. 2) _Protocol_ I've seen this used in various open-source libraries such as Bloomberg BSL and it's a compiler directive/keyword in Objective-C, but does not necessarily need to be in the inheritance hierarchy. In the broader computer science sense, protocol is a formal definition of information exchange between two parties, like TCP and HTTP, but this definition kind of holds for the above class too. Is there any clear distinction between these in C++ or are they pretty much interchangeable?


Two bosses, both want different way of implementation

Over lunch, a colleague of mine, that has a manager (person in direct charge of the project) and a BOSS up top was asked to resolve one issue. The manager had arguments with the boss regarding how it should be resolved. They both agreed they would go with the manager's way. When my colleague was starting to resolve the issue, the Boss calls and said, "You do it my way." In this case, what would you do?!


What does the python Codecs module do?

I just read through the documentation on the Codecs module, but I guess my knowledge/experience of comp sci doesn't run deep enough yet for me to comprehend it. It's for dealing with encoding/decoding, especially Unicode, and while to many of you that's a complete and perfect explanation, to me that's _really_ vague. I don't really understand what it means at all. Text is text is text in a .txt file? Or so this amateur thought. Can anyone explain?


How to build child classes as parent configuration?

I'm using Codeigniter PHP Framework for developing a web application, and when developing an admin zone, I've ended building a generic parent class called AdminController which is extended by the child classes to develop my Admin zones. **I've shortened my code to show what I really want to show** , my code is something like: Parent Class:               class AdminController {          protected $url_action   = null;     protected $permissions  = null;     protected $formulario_gestion  = null;          function __construct() {         if ( empty( $this->permissions ) ) {             throw new Exception( 'No se ha definido permissions' );         }         if ( empty( $this->url_action ) ) {             throw new Exception( 'No se ha definido la url_action' );         }         if ( empty( $this->formulario_gestion ) ) {             throw new Exception( 'No se ha definido el formulario_gestion' );         }     }          public function create() {         if ( ! $this->checkPermissions( $this->permissions, $this->user ) {              redirect( base_url );           }              $formulario = new $this->formulario_gestion( null );         $formulario->setFormValues( $this->get_update_values() );              // More code below...     }          // Doing this to make sure I'll overwrite it     public function get_update_values() {         throw new Exception('No has definido get_update_values');     }          // More Methods and things...      And then, I use my child class to initiate all the values required in the parent, overwrite all the functions I need have to be overwritten, and go: Child Class               class Webs extends AdminController {          function __construct() {              // Initiating parent values:         $this->permissions = 'webs';         $this->url_action  = strtolower( __CLASS__) ;         $this->formulario_gestion = 'FormularioWebs';              parent::__construct();     }          // Overwriting what I need to be overwritten     public function get_update_values() {          $values = $array(              'field1' => 'value1'          ,   'field2' => 'value2'          );          return $values;     }      And this work quite well: All the pages share the same behaviour and I only write relevant code. **My problem is** : This is a nightmare when building a whole CRUD with it: I ended up with many properties I only use in some methods, and I don't know if there is a "standard" or correct way of doing it. I mean what are the flaws of doing this in this way? It is correct? I don't like having so many properties laying out there that are only going to be used in a method, and I don't know how to encapsulate them in a way only the method use it it'll have it. What I ended up is something like the code bellows, but I don't really like it, as you don't know in the parent where the value is declared. Method in Parent Class:               public function show() {          echo $this->var;     }      Method in Child Class:               public function show() {          $this->vars = 'value'          parent::show();     }


Merging around 15 small Git repos of non-optional centralized web service components to a single large repo

In a centralized web service we break down the components into various small Git repos by software modules, e.g. authentication module, authorization module, data access module etc. (around 15 repos at the moment) The good thing is it is easy to manage the smaller code base, however, our productivity has decreased a lot since quite a lot of changes need to be update several repos at once. Also, deployment is more difficult as there are multiple versions of module involved, we always need to think about the dependency. I am considering to merge all the modules back to a single repo, because   * our services must require all the modules to exists, they are not optional for our service   * we are not a big team (3 people actually) and the overhead in maintaining too many repos does not worth it, they all need to have knowledge on all the code bases What do you think? Any pros and cons if we merge into a giant repo?


Is modern C++ replacing C#? Is Microsoft pushing developers to adopt C++?

I hear about modern C++ popularity and some talks about migrating back to C++ from C# or other C-like languages. I know about C++11 features but I would like to hear your experiences, especially from developers who migrated from C# to C++. More importantly, does Microsoft push developers to use C++? If yes, why?


What exactly is “computer systems”?

My professor made a comment today - "...They've been having trouble with filesystem performance, and since they're more graphics guys, they asked us systems guys to help out...". What exactly is "computer systems"? What does it mean to be a "systems guy"? And, what is a "systems guy" passionate about? For contrast, what is not computer systems? What would possibly bore a "systems guy"?


One-time income with recurring costs: how to mantain an app in the cloud

You have an idea of a software/app/webapp/website that you would like to spend some effort and implement. Your idea uses a cloud system to keep things up and you think you could earn some money by distributing your product and charging a **small** one-time fee. But there is a problem: the first thing you realize is that one day that user using your system may eat all the money he gave you with his indirect recurring little spending in the cloud. How would you do the math to find out if your idea was feasible?


iOS app with a lot of text

I just asked a question on StackOverflow, but I'm thinking that a part of it belongs here, as questions about design pattern are welcomed by the faq. Here is my situation. I have developed almost completely a native iOS app. The last section I need to implement is all the rules of a sport, so that's a lot of text. It has one main level of sections, divided in subsections, containing a lot of structured text (paragraphs, a few pictures, bulleted/numbered lists, tables). I have absolutely no problem with coding, I'm just looking for advice to improve and make the best design pattern possible for my app. My first shot (the last one so far) was a `UITableViewController` containing the sections, sending the user to another `UITableViewController` with the subsections of the selected section, and then one _strange_ last `UITableViewController` where the cells contain `UITextViews`, sections header help structure the content, etc. What I would like is your advice on how to improve the structure of this section. I'm perfectly ready to destroy/rebuild the whole thing, I'm really lost in my design here.. As I said on SO, I've began to implement a `UIWebView` in a `UIViewController`, showing a html page with JQuery Mobile to display the content, and it's fine. My question is more about the 2 views taking the user to that content. I used `UITableViewController`s because that's what seemed the most appropriate for a structured hierarchy like this one. But that doesn't seem like the best solution in term of user experience.. **What structure / "view-flow" / kind of presentation would you try to implement in my situation?** As always, any help would be **greatly** appreciated! * * * Just so you can understand better the hierarchy, with a simple example :                                         -----> Section 1   -----> SubSection 1.1   -----> Content                               |                  -----> SubSection 1.2   -----> Content                               |                  -----> SubSection 1.3   -----> Content                               |                               |                               |     UINavigationController  -------> Section 2   -----> SubSection 2.1   -----> Content                               |                  -----> SubSection 2.2   -----> Content                               |                  -----> SubSection 2.3   -----> Content                               |                  -----> SubSection 2.4   -----> Content                               |                  -----> SubSection 2.5   -----> Content                               |                               -----> Section 3   -----> SubSection 3.1   -----> Content                                                  -----> SubSection 3.2   -----> Content                                |------------------|   |--------------------|  |-------------|                       1 UITableViewController   3 UITableViewControllers  10 UIViewControllers                              (3 rows)              (with different         with a UIWebView                                                     number of rows)


server and request understanding

I want to know what a server does to run a php application. Below is what I think: client A types www.blahblahblah.blah/   1. Server resolves url and directory etc.    2. Server go the index.php    3. index.php has a Singleton Pattern Class in it with a static variable called instance.  Now does the server allocate the memory to that static variable in its own RAM so that all the requests following this first one uses the same static variable? OR for every new request does the server allocate new memory and that new memory will have a new space allocated to that static variable? My Confusion: if every request is run in its own memory space then what is a persistant connection? Second thing I wondering about: Can I have a desktop program which is continuously sending a special key to my web application and my web application is sending the key back continuously to make HTTP a connection full instead of connection less? That way I can confirm who is connected to my APP as a client instead who is connected to INTERNET. I know sessions but they make http connection less and then chance of spoofing and session hijacking is there. I know you can make session secure but still my App won't know if the client is dead and can delete the data from the session and tell others that client blah is disconnected.


Performance impact of not implementing relationships at the database level?

Let's imagine a data model with customers and invoices. There is a 1 to n relationship between a customer and its invoices. We uses an ORM (like Hibernate). One can explicitely implement the 1-n relationship (using JPA for example) or not. If not, then one must do a bit more work to fetch invoices. However, it is much easier to maintain, improve and develop the data model of applications where relationships between objects are not explicitely implemented in the database. My question is, has anyone noticed a significant performance impact when not implementing the relationships in the database?


Strategy / resources for writing LISP webservices?

Background: I'm looking to write some fully functional webservices in Common Lisp as an April Fools prank on the rest of the development team at my company. There are two pieces to this: reading info from / writing it to a MySQL database, and receiving / processing / responding to requests over HTTP. (Actually, there's a third piece, writing automated tests, but my QA partner- in-crime is going to handle that part.) After some Googling I found a good resource here ( http://www.ymeme.com/creating-dynamic-websites-lisp-apache.html ), but I'm surprised that there's seemingly only the one walkthrough. Does anyone know of others, or can anyone share personal experiences with writing webservices in CLisp?


Cloud computing cost savings for large enterprise

I'm trying to understand whether cloud computing is meant for small to medium sized companies OR also for large companies. Imagine a website with a very large user base. The storage and bandwidth demands as well as the number of database transactions are incredibly high. The website might be hosting videos, music, images, etc. that keep the demands high. Does it make sense to be in the cloud when you know you need huge volumes of storage, bandwidth, and GET,PUT,etc. requests? (Each of these variables costs money in the cloud) OR does it make sense to build your own infrastructure? I can see the cost savings of cloud computing if you are a small business, but if you were aiming at the next big thing on the Internet, I can't quite see the benefits.


What would you think of a job based on mostly doing the proof of concept?

I'm working as a developer in a small software company whose main job is interfacing between separate applications, like between a telephony system and an environment control system, between IP TVs and hospitality systems, etc...And it seems like I am the candidate for a new job title in the company, as the person who does the proof of concept of a new interfacing project and does some R&D for prototyping. What do you think the pros and cons of such a job would be, considering mainly the individual progress/regress of a person as a software engineer? And what aspects would you consider essential in a person to put him/her in such a job position?


Are null references really a bad thing?

I've heard it said that the inclusion of null references in programming languages is the "billion dollar mistake". But why? Sure, they can cause NullReferenceExceptions, but so what? Any element of the language can be a source of errors if used improperly. And what's the alternative? I suppose instead of saying this:               Customer c = Customer.GetByLastName("Goodman"); // returns null if not found     if (c != null)     {         Console.WriteLine(c.FirstName + " " + c.LastName + " is awesome!");     }     else { Console.WriteLine("There was no customer named Goodman.  How lame!"); }      You could say this:               if (Customer.ExistsWithLastName("Goodman"))     {         Customer c = Customer.GetByLastName("Goodman") // throws error if not found         Console.WriteLine(c.FirstName + " " + c.LastName + " is awesome!");      }     else { Console.WriteLine("There was no customer named Goodman.  How lame!"); }      But how is that better? Either way, if you forget to check that the customer exists, you get an exception. I suppose that a CustomerNotFoundException is a bit easier to debug than a NullReferenceException by virtue of being more descriptive. Is that all there is to it?


Is there a canonical book on design patterns?

I am interested in learning design patterns and would like to know what are considered top tier books in learning this subject. Is there a book out there that's the de-facto standard for describing best practices, design methodologies, and other helpful information on design patterns? What about that book makes it special?


Setting realistic expectations for deadlines

I'm a tech lead for a small team. One of the major tasks on my plate is communicating with the client. One thing I find particularly difficult is dealing with deadlines because they are mandated by the client and I'm frequently not consulted. Usually, the interaction follows the following pattern. The client comes up with a feature they want to add, Feature X. Feature X would look good in the next week's app release that is about 6 business days away. At this point, the feature request needs to go through approval and there are frequently other dependencies that need to be deal with. Eventually, N days later, the feature request trickles down to my team. Even if the original dead line (that was set by a non-developer manager) was achievable it no longer is. My team is blamed, ~~feels discouraged and there's an overall atmosphere of defeat~~ , I feel discouraged and defeated. Clearly the overall process is broken. Unfortunately, there's not much I can do because I'm not in a position of power here. My current approach is to gently remind the client about our start date versus the deadline, the scope of the Feature, etc. This feels a lot like I am making excuses though. Have you guys been in similar situations? What has/hasn't worked for you?


Math Major wants to become a Software Engineer

I am a math major, what would be the best field of computer science/computer engineering for me to go into, where I could apply my skills that I used as a math major(i.e. Linear Algebra, Real Analysis, Number theory, Numerical analysis, etc...) Thanks


How defensive should we be?

We've been running Pex over some code, and it has been showing some good things (well bad things, but showing them before it gets to production!). However, one of the nice things about Pex is that it doesn't necessarily stop trying to find issues. One area we found is that when passing in a string, we were not checking for empty strings. So we changed:               if (inputString == null)      to               if (string.IsNullOrEmpty(inputString)) // ***      That fixed the initial issues. But then, when we ran Pex again, it decided that:               inputString = "\0";      was causing problems. And then               inputString = "\u0001";      What we've decided is that defaults can be used if we encounter `// ***` and that we are happy seeing the exception caused by any other odd input (and dealing with it). Is that enough?


What do you do to make sure you take proper/enough breaks, while avoiding unwanted side-effects of break taking?

preamble> It seems to me that computer programmers are one of a select few groups of people who actually take pleasure from sitting in front of computers for long periods of time. Most people in other professions actively dislike their time at computers, and do their best to avoid it (so, I assume, they don't have problems taking breaks). At least for me, having external cues for taking breaks, and clear instructions on what to do with each break (stretch, go for a walk, close my eyes, look into a distance of preferably a few km and focus on faraway objects, etc...), is a must. So far, I've just been making up the breaks and tools to get them as I go along, based on what looks to be low-specificity information found on the net (generic stuff ala ergonomics advice for office staff). This has led to all sorts of side effects - loss of attention as I get distracted if I walk around, breaks in flow with alarm clocks interrupting my thoughts, and people around me assuming I'm low on work due to the frequency of my walking around compared to everyone else. /preamble> **tl;dr**   * Taking breaks is important   * My internal break taking system doesn't work, and ad-hoc ones have unwanted side effects    * What do you do to make sure you take proper breaks?   * How do you avoid unwanted side-effects, such as getting distracted or interrupting flow or giving your co-workers the impression you're spending a lot of time goofing off?


Roll your own web crawler to crawl one specific website that has multiple entries

What sort of languages would be able to handle writing your own web crawler? Could PHP handle this? I'm quite good with PHP (following best practices etc). But I'd like a good reason to learn a new language if I need to. The idea is to crawl one specific website that has multiple entries, much like an RSS feed, but they don't offer that an RSS feed of the site...


Is it typical for a provider of a web services to also provide client libraries?

My company is building a corporate Java web-app and we are leaning towards using GWT-RPC as the client-server protocol for performance reasons. However, in the future, we will need to provide an API for other enterprise systems to access our data as well. For this, we were thinking of a SOAP based web service. In my experience it is common for commercial providers of enterprise web applications to provide client libraries (Java, .NET, C#, etc.). Is this generally the case? I ask because if so, then why bother using SOAP or REST or any standard web services protocol at all? Why not just create a client libraries that communicate via GWT-RPC?


How to collect seed data for a Products/Services User review website?

Data = information like name, address of local businesses. Companies, their products, services etc. Once users start engaging then they themselves can add/edit data wikipedia style. because if there is no data initially then users will not be attracted to come, and if there are no users then cannot expand the data. What are the various options to bootstrap with a seed dataset ? \- Crawl and find info from various web resources \- Collect and enter it manually \- Hire data collectors \- Any place to buy such data \- Any other ?


Repository query conditions, dependencies and DRY

To keep it simple, let's suppose an application which has `Accounts` and `Users`. Each account may have any number of users. There's also 3 consumers of `UserRepository`:   * An admin interface which may list all users   * Public front-end which may list all users   * An account authenticated API which should only list it's own users Assuming `UserRepository` is something like this:               class UsersRepository extends DatabaseAbstraction {         private function query() {             return $this->database()->select('users.*');         }         public function getAll() {             return $this->query()->exec();         }         // IMPORTANT:         // Tons of other methods for searching, filtering,         // joining of other tables, ordering and such...     }      Keeping in mind the comment above, and the necessity to abstract user querying conditions, How should I handle querying of users filtering by `account_id`? I can picture three possible roads: ### 1\. Should I create an `AccountUsersRepository`?               class AccountUsersRepository extends UserRepository {         public function __construct(Account $account) {             $this->account = $account;         }         private function query() {             return parent::query()                 ->where('account_id', '=', $this->account->id);         }     }      _This has the advantage of reducing the duplication of`UsersRepository` methods, but doesn't quite fit into anything I've read about DDD so far (I'm rookie by the way)_ ### 2\. Should I put it as a method on `AccountsRepository`?               class AccountsRepository extends DatabaseAbstraction {         public function getAccountUsers(Account $account) {             return $this->database()                 ->select('users.*')                 ->where('account_id', '=', $account->id)                 ->exec();         }     }      _This requires the duplication of all`UserRepository` methods and may need another `UserQuery` layer, that implements those querying logic on chainable way._ ### 3\. Should I query `UserRepository` from within my account entity?               class Account extends Entity {         public function getUsers() {             return UserRepository::findByAccountId($this->id);         }     }      _This feels more like an aggregate root for me, but introduces dependency of`UserRepository` on `Account` entity, which may violate a few principles._ ### 4\. Or am I missing the point completely? Maybe there's an even better solution?    **Footnotes:** Besides permissions being a Service concern, in my understanding, they shouldn't implement SQL query but leave that to repositories since those may not even be SQL driven.


Object inheritance and method parameters/return types - Please check my logic

I'm preparing for a test and doing practice questions, this one in particular I am unsure I did correctly: We are given a very simple UML diagram to demonstrate inheritance: I hope this is clear, it shows that W inherits from V and so on:                                 |-----Y     V <|----- W<|-----|                       |-----X<|----Z      and this code:               public X method1(){....}     method2(new Y());     method2(method1());     method2(method3());      **The questions and my answers:**   1. **Q:** What types of objects could method1 actually return? **A:** X and Z, since the method definition includes X as the return type and since Z is a kind of X is would be OK to return either.   2. **Q:** What could the parameter type of method2 be? **A:** Since method2 in the code accepts Y, X and Z (as the return from method1), the parameter type must be either V or W, as Y,X and Z inherit from both of these.   3. **Q:** What could return type of method3 be? **A:** Return type of method3 must be V or W as this would be consistent with answer 2.


How can I justify a technology over another? (Java over .NET)

We are working in a Java/.NET company and my team and I are planning a project for a client. One of the requirements is that the project has to be done in .NET I've asked about this requirement, and the client said that it doesn't matter, and that if I have a good reason we can use other technology. But, I have to justify the decision. As a Project Manager / Analyst I'm interested in making the project in Java because:   * The team knows java much better, regarding the language and frameworks   * I don't know anything about .NET technology (and maybe we could make bad decisions thinking in a Java way to do things)   * There are other people in company that have more skills in .NET but they have other projects with more priority. For experience, I'm sure that if we use Java, the project will have much more quality. But this arguments could be weak from the client perspective. How can I justify making the project in Java? EDIT: I'm not asking if one technology is better than other. "It's not a technology war" question.


What is the difference between  a freelancer programmer and a Programmer working in a Software company?

I was told by a HR department that freelancing experience is not considered as professional experience. What could be the reason?


Ruby: Multithreading a CSV with output

I have a script written in Ruby that has maxed out a core in my server's Xeon processor for the last 2 hours. Since it's currently only using 1 of four possible cores, I want to try and rewrite the script to take advantage of all four cores. I can use the .each_slice(n) method on the array that contains my data, but I'm curious as to what would then be the best/most efficient way to then write this data to a file. It seems that I have a couple options.   1. Pass the file object to the functions being called by the Thread.new function (I assume this is legal in ruby?) and have them write as they see fit.   2. Have each function store the results in arrays, return the array on completion and let the main program then write to the disk.   3. Pass the same array object to each item and have them all add to it, then sort it. My assumption is that although 2 would probably be more memory intensive, it'll by far be most efficient method. Is there a different way to accomplish what I'm doing?


The architecture and technologies to use for a secure, fast, reliable and easily scalable web application

^ _For actual questions, skip to the lists down below_ I understand, that his is a vague topic, but please, before you turn the other way and disregard me, hear me out. I am currently doing research for a web application(I don't know if application is the correct word for it, but I will proceed w/ that for now), that one day might need to be everything mentioned in the title. I am bound by nothing. That means that every language, OS and framework is acceptable, but only if it proves it's usefulness. And if you are going to say, that scalability and speed depend on the code I write for this application, then I agree, but I am just trying to find something, that wouldn't stand in my way later on. I have done quite a bit reading on this subject, but I still don't have a clear picture, to what suits my needs, so I come to you, StackOverflow, to give me directions. I know you all must be wondering what I'm building, but I assure you, that it doesn't matter. I have heard of _12 factor app_ though, if you have any similar guidelines or what is, to suggest the please, go ahead. For the sake of keeping your answers as open as possible, I'm not gonna provide you my experience regarding anything written in this question. ^ _Skippers, start here_ First off - the weights of the requirements are probably something like that (on a scale of 10):   * Security - 10   * Speed - 5   * Reliability (concurrency) - 7.5    * Scalability - 10 _Speed and concurrency are not a top priority, in the sense, that the program can be CPU intensive, and therefore slow, and only accept a not-that-high number of concurrent users, but both of these factors must be improvable by scaling the system_ Anyway, here are my questions:   * **How many layers should the application have, so it would be future-proof and could best fulfill the aforementioned requirements?** For now, what I have in mind is the most common version:      1. Completely separated front end, that might be a web page or an MMI application or even both.     2. Some middle-ware handling communication between the front and the back end. This is probably a server that communicates w/ the front end via HTTP. How the communication w/ the back end should be handled is probably dependent on the back end.     3. The back end. Something that handles data through resources like DB and etc. and does various computations w/ the data. This, as the highest priority part of the software, must be easily spread to multiple computers later on and have no known security holes. I think ideally the middle-ware should send a request to a queue from where one of the back end processes takes this request, chops it up to smaller parts and buts these parts of the request back onto the same queue as the initial request, after what these parts will be then handled by other back end processes. Something *map-reduce*y, so to say.   * **What frameworks, languages and etc. should these layers use?**     1. The technologies used here are not that important at this moment, you can ignore this part for now     2. I've been pointed to node.js for this part. Do you guys know any better alternatives, or have any reasons why I should (not) use node.js for this particular job.     3. I actually have no good idea, what to use for this job, there are too many options out there, so please direct me. This part (and the 2. one also, I think) depend a lot on the OS, so suggest any OSs alongside w/ the technologies/frameworks.  Initially, all computers (or 1 for starters) hosting the back end are going to be virtual machines. Please do give suggestions to any part of the question, that you feel you have comprehensive knowledge and/or experience of. And also, point out if you feel that any part of the current set-up means an instant (or even distant) failure or if I missed a very important aspect to consider. I'm not looking for a definitive answer for how to achieve my goals, because there certainly isn't one, for I haven't provided you w/ all the required information. I'm just looking for recommendations and directions on what to look into. Also, bare in mind, that this isn't something that I have to get done quickly, to sell and let it be re-written by the new owner (which, I've been told for multiple times, is what I should aim for). I have all the time in the world and I really just want to learn doing something really high-end. Also, excuse me if my language isn't the best, I'm not a native. Anyway. Thanks in advance to anyone, who takes the time to help me out here. PS. When I do seem to come up w/ a good architecture/design for this project, I will certainly make it an open project and keep you guys up to date w/ it's development. As in what you could have told me earlier and etc. _For obvious reasonsthe very same question got closed on SO, but could you guys still help me?._


How to explain OOP to a matlab programmer?

I have a lot of friends who come from electrical / physical / mechanical engineering background, and are curious about what is "OOP" all about. They all know Matlab quite well, so they do have basic programming background; but they have a very hard time grasping a complex type system which can benefit from the concepts OOP introduces. **Can anyone propose a way I can try to explain it to them?** I'm just not familiar with Matlab myself, so I'm having troubles finding parallels. I think using simple examples like shapes or animals is a bit too abstract for those engineers. So far I've tried using a Matrix interface vs array-based / sparse / whatever implementations, but that didn't work so well, probably because different matrix types are already well-supported in Matlab.


Any empirical evidence on the efficacy of CMMI?

I am wondering if there are any studies that examine the efficacy of software projects in CMMI-oriented organizations. For example, are CMMI organizations more likely to finish projects on time and/or on budget than non-CMMI organizations? _Edit for clarification:_ CMMI stands for "Capability Maturity Model Integration". It's developed by the Software Engineering Institute at Carnegie-Mellon University (SEI-CMU). It's not a _certification_ , but there are various companies that will "appraise" your organization to various levels of CMMI, such as level 2 and level 3. (I believe CMMI level 1 is an animalistic, Hobbesian free-for-all that nobody aspires to. In other words, everybody is at least CMMI level 1, even if you've never heard of CMMI before.) I'm definitely not an expert, but I believe that an organization can be appraised for CMMI levels within different scopes of work: i.e. service delivery, software development, foobaring, etc. My question is focused on the software development appraisal: is an organization that has been appraised to CMMI Level X for software projects more likely to finish a software project on time and on budget than another organization that has not been appraised to CMMI Level X? However, in the absence of hard data about software-oriented CMMI, I'd be interested in the effect that CMMI appraisals have on other activities as well. I originally asked the question because I've seen various studies conducted on software (e.g. the essays in The Mythical Man Month refer to numerous empirical studies, as does McConnell's Code Complete), so I know that there are organizations performing empirical studies of software development.


Is this a pattern? Proxy/delegation of interface to existing concrete implementation

I occasionally write code like this when I want to replace small parts of an existing implementation:               public interface IFoo     {         void Bar();     }          public class Foo : IFoo     {         public void Bar()         {         }     }          public class ProxyFoo : IFoo     {         private IFoo _Implementation;              public ProxyFoo(IFoo implementation)         {             this._Implementation = implementation;         }              #region IFoo Members              public void Bar()         {             this._Implementation.Bar();         }              #endregion     }      This is a much smaller example than the real life cases in which I've used this pattern, but if implementing an existing interface or abstract class would require lots of code, most of which is already written, but I need to change a small part of the behaviour, then I will use this pattern. Is this a pattern or an anti pattern? If so, does it have a name and are there any well known pros and cons to this approach? Is there a better way to achieve the same result? Rewriting the interfaces and/or the concrete implementation is not normally an option as it will be provided by a third party library.


What's the benefit of object-oriented programming over procedural programming?

I'm trying to understand the difference between procedural languages like C and object-oriented languages like C++. I've never used C++, but I've been discussing with my friends on how to differentiate the two. I've been told C++ has object-oriented concepts as well as public and private modes for definition of variables: things C does not have. I've never had to use these for while developing programs in Visual Basic.NET: what are the benefits of these? I've also been told that if a variable is public, it can be accessed anywhere, but it's not clear how that's different from a global variable in a language like C. It's also not clear how a private variable differs from a local variable. Another thing I've heard is that, for security reasons, if a function needs to be accessed it should be inherited first. The use-case is that an administrator should only have as much rights as they need and not everything, but it seems a conditional would work as well:               if ( login == "admin") {         // invoke the function     }      Why is this not ideal? Given that there seems to be a procedural way to do everything object- oriented, why should I care about object-oriented programming?


What makes OOP "good"?

It's fairly obvious that OOP is viewed as a sort of silver bullet of programming today. In any computer science course, the merits of OOP are heralded. I would like to know why people like OOP. To be honest, combining procedures, types, and data structures into a single conglomerate seems bad to me. I'd much rather view data as simply data. I like to be able to think that I will pass the right data through a function and get the right output, and not have to consider that the data is capable of operating on itself. Also, I want to know if there are any good examples of robust programs written specifically with or without OOP, that have their source code available.


How is localStorage different from indexedDB?

localStorage and indexedDB are used for offline storage of data in HTML5. What are their key differences and which one is preferable in what situations?


Efficient algorithm to find a the set of numbers in a range

If I have an array of sorted numbers and every object is one of the numbers or multiplication. For example if the sorted array is `[1, 2, 7]` then the set is `{1, 2, 7, 1*2, 1*7, 2*7, 1*2*7}`. As you can see if there's n numbers in the sorted array, the size of the set is 2n-1. My question is how can I find for a given sorted array of n numbers all the objects in the set so that the objects is in a given interval. For example if the sorted array is `[1, 2, 3 ... 19, 20]` what is the most efficient algorithm to find the objects that are larger than 1000 and less than 2500 (without calculating all the 2n-1 objects)?


Running a process multiple times at the same time

I have a c++ program with opencv library which takes an image as input and perform pose estimation,color detection,phog. When I run this program from the command line it takes around 4-5sec to complete. It takes around 60%cpu. When I try to run the same program from two different command line windows at the same time the process takes around 10-15 sec to finish and both the process finish in almost the same time. The CPU Usage reaches upto 100%. I have a website which calls this c++ exe using exec() command. So when two users try to upload an image and run it takes more time as I explained above in the command line. Is this because the c++ program involves high computation and the CPU reaches 100% it slows down? But I read that the CPU reaching 100% is not a bad thing as the computer is using its full capacity to run the program. So is this because of my c++ program or is it something to do with my server(computer) settings? This is probably not the apache server problem because when I try to run it from the command line also it slows down. I am using a quad core processor and all the 4 CPU reaches 100% when I try to run the same process at the same time so I think that its distributed among all the processor. So I have few more questions: 1) Can this be solved by using multithreading in my c++ code?As for now I am not using it but will multithreading make the c++ code more computationally expensive and increase the CPU usage(if this is the problem). 2) What can be the reason of it slowing down? Is the process in a queue and each process is ran only a certain amount of time and it switches between the two process? 3) If this is because it involves high computation will it help if I change some functions to opencv gpu functions? 4) Is there a way I can solve this problems any ideas or tips? I have inserted the result of top when running one process and running the same process twice at the same time: Version5 is the process,running it once ![enter image description here](http://i.stack.imgur.com/V9KVi.png) Two Version5 running at the same time ![enter image description here](http://i.stack.imgur.com/h6aP4.png) Thanks in advance.


Java sql annotations ManyToMany relationships

I was wondering your thoughts on the best way to implement a SQL ManyToMany relationship in Java using annotations - in this case eBeans \- where there is extra data associated with the join. I have created a db diagram to help explain: ![An ERD](http://i.stack.imgur.com/brOxP.png) Using @ManyToMany on the organisation and users classes would create the join table but without the extra Job Title. Is the best way to implement this to create the Org_has_users class and use @OneToMany and @ManyToOne annotations? Would cascade on save ensure that I can access the full join relationships from both the Users and Organisations classes? I hope this is enough to get started. I am more interested in how you would implement this. Thanks! Anthony


TDD with SQL and data manipulation functions

While I'm a professional programmer, I've never been formally trained in software engineering. As I'm frequently visiting here and SO, I've noticed a trend for writing unit tests whenever possible and, as my software gets more complex and sophisticated, I see automated testing as a good idea in aiding debugging. However, most of my work involves writing complex SQL and then processing the output in some way. How would you write a test to ensure your SQL was returning the correct data, for example? Then, say if the data wasn't under your control (e.g., that of a 3rd party system), how can you efficiently test your processing routines without having to hand write reams of dummy data? The best solution I can think of is making views of the data that, together, cover most cases. I can then join those views with my SQL to see if it's returning the correct records and manually process the views to see if my functions, etc. are doing what they're supposed to. Still, it seems excessive and flakey; particularly finding data to test against...


Linux OS developers : do they unit test their code?

Linux OS developers : do they unit test their code ? If yes :   * since this OS is coded in C, how do they manage to write effectively unit tests in this language ?   * what are the "zones" in OS where unit testing is easier to write ? where is it harder ? where is it valuable ?


Why categorization into "Property" and "Methods"

I am looking at the String class in Actionscript 3.0. It's having a property String.length . Internally it's a getter function ( or method ?) returning the length of string. Why it can't be String.getLength() ? Methods can take in 1, 2 or more values.. so their significance can be understood. But what significance "property" has. As it's afterall, a function only. So, why categorization into properties? Just adding an overhead botheration to remember that something has been categorized into property ? In other words, as a programmer, how i am helped, when i am told that String.length is a property of String class. And you can't find any method for the same. While writing a program, how i would know what is a property, and what is a method? Appreciate having some light on this. V.


which license fits my needs?

Which license would fit the following requirements the most?   * Everyone is welcome to make updates and use the source code    * But nobody should sell it or sell an application that is using it, unless they make a deal with owners


Is it ok to include jQuery in a jQuery plugin?

The question jQuery plugin file including the jQuery library came up today on stackoverflow, and I strongly advised against including jQuery in the plugin. I didn't really get any support from others on this; in fact there was more support to include jQuery than not. Is this ok or are there good reasons not to do this? I think it's a really bad idea as I think it should be up to the developer using the plug as to what version of jQuery is being used.


CPU recommendation for learning multiprocessor programming

This might be an odd question and the place to ask might not be appropriate. I am very interested in working with multiprocessor programming and parallel algorithms, mostly for research purposes. I want to build a computer specially for this and it should have at least 8 cores (many algorithms have contention problems only starting with 8 cores). Looking at what Intel and AMD offer I think the 8-core Intel CPUs are far too expensive, so I would have to choose between:   \- 6-core Intel i7 980X (3.33 Ghz)   \- 8-core AMD FX 8150 (3.6 Ghz)   \- 2x8-core AMD Opteron 4248 (3.0 Ghz, server version of FX 8150)   \- 1x or 2x-12-core AMD Opteron 6172 (2.1Ghz, expensive, but sometimes affordable on Ebay) I'm inclined for the 2xOpteron, but I'm not sure how the Bulldozer architecture compares to the Intel one; from what I understand the 8 cores actually share some parts and are not compleltely independent like the Intel ones (ignoring the shared L3 cache). I'm not sure that the results I get would reflect the ones that would be obtained on a " classical" CPU. On the other side, the i7 is much more powerful and might be sufficient for testing the parallel algorithms. The 2x12-core Opteron would probably be the best for testing, but they are also the slowest by far and I would like to use this computer as a workstation too. What would be the best solution? Is the Bulldozer architecture suitable for research (mostly for the massive parallelization of a compiler I wrote)?


How do you write straight to the point documentation without looking sloppy and informal?

I'm currently at a contract position and am looking to add to the documentation of the projects I worked on, to assist the next hiree taking over my projects. The documentation I received was overly technical (i.e. references code right away, references replacing certain values on certain lines, no high level description at all) How do I write documentation in simple plain English that is of actual benefit without looking sloppy? I find it difficult in areas such as outlining a system's flaws without coming off as judgmental, but still emphasize the severity of how detrimental some of the flaws are.


Will SSD make the distinction between column oriented DB and row oriented DB obsolete?

I had a discussion with a friend about row vs column oriented RDBMS. From my understanding, these things are closely linked with the fact that there's a concrete drive head reading and writing the data. This head moves and reading/writing data is faster if the head moves are limited. Still from my understanding, SSD drives drops those mechanical artifacts and accessing the data is now taking the same amount time regardless of where they are physically stored on the chip / device (don't know the right term). Considering these two points, will the SSD drives (when they'll have reached their full potential) make the distinction between row oriented and column oriented either obsolete or pointless?


Extending Mono's C# compiler with additional custom features (more or less syntactic sugar)

I'm aware that this is a rather broad question, but here it goes anyway... What is, in your opinion, the most practical way to create own C# implementation with minor additions to the existing 4.0 feature set? For context: I'm thinking about adding a couple of (mostly syntactic) niceties to the dynamic feature set that would improve the whole duck-typing experience. For example, these would include the idea of a dynamic interface, as proposed in this debate (particularly in the last comment from MiddleTommy). I'm aware that nothing is stopping me from simply diving into the Mono sources. However, I'm compelled to first ask about potentially similar projects that may already exist in the wild. Any such extension efforts underway?


How to debug/change Java code while the program is running?

I just saw a video showing how Notch (of Minecraft fame) is debugging and changing Minecraft while it is running. He pauses the game, changes something in the code and then unpauses the game where the change takes immediate effect without the need to restart the program. How does this work? Which kind of technique is used to achieve this?


Object design where hard-coded values are used to instantiate objects?

I'm creating the design for a browser bookmark merging program and I've ran into a design problem that I've seen before yet I've never come up with a good solution for it. So lets say I have a Browser class:               Browser:       String bookmarkFilePath       String type       Bool bookmarkFileExists()      When my program runs I will want to have hard-coded values of common browsers and the locations of their Bookmarks file:               Object with hard-coded values:       "~/Library/Application Support/Google/Default/Bookmarks", "Chrome"       "~/Library/Safari/Bookmarks.plist", "Safari"      **Is there a design pattern or object type that could effectively take an object with hard-coded values (Browser name / bookmarks file path) and uses it to instantiate (and possibly manage) other (Browser) objects?** Also, flexibility is important since there are edge cases such as Firefox's file path to the bookmarks file is always different and some searching needs to be done. **EDIT: I will be implementing this in Python. _Sorry for not mentioning this before_.**


Trial/Free & Full Version VS. Free App + In-app billing?

I'm just wondering what would be the best strategy to publish an application on the Android Market. If you have a free and paid version you have two codes to update (I know it will be 99% the same but still) and besides all the popular paid apps are quite easy to find for "free" in "alternative" markets. Also if you have any stored data in the trial/free version you lose it when you buy the full version.. On the other hand if you put a free application but inside you allow the user to unlock options (remove ads/more settings/etc...) you only have to worry about one code. I don't know the drawbacks of that strategy and how easy/hard is to hack that to get all the options for "free".


Is OCaml any good for numerical analysis?

I'm currently using C and some FORTRAN to solve numerically systems of differential equations. I'm a bit fed up with both of these languages but I need to have some (rather) efficient code... I'm thinking of switching to OCaml. Is it worth it?


Application design for web/iPad/iPhone/Android application

I have a web application which is a pretty standard SAAS database driven app. I have a few customers asking for iOS or Android versions of the app. Is it better to build an API on the web app which is then used to drive the native mobile apps UI? This would be simplest but mean the mobile apps are not 'stand alone'. Alternatively I could try and implement a full mobile solution that then synchronizes with the web app somehow. This would be much more work as all the business logic needs to be build into the mobile apps rather than behind the API. What is standard practice for this kind of thing?


Organizing MVC entities communication

I have the following situation. Imagine you have a MainWindow object who is layouting two different widgets, ListWidget and DisplayWidget. ListWidget is populated with data from the disk. DisplayWidget shows the details of the selection the user performs in the ListWidget. I am planning to do the following: in MainWindow I have the following objects:   * ListWidget   * ListView   * ListModel   * ListController ListView is initialized passing the ListWidget. ListViewController is initialized passing the View and the Model. Same happens for the DisplayWidget:   * DisplayWidget   * DisplayView   * DisplayModel   * DisplayController I initialize the DisplayView with the widget, and initialize the Model with the ListController. I do this because the DisplayModel wraps the ListController to get the information about the current selection, and the data to be displayed in the DisplayView. I am very rusty with MVC, being out of UI programming since a while. Is this the expected interaction layout for having different MVC triplets communicate ? In other words, MVC focus on the interaction of three objects. How do you put this interaction as a whole into a larger context of communication with other similar entities, MVC or not ?


Can the customer be a SCRUM Product Owner in a project?

I just had a discussion with a colleague about the Product Owner role: In a project where a customer organization has brought in a sofware developing organization (supplier), can the role of Product Owner be successfully held by the customer organization, or should it always be held by the supplier? I always imagined, that the PO was the supplier organizations guy. The guy that ensured that the customer is happy, and continously fed with new and high-businessvalue functionality, but still an integral part of the developer organization. However, maybe I have viewed the PO role too much like the waterfall project manager. My colleague made me think: If the customer organization is mature and proffessional enough, why not let a person from their camp prioritize the backlog?? That would put the PO role much closer to the business, thus being (in theory) better to assess the business value of backlog items. To me, that is an intriguing thought. But what are the implication of such a setup??? I look forward to your input.


Is object-oriented conceptual thinking something you build with experience?

I know that the answer is pretty clear because you get better on everything with time and experience. But I'll tell you where I'm coming from: A couple of months ago I decided to learn iOS development, so I studied C (read the C primer plus book, pretty good book). Recently I finished "Programming in Objective C" and lately I started following the Stanford course for Winter 2013 (I'm really enjoying it. I'm only at the beginning of the course, on lecture #3, and had to do only 2 homeworks). I understand all the syntax and concepts so far, and I think Objective C is an amazing language. But something has been bothering me, I thought it might be because I'm new to OOP. For example when the instructor defines models (matching cards game for instance), I definitely understand the syntax and logic, but sometimes I'm trying to think if it as taking a task (card game for instance) and breaking it into the right logic. Is this something I will get used to with time? Because at this stage when I try to predict things I'm supposed to do, pretty often I go and see some of his logic and go back to code. Actually we haven't had to go from zero, he always tells us to follow the presentation with the code in this stage, but I really want to improve at taking a task and knowing how to break it into the right models, controllers, etc.


What is "toolkit design"?

What does "toolkit design" mean and what are the basic steps to design a toolkit for a specific task/project? It appears in a task description which says: "This task deals with the design of detailed specification of the various tools that are employed in order to implement [insert some development task here]" So what I understand is that: it's required to design and provide the specifications of a toolkit which will be used for doing some specific tasks. But how is toolkit design done? Searching Google hardly gives any meaningful result. They are mostly about "design toolkits" which is not what I'm looking for. For example this guy has designed a software toolkit in some of his previous projects http://logonpro.com/resume.doc


Project Management - Asana / activeCollab / basecamp / alternative / none

I don't know whether this should be on programmers - I've been looking at the above three apps over the past few weeks just for myself and I'm in two minds. All three look good, are easy to use, and I came to this conclusion;   * Asana is the easiest to use    * ActiveCollab is the feature rich and easiest flow   * BaseCamp is the best UX / design But I didn't really find my workflow was any more quicker / efficient, in fact it was a bit slower and organized. Is there a realistic place for them in workflow - should programmers use them for themselves, or only when a project manager can take control of it?


What is a good design strategy for retaining history of user activities and files like Visual Studio projects?

OK so I'm not so sure that "project" is the right term, but for my purposes, I define "project" as similar to what Visual Studio uses, or Microsoft word - files that the user can open and work on and then save, and when the user runs the application again the program is aware of the files that were worked on last time the application was open. So I ask, what is a good design strategy for retaining history of user activities and files like Visual Studio projects?


Differences between a Unified Process and an Agile project plan?

There've been many discussions on SO about the differences between (Rational) Unified Process and the Agile methodology. Can someone please give me an example on how different a project plan would be if there are 2 teams doing the same project, but following these 2 different methods?


What are the best XP practices?

In "Extreme Programming Explained", Beck lists 13 "primary practices". They are:   * Sit Together   * Whole Team   * Informative Workspace   * Energized Work   * Pair Programming   * Stories   * Weekly Cycle   * Quarterly Cycle   * Slack   * 10 Minute Build   * Continuous Integration   * Test-First Programming   * Incremental Design Which of these have you actually implemented in your workplace? Which has been the most useful?


What software development process should I learn first for a solo project?

I want to develop a project on my own (if it is sucessful more people might start working on it too). Also I want to apply some proper software engineering from the first until the last day. On one hand just to try it out and compare results with previous projects that were just about writing code quick and dirty, and on the other hand to learn! I know the proper answer to this question is "It depends very much on the project...", "There is no single correct answer...". But I just need someplace to start, somewhere where every step is written down and tells me what to do. If I'm not happy next time I'll try something else. So, how/where should I start? I would love to hear some book suggestions cause I'm all about books :-D. EDIT: Answering a few of the questions that popped up: **Customer** : There is kind of a customer/friend. No real pressure.   **Version Control** : I have used subversion in the past and want to try mercurial.   **Bug tracking** : I was under the impression that for s single developer a checklist was enough (am I wrong there?)   **Testing** : I want to try Lime (because I use Symfony) and Selenium.   On the whole I will try out a lot of stuff I haven't used before but as I said one of the main points is learning. The Pomodoro Technique keeps popping up wherever I look, so maybe I should have a look at that...


How can programmers improve their UX skills?

As programmers we can solve very complex problems, but then, when we have to design a user interface we tend to fail on making them easy to use. In small companies they can’t afford having designers and UX experts, programmers have to do almost everything in the software. But these interfaces are rarely intuitive (the classic example). What is the problem? How can developers improve their skills in designing good user experiences?


Original author rights in a licensed software project

I'm working on a software project where so far I'm the sole developer. As of right now the code is unlicensed, but the copyright of whatever I've written belongs to me (this is true at least in North America AFAIK). Before I release the software to the public, I'm going to license its distribution, probably under something like MPL or GPL. Question 1: As the original copyright holder, does this effect me in anyway? Or do I still have unrestricted distribution rights? Question 2: After some time, more developers join the project. Now much of source code copyright belongs to me+contributors. How do distribution rights work for the authors now? Regards, kfl


What is the / your most effective QA process?

I'm looking for some ideas on how to improve our current Quality Assurance process. There is no official QA method in place right now, but we basically just get some requirements using a ticket system and we go back and forth until all the requirements are covered. The problem right now is some requirements change and we may spend a day or 5 days on multiple requirements but in the end they all get tossed because the end user decided it's not appropriate or wanted something else. So we lose time and money, but how can we have foreseen these situations? I have to believe there is an effective way to communicate with end users about their set of requirements so that we can EXTRACT and squeeze out any doubts to foreshadow a change in a range of requirements. And then we need to be very sure that the requirements won't be tossed or changed so drastically that our work was a waste. In some ways it is about understanding really really well what the user eventually wants. But what is this effective QA process? Any ideas are greatly appreciated. I'd be happy to clarify any concerns. Thank you!


Estimed number of tries

**Problem:** The Oscar Committee wants to decide which person should get the best actor award among the given N actors.For that they decided to use a random function random_bit() which returns either 0 or 1 with equal probablity. For the results to be fair,the committee was asked to generate a random number between 1 to N (inclusive) , such that all actors have equal probability of being chosen (which in this case should always be equal to 1 / N. First of all Committee wants to know the expected number of times they will need to call random_bit() function to generate a random number between 1 to N.Also, while calling the function, they should follow the optimal strategy (i.e. the strategy that minimizes the expected number of function calls) * * * This is problem of past contests at codechef.com and here's the link to it. This site allows to see other users solution and till now only one solution has been accepted. The solution is in C++ code:               #include <iostream>     using namespace std     int main() {         int T;         cin >> T;         for(int ii = 0; ii<T; ++ii)          {              int N;              cin >> N;              double p = 1, ans = 0;              int x = 1 % N;              for(int i = 0; i<100000; ++i)              {                   ans += x * p;                   x = (x * 2) % N;                   p /= 2;              }              cout << ans;         }         return 0;     }      I know how the code runs and what it does, but I can't find the logic behind it. Any help/ clue? Also it would be nice if someone can post another algorithm.


What happens to equal elements when inserting into a binary search tree?

Most BST examples show a sample of a BST with unique values; mainly to demonstrate the order of values. e.g. values in the left subtree are smaller than the root, and values in the right subtree are larger. Is this because BSTs are normally just used to represents SETs ? If I insert an element say 4 which already exists in the BST, what should happen ? e.g. In my case, 4 is associated with a payload. Does it mean I override the existing node's payload.


How do you coordinate with interaction designers during implementation?

Programmers are largely responsible for helping move a product from design to implementation. This process is always full of snags:   * implementation details rear their ugly head and make parts of the design infeasible   * user feedback on early prototypes leads to changes in the design   * new technologies alter the field of what is possible, bringing back designs previously thought impossible   * priorities shift, schedules change, and requirements wander How do you keep design and implementation in contact during the implementation? What processes do you use? Tools? Artifacts? Guidelines? Communication strategies?


Origin of "Readme"

When did people start writing Readme files? It seems that pretty much all programs have this file, regardless of the format. Is there any documented first use of this document?


Dynamic vs Statically typed languages for websites

This statement suggests that statically typed languages are not ideal for web sites: > I’ll contrast that with building a website. When rendering web pages, often > you have very many components interacting on a web page. You have buttons > over here and little widgets over there and there are dozens of them on a > webpage, as well as possibly dozens or hundreds of web pages on your website > that are all dynamic. With a system with a really large surface area like > that, using a statically typed language is actually quite inflexible. I > would find it painful probably to program in Scala and render a web page > with it, when I want to interactively push around buttons and what-not. If > the whole system has to be coherent, like the whole system has to type check > just to be able to move a button around, I think that can be really > inflexible. Source: http://www.infoq.com/interviews/kallen-scala-twitter Is this correct? Why or why not?


Production-safe SQL stored procedure debugging

We have an enormous number of nested SQL stored procedures, and a number of different ways of debugging them (varying from developer to developer). So far, our methods include:   1. An optional `@debug` parameter, that causes the procedure to `print`messages as it runs (passing the variable down to called procedures).   2. Checking `@@servername` against a table of test server names, and `print`ing as above   3. Writing everything the procedure does to a log table (in production and test) Which of these is preferable (and why), or is there a better method we've overlooked?


Creating New Wrapper Objects and Extension Classes and Keeping it Organized

Here's my situation: I'm programming an embedded device with a very simple, but customizable LED array display. It's 10 RGB LEDs linearly setup. The LEDs will be used to display many different things depending on the device's mode. Now, I've started down the road, but feel after spending a lot of time coding and finding a lot of duplicate coding that this should be simplified with some abstraction and wrappers methods and classes. At the very bare minimum and starting point, I have a class, the LED driver, which represents the hardware driving the LEDS. It has one Method which is primarily used `TLC5940.Display(ushort[] greyscaleData)` where greyscaleData is an array of size equal to the amount of output pins, a multiple of 16(16 per chip, chips can be connected to each other).This array controls each pins individually allowing direct control of the leds. This lead me to creating different "extension" methods in a static class which had different routines of populating this array and then passing it into the `Display` method. This works ok for testing different methods, but I found a lot of duplicate code with how I populate the array because each RGB led consumes 3 physical pins(and 3 consecutive array values) to control a specific RGB LED. So, I need to write a consecutive chunk of three values to control an LED. I came up with this private method in the static extension class:               private static void FillLEDArray(ref ushort[] brightnessArray, ushort LEDNumber, ushort rVal, ushort gVal, ushort bVal, short ledStartPin = 2, ushort numLEDs = 10)     {         //logic for how to shift array for physical pin layout         if (ledStartPin == 2) { ledStartPin = 0; }         else if (ledStartPin == 1) { ledStartPin = -1; }         else { throw new Exception("Can only be 1 or 2"); }              ushort pinStart = (ushort)(LEDNumber*3  + ledStartPin);         brightnessArray[pinStart] = bVal;         brightnessArray[pinStart-1] = gVal;         brightnessArray[pinStart - 2] = rVal;     }      It's simple and this makes things easier with my extension display methods so I can loop from 1 to 10 and call this method to write a specific LED to the array in one call. On a deeper level, I thought to make an LED object, which would contain an array of the 3 values and also offer some functions like LED.Colors.Red, LED.Colors.Blue, etc and return an array that would represent that color to make coding easier and more fun. Moreover, create a LED container object class to contain LED object. ex: `LEDS.LED(1).Color.Red` this could also generate an array on demand. One more level of complexity, My device is user customizable, so I have created a User Settings class, which contains all of the device's user settings, many of which apply to the LEDs like certain colors of the RGBs, overall brightness, color schemes, etc. These settings, such as brightness, would need to be applied the whole array before it's sent to the display also. If you've read this far, Thanks. **Question:** At this point have all the tools and ways to control the LEDs, but I'm looking to rewrite this all and wondering what's the best way to encapsulate all of this functionality? Is there a certain coding pattern or style that would apply to this? * * * My Own thoughts: In writing this out and getting it out of my head, maybe a new `DeviceDisplay` class which would contain an instance of the LED hardware and settings classes? Should this class be Static or Singleton? I'm also concerned about Memory/RAM/Speed because this is an embedded device. I would appreciate some feedback on this as it seems there's a lot of different dependencies and getting a little lost in my brain.


Child to Parent linking - bad idea?

I have a situation where my parent knows about it's child (duh) but I want the child to be able to reference the parent. The reason for this is that I want the child to have the ability to designate itself as most important or least important when it feels like it. When the child does this, it moves it to the top or bottom of the parent's children. In the past I've used a WeakReference property on the child to refer back tot he parent, but I feel that adds an annoying overhead, but maybe it's just the best way to do it. Is this just a bad idea? How would you implement this ability differently? Update 1: Adding more context. This is a rendering system so the parent container is a list of windows grouped together. The child item (window) that says "I'm most important!" wants to basically be rendered on the top of the rest of the windows. The parent is just a logical container to group these children together. I can see where adding an event to signal the request to be on the top is a good idea. But implementation (what the child wants to do with the parent) aside, why wouldn't you want to have child->parent linking? Doubly linked lists do this so people can traverse to and from something.