title: Is it OK for me to suggest ready-made scripts to a programmer? If so, how can I do it without offending him/her?

text: Is it ok to suggest pre-built scripts from a place like codecanyon to a programmer who is building a startup web app? Or is it more likely to offend? I don't expect that a whole web app could be built from bits and bobs purchased from a site but I'm unsure of whether its the right thing to ask someone to do. Also, I am not a programmer.


title: How to get JMS to front end

text: I currently have a web application and I would like to add a messaging feature to it. In order to do that, I use JMS(actually OpenMQ, the implementation provided with Glassfish 3). The problem is that I do not know how to get the message notification from the background(from the listener) to the foreground. I am using JSF as a framework, if it does have an importance. Could you please tell me how should I notify the user about a received message(like a chat). Any suggestions are welcomed.


title: Rendezvous in Ada

text: In a test I was asked: > What elements present in the general form of a rendezvous are not present in > Ada language? I was a bit stumbled as I thought Ada fully supported rendezvous. Now it seems it doesn't. Can anyone tell me what are those elements?


title: What are the reasons for great performance differences running the same program?

text: I'm no computer scientist so please bear with me. Lately I wrote a python program that has to perform some expensive spatial searches while holding lot's of data in memory. I tried to improve the performance, that is tried different approaches (see my question here for example). First, and maybe not so surprisingly, I found great performance differences when running the same code on two different machines (up to 6 x faster on one machine). Then however and very much to my own surprise, running the exactly same code on the same machine on two different days showed great performance differences. To give you a rough idea what I mean by great. Machine 1, day 1: 11 minutes Machine 1, day 2: 2 minutes There was no reboot in the meantime by the way. So my question really is: what could be possible reasons for this difference? How can I can I make sure my system is ready for high performance when I start running my program?


title: Keeping third-party source code up to date

text: What is the best way to keep third-party source code up to date? For instance in my app, I'm using third-party source code from an open GitHub repository. What I've done is that I have downloaded the zip of the source code, unpacked it and imported it in my iOS app and then started modifying this source code to my hearts content. So this third-party source code has been working great for me, but now some months later the developer of the third-party source code released an update to his code from `1.0 -> 2.0`. Now of course I want to have this update as well in my iOS app. What would be the easiest way to migrate my `1.0` third- party source code (together with all my additions to the code) to `2.0`?


title: Product agnostic book on Message Queues?

text: Are there any recommendations for book(s) that are largely agnostic (with examples of MQ implementations is fine) on vendor but go to great details on the architecture, management, nomenclature, atomicity, durability, patterns, and logical deployments on Message Queue systems? Surely there are enough shared concepts between MQ Series, MSMQ, SysV IPC (OK, that might be stretching it), RabbitMQ, &c &c?


title: Algorithms for making image mosaics - is there a quicker way than this?

text: I've been playing with making image mosaics. My script takes a large number of images, scales them down to thumbnail size and then uses them as tiles to approximate a target image. The approach is actually quite pleasing: ![](http://i.stack.imgur.com/RZKkTm.jpg) I compute the mean square error for every thumb in every tile position. At first I just used a greedy placement: put the thumb with the least error on the tile it best fits, and then the next and so on. The problem with greedy is that it leaves you eventually placing the most different thumbs on the least popular tiles, whether they match closely or not. I show examples here: http://williamedwardscoder.tumblr.com/post/84505278488/making-image-mosaics So I then do random swaps until the script is interrupted. The results are quite OK. A random swap of two tiles is not always an improvement, but sometimes a rotation of three or more tiles results in a global improvement i.e. `A <-> B` may not improve, but `A -> B -> C -> A``1` may.. For this reason, after picking two random tiles and discovering they do not improve, I pick a bunch of tiles to evaluate if they can be the third tile in such a rotation. I do not explore if any set of four tiles can be profitably rotated, and so on; that'd be super-expensive real soon. But this takes time.. A lot of time! Is there a better and faster approach? * * * **_Bounty Update_** I tested out various Python implementations and bindings of the Hungarian Method. By far the fastest was the pure-Python https://github.com/xtof- durr/makeSimple/blob/master/Munkres/kuhnMunkres.py My hunch is that this approximates the optimal answer; when run on a test image, all other libraries agreed on the result but this kuhnMunkres.py, whilst being orders of magnitude faster, only got very very very close to the score the other implementations agreed on. Speed is very data-dependent; Mona Lisa rushed through kuhnMunkres.py in 13 minutes, but the Scarlet Chested Parakeet took 16 minutes. Results were much the same as random swaps and rotations for the Parakeet: ![enter image description here](http://i.stack.imgur.com/ZW8uh.jpg)![enter image description here](http://i.stack.imgur.com/RZKkTm.jpg) (kuhnMunkres.py on the left, random swaps on the right; original image for comparision) However, for the Mona Lisa image I tested with, the results were noticeably improved and she actually had her defined 'smile' shining through: ![enter image description here](http://i.stack.imgur.com/u4muy.jpg)![enter image description here](http://i.stack.imgur.com/2fI3G.jpg) (kuhnMunkres.py on the left, random swaps on the right)


title: Are there elements common to nearly every SRS?

text: An SRS is a staple of any serious contract work, and it can be _incredibly_ dull for those who've never had the misfortune of needing to read one through in one go. I'm writing a series of document classes with LaTeX (markup language for profession-quality documents; see these questions and this answer on TeX.SE) and, in so doing, I need to define the core tenets and common logical structures evident through any reasonable SRS. I have unfortunately never had the opportunity to participate in the creation of an SRS from scratch save a simplified, somewhat contrived example during college, so I don't think I know the breadth of what goes into a Software Requirements Specification (SRS). I do know it consists of at least the changelog and the requirements themselves, but beyond that... ? What are the indispensable parts of the document that every SRS should have? * * * I'm still pretty new here, but I'm open to making this CW if Programmers.SE is _all about_ this kind of stuff.


title: License Requirements for Including Dual-Licensed Open-Source Software

text: How do you opt into one software license and not the other when the distributor gives the consumer more than one choice? For example I would like to use the DataTables JavaScript library in my web application. According to their web site, "DataTables is dual licensed under the GPL v2 license or a BSD (3-point) license." Furthermore, the source code of the JavaScript library has this text **that calls out both licenses:**               /**      * @summary     DataTables      * @description Paginate, search and sort HTML tables      * @version     1.9.4      * @file        jquery.dataTables.js      * @author      Allan Jardine (www.sprymedia.co.uk)      * @contact     www.sprymedia.co.uk/contact      *      * @copyright Copyright 2008-2012 Allan Jardine, all rights reserved.      *      * This source file is free software, under either the GPL v2 license or a      * BSD style license, available at:      *   http://datatables.net/license_gpl2      *   http://datatables.net/license_bsd      *       * This source file is distributed in the hope that it will be useful, but       * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY       * or FITNESS FOR A PARTICULAR PURPOSE. See the license files for details.      *       * For details please refer to: http://www.datatables.net      */      Finally, the web pages with the licensing text (e.g. the DataTables BSD license page) has this statement: "DataTables is made available under both the GPL v2 license and a BSD (3-point) style license. **You can select which one you wish to use** the DataTables code under." My specific question is "how do you select which one you want to use." In my case, I want to only use the BSD license and I want to make it explicitly clear that I do not opt into the GPL v2 license in any way. How do you do that **and have it hold up to legal challenge?**


title: Design pattern for complex view creation in sheet music

text: I've got a bunch of `Note`-Models with properties like `pitch`and `duration`. In music notation, these notes must now be placed into a certain bar on a certain line on a certain page, and so on. Many more factors influence the positioning of these notes like the notes that are placed in the same bar before them. Also, style-properties influence many different view-elements. The positioning of notes is affected by the "line-height" of the music lines, whether the bar is justified to the width of the page or not, and so on. **I'm looking for a design pattern that can help me cleanly position all these views relative to each other.** Can anybody help me out? I'm using SVG with JavaScript for my current project, if this is important. Thank you so much for helping out! :)


title: Executables and Python

text: I've started learning my first language recently, Python, and I became interested in how it differed from the myriad of other programming languages. I've been able to find most of it out with some searching: There is interpreted, compiled and assembly language. Then there is numerical machine code (which as I understand is just binary?) that is read by hardware directly. So Python is an interpreted language because it isn't explicitly compiled to machine code (although from what I understand this is a false distinction since most code is both compiled and interpreted, if only behind the scenes). I still have one question I couldn't figure out how to search an answer for. I assume Python code requires the Python platform to be read because it contains the interpreter. But how do you get those "standalone" .exe programs which you can run on most computers? Are those files just using a platform which every computer has by default, or are these files that are already compiled completely to machine code? (Like with C++?) The main reason I'm wondering this is that I was wanting to send someone my simple Python programs without having them install the platform. I've searched online and found some 'compilers?' that will do this, but they don't seem to work very well and are very difficult to work with.


title: Must all new features go through betatest?

text: Obviously, small usability fixes and bugfixes go directly into the stable product. What about small new features? Can you afford to just release them after internal testing, or do they have to be betatested by customers first? Situation: This is a young commercial project, produced by a one-person company. It has an existing userbase and is at it's second major version. Previous betatests have produced some results, however most feedback came from the stable product and not from beta versions.


title: Which license can I use for my open source AWS project

text: I'm creating a project on codeplex that uses Amazon Web Services and the AWS SDK for .NET Which licenses can I use? The SDK is released under Apache 2.0 license, so I assume my project can or should use the same. If I add another open source library released under a different license, do I need to find a license that is 'compatible' with both ie. one that has the same requirements for derivative works? * * * My requirement is for a license that allows me to publish a derivative work from the AWS .NET SDK. I can use any of the licenses that codeplex supports, which includes:   * Apache 2.0    * GNU GPLv2    * MIT    * Mozilla Public License 2.0    * Microsoft Public License


title: Creating an entity relationship in REST: May I create the parent by posting to a child id?

text: We are currently designing a REST API to access classical customer data. One of the elements in the API are the assets of an user. The assets are added under a given service. The backend API will only add an asset to an user under a given service. So, there's no User--Asset relation, but a User--[Service]--Asset relationship. Our URI's will look like this:               /users/{id}/assets/{id}/services/{id}      Uses of the API will know the asset id and the service id to create a new entry. What we are struggling with is the creation of this relation. One straightforward way would be to post the whole relation to `/users/{id}/assets/`               POST /users/{id}/assets         {asset:${id}, service:{id}, attribute1:"{var}", attribute2:"{var}"}      but then we are not actually creating an asset as the URI might indicate, but an asset-service relation. As an alternative, we are considering POST'ing to the URI addressing the relation, like this:               POST /users/{id}/assets/{id}/service/{id}     {attribute1:"{var}", attribute2:"{var}"}      But in this case, the resource path `/users/{id}/assets/{id}` will not exist before the POST and will be created as a side-effect. Is POST'ing to a resource path that does not exist yet allowed at all? Thanks for your thoughts, Gerard.


title: Sproc chaining verse discrete calls from OO code

text: I'm currently working on a change at work to generalize a function that was sloppily coded up to work for a particular use case. The function calls a particular sproc that checks if an entity exists and if it does not inserts it, this is the core problem. In discussion about the change with a co-worker we both agreed this should be more modular (you need to be able to get without inserting), however I stated a preference to have two individual sprocs which are discretely invoked in our C# code. He claimed it's superior to have one sproc call the other but wasn't actually able to provide me a convincing argument for why that practice would be better (other than making a the generalized claim that it performs better, to which I said there is much lower hanging fruit for performance optimizations). Which practice do you believe to be better? Why?


title: Do you unit-test your PODs?

text: do you create unit-tests for PODs (Plain Old Data Structure)? And why? I'm interested in your opinions. Regards Tobias


title: What is the Most Expedient Way to Make Legacy Code Conform to 'The Principle of Proximity'?

text: On page 242 of Code Complete 2, Steve McConnell touts **The Principle of Proximity**.   Put simply, Mr. McConnell advises programmers to **keep related actions together**. In my case, the applicable emphasis is:   * It's important to initialize and set variables (and objects) close to where they are being used. It's usually easy to abide by 'The Principle of Proximity' when you're working within a single code block or method body; but what if you're working with legacy code and an object at the top of the stack is set or mutated deep within the stack? To make things more complicated, what if that object is set, mutated, or referenced _multiple times_ within the stack? So here's my question: > What is the Most Expedient Way to Make Legacy Code Conform to 'The Principle > of Proximity'? Incidentally, I'm working with Visual Studio 2010 and Resharper 5.   Are there any IDE tricks that could help me out?


title: Javascript project for analysis and learning

text: I started learning and using Javascript now for about six months. First i started by following different tutorial on the internet. Testing them, playing with them and trying different variation. Afterwards i picked up up a couple of intermediate Javascript book and learned valuable thing from them. And now i am interested in the following:   * If someone can recommend a Javascript project from where i can learn the structure of a serious Javascript application and a project that will give me an a idea how Javascript application should be written.   * Example:realworld uses of prototyping, anonymous(lambda) functions, general program structure, how to write OO applications, what is the appropriate task to use a closure   * etc.. Further explanation: I'm working on my college final paper, on the subject of graph visualization. So im looking at project that will help me realize good patterns, so i can apply them in my project and also to see viable examples of Javascript design patterns Regards, FJ


title: Why is Javascript used in MongoDB and CouchDB instead of other languages such as Java, C++?

text: I asked this question on SO but was suggested to try here. So here it goes: My understanding of Javascript so far has been that it is a client-side language that capture events and makes a web-page dynamic. But on reading the comparison between MongoDB and CouchDB I noticed that both are using Javascript. This makes me wonder the reason behind the choice of JavaScript over other conventional languages. I guess I am trying to understand the role of JavaScript and its advantages over other languages. Update: I am not asking about the languages / drivers supported by the two databases. The comparison says: > Both CouchDB and MongoDB make use of Javascript. CouchDB uses Javascript > extensively including in the building of views. > > MongoDB also supports running arbitrary javascript functions server-side and > uses javascript for map/reduce operations. My lack of understanding pertains to why is Javascript being used at all for the backend work. Why is it preferred for building views in CouchDB, or for using map/reduce operations? Why C/C++ or Java were not used? What are the advantages in using Javascript for such back-end work?


title: Why are a seemingly disproportionate amount of programmers just, well, not nice?

text: Maybe it's just my personal experience, but I associate with varying different groups and types of people and it seems to me that an oddly large percentage of programmers I have encountered are "not nice" or for an attempt at a better definition:   * Condescending    * Snarky   * Negative in the way they talk about people If you have noticed the same thing, any theories as to why? Any suggestions on how to politely or not so politely let one of these programmers know how they are acting and suggest they correct it if they want to be perceived as professional one would want to work with? Or perhaps I've just come across a bad sample and there are bad seeds in every group of people one can name.


title: Learning a new language using broken unit tests

text: I was listening to a dot net rocks the other day where they mentioned, almost in passing, a really intriguing tool for learning new languages -- I think they were specifically talking about F#. It's a solution you open up and there are a bunch of broken unit tests. Fixing them walks you through the steps of learning the language. I want to check it out, but I was driving in my car and I have no idea what the name of the project is or which dot net rocks episode it was. Google hasn't helped much. Any idea?


title: How does a dependently typed programming language cope with mutability?

text: I have been investigating on the viability of a "normal" programming language with dependent types. Think for example in Java and add dependent types to it. One difficulty which I have found is that the type of a variable may change when mutated, like in the following piece of pseudo-code:               let xs = [1, 2, 3]; // The type of xs is List<int, 3>     let ys = [4, 5];    // The type of ys is List<int, 2>     xs.concat(ys);      // We concatenate the lists, so the type of xs is now List<int, 5>      This becomes a problem when we mutate a variable inside an `if` statement:               let xs = [1, 2, 3]; // The type of xs is List<int, 3>     if random_bool {         xs.push(4);     // The type of xs is List<int, 4>     }     // The type of xs is unknown, because random_bool is set at runtime      Is there any research on this topic? Is it possible to address this issue without renouncing to mutability?


title: Intersection of geometric entities

text: I was trying to design a small C++ geometric API for learning purposes, but came across a problem when dealing with intersections of geometric entities. For example, the intersection of a line and a sphere can have three different types: a couple of points, a point or nothing at all. I found several ways to deal with this problem, but I don't know which of them seems to be the best: ## CGAL `Object` return type I first tried to see what was done in other geometric libraries. The most complete I can found was CGAL. In CGAL, intersection functions return an `Object` which is a generic type that can hold anything (like `boost::any`). Then, you try to assign the `Object` to a value of another type, here is an example:               void foo(CGAL::Segment_2<Kernel> seg, CGAL::Line_2<Kernel> line)     {         CGAL::Object result;         CGAL::Point_2<Kernel> ipoint;         CGAL::Segment_2<Kernel> iseg;              result = CGAL::intersection(seg, line);         if (CGAL::assign(ipoint, result)) {                  // handle the point intersection case.              } else if (CGAL::assign(iseg, result)) {                  // handle the segment intersection case.              } else {                 // handle the no intersection case.         }     }      By the way, the `assign` function uses `dynamic_cast` to check whether the two variables are assignable (everybody loves RTTI). ## Union return type A union can also be used as a return type, but it means using an `id` for every geometric type and having some kind of variant type to cover all the problems.               struct Variant     {         int id;         union         {             Point point;             std::pair<Point, Point> pair;         };     };          int main()     {         Point point;         std::pair<Point, Point> pair;              Variant v = intersection(Line{}, Sphere{});         if (v.id == ID_POINT)         {             point = v.point;             // Do something with point         }         else if (v.id == ID_VARIANT)         {             pair = v.pair;             // Do something with pair         }         else         {             // No intersection         }     }      ## Avoiding the "no intersection" problem In order to split the "no intersection" case from the main problem, some libraries used to require the user to check whether there was an intersection before trying to find what was the intersection return type. It looked like this:               Line line;     Sphere sphere;          if (intersects(line, sphere))     {         auto ret = intersection(line, sphere);         // Do something with ret     }      Another way to split the "no intersection" case from the rest of the problem would be to use an `optional` type:               std::optional<...> ret = intersection(Line{}, Sphere{});     if (ret)     {         // Do something with ret     }      ## Using exceptions to control the "return" type _I can already see some of you crying._ Yet another way to handle that problem of having different return types would be to `throw` the results instead of returning them. The "no intersection" return could still use one of the techniques from the previous paragraph:               try     {         intersection(Line{}, Sphere{});     }     catch (const Point& point)     {         // Do something with point     }     catch (const std::pair<Point, Point>& pair)     {         // Do something with pair     }     // Can still catch errors (or "no intersection" special type?)      ## Having a "main" return type, throwing the other ones Another way would be to have a "main" return type for the intersection, let's say `std::pair<Point, Point>` and considering the other return types as "exceptional"; it gives more meaning to the use of exceptions while this is still not quite an error gestion. On the other hand, it could seem strange to handle a "main" type differently than the others...               try     {         auto pair = intersection(Line{}, Sphere{});         // Do something with pair     }     catch (const Point& point)     {         // The chances for a sphere and a line to meet at         // a single point are so small that the case can         // already be considered exceptional.         // ...     }      I purposedly left the errors gestion and the "no intersection" case out of this last example since many techniques already described could be used to handle it and I don't want the number of examples to be exponential. Here is one though:               try     {         // res is optional<pair<Point, Point>>         if (auto res = intersection(Line{}, Sphere{}))         {             std::cout << "intersection: two points" << '\n'                       << std::get<0>(*res).x() << " "                       << std::get<0>(*res).y() << '\n'                       << std::get<1>(*res).x() << " "                       << std::get<1>(*res).y() << '\n';         }         else         {             std::cout << "no intersection" << '\n';         }     }     catch (const Point& point)     {         // Exceptional case         std::cout << "intersection: one point" << '\n'                   << point.x() << " "                   << point.y() << '\n';     }      Since the cases where the result is thrown are exceptional, it should not add any runtime overhead to the program if the underlying system uses zero cost exceptions instead of the old SJLJ exceptions system. ## The actual question Well, that was a pretty long introduction, so here is the question: is there an idiomatic solution to the problem in these examples? And if not, are there at least some of the examples which could be banned without a second thought (well, you could give a second thought to the exception examples though...)? **Note:** something seemed evident to me but apparently is not: the entity returned by intersection between two geometric entities is not limited to a nothing, a point or a set of point. An intersection can pretty much return any geometric entity. Therefore, using a container to hold the values does not sound like a good idea.


title: Which database schema should I pick?

text: I am planning a database scheme and I hesitate between two designs, which one should I choose? For the purpose of the question, assume we want to prepare a database scheme for an application managing student information in a university. There is several modules in the application:   * **Registry,** dealing with general informations, like date of birth, health insurance number, and the like.   * **Library,** dealing with the properties useful to the library management, like the number of books withdrawn, quitus or penalties.   * **Exams,** dealing with the exams taken and the grades. The modules Library and Exams see the modules Registry, but apart from that, are independant. In the application scenario, there is a very large number of students, data is written once, seldom updated and often read. Furthermore, the university expands its system each year, so that modules are added: Sport, Campus, whatever. Modules remain quite independant. I hesitate between two database layouts. ### First layout In the first layout, a table `MODULE` is associated to each Module and a `UID` is used as primary key. Since each module needs the properties under control of Registry, we also prepare views of the join of `REGISTRY` and `MODULE` on `UID`, so that the database knows we will use this join extensively. When the system expands, we add a new table and a new view to reflect this expansion. ### Second layout In the second layout, we create a table with a large number of columns holding the properties of the various modules. When the system expands, we add columns to the tables. ### Comparison How does these two approaches compare? If, say, some software upgrade comes with a major bug, requiring to downgrade the software and perform later a second upgrade, the first layout seems to be more robust. Regarding perfomance, the second layout saves a lot of join operations, but in the first layout, we defined views for the join operations, thus advertising which complex operations are likely to happen so that the database system can plan this. I am far from a database expert, but am I right if I think that if I put all relevant information into the hands of the database system, it will be able to properly carry operation? If I did not see it used in industrial applications, I would never had given 2 pences on the second layout. But since I did, I would like to get other advises.


Why do generics in Scala have erased types, and are not reifiable? Is it due to lack of support from the JVM or for compatibility with Java libraries? What are the advantages in general of having generics as reifiable?


title: Generics and Type-erasure

text: Generics in Java are implemented using type erasure. The JLS says that the inspiration was backward compatibility. Where as on the other hand C# generics are reifiable. Theoretically what are the advantages and disadvantages by having Generics as "erasure" or "reifiable"? Is Java missing onto something?


title: Is it good practice declare a function inline?

text: I'm writing a method and depending on a config field I need to change where I get my data from. What this results in me having to write code that looks like this:               List<string> result = new List<string>();     if (configField)     {         result.Add(fieldA);     }     else     {         result.Add(...BusinessLogic...);     }      I'll have to write that if statement many many times so of course I want to turn it into a method instead so I can just write `result.Add(newMethod(configField, fieldA, dataForBusinessLogicToParse))`. This method would be useless to anyone not writing the specific method I'm writing so does it make sense to declare this method as a separate `private` method or can I just declare it inline as a `delegate` like this:               Func<Enum, int, int> newMethod = (configField, fieldA, dataForBusinessLogicToParse) => ...businessLogic...      I'm worried declaring it inline might make the code more difficult to understand but I think it makes the class cleaner.


title: Repository pattern implementation that knows nothing about the database table and column names

text: I've seen around the Internet and Github, implementations for the design pattern Repository that knows about database table and column names. I was think, if I want to work with the database as a plugin, that I can unplug and plug another respecting Open/Closed for the rest of my code, my repository should not know about the column names of the database I'm using. So how to implement this pattern in a way that it can transform the result from the database into a Entity of my domain, without knowing about the database table and column names? As my main language is PHP, I saw that in Doctrine\ORM you can easily pass different yamls or xmls config files, mapping the column names to property names on the Entity, but... I cant be a hostage of a library implementation, if I want to implement raw PDO, or any other library for my repositories that doesn't make this hydration out-of-the-box, my implementation should do, so how? **Update**   ![Illustration](http://s30.postimg.org/u2vp7n0xt/Desenho_sem_t_tulo_1.jpg) **Update 2**   Please, take a look at: http://leocavalcante.github.io/patterns/2014/07/11/repository-pattern-and- database-schema.html


title: Views : ViewControllers, many to one, or one to one?

text: I have developed an Android application where, typically, each view (`layout.xml`) displayed on the screen has it's own corresponding fragment (for the purpose of this question I may refer to this as a `ViewController`). These views and Fragments/ViewControllers are appropriately named to reflect what they display. So this has the effect of allowing the programmer to easily pinpoint the files associated with what they see on any given screen. The above refers to the one to one part of my question. _Please note that with the above there are a few exceptions where very similar is displayed on two views so the`ViewController` is used for two views. (Using a simple switch (type) to determine what `layout.xml` file to load)_ On the flip side. I am currently working on the iOS version of the same app, which I didn't develop. It seems that they are adopting more of a one-to-many (`ViewController`:`View`) approach. There appears to be one `ViewController` that handles the display logic for many different types of views. In the `ViewController` are an assortment of boolean flags and arrays of data (to be displayed) that are used to determine what view to load and how to display it. This seems very cumbersome to me and coupled with no comments/ambiguous variable names I am finding it very difficult to implement changes into the project. What do you guys think of the two approaches? Which one would you prefer? I'm really considering putting in some extra time at work to refactor the iOS into a more 1:1 oriented approach. My reasoning for 1:1 over M:1 is that of modularity and legibility. After all, don't some people measure the quality of code based on how easy it is for another developer to pick up the reigns or how easy it is to pull a piece of code and use it somewhere else?


title: Why isn't testing a language a supported feature at the syntax level?

text: You can find an endless list of blogs, articles and websites promoting the benefits of unit testing your source code. It's almost guaranteed that the developers who programmed the compilers for Java, C++, C# and other typed languages used unit testing to verify their work. So why then, despite its popularity, is testing absent from the syntax of these languages? Microsoft introduced LINQ to C#, so why couldn't they also add testing? I'm not looking to predict what those language changes would be, but to clarify why they are absent to begin with. As an example: We know that you can write a `for` loop without the syntax of the `for` statement. You could use `while` or `if`/`goto` statements. Someone decided a `for` statement was more efficient and introduced it into a language. Why hasn't testing followed the same evolution of programming languages?


title: Determining which decorator classes are available via reflection

text: I'm creating a pizza place application where employees will be able to create orders for customers(pizza and any number of toppings). This is for a school project but the requirements have nothing to do with this question. On the GUI I have a number of checkboxes that the employee will use to determine which toppings the pizza should have. I want to use the decorator pattern for this. **This is what I want to do(just not sure if its a good idea):** I want to put all of my decorators in a separate namespace, and then using reflection grab all of the decorator names out of that name space and use them to build the checkbox list. The reason for doing this is because if more toppings are added later I think it would be beneficial to just be able to add assemblies (topping decorators) without having to recompile/re-distribute the entire application. Thoughts? (I just learned reflection and I have a hammer and am just trying to pound everything in that even remotely looks lilke a nail)


title: Remote limitations of hg4j?

text: I’m evaluating hg4j to see if it’s useable in my current project. I need a (preferably) pure Java hg library that can:   1. Check out a working copy of a _remote_ hg repo at, say, http://myhg01.example.com/myapp   2. Create a new repo on the same hg server; perhaps a new repo called “fizzbuzz” that would then be hosted from http://myhg01.example.com/fizzbuzz   3. Check code in (“push”) to that new repo My question: does hg4j currently do this? If not, does anyone have any suggestions for me?


title: How many indexes is too many indexes?

text: I have a table with about 37 indexes. Would that be considered too many? What are some best practices regarding indexing? EDIT: It is warehousing data, updated daily with new transactions. There are 47 million rows. 3 of the indexes are very necessary. The other 34~ are 'where' clause indexes intended to speed up queries.


title: Service layer coupling

text: I am working on writing a service layer for an order system in php. It's the typical scenario, you have an Order that can have multiple Line Items. So lets say a request is received to store a line item with pictures and comments. I might receive a json request such as               {          'type': 'Bike',         'color': 'Red',         'commentIds': [3193,3194]         'attachmentIds': [123,413]     }      My idea was to have a `Service_LineItem_Bike` class that knows how to take the json data and store an entity for a bike. My question is, the `Service_LineItem` class now needs to fetch comments and file attachments, and store the relationships. `Service_LineItem` seems like it should interact with a `Service_Comment` and a `Service_FileUpload`. Should instances of these two other services be instantiated and passed to the `Service_LineItem` constructor,or set by getters and setters? Dependency injection seems like the right solution, allowing a service access to a 'service fetching helper' seems wrong, and this should stay at the application level. I am using Doctrine 2 as a ORM, and I can technically write a dql query inside `Service_LineItem` to fetch the comments and file uploads necessary for the association, but this seems like it would have a tighter coupling, rather then leaving this up to the right service object.


title: What syntax should I use to execute functions in jQuery Terminal?

text: I want to add feature, to jQuery Terminal, that will allow to execute commands from the server. Right now it only have formatting syntax that look like this:               [[<list of one letter styles> ; <color> ; <background> ; <class>] TEXT ]      and if you want to display bold white text you can use: `[[b;#fff;]Some Text]`. What syntax should I use for executing commands that will not interfere with formatting but will be similar? Maybe something like `[{name}(param1, param2, param3)]` or `[[exec:name(param1, param2, param3)]]` Any suggestions are wellcome.


title: From a DDD perspective is a report generating service a domain service or an infrastructure service?

text: Let assume we have the following service whose responsibility is to generate Excel reports:               class ExcelReportService{             public String generateReport(String fileFormatFilePath, ResultSet data){           ReportFormat reportFormat = new ReportFormat(fileFormatFilePath);           ExcelDataFormatterService excelDataFormatterService = new ExcelDataFormatterService();           FormattedData formattedData = excelDataFormatterService.format(data);           ExcelFileService excelFileService = new ExcelFileService();           String reportPath= excelFileService.generateReport(reportFormat,formattedData);                    return reportPath;            }         }      This is pseudo code for the service I want to design where:   * `fileFormatFilePath`: path to a configuration file where I'll keep the format of my excel file (headers, column widths, number of columns,..etc)    * `data`: the actual records returned from the database. This data   can't be used directly coz I might need to make further calculations to the data before inserting them to the excel file.   * `ReportFormat`: Value object to hold the report format, has methods   like `getHeaders()`, `getColumnWidth()`,...etc.   * `ExcelDataFormatterService`: a service to hold any logic that need to be applied to the data returned from the database before inserting it to the file.   * `FormattedData`: Value object the represents the formatted data to be inserted. `ExcelFileService`: a wrapper top the 3rd party library that generates the excel file. Now how do you determine whether a service is an infrastructure or domain service?   I have the following 3 services here:   `ExcelReportService`, `ExcelDataFormatterService` and `ExcelFileService`?


title: Front end developers vs HTML/CSS coders plus "the JavaScript developer"

text: I was just googling around to find a good definition of front-end developer and the definitions that I found were pretty much "a guy that does HTML/CSS/JavaScript (jQuery)". But I think this is no longer the case. Today we have very complex interfaces, say a single page BackboneJS app that require a lot more than just "a guy that does HTML/CSS/JavaScript" and has no background in Computer Science. I would argue that the guy that engineers the front-end app (Backbone, Angular, etc) should be as (if not more) skilled programmer than the guy that engineers the back-end. So in my scenario (single page webapp - say with Backbone), I have 3 people:   1. A back-end programmer - the guy responsible for all the API calls that the Backbone app would make    2. A "front-end" programmer - they guy that's responsible for getting the work from the designer (wireframes if you will) and turning it into responsive, cross-browser, cross-platform HTML/CSS code   3. The "JavaScript" developer who makes everything light up, hooks up the HTML/CSS to the API and brings the app to life.  My question is: What is the most usual modern dev team structure? How is the work usually divided between the front end and back end developers. Of course if you only have full-stack developers that can produce JavaScript and say PHP equally well, then you have less of an issue. But still, who is the front-end developer and how do you call "the JavaScript developer"? Excuse my simple language, I tried to stay as far away from terminology as possible.


title: Software License for project using .NET and Sql Server Express

text: I considering making my application open source on github. I don't intend to sell it (neither in binary form nor source code form). It probably isn't even useful to a lot of people except maybe for learning purposes. The application is developed in .NET 4.5 (WPF). It doesn't use any external libraries. Only pure .NET libraries as provided by Microsoft. However, it is dependent on Microsoft Sql Server Express 2008. I would like to license the application under the GPLv3 but I don't know if that will work because of the SQL Server requirement. If not, what would you recommend? Sorry, but English isn't my first language and hence I'm having difficulties understanding all this legal stuff. Thanks for your time.


title: static set and non-static get method

text: I've the following Interface.               public interface ValueInterface     {       long  getValue();     }      And the class:               public class ValueCreator implements ValueInterface     {       private static long value  = 0;            public void setValue(long valueInDollar)       {         value= valueInDollar;       }            @Override       public long getValue()       {         return value;       }     }      The static code analyzer findbugs warned me not to set a static field in a non-static method. If I make the set method static, I can't make the getter static as it is an interface overridden method. So, is it okay to have a static setter and non-static getter or what could be a better approach?


title: What is the standard for modeling modern applications prior to development?

text: I'm taking on my first enterprise-level application ~~and I want my team to model the entire ASP.NET MVC C# application before we even tap out one line of code.~~ UPDATE: This was not intended to be a philosophical discussion about when to document/model an application. Please only provide answers for "how" to document/model. The truth is that I've always skimped in this department and I've never really modeled an application before. What is the standard way to do this? What type of diagrams should be used and what would the documentation look like? Links to sample diagrams and documentation is appreciated. When searching I can find numerous things around the net but I wanted to see if there is a current modern consensus on how to go about doing this. Thanks in advance! ### Closing Statement I had no idea this was such a sticky subject. Thank you to all of you that could set aside the obvious controversy and provide useful answers. It was an interesting discussion to say the least :) Another useful link I discovered is this: Do you use UML in Agile development practices?


title: What is happening to PHP 6?

text: I am excited about the changes in PHP 6 previewed in PHP 5.3+. However, I wonder why it takes so long to release PHP 6? Books about it have been published since 2008, and announcements on it since 2007, but I am yet to hear about an alpha or a beta. Why does it take so long to release it? Or is that the way it goes with all languages when they transition to a major release where I guess it takes around 4-5 years to release?


title: Should we have a database independent SQL like query language in Django?

text: **Note :**   * I know we have `Django ORM` already that keeps things database independent and converts to the database specific `SQL` queries.   * Once things starts getting complicated it is preferred to write `raw SQL` queries for better efficiency.   * When you write `raw sql` queries your code gets trapped with the database you are using.   * I also understand its important to use the full power of your database that can-not be achieved with the `django orm` alone. My Question :   * Until I use any database specific feature, why should one be trapped with the database.   * For instance : > We have a query with multiple joins and we decided to write a raw sql query. > Now, that makes my website `postgres` specific. Even when I have not used > any postgres specific feature. I feel there should be some `fake sql` language which can translate to any database's sql query. Even Django's ORM can be built over it. So, that if you go out of ORM but not database specific - you can still remain database independent. I asked the same question to `Jacob Kaplan Moss` (In person) :   * He advised me to stay with the database that I like and endure its whole power, to which I agree. But my point was not that we should be `database independent`.   * My point is we should be database independent until we use a database specific feature. Please explain, why should be there a `fake sql` layer over the actual sql ? ================================ **Update:** ================================ **My suggestion:** Solve the independence of the database on a `fake sql` level and then build ORM over that fake sql. So, if I have to write a sql query - I will use `fake sql` that would work on all databases yet raw SQL. That way, I will remain database independent unless I use a feature very specific to my database. Therefore, a query like `select * from table limit 10;` will work on both `postgres` and 'MS-SQL Server'. Is that sensible ? **Note:**   * I am not talking about `ANSI SQL`, I am suggesting a `fake sql` to make all databases work with 1 standard sql. **[ Which may not cover db specific features ]**


title: Team Parallel development in ASP.NET

text: I am developing an application written in ASP.NET (C#) which heavily use on Master Page and Session. As there will be enhancement in the same web application, and will be done by my teammate. is there any good approach that can enable we to work on the same solution, and delivery the change to UAT / PDN separately? the change control team of my company don't allow us to create 2 set of code in UAT and merge it into one set in PDN. any idea is welcome. Thanks.


title: The term "interface" in C++

text: Java makes a clear distinction between `class` and `interface`. (I believe C# does also, but I have no experience with it). When writing C++ however there is no language enforced distinction between class and interface. Consequently I've always viewed interface as a workaround for the lack of multiple inheritance in Java. Making such a distinction feels arbitrary and meaningless in C++. I've always tended to go with the "write things in the most obvious way" approach, so if in C++ I've got what might be called an interface in Java, e.g.:               class Foo {     public:       virtual void doStuff() = 0;       ~Foo() = 0;     };      and I then decided that most implementers of `Foo` wanted to share some common functionality I would probably write:               class Foo {     public:       virtual void doStuff() = 0;       ~Foo() {}     protected:       // If it needs this to do its thing:       int internalHelperThing(int);       // Or if it doesn't need the this pointer:       static int someOtherHelper(int);     };      Which then makes this not an interface in the Java sense anymore. Instead C++ has two important concepts, related to the same underlying inheritance problem:   1. `virtual` inhertiance   2. Classes with no member variables can occupy no extra space when used as a base > "Base class subobjects may have zero size" Reference Of those I try to avoid #1 wherever possible - it's rare to encounter a scenario where that genuinely is the "cleanest" design. #2 is however a subtle, but important difference between my understanding of the term "interface" and the C++ language features. As a result of this I currently (almost) never refer to things as "interfaces" in C++ and talk in terms of base classes and their sizes. I would say that in the context of C++ "interface" is a misnomer. It has come to my attention though that not many people make such a distinction.   1. Do I stand to lose anything by allowing (e.g. `protected`) non-`virtual` functions to exist within an "interface" in C++? (My feeling is the exactly the opposite - a more natural location for shared code)   2. Is the term "interface" meaningful in C++ - does it imply _only_ pure `virtual` or would it be fair to call C++ classes with no member variables an interface still?


title: How to Be a Software Engineer?

text: My problem is kind of weird so please bear with me. I have been working in a start up concerned basically with mobile development since my graduation 2 years ago. I develop apps for iOS but it's not really relevant. The start up structure is simply founders > developers, with no middle-tier technical supervision or project management whatsoever. A typical project cycle of ours is like this: meet with a client > send very vague requirements to an outsourced graphics designer > dig in development right after we get the design, no questions asked > then improvise improvise improvise! It's not that we are unaware that stuff like requirements analysis, UML, design patterns, source code control, testing, development methodologies... etc. exist, we just simply don't use them, and I mean like never. The result is usually a clunk of hardly-maintainable yet working code. Despite everything we are literally flourishing with many successful apps on all platforms and bigger clients each project. The thing is, we want the chaos to stop and we're looking for advice. How would you fix our company technically? Given that you can't hire project managers or team leaders just because we are barely 5 developers, so it wouldn't be a justified cost for the founders, but one-time things like courses, books, private training... etc is an option. Lastly, if it's relevant, we are based in Egypt. Thank you a lot in advance.


title: Program more professionally (planning, notation, ...)

text: I program a data-analysis framework for my company (20000LOCs by now). There are 2 programmers who help writing individual module for interfaces I have predefined. So far I haven't used much planning or tools. I basically think of new classes in my head and write them down in Python+Eclipse. As Python is good for proto-typing I can easily modify it if I overlook one aspect. However, sometimes I need to refactor some structure and I wonder if that hadn't happened if I used planning tools. What do you think is the most important start to plan programming more professionally? The project won't become too big as it's only for data analysis, but managing which data is processed which way is also tedious. Can you suggest methods, reading or tools? My class hierarchy is pretty flat so I don't see much use in class diagrams. However, something like call diagrams and diagrams which show how objects reference each other might help. I've learned OOP by myself, but I'm confident that once I consider all requirements I can design a nice class structure. What about TDD? For the moment I cannot imagine how to use it since most calculation are on network-like data with objects and many object references (links). Moreover data content hasn't been a problem yet. Yet, I suspect that some more professional approach might be more efficient. Ideas?


title: Methods for systematically researching technologies to use in a project?

text: If I want to recommend a technology/plugin/library to my company for use in a project, are there any methodologies I can use that will produce more reliable results and a more convincing presentation of said results than just my own "common sense" approach?


title: Should I Correct Candidates' Interview Answers?

text: I've been interviewing software engineers lately and I tend to ask harder and hardeer questions until they get something wrong, then switch to another technology track and do the same. When the candidates do get something wrong, I always tell them the right answer...mainly because that's what I would want if I were being interviewed. It sucks to just hear "no that's not right" and nothing else... Yesterday a candidate made a snarky comment when I gave him the correct answer after he answered incorrectly, saying "well I'm not sure I'll ever use that information...". I never speak condescendingly or critically. I just say in a matter of fact tone: "actually, in xyz language, abc is implemented in such a way, not in that way". Is my practice of providing correct answers inappropriate? Should I reconsider this practice?


title: Code Review process

text: I'm looking for a light-weight code review process. A couple of requirements, the reviewer must be able to do the review alone at the time of his/her choosing (not tied to check-ins), the reviewer must be able to easily find the target code, the review has to leave some document showing what was reviewed. I know there are tools available for code review but I work in a very ridig environment and introducing new tools is not an option. One idea I've been thinking about is to create a new Visual Studio Task List token called REVIEW, and use it to mark the code that needs reviewing. Something like,               // REVIEW doe_john: New method, not sure about the exception.      Then we would add a Review workitem in TFS (we're using the CMM template). Another possibility, which I would actually prefer, would be to have developers create a TFS Review workitem and add links to code to it, but I don't know if this is possible. Obviously you can add a link to a file, but I'd like to have a link to a particular method.


title: is 'protected' ever reasonable outside of virtual methods and destructors?

text: so, suppose you have some fields and methods marked protected (non-virtual). presumably, you did this because you didn't mark them public because you don't want some nincompoop to accidentally call them in the wrong order or pass in invalid parameters, or you don't want people to rely on behaviour that you're going to change later. so, why is it okay for that nincompoop to use those fields and methods from a subclass? as far as i can tell, they can still screw up in the same ways, and the same compatibility issues still exist if you change the implementation. the cases for protected i can think of are: non-virtual destructors, so you can't break things by deleting the base class. virtual methods, so you can override 'private' methods called by the base class. constructors in c++. in java/c# marking the class as abstract will do basically the same. any other use cases?


title: Are these advanced/unfair interview questions regarding Java concurrency?

text: Here are some questions I've recently asked interviewees who say they know Java concurrency:   1. Explain the hazard of "memory visibility" - the way the JVM can reorder certain operations on variables that are unprotected by a monitor and not declared `volatile`, such that one thread may not see the changes made by another thread. Usually I ask this one by showing code where this hazard is present (e.g. the `NoVisibility` example in Listing 3.1 from "Java Concurrency in Practice" by Goetz et al) and asking what is wrong.   2. Explain how `volatile` affects not just the actual variable declared `volatile`, but also any changes to variables made by a thread before it changes the `volatile` variable.    3. Why might you use `volatile` instead of `synchronized`?    4. Implement a condition variable with `wait()` and `notifyAll()`. Explain why you should use `notifyAll()`. Explain why the condition variable should be tested with a `while` loop. My question is - are these appropriate or too advanced to ask someone who says they know Java concurrency? And while we're at it, do you think that someone working in Java concurrency should be expected to have an above-average knowledge of Java garbage collection?


title: Are there any off the shelf solutions for feature use analysis?

text: I write a set of productivity tools that sells online and have tens of thousands of users. While we do get very good feedback, this tends to come from only the most vocal users, so we fear we might be missing the big picture. We would like to know if there is any off the shelf (or nearly so) solution to capture usage of different features and to report usage patterns and trends over time. Note: These tools are native apps, not web-based. I know about Google Analytics and the like. They're great, but I'm looking for native code solutions.


title: Computed Values and Simple Reads - A nagging pain for my Domain Driven Designs!

text: The problem I continually face is how to deal with computed values driven by domain logic while still working efficiently against the data store. Example: I'm returning a list of Products from my repository via a service. This list is limited by pagination info from request DTO sent by the client. In addition, the DTO specifies a sort parameter (a client-friendly enum). In a simple scenario, everything works great: the service sends paging and sorting expressions to the repo and the repo issues an efficient query to the DB. That all breaks down, however, when I need to sort on values generated in memory from my domain model. For instance the Product class has an IsExpired() method that returns a bool based on business logic. Now I can't sort and page at the repo level --it would all have be done in memory (inefficient) and my service would have to know the intricacies of when to issue these params to the repo and when to perform sorting/paging itself. The only pattern that seems to make sense to me is to store the state of the entity in the db (make IsExpired() a readonly field and update it via the domain logic before saving). If I separate this logic into a separate "read model/dto" and "reporting" repository, I'm making my model more anemic than I'd like to. BTW, every example I've seen out there for computations like this really seems to lean on in-memory processing and glossing over the fact that it is far less efficient in the long run. Maybe I'm prematurely optimizing, but that just doesn't sit right with me. I'd love to hear how others have dealt with this as I'm sure it's common on nearly project involving DDD.


title: Web interface with FastCGI or with direct HTTP?

text: Let's assume I want (for fun at start) to play with some new DSL (domain specific language) idea. And I really want its user[s] (probably only me at first) to interact thru a web interface. I'll probably implement it in C++ (probably using LLVM). Should I use an HTTP server library (like libonion or microhttpd) to talk directly HTTP or should I use FastCGI? I could also use libraries doing both like cppcms or wt... In particular, I am noticing that several recent web frameworks (Opa, Ocsigen, ...) do not have any FastCGI interface but only HTTP one.... (but Ur/Web seems to have both) So my feeling is that FastCGI is really out of fashion.... Any opinions on that? Do you know recently started project using FastCGI ? (and what about SCGI?)


title: Is there a better way of handling access control logic instead of it being in the UI?

text: Through most of my dev experience, I've never had to deal with much variety of access control architectures. They've all been pretty straight forward:               Group [Create, Update, Delete]         - User 1         - User 2          Group [Update, Delete]         - User 2      Which, for all intents and purposes, works well. The problem I have is the actual implementation of it. All the solutions I've worked on either grant/deny the visibility of a menu link, or disable a button etc. This is all controlled via the top-most layer of the app, whether it be a WebApp or WinForms UI. I'm in the early stages of designing a rather large WinForms system so I'd like to get the security architecture right from the beginning. Although I don't see myself getting away from visually limiting the user from performing certain actions (by disabling restricted controls etc), I'm sure there are better solutions available then doing most of the work in the UI. As I understand it (and these might be limited by my ignorance), these are my options:   * Put the logic to return and verify user rights in the business layer   * On the form_load event, get these rules and enable/disabled UI elements   * Leave the UI elements in tact and halt the operation from within the business layer if the user doesn't have permission for the action (dirty!) Surely there must be more elegant solutions than this. Could someone please provide me with alternatives or improvements to the aforementioned ideas? Am I thinking about it incorrectly? Should I re-evaluate my database design while I'm at it?


title: Will staying in this position affect my career negatively?

text: I work at a small software company where the owners are also the managers. My concern is that any and all progression in technology is met with utter disdain by management. Some of the comments are as follows:   * LINQ, nHibernate, and ORM are bad programming practice, we will never use them.   * The majority of large applications are still written in VB6.   * The web is just a waste of time, its not meant for applications. Every time a new version of development software is released, I have to listen to the management complain about it for hours. Technologies like WPF, WCF, MVC and Entity are completely ignored. All that said, its not a horrible place to work, the pay is average and its close to home. My concern is that, even though we are technically using the latest version of .NET, we are hardly using the latest technologies, we might as well be using .NET 1. If I decide to move, will this "experience" limit me career wise? I have been here for a few years already. EDIT: I am really grateful for the superb response. I honestly think it might be in my own best interest to make a move.


title: Multiple possible jsp views for a request

text: I'm looking to offer the user some way of changing how a single page looks based on some pre-defined jsps. i.e. Two or more jsp's contain similar information, and would be backed by a single controller method. The controller would decide which view to return.   1. Is there a common way of achieving this? At the moment I have some administration screens where I control a list of possible views. The user can then choose which one to see from a drop-down. My current issue is that I don't know how to confirm (at the admin screen) that the view is valid.   2. Is there a way of asking spring for all possible views so I can filter them and resent a drop-down on the admin screen rather than a free text field? If not is there a way of asking spring if a single view is valid? All these views will reside under a common directory, so it would probably be possible to scan recursively from that point and build a list of possible views. This goes beyond simply changing the css, since the page content might be different despite being backed by the same model.


title: Books and stories on programming culture, specifically in the 80's / early 90's

text: I've enjoyed a number of (fiction/non-fiction books) about hacker culture and running a software business in the 80's, 90's. For some reason things seemed so much more exciting back then. Examples are:   * Microserfs (Douglas Coupland)   * Accidental Empires (Robert X. Cringely   * Almost Pefect (W.E. Peterson, online!)   * Coders at Work (Peter Seibel) Today I'm an entrepeneur and programmer. Back in the 80's a I was a young geek hacking DOS TSR's and coding GWBasic / QBasic. In the 90's I was a C.S. university student, experiencing the rise of the Internet world wide. When reading these books running a software business seemed so much more fun than it is nowadays. Things used to be so much simpler, opportunities seemed to be everywhere and the startups seemed to work with much more real problems (inventing spreadsheets, writing word processors in assembly on 6 different platforms) than all our current web 2.0 social networking toys. Does anyone share these feelings? Does anyone have any good (personal) stories from back then or know of other good books to read?


title: Source code modification and GPLv3 compatibility

text: Assume that the source file A contains the following license notice: "This code is Copyright 1234 by XYZ. It may be freely redistributed in its entirety provided that this copyright notice is not removed." Can I combine it with a project B published under the GPL version 3 license? In particular, does the lack of a permission to modify source file A ("redistributed in its entirety") prohibit that?


title: Is there a good reason not to display error messages to users?

text: Windows 8 seems to have chosen to silently shutdown applications that misbehave, there is no message informing the user something bad happened and no information on why the application closed. I heard through the grapevine that employees at Microsoft are tired of customers blaming them for crashes and that they believe when they display an error to the user the user will accuse Microsoft of the crash instead of the app developer. Regardless of whether that is true or not is it really not a good idea to display error messages? I thought that error messages at least give users something to use when they are searching the web for help or talking to customer service. What possible good reason is there for crashing silently and not showing an error message?


title: Use of Unmodified AGPLv3 lib - am I AGPL too?

text: So, I've been reading the AGPL and here is my understanding (not being a lawyer and I'm not trying to look at it through the lens of "Since I WANT it to be ''free'', it therefore is.". In my case, I am considering the use of itext, an AGPL library, to crack open PDF files and extract the text - that's it. There will be an internal desktop app and I've proposed using my extraction code (which uses the itext dll) on the website to speed up the process for those folks upstairs who've been doing it manually for years. Under definitions:   * "the program" means the itext lib, being the copyrightable work.   * "modify" or "based on" means, a version of the program which differs from the original. Not applicable here since I am not modifying the code.   * "covered work" means the original or modified versions of the original work. In my case, it would be the original work.   * "propagate" and "convey" mean to copy or distribute the program (the itext lib, in my case, compiled as a dll), in which case, as I understand it, the source to the covered work must be made available. This doesn't apply to use within companies (since the company can require employees to not make copies and distribute software). Use on public facing networks though, might be a consideration per sec13, though the web users won't be interacting with the program itself or with the output of the program.   * "interactive user interface"... so far, haven't seen one in the lib but this is probably the least clear of the definitions since it mentions the "work" and libs (the work, in this case) generally don't interact with users. If I need to, I can include a mention somewhere, no biggie. So, by my interpretation of the definitions, the covered work is the itext code I am using. The code I write separately, is not based on or modified from the itext code and thus, can be licenced any way I choose, incl locking it down tightly or posting openly on my fav forum. So long as I do not modify or incorporate copyrighted AGPL code directly into my code, there is nothing I can see in this licence that prevents me from linking to the original version I downloaded. Most I might have to do is provide the source to the version of the covered work. So, emotions aside and focusing solely on legality, what say you? I think it's clear from the FSF FAQ, that internal corporate use means I can do pretty much anything I like and no source needs to be distributed outside the organization. My only real concern is making a web app which in turn, makes calls to the itext lib. What am I required to do in this case? I believe I only need to provide a link or location to download the itext code. Another option, what if I made a small, separate, standalone program, and had the website call it via a standard "run" mechanism? The rest of the existing website should not have to suddenly fall under the AGPL even if my text extractor portion does, correct?


title: see what ARC does?

text: If I understand correctly, all ARC does is automatically add memory-management statements such as `retain` and `autorelease` in the proper places in a program. Is there any way to see all the memory-management statements that ARC automatically adds to a program?


title: One codebase - lots of hosted services (similar to a basecamp style service) - planning structure

text: We have built a service (PHP Based) for a client, and are now looking to offer it to other clients as a hosted service. For this example, think of it like a hosted forum service, where a client signs up on our site, and is given a subdomain or can use their own domain, and the code picks up the domain, checks it against a 'master' users table, and then loads the content as needed. I'm trying to work out the best way of handling multiple clients. At the moment I can only think of two options that would work:   * **Option 1** - Have 1 set of database tables, but on each table have a column called 'siteid' - this would mean every query has to check the siteid. This would effectively work with just 1 codebase, and 1 database.   * **Option 2** - Have 1 'master' database with all the core stuff such as the client details and their domain. Then when the systen checks the domain, it pulls the clients database details (username/password/dbname) from a table, and loads a second database. The issue here is security of the mysql server details, however it does have the benefit that they are running their own database instead of sharing one. Which option would I be better taking here, and why? Ideally I want it to be fairly easy to convert the 'standalone' script to the 'multi-domain' script as we're on a tight deadline.


title: Refactoring a live system that is tightly coupled with improper data models and business logic in the front-end

text: # Scenario This was a project that I once had to maintain. After reading _Working Effectively with Legacy Code_ , I started to think how I would refactor this system in a live environment, _if I had to (thankfully, I didn't)._ The system was a legacy system without documentation and extremely tightly coupled. Database relationships were incorrectly modelled - i.e. objects that were meant to be many-to-one were mapped as one-to-one. Using "duplication" allowed for "pseudo-many-to-one" relationships. Business logic was stored as JavaScript solely on the front-end. Data was tightly coupled to Presentation data. As an example, a Question object could not exist without a Table Cell object. The database had a table call "TableCell" to store inline CSS for each cell which was mapped one-to-one with a "Question" object. The system was a horrendous mess and eventually lead to loss of data and a complete re-write in the end. In total the project was about 350K LOC. As a side note, the reason why the system was re-written (or needed refactoring) was that it was to be exposed to the Internet, but we were able to modify the business logic using the Chrome Debugger to elevate roles, inject code, and execute all sorts of undesired functions. ## Question The book used examples where the logic was placed in the middle tier. However, what happens when the business logic is placed in the front-end? From my point of view the refactor process would have to go this way:   1. Refactor the front-end JavaScript to understand the business logic   2. Refactor the middle-tier to include validation   3. Refactor the database to decouple the data models   4. Migrate the data   5. Refactor the middle-tier to decouple the data models   6. Refactor the front-end to reflect the changes in the data models. I have read Techniques to re-factor garbage and maintain sanity? and it is helpful, but it doesn't address the order in which refactoring should occur for this specific scenario. This process seems to add a lot of redundancy as the front-end and middle-tier are refactored twice in the live system.   * What is a more efficient way to refactor such a system while keeping the system live?


title: Handling multiple packet types in Java 8

text: I have a Netty-based game server implementation that handles 40 or so distinct packets with their own serialization structure, for brevity I'll refer to them as `FooPacket`, `BarPacket`, ... These packet types have been assigned consecutive numerical "packet types", which are unsigned bytes. For example, `FooPacket` is type 0x01, `BarPacket` is type 0x02, etc... All of these packets extend an abstract class, `MyGameNetworkPacket`. My current approach with Netty is to use an initial decoding layer to convert a TCP stream into a series of unparsed packet objects, which are defined as consisting of a packet type, length, and buffer containing the actual packet contents. (no byte stuffing is performed). I then feed this packet down the pipeline to one of a few "deserializing processors", each of which handles a set of packet types that are semantically related to each other (for example one such processor might handle connection state messages, while another may handle packets related to a certain aspect of the game itself). As per the design of Netty's MessageToMessageDecoder usage, my decoder is implemented as:               protected void decode (ChannelHandlerContext ctx, UnparsedPacket msg, List<Object> out)             throws Exception {         switch (msg.command) {             case FooPacket.COMMAND_ID:                 FooPacket fooPacket = new FooPacket(msg.frame);                 out.add(fooPacket);                 break;             case BarPacket.COMMAND_ID:                 BarPacket barPacket = new BarPacket(msg.frame);                 out.add(barPacket);                 break;         }          }      Once I get a structure decided upon I can easily create this with a code generator. In addition, I override `public boolean acceptInboundMessage(Object)` to specify if an unparsed packet should be handled by this decoder. This is attaining a bit of what appears to be a code-smell for me, so I was looking into alternative solutions, such as:   * Having an array whose (integer keys) map to values of a lambda that takes a RawPacket and returns the parsed packet. This seems like a somewhat weird way to use an array and requires that I manually maintain the definition of that array so that its index-element mapping exactly matches the actual packet type to packet structure mapping already in use.   * Having a map structure that does the same thing as the array. Similar pitfalls, but somewhat more maintainable. Are these any more novel ways to approach this that I haven't thought of yet?


title: How create unit test the performance of an application?

text: What I want is to run automatically methods to tests the performance of an application. Just like the unit tests, but with the purpose of evaluate the performance and create reports if is it possible. Is there any framework or tool to achieve this?


title: Using Mockito.reset

text: I've just read a lot of arguments against using `Mockito.reset` and can't make much sense of it. Put differently, I agree in general, but there's always a case which looks like using `reset` is useful or even necessary. Grossly simplified, my class under test is an encapsulated map like               class Handler {         private final Map<String, String> map;              public void handle(RequestResponse rr) {             if (rr.isPut()) {                 map.put(rr.key(), rr.value());                 rr.response("OK");             } else {                 rr.response(map.get(rr.key());             }         }     }      To test it, I mock `RequestResponse` and do something like               when(rr.isPut()).thenReturn(true);     when(rr.key()).thenReturn("key");     when(rr.value()).thenReturn("value");     handler.handle(rr);     verify(rr).response("OK");          reset(rr);          when(rr.isPut()).thenReturn(false);     when(rr.key()).thenReturn("key");     handler.handle(rr);     verify(rr).response("value");          reset(rr);          when(rr.isPut()).thenReturn(false);     when(rr.key()).thenReturn("anotherKey");     handler.handle(rr);     verify(rr).response(null);      I can see, I'm testing three things at once:   * proper response after "put"   * proper value returned from get with the same key   * `null` returned from get with another key I can imagine reasons to separate the two last tests. However, they both need the first one and I still need a `reset` in between? Or don't I? ### Update In the meantime the class under test has got a bit more complicated and the need for `reset` bigger. It's sort of a state machine and the test looks like   * repeat the following accross different paths      * try an illegal step and expect an exception     * try another illegal step and expect an exception     * do a legal step and verify output I actually only need two methods, one verifying the exception for an illegal step and the other verifying correct output for a legal step. Executing an illegal step mustn't change the state, so it's safe to mix it in. Consider this example: If the only valid input sequence was `A, B, C` (three steps) and the corresponding outputs were `a, b, c`, then a test looks like               checkException("B")     checkException("C")          checkOutput("A", "a")     checkException("A")     checkException("C")          checkOutput("B", "b")     checkException("A")     checkException("B")          checkOutput("C", "c")     checkException("A")     checkException("B")     checkException("C")      walks through the whole path and verifies everything. It would take many "normal" single-condition-verifying tests to achieve the same, right?


title: Basic logical operator question

text: #include <stdio.h>     int main()     {         int k=5;         if(++k < 5 && k++ / 5 || ++k <= 8)         {              printf("%d",k);         }         return 0;     }      Why is the output 7 and not 8?(I am a beginner in programming so please bear with me.)


title: Simple method for reliably detecting code in text?

text: GMail has this feature where it will warn you if you try to send an email that it _thinks_ might have an attachment. ![Did you mean to attach files?](http://i.stack.imgur.com/sHTG9.png) Because GMail detected the string `see the attached` in the email, but no actual attachment, it warns me with an OK / Cancel dialog when I click the Send button. We have a related problem on Stack Overflow. That is, when a user enters a post like this one:               my problem is I need to change the database but I don't won't to create      a new connection. example:          DataSet dsMasterInfo = new DataSet();     Database db = DatabaseFactory.CreateDatabase("ConnectionString");     DbCommand dbCommand = db.GetStoredProcCommand("uspGetMasterName");      **This user did not format their code as _code!_** That is, they didn't indent by 4 spaces per Markdown, or use the code button (or the keyboard shortcut `ctrl`+`k`) which does that for them. Thus, our system is accreting a lot of edits where people have to go in and manually format code for people that are somehow unable to figure this out. This leads to a lot of bellyaching. We've improved the editor help several times, but short of driving over to the user's house and pressing the correct buttons on their keyboard for them, we're at a loss to see what to do next. That's why we are considering a Google GMail style warning: > Did you mean to post code? > > You wrote stuff that we think looks like code, but you didn't format it as > code by indenting 4 spaces, using the toolbar code button or the `ctrl`+`k` > code formatting command. However, presenting this warning requires us to **detect the presence of what we think is unformatted code in a question**. What is a simple, semi-reliable way of doing this?   * Per Markdown, code is always indented by 4 spaces or within backticks, so anything correctly formatted can be discarded from the check immediately.   * This is only a _warning_ and it will only apply to low-reputation users asking their first questions (or providing their first answers), so some false positives are OK, so long as they are about 5% or less.   * Questions on Stack Overflow can be in _any_ language, though we can realistically limit our check to, say, the "big ten" languages. Per the tags page that would be C#, Java, PHP, JavaScript, Objective-C, C, C++, Python, Ruby.   * Use the Stack Overflow creative commons data dump to audit your potential solution (or just pick a few questions in the top 10 tags on Stack Overflow) and see how it does.   * Pseudocode is fine, but we use c# if you want to be extra friendly.   * The simpler the better (so long as it works). KISS! If your solution requires us to attempt to compile posts in 10 different compilers, or an army of people to manually train a bayesian inference engine, that's ... not exactly what we had in mind.


title: Licensing issue for RSA and Rijndael algorithms

text: I'm using .Net to build a commercial application, i.e. a secure chat application. This application is using RSA and Rijndael algorithms. Do we need licenses for using RSA and Rijndael algorithms for commercial product?


title: How do you design code?

text: Even though I work as a programmer, I've never actually been trained as one. Everything I know is self-taught. As part of my continual process of self- improvement, I want to develop better habits/techniques. I'm wondering how most of you design your code before you actually begin coding? Right now, I write an empty program with all my methods and variables commented, and pseudo-code in place of blocks of logic. Do you guys have other tricks/techniques you can share? Right now, most of my work is in client-side Javascript development but of course, these techniques should be global.


title: Making the move to team leading

text: I'm looking for some examples of experiences from people who have made the move from programmer to team leader. I'm kind of wanting to know the reasons why people have done it. Specifically, these are some questions and concerns that are floating around in my head.   * Did you have a waning desire to write code but still a strong desire to create programs?   * Did you realise that you were more of a people person and you could utilise your communication skills better?   * Was it because you were asked by management and thought why not?   * For the money?   * How were the initial few months after making the move?   * Were relations with colleagues affected?


title: OSS - GPL v3 plugins in non-copyleft codebase.

text: I've been working on software to modify a game's resource files, and I'm planning on releasing it in open source. I'm perfectly fine with releasing my code under gpl v3. However, I'm afraid that that would deter others from writing extensions for my software, as I have had others offer to do so - the community which I'm working with is very much afraid of open source leeches, and as a result, the majority of popular released projects are closed source. As such, I'd be more comfortable with something like BSD or MIT. The codebase is extremely modular, and one window might consist of the end products of many different plugins. One plugin which I am working with is the work (licensed under gpl v3) of a person who I have communicated with, who was enthusiastic of me using his software. As one other person has contributed to that software, I don't think he can simply release his source to me under a different license. In the future, I'd like to have more plugins for a variety of things which would be difficult to manually implement (as doing so would require large amounts of reverse engineering). Tl;dr: As I am in good terms with these people, is there any means for me to use their code as plugins? I would have permission, but licensing would be the issue, since others have contributed to the codebases. If so, would it be okay if i distributed their plugins with my built software (in a plugins folder)? How about placing them in the code repository and visual studio solution? Any other advice would be appreciated. Thanks!


title: Continuously Improving output of a team

text: I am having my own software service company, DIGICORP and I am leading a team of 10 developers. The total company size is of around 50 persons. We are four friends who have started this venture from 2004. During last year, we have read the Getting Real and Rework books from 37signals founders. We closely followed what Zappos did, we have started focusing more on providing quality service and building great environment in the company. This has changed a lot in the way we were doing business. We have been able to build a friendly culture. We also make sure that the team does not face any issues with infrastructure. We keep doing innovative events to make sure that the team has more and more reasons to work at the company. We started making following changes to our business decisions   * Limited Team Size   * Not throwing more time at a problem (Avoiding late night stays and working on weekends)    * 5 days and 8 hours of effective output We face mainly following two issues.   * We find that the output we get today was less as compared to past. This is not just an observation, some of our old employees talk to us in one to one and they also raise the same question.    * We recently discovered that in the friendly culture we have most of the time started showing the better side of the work that way it is becoming more difficult nowadays to reprimand someone when they make mistake. Also due to the same fact, everyone in the company has a feeling that they are producing the greatest output.  So the answer I am looking for :   * How can we improve culture so that everyone in the team keeps improving output regularly and their 8 hours keep becoming more and more valuable?


title: Choice of technology to develop multi-platform application

text: What I have is business WinForms application written in C#.   What I would like to do is to redesign it to meet multi-platform approach. I was thinking about architecture involving application server (executing all the logic and performing database operations) and thin client side running on Windows and Mac OS as well as Android, iPhone or just in web browser. Windows version should also have to be able to use methods from some DLLs. Solution that comes to my mind is desktop client developed to target Silverlight (for Windows and Mac OS users). Web part, based on ASP.NET, would be adjusted for mobile devices. All would use WebServices provided by WCF server running on Mono. What do you think about this approach? Why is it good and why if it's not? I know that all of those platforms are in range of Adobe AIR but choosing it will result in abandonment of all existing code and development team's knowledge about .NET. Thank you for any hint.


title: If the user declines a "continue?" prompt, what exit code should be returned?

text: In terminal based scripts (Shell, Bash, Python, etc), if you prompt the user _"Do you wish to continue?"_ and the user chooses _"No"_ , what exit code should the script ideally return? On one hand, the script executed as the user expected it to (the user wanted to quit, so it quit), so it should give an exit code of `0`. On the other hand, the script was unable to complete its main task, which should be a non- zero exit code.


title: Multiple applications in a single Visual Studio solution

text: I am doing work for a company that is wanting to put all their .Net applications (web applications, Windows applications and console applications) together in a single Visual Studio solution. I am looking for experience from developers who either structure their own applications this way or who work in a company that does this. Is this a good idea?   * What are the pro's/con's to putting all your applications in a single solution rather than having separate solutions for each application?    * How fast is Visual Studio with a solution of 20+ projects?    * And how stable is the solution file with source-controlled concurrent development?


title: Discovering functionality from parallel class hierarchy

text: I have an abstract syntax tree which I want to compile down to different representations. I am now struggling to arrange the classes in a way that new representations can be added easily. The easiest way to achieve this is to add a method for each representation, e.g. `compile_to_foo`, `compile_to_bar`. Additional representations can be added by monkey patching. The problem with this is that the compilation implementations are spread all over the place, and that it violates the single responsibility principle. The advantage is that compilation can be inherited. Now, I could also define a compilation function containing a giant switch which dispatches on argument type. But this looses advantages of polymorphism, and makes inheriting behavior of the compilation more difficult. This is not a viable option. An interesting solution would use an abstract factory: ![Abstract Factory](http://i.stack.imgur.com/Lhciy.png) This design looks fairly promising, but has some disadvantages:   * The AST Node hierarchy cannot be extended without also extending the `AbstractCompiler`, and in turn all concrete compilers and their parallel hierarchies of concrete nodes.   * The subtyping information of the AST nodes is spead across the whole system. it has to be specified between the `AbstractNode`s in order to share behaviour (I will be using roles), between the `ConcreteNode`s in order to share `compile` implementations, and in at least in the `AbstractCompiler` to provide default implementations (e.g. `method NodeA() { return Node() }`). This could be partially solved via metaprogramming.   * When an AST is built, this can only compile down to _one_ representation. If I want to have multiple outputs, I need to rebuild the AST with a different `ConcreteCompiler`. Ideally, I would just pass a concrete compiler instance as a parameter to the `compile` method: ![Ideal class diagram](http://i.stack.imgur.com/pRbBz.png) … but I have no idea how the `compile` method could obtain the actual implementation from a parallel class hierarchy (without again using a giant switch on the node type). I also investigated the Bridge pattern, but the solution does not seem applicable to my problem without creating a thousand little bridges. I carefully read through this previous question: “Designing a robust architecture for multiple export types?”. The key difference is that the input data (there: equivalent, standalone data represenations) are now hierarchical AST nodes, so that inheritance between the compilation implementations is crucial. The system will be implemented in Perl, so I'm not restricted to classic OOP, but can also use Metaprogramming, Roles (aka. traits), and Functional Programming. What am I missing? Is there an architecture I could use to elegantly structure this system? How can I make the corresponding class from the parallel class hierarchy discoverable to the node classes, without sacrificing polymorphism?


title: How can I separate the user interface from the business logic while still maintaining efficiency?

text: Let's say that I want to show a form that represents 10 different objects on a combobox. For example, I want the user to pick one hamburguer from 10 different ones that contain tomatoes. Since I want to separate UI and logic, I'd have to pass the form a string representation of the hamburguers in order to display them on the combobox. Otherwise, the UI would have to dig into the objects fields. Then the user would pick a hamburguer from the combobox, and submit it back to the controller. Now the controller would have to find again said hamburguer based on the string representation used by the form (maybe an ID?). Isn't that incredibly inefficient? You already had the objects you wanted to pick one from. If you submited to the form the whole objects, and then returned a specific object, you wouldn't have to refind it later on since the form already returned a reference to that object. Moreover, if I'm wrong and you actually should send the whole object to the form, how can I isolate UI from logic?


title: Is this bad design? How can it be improved?

text: I wrote the following a while back, but I've come to review it recently, and now don't think it's good design. The design is for a kind of modular database layer using Entity Framework 4. There is a single database object which loads (lazily) entity framework contexts from external libraries in a specified location, and instances of the loaded contexts are stored in a hash table against their name (EG "ContentMgmtContext"). All contact with the database in this system is through stored procedures. To make a call to the database, the query method signature looks like this:               List<TReturn> Query<TReturn>(string Context,                                   string Procedure,                                   TransactionScope Scope,                                   List<ObjectParameter> QueryParameters)      This modularity is something I like. However, there is one significant drawback to this approach: `when using the database layer, the code using it has to have a reference to the library in which the context is stored, in order to access the types returned by the stored procedures through Entity Framework.` In the model, the objects from the database layer are translated in to new objects that the view and controller use. I think this is bad design, but how can I improve it? I've considered adding an empty interface like `IStoredProecedureObject` to give every data type returned by a stored procedure a common base type, however this appears to be foiled by Entity Framework. Every time the `.edmx` file is recompiled, the code is generated anew, and any additions removed. Is there any way to stop this happening? How can I improve this design? What (else) is wrong with it? Or am I on the right track?


title: Do hardcopy certificates matter?

text: I'm asking this question because Oracle has decided not to give hardcopy certificates for all Sun certifications Is this good or bad? and does any employer ask for the certificate itself?


title: I use an IDE (Eclipse) to develop software.  Why should I switch to vim or emacs?

text: My day job is java/web developer. I have been using eclipse for ~5years. I think its excellent and I also use Webstorm for javascript and html/jsp. I do on occasion need to ssh into server and mess around with config files; for this I use vi and it pains me. I have to get up a webpage listing the syntax/commands : _press escape, then asterix, turn around three times and the text will be entered two lines above your cursor_. Its so **unintuitive** to me, and I imagine anyone who grew up in the late eighties nineties. Here are the main reasons I think eclipse is brilliant(and I assume other IDE's), and do not switch to emacs and/or vim.   * Error highlighting with no need to recompile project.   * Code assist.   * Refactoring.   * Opening call hiearchy/Opening declaration.   * Fully integrated with source control.   * Debugger is included.   * availablity of 3rd party plugins - eg findbugs/checkstyle. One of the arguments I hear is that with emacs/vim you can create your own plugins - well OK, but you can do that in eclipse too. But you don't need to as everything is already there! Its like saying buy this half built car, you can build the rest yourself. Why are people using emacs/vim ? Do people who use it actually work on complex object-oriented projects in large organisations ? **What are the reasons to switch to vim/emacs. How would my productivity increase if I did switch?**