title: Why does this method return 2 values if I only ask for one and there is no sort of conditional statement anywhere?

text: I'm writing this very simple program from this one PDF called Think AP Java, and I can't seem to wrap my head around this: When I write               public static double method_1(double x)     {         double result =( x*(Math.exp(-x)  )    ) + (Math.sqrt(1-Math.exp(-x) )    );              System.out.println(result);              return result;       }      I get the output of: 1.1629395387920924 But when I write:               public static double multAdd(double a, double b, double c)     {              double result = (a*b) +c;              System.out.println(result);         return result;     }      and               public static double method_2(double x)     {              double result_1 =  (multAdd(1.0,  (Math.exp(-x)), 0.0)) ;         double result_2 = (Math.sqrt(1.0-Math.exp(-x)));              double final_result =  result_1 + result_2;         System.out.println(final_result);              return final_result;     }      The output for method_2 is: 0.36787944117144233 AND 1.1629395387920924, printed directly over one another. What can explain the cause of this? Any help will be greatly appreciated, as I'm only just a beginner.


title: Redirection methods for webpages

text: (This is question involving user experience, but I am primarily interested in the best practice technical solution to this common problem.) * * * There are several places in my website where users are redirected: login screens, pay walls, etc. Sometimes these can be stacked. For example, login, then pay, then land on a particular page. (But I can't just hardcode them...sometimes they would login, pay, and the go to another page.) And the flow for users is dynamic, e.g. perhaps during the login flow the user may start an OAuth flow. * * * I can keep a "stack" of redirects. I could chain the redirects in the URL:               http://my.website.com/login?return_url=%2Fpay%3Freturn_url%3D%252FfinalUrl      or I could keep track of them in a cookie (e.g. serialized JSON array). * * * Is one of these two ways that is better of keeping track of redirects, or is one of these ways commonly used?


title: Why are there so many CSS properties which are essentially the same?

text: This answer really made me wonder. I've written CSS before and (usually) I don't really bother to support browsers other than recent firefox and chrome, but in researching I've noticed that, for the exact same CSS property, there are usually at least three different forms which behave identically, and can have the same values, but which all simply have different prefixes for the specific library that implements them. Here, for example:               -webkit-touch-callout: none;     -webkit-user-select: none;     -khtml-user-select: none;     -moz-user-select: none;     -ms-user-select: none;     user-select: none;      With the sole exception of the first one, these only differ by prefix. Why don't maintainers simply change the lexer rule which matches the string "-moz- user-select" to also match "user-select"? Sure, there's the possibility that the author of the original CSS wanted different behavior for Firefox v. other browsers, so "user-select" won't be the same as "-moz-user-select", but the risk of that weird corner case is far outweighed by the advantage, and there are other, arguably better ways to accomplish the browser-specific goal. If this is already occurring, why do people still use all of these? If they stopped:   * there would be fewer bits clogging the metaphorical pipes of the internet (network latency would go way down, plus individual pages would load faster), and   * people using ancient browsers would be given the impetus they need to update (which they should do for security reasons, anyway) ## TL;DR What would the disadvantage be of everyone using the same naming convention? Why haven't things normalized by now?


How much better is Apache Solr than its non-Java competition? Is it so much better than other solutions, e.g. this one (Sphinx with PHP API) or Zend_Search_Lucene that it would be worth suggesting that a client move to a different hosting provider than the one they are working with now? The current host does not support Java. If there are other decent solutions for indexed database search which are more palatable to typical web hosts, I'd like to hear about them. It is A Big Deal for them to change hosting providers, so I would like to know if the move would be justified.


title: JavaScript Compression and Caching of Assets

text: I'm working on an idea that i can't seem to find a good answer though hours and hours of searching, I'm planning a small Canvas/WebGL Application this application will be using WebSockets to talk to a game server for syncing data to and from so think of it as a MMO type service so im planning to have a queuing system to load assets E.G I make a request to get model1 and it's texture so that will quee               Mthd | Data                   | q | p | s     GET  | /asset/model_1/model   | 0 | 0 | 0     GET  | /asset/model_1/texture | 0 | 0 | 0     GET  | /asset/model_1/model   | 1 | 1 | 0     GET  | /asset/model_1/texture | 1 | 1 | 0     ...     GET  | /asset/model_1/model   | 5 | 5 | 0     GET  | /asset/model_1/texture | 5 | 5 | 0      **Key**               q = quality modifier      p = priority lower is better     s = status `0 not started, 1 downloading, 2 complete`      so my client is processing that download que however while this is going on another player has come into my view so i need that players model and texture so i add them to the que and end up like so               Mthd | Data                   | q | p | s     GET  | /asset/model_1/model   | 0 | 0 | 2     GET  | /asset/model_1/texture | 0 | 0 | 2     GET  | /asset/model_2/model   | 0 | 0 | 0     GET  | /asset/model_2/texture | 0 | 0 | 0     GET  | /asset/model_1/model   | 1 | 1 | 1     GET  | /asset/model_1/texture | 1 | 1 | 0     GET  | /asset/model_2/model   | 1 | 1 | 0     GET  | /asset/model_2/texture | 1 | 1 | 0     ...     GET  | /asset/model_1/model   | 5 | 5 | 0     GET  | /asset/model_1/texture | 5 | 5 | 0     GET  | /asset/model_2/model   | 5 | 5 | 0     GET  | /asset/model_2/texture | 5 | 5 | 0      Now i'm wanting to cache these file into the browser cache so i'm tied between using the database and compressing using something like LWZ, or putting the assets online and using appCache and loading them. So My Questions. If i load an asset though the browser normally (http request) will the browser will keep that image in memory once it's no longer being rendered. If i use Javascript to hold the base64 string should i then remove the string from the javascript variable (delete) i know it would free up the memory holding the string but would it free it all the memory used or would the browser still keep a copy of the image generated from base64 in memory. Is it possible to write content loading through WebSockets into the appCache E.G the base64 string from the WebSocket Server. Has any one found a better string compression system for Javascript other than LWZ i'm planning on compressing using a application at the server side so the only limit on compression is javascript supporting it.


title: Android, OpenGL and extending GLSurfaceView?

text: This question is part-technical, part-meta, part-subjective and very specific: I'm an indie game dev working on android, and for the past 6 months I've struggled and finally succeeded in making my own 3D game app for android. So I thought I'd hop on SO and help out others struggling with android and openGL- ES However, the vast majority of questions relate to extending `GLSurfaceView`. I made my whole app without extending `GLSurfaceView` (and it runs fine). I can't see any reason at all to extend `GLSurfaceView` for the majority of questions I come across. Worse, the android documentation implies that you ought to, but gives no detailed explaination of why or what the pros/cons are vs not extending and doing everything through implementing your own `GLSurfaceView.Renderer` as I did Still, the sheer volume of questions where the problem is purely to do with extending `GLSurfaceView` is making me wonder whether actually there is some really good reason for doing it that way vs the way I've been doing it (and suggesting in my answers to others to do). So, is there something I'm missing? Should I stop answering questions in the meantime? Android openGL documentation


title: Delphi to Java change - career advice

text: I'm a Delphi developer with aprox 5 years of experience. But now, Delphi seems to be dead, and the job opportunities are smaller. So, I want to begin learn Java, because I like it, and the job market is bigger(and competition also...). Until now I've searched for opinions about the best Java books and I've founded several books(Thinking in Java by Bruce Eckel,"Java 6 The Complete Reference " , complete JAVA for SCJP, etc - you can provide more examples if you want). Now, what I'm asking you: when you start to learn a new programming language (in this case Java) which are the steps you're following? How do manage the learning curve? (how you allocate time for different chapters and technologies) Thank you in advance


title: How to interview a natural scientist for a dev position?

text: # Original Question I already did some interviews for my company, mostly computer scientists for dev positions but also some testers and project managers. Now I have to fill a vacancy in our research group within the R&D department (side note: “research” means that we try to solve problems in our professional domain/market niche using software in research projects together with universities, other companies, research centres and end user organisations. It’s not computer science research; we’re not going to solve the P=NP problem). Now we invited a guy holding an MSc in chemistry (with a lot of physics in his CV, too), who never had any computer science lesson. I already talked with him about half an hour at a local university’s career days and there’s no doubt the guy is smart. Also his marks are excellent and he graduated with distinction. For his BSc he needed to teach himself programming in Mathematica and told me believably that he liked programming a lot. Also he solved some physical chemistry problem that I probably don’t understand using his own software, implemented in Mathematica, for his MSc thesis. It includes a GUI and a notable size of 8,000 LoC. He seems to be very attracted by what we’re doing in our research group and to be honest it’s quite difficult for an SME like us to get good people. I also am very interested in hiring him since he could assist me in writing project proposals, reports, doing presentations and so on. He would probably fit to our team, too. The only question left is: **How can I check if he will get the programming skills he needs** to do software implementation in our projects since this will be a significant part of the job? Of course I will ask him what it is, that is fascinating him about programming. I’ll also ask how he proceeded to write his natural science software and how he structured it. I’ll ask about how he managed to obtain the skills and information about software development he needed. But is there something more I could ask? Something more concrete perhaps? Should I ask him to explain his Mathematica solution? To be clear: I’m not looking for knowledge in a particular language or technology stack. We’re a .NET shop in product development but I want to have a free choice for our research projects. So I’m interested in the meta- competence being able to learn whatever is actually needed. I hope this question is answerable and not open-ended since I really like to know if there is a default way to check for the ability to _get_ further programming skills on the job. If something is not clear to you please give me some comments and let me improve my question. # Update to reflect the answers given until 2011-12-01 ## What answer I accepted and why Thank you all for your answers, most of them are quite helpful, so I upvoted a lot! Although Tom Squires' answer got the most votes, I'm going to accept the answer given by Prince Goulash. Of course Tom is objectively correct, but Prince's answer is just more helpful for me and I double-checked the FAQ that _this_ is the criterion to accept an answer. ## What I am going to ask him during the interview   * I'll let him explain some simple assignments like the example in The Camel Has Two Humps mentioned by Chris Burt-Brown   * I'll ask him to explain some more advanced control flows maybe in a graphical notation.   * I'll check his understanding of recursion using a math example.   * I'll let him explain an algorithm of his choice in natural language.   * I'll let him explain his Mathematica solution, in particular I'll ask for his procedure model, usage of tools, structuring of code and software in general as well as different abstraction layers.   * To check his motivation I will ask for his software development fascination.   * I'll ask him if he is aware of what he will need to learn about enterprise software development. Especially I want to turn the discussion into the direction of working in teams, pair programming, TDD since I expect him not to know a lot about this after working on his MSc alone. Sounds like it's going to be a long interview ;) # Update after the interview 2011-12-09 Again thank you all for your good answers. He passed the interview with flying colours. I never was more satisfied with an applicant. His Mathematica solution seems to be structured quite well. He was able to explain where he used higher-order functions, although he didn't know that these are referred like this. He answered my math-based recursion questions as well as simple assignments and control flow things from The Camel Has Two Humps. When he was explaining some algorithms I learned a lot about non-linear fitting ;) Also he honestly said that of course he can't guarantee that he will be able to learn things about professional software development that he doesn't know so far. But he believably statet that he was always good in learning new concepts -- even by himself -- and is really interested in software development. He also asked for the technology stack of the project, he would be applied to first, to have a look at it at home. He was curious about pair programming and team work, too. Now I hope that the employment contract will be concluded.


title: Backward compatibility with event-sourcing

text: How do you stay backward compatible with event-sourcing? Let say you release a version that has one kind of event, let call it X. You know how to handle that event in all the systems that extracts the events from the event source. In a later release you make a change to event X or delete it, how do you stay backward compatible with that? To have a fully functional system you need to be able to handle the old event as the same time as you need to handle the updated version. Or if you delete that event type, then you will be stuck with code that is only there to handle legacy events which in my head can be a little bit messy in the long run.


title: Where can I get a definition of how the code is laid out in VB.NET 2010?

text: I am just starting out learning Visual Basic 2010. I have books and videos. The books all seem to be written for people who have some programming experience, even the books that say they are for beginners. The videos were great until they started talking about variables. I got the basics of them but they started into complicated variables and I don’t see the need for them right away. Where can I go to see code for fairly intricate applications written out, with an over lay of definitions of which part of the code is a method as opposed to a class and so on? Also, I am working at a company that does not use SQL. So I need to use Access 2007 for all of my tables. Is there much of a difference to the coding?


title: How do you end up with event-sourcing if you use a xDD approach?

text: When working in a TDD or BDD manner your unit tests are supposed to drive your design. But how do you end up with event-sourcing using a xDD techniques? As I see it event sourcing is something you need to adopt early on to take full advantage of it. Lets say that you start without event-sourcing and do a release. Later on when you are releasing version 2.0 you realize that it would be great to use event- sourcing, but at that point you alread have missed all the events from version 1.0 so it makes it much harder to implement. Or do you take some kind of backup of your db from before event-sourcing and use that as base line and then add event-sourcing on top of that?


title: Finish feature reverted commits from develop

text: I am using git as a version control system, and using git-flow as the branching model. I started a feature branch some weeks ago in order to maintain the system in a clean state while developping that feature. The main development continued on the `develop` branch, and changes from develop were merged periodically into the feature, to keep it up to date as much as possible. However came the time where the feature was finished, and I used git-flow's `finish feature` to merge the feature back into develop. The merge was successfully done, but then I found out that some of the commits I made in develop were reverted by the merge commit! Nowhere in `develop` or in the feature branch were these changes reverted, I can't see any commit that overwrote them. I just can't find anything. The only theory I have for the moment is that git is failing on me, but that would be extremely unlikely. Maybe I did some kind of wrong manipulation that made this situation come true? I can trace back in the history when the commit was made. I can see that the changes from that commit were reverted by the merge commit. Nowhere in the branch I see a commit that reverts those changes. Yet they were reverted. How is this even possible?


title: Has anyone used OpenCalais succesfully in a project?

text: In a previous question here on programmers, the OpenCalais system has been referenced as a solution. Has anyone used OpenCalais? Can you identify pros and cons of the system ?


Pretty simple question. Should package structure closely resemble class hierarchy? If so, how closely? Why or why not? For instance, let's say you've got class A and class B, plus class AFactory and class BFactory. You put class A and class B in the package com.something.elements, and you put AFactory and BFactory in com.something.elements.factories. AFactory and BFactory would be further down the hierarchy package-wise, but they'd be further up class-wise. Is this sort of thing a good idea or a bad idea?


title: Why is the complexity of fetching a value from an array be O(1)?

text: How come the complexity of fetching a value from an array by it's index is O(1)? I thought the algorithm has to go through all the indexes, find the correct index, and then know what value to return. So that means the complexity is O(n/2) on average. Why is it actually O(1)?


title: What Functional features are worth a little OOP confusion for the benefits they bring?

text: After learning functional programming in Haskell and F#, the OOP paradigm seems ass-backwards with classes, interfaces, objects. Which aspects of FP can I bring to work that my co-workers can understand? Are any FP styles worth talking to my boss about retraining my team so that we can use them? Possible aspects of FP:   * Immutability   * Partial Application and Currying   * First Class Functions (function pointers / Functional Objects / Strategy Pattern)   * Lazy Evaluation (and Monads)   * Pure Functions (no side effects)   * Expressions (vs. Statements - each line of code produces a value instead of, or in addition to causing side effects)   * Recursion   * Pattern Matching Is it a free-for-all where we can do whatever the programming language supports to the limit that language supports it? Or is there a better guideline?


title: Should I Leave off the Currency Symbol?

text: I'm upgrading a desktop application that currently displays the currency symbol anytime money values are displayed or printed. A friend of my from the UK told me "Whenever British people see software with the American Dollar Sign ($) it automatically turns them off." Given the fact that we (developers) only have one shot at making a favorable first impression, wouldn't it make more sense to simply format all money values without a currency symbol?


title: Best Practices for Redesigning a Database

text: I'm aware of some general best practices when designing a database for an application, but what about redesigning? I'm on a team tasked with re-designing an internal business application, though despite me saying "internal," I'm unfortunately many, many layers of people away from contact with the actual users of the system. The current program is in Oracle Forms, scattered across a bunch of non- normalized tables, sometimes with multiple near-duplicate tables holding slight variants on each others' data. The constraints are often in the form of poorly-enforced stored procedures. Even the types don't seem to be stored right. I've encountered all sorts of bad data that Oracle seems to ignore but gave fits (and rightly so) to SQL Server's Import/Export Wizard. (For example, two digit integers do not constitute a complete datetime!) The original program probably goes back twenty years, and all of the original developers have retired so long ago that even the older people here have no idea who they were. As a result, there also aren't really any clean requirements to go off of--we're just supposed to duplicate the existing application's functionality and keep its existing data. The end result of the rewrite is going to be a web-based version running on ASP.NET with MS SQL Server for the back end. My other two developer teammates are much, much older than me, both with business/MIS backgrounds whereas mine is CS. The senior member's experience has been almost exclusively Oracle forms and the other member has mostly done business applications work in Visual Basic. Although my database background has been limited to designing new databases for projects in MySQL or SQLite, mostly for my undergrad classes, I seem to be the only one with experience actually designing databases at all. I've already written a little program in C# that reads in all the existing data to a neutral format, ready to be re-cast and placed into a new database. I plan to write the load-in code after the destination database is designed, so that data can be properly split across the new normalized tables, added in the correct order to follow new constraints, etc. The same program could then be run again later to copy the production data to the real newly deployed finished redesign. This leaves the actual redesign of the database as the main thing to figure out. **So the heart of my question:** what are some best practices for doing a redesign from the database level up of an existing application?


title: Designing a web app that will be used from distant geographic locations

text: I have designed/built a number of small web apps. Most have been used by clients who operate in a specific geographic area, mostly within the same state/province. For these I would follow best practices but normally didn't worry too much about issues caused by distance from the server. I have a potential client whose locations are spread out in several countries around the world. What specific considerations should I make in designing an app that will be used in locations that are not near each other? Some of the more obvious ones I've thought about:   * i18n/localized strings   * Static content delivery via CDN   * Reducing instances where the client needs to communicate with the server   * Communicating with the server in the background while the client is doing other things I feel that list should be longer, but I don't have the breadth of experience to be sure. I am mostly concerned about the marginal issues presented by serving a geographically-distributed userbase that would not otherwise be high-ranking concerns for clients in closer proximity.


title: How do I share my jQuery plugin with the world?

text: I made a plugin for jQuery, which I think is quite useful. It combines an animated colours plugin with an easings plugin, and adds a completely new feature of being able to refer to colours numerically (more useful in hex notation, so 0xff00cc for example) and therefore manipulate them mathematically more easily. I created a repository on github, and it sits there, nobody looks at it. Mostly, I would like people to look at it, use it, and improve it, so I can use the improvements and so on. I think this idea of numerically manipulating colors could be interesting. It makes it easy to change the hue without changing the saturation for example. Combined with animated colors, I think something interesting could be done, but I don't know what exactly. How do I let people know it (or any other project) is there..? I was going to post it on http://plugins.jquery.com which is currently down. Are there any other outlets for this kind of code?


title: MVC: View-Controller Interaction

text: I have a Java application that I am implementing following the MVC pattern. I want to have a window (view) that contains a form which allows the user to add several text fields. There will also be a button that will allow the user to add more text-fields to the form. I have several questions about this. Will the code for adding new text-fields be considered part of the controller or the view?   1. If controller, then this controller will not do anything to the model, it will just modify my view, so is this a violation of MVC?   2. If view, then will it be a violation of MVC as the changes in view were not directed from the model?


title: Is it possible to compile Java into machine code? (Not bytecode)

text: Can you have Java compiled straight into machine code? I want to do this so I have control over what platforms it's used on, and don't know C,C++ etc.


title: Determining the right amount of documentation

text: Where I currently work the general approach is - **avoid documentation as much as possible** **Only document if a different team will need it** just for clarification, I don't mean code-documentation - this we do, I mean all the documentation surrounding the design process - if it's UML or DB Schemas, class diagrams and word documents with specifications and the likes. I will list my Boss' reason to not document:   1. it's time consuming - focus on implementing   2. if design change - then the documentation should change, double trouble   3. in the end you just get hundreds of pages nobody wants to read, and nobody really edits so by time it will get out of date   4. Its a pain - nobody really wants to do it Now I realize we do work faster, but I also remember the time getting here and diving straight to some old code, not understanding anything. Actually, I still don't get most of this old code, and sometimes when I get in I see many patches from different developers trying to make small tweaks. I really think lack of documenting promotes these kind of patches and lack of system understanding in a broad sense. my question is: **How can we balance documentation so that we will promote continuous knowledge among the team and still be fast and efficient?**


title: Modern Java implementation of Blackboard Pattern?

text: Is there room for a practical modern application in Java of the Blackboard Pattern detailed in **"The Pragmatic Programmer"**? Is there any particular library that attempts to assist in the implementation of this concept? What is the general consensus on this pattern in the present software community (especially Java)? Though the idea is intriguing, I have a feeling that this portion of the book may be outdated. In case you are not familiar with this concept: http://flylib.com/books/en/1.315.1.55/1/


title: What's the most polite way to handle library dependencies when hosting code online?

text: Let's say you've written nifty JavaScript library that requires jQuery, and you want to host this project on github. Do you include the jQuery source with your project? Do you direct users to a download link for jQuery?


title: How should I manage short-term user preferences, to simplify data cleanup?

text: When rolling out a new feature, sometimes it makes sense to notify the end user what it is, and give them an opportunity to provide feedback whether the software should get them to 'try something new' or 'put it off'. ![Gmail new feature, "Try it now", "Not now"](http://i.stack.imgur.com/6jWVc.png) In a cloud software, how should user preference data such as this be managed? A small piece of information would have to be stored to save the preference, but eventually, it becomes irrelevant. (The old way is phased out.) The simple thing to do is just leave that data there. After all, it doesn't take much space. Eventually, as more features and changes come and go, and more messages are added, dismissed, and removed; there would be many items in the data storage that is no longer used, and there would be cost in the form of programmer hours in preserving or separating that data. Are there coding and software maintenance patterns that would make sense to get rid of old data structures along with removal of old features? Is there a common solution to this data cleanup?


title: Distinction between API and frontend-backend

text: I'm trying to write a "standard" business web site. By "standard", I mean this site runs the usual HTML5, CSS and Javascript for the front-end, a back-end (to process stuff), and runs MySQL for the database. It's a basic CRUD site: the front-end just makes pretty whatever the database has in store; the backend writes to the database whatever the user enters and does some processing. Just like most sites out there. In creating my Github repositories to begin coding, I've realized I don't understand the distinction between the _front-end back-end,_ and the _API_. Another way of phrasing my question is: **where does the API come into this picture?** I'm going to list some more details and then questions I have - hopefully this gives you guys a better idea of what my actual question is, because I'm so confused that I don't know the specific question to ask. Some more details:   * I'd like to try the Model-View-Controller pattern. I don't know if this changes the question/answer.   * The API will be RESTful   * I'd like my back-end to use my own API instead of allowing the back-end to cheat and call special queries. I think this style is more consistent. My questions:   * Does the front-end call the back-end which calls the API? Or does the front-end just call the API instead of calling the back-end?   * Does the back-end just execute an API and the API returns control to the back-end (where the back-end acts as the ultimate controller, delegating tasks)? Long and detailed answers explaining the role of the API alongside the front- end back-end are encouraged. If the answer depends on the model of programming (models other than the Model-View-Controller pattern), please describe these other ways of thinking of the API. Thanks. I'm very confused.


title: XML/HTML: Do we need the element name in closing tags?

text: Compared to other serialization languages, one of the main criticisms directed at XML is its verbosity; JSON's more terse and readable for most cases, but not all. But it seems to me that we could cut a lot of the excess from XML simply by stripping away the names from the closing tags. With proper indentation readability shouldn't be an issue (it should be an improvement, if you ask me), and since they're not structurally required any decent XML editor/viewer could easily be made to strip/hide or add them. **As such, the two formats should be completely equivalent and interchangeable.** Compare the following (source taken from http://www.w3schools.com/xml/simple.xml):               <breakfast_menu>         <food>             <name>Belgian Waffles</name>             <price>$5.95</price>             <description>                         Two of our famous Belgian Waffles with plenty of real maple syrup             </description>             <calories>650</calories>         </food>         <food>             <name>Strawberry Belgian Waffles</name>             <price>$7.95</price>             <description>                         Light Belgian waffles covered with strawberries and whipped cream             </description>             <calories>900</calories>         </food>         <food>             <name>Berry-Berry Belgian Waffles</name>             <price>$8.95</price>             <description>                         Light Belgian waffles covered with an assortment of fresh berries and whipped cream             </description>             <calories>900</calories>         </food>         <food>             <name>French Toast</name>             <price>$4.50</price>             <description>                         Thick slices made from our homemade sourdough bread             </description>             <calories>600</calories>         </food>         <food>             <name>Homestyle Breakfast</name>             <price>$6.95</price>             <description>                         Two eggs, bacon or sausage, toast, and our ever-popular hash browns             </description>             <calories>950</calories>         </food>     </breakfast_menu>      and               <breakfast_menu>         <food>             <name>Belgian Waffles</>             <price>$5.95</>             <description>                             Two of our famous Belgian Waffles with plenty of real maple syrup             </>             <calories>650</>         </>         <food>             <name>Strawberry Belgian Waffles</>             <price>$7.95</>             <description>                             Light Belgian waffles covered with strawberries and whipped cream             </>             <calories>900</>         </>         <food>             <name>Berry-Berry Belgian Waffles</>             <price>$8.95</>             <description>                             Light Belgian waffles covered with an assortment of fresh berries and whipped cream             </>             <calories>900</>         </>         <food>             <name>French Toast</>             <price>$4.50</>             <description>                             Thick slices made from our homemade sourdough bread             </>             <calories>600</>         </>         <food>             <name>Homestyle Breakfast</>             <price>$6.95</>             <description>                             Two eggs, bacon or sausage, toast, and our ever-popular hash browns             </>             <calories>950</>         </>     </>


title: How can I port msvc++ code with non-dependent names in templates to Linux?

text: I can deal with porting platform dependent functions. I have a problem that the compilers I tried on Linux (clang and g++) do not accept the following code, while the msvc++ compiler does:               template <class T>     class Base {     protected:         T Value;     };          template <class T>     class Derived : public Base<T> {     public:         void setValue(const T& inValue){             Value = inValue;         }     };          int main(int argc, char const *argv[])     {         Derived<int> tmp;         tmp.setValue(0);         return 0;     }      g++ error:               main.cpp: In member function ‘void Derived<T>::setValue(const T&)’:     main.cpp:11:3: error: ‘Value’ was not declared in this scope      I believe this due to the use of a non-dependent name (`Value`) in the second class. More information. The problem is that I have a very large code base, in which this type of code is used very often. I understand that it is wrong when looking at the standard. However it is very convenient not having to write `this->` or `Base<T>::` in front of every use of `Value`. Even writing `using Base<T>::Value;` at the start of the derived class is problematic when you use ~20 members of the base class. So my question is: are there compilers for Linux that allow this kind of code (with or without extra compiler switches)? Or are there **small** modifications that will allow this code to compile on Linux?


title: Patterns for a tree of persistent data with multiple storage options?

text: I have a real-world problem which I'll try to abstract into an illustrative example. So imagine I have data objects in a tree, where parent objects can access children, and children can access parents:               // Interfaces     interface IParent<TChild> { List<TChild> Children; }     interface IChild<TParent> { TParent Parent; }          // Classes     class Top : IParent<Middle> {}     class Middle : IParent<Bottom>, IChild<Top> {}     class Bottom : IChild<Middle> {}          // Usage     var top = new Top();     var middles = top.Children; // List<Middle>     foreach (var middle in middles) {         var bottoms = middle.Children; // List<Bottom>         foreach (var bottom in bottoms) {             var middle = bottom.Parent; // Access the parent             var top = middle.Parent; // Access the grandparent         }     }      All three data objects have properties that are persisted in two data stores (e.g. a database and a web service), and they need to reflect and synchronise with the stores. Some objects only request from the web service, some only write to it. **Data Mapper** My favourite pattern for data access is Data Mapper, because it completely separates the data objects themselves from the communication with the data store:               class TopMapper {         public Top FetchById(int id) {             var top = new Top(DataStore.TopDataById(id));             top.Children = MiddleMapper.FetchForTop(Top);             return Top;         }     }          class MiddleMapper {         public Middle FetchById(int id) {              var middle = new Middle(DataStore.MiddleDataById(id));              middle.Parent = TopMapper.FetchForMiddle(middle);              middle.Children = BottomMapper.FetchForMiddle(bottom);              return middle;         }     }      This way I can have one mapper per data store, and build the object from the mapper I want, and then save it back using the mapper I want. There is a circular reference here, but I guess that's not a problem because most languages can just store memory references to the objects, so there won't actually be infinite data. The problem with this is that every time I want to construct a new `Top`, `Middle` or `Bottom`, it needs to build the entire object tree within that object's `Parent` or `Children` property, with all the data store requests and memory usage that that entails. And in real life my tree is much bigger than the one represented here, so that's a problem. **Requests in the object** In this the objects request their `Parent`s and `Children` themselves:               class Middle {         private List<Bottom> _children = null; // cache         public List<Bottom> Children {             get {                 _children = _children ?? BottomMapper.FetchForMiddle(this);                 return _children;             }             set {                 BottomMapper.UpdateForMiddle(this, value);                 _children = value;             }         }     }      I think this is an example of the repository pattern. Is that correct? This solution seems neat - the data only gets requested from the data store when you need it, and thereafter it's stored in the object if you want to request it again, avoiding a further request. However, I have two different data sources. There's a database, but there's also a web service, and I need to be able to create an object from the web service and save it back to the database and then request it again from the database and update the web service. This also makes me uneasy because the data objects themselves are no longer ignorant of the data source. We've introduced a new dependency, not to mention a circular dependency, making it harder to test. And the objects now mask their communication with the database. **Other solutions** Are there any other solutions which could take care of the multiple stores problem but also mean that I don't need to build / request all the data every time?


title: Store data for multiple User Type

text: I am developing an app where four types of user share same module. So is it a good idea to create:   1. one table and user_type and user_id (something like that)   2. table prefixes basically 4 diff tables of same columns   3. your own suggestion (keeping in mind its a CakePHP App so joins and contain will be there)


title: Tools to produce & manage specifications/requirements (not ticket trackers)

text: I'm interested if there are any websites or software out there to aid in initial project design, and then management of the project's design over time as features are implmented, bugs are found, etc... My design will include requirements (functional & non-functional), use cases, and basic database schema design. Most sought-after feature:   * Being able to define requirements and track their changes over time (i.e. how is version 1.5 different than 1.0?) Nice-to-haves:   * Being able to collaborate with other project managers and the team when putting together the specifications What I'm _not_ looking for:   * Ticket trackers (JIRA, fogbugz, etc...)   * Software version control systems   * Wikis (unless they are built with requirements management in mind) Thanks.


title: PHP Frameworks That Don't Use a Front Controller?

text: Just like the title says, are there any PHP web application frameworks that don't use a front controller? > The Front Controller Pattern is a software design pattern listed in several > pattern catalogs. The pattern relates to the design of web applications. It > "provides a centralized entry point for handling requests." > > The front controller may be implemented as a Java object, or as a script in > a script language like PHP, ASP, CFML or JSP that is called on every request > of a web session. This script, for example an index.php, would handle all > tasks that are common to the application or the framework, such as session > handling, caching, and input filtering. Based on the specific request it > would then instantiate further objects and call methods to handle the > particular task(s) required. > > The alternative to a front controller would be individual scripts like > login.php and order.php that would each then satisfy the type of request. > Each script would have to duplicate code or objects that are common to all > tasks. But each script might also have more flexibility to implement the > particular task required.


title: Syntax-highlighting color scheme studies

text: Most programmers have their own personal preferences for syntax-highlighting color schemes, but I've been wondering, has anyone ever done an actual scientific study on what the best color scheme would be? I imagine such a study would look at things like the readability of the code, whether the programmer's eyes are drawn to the most important parts, etc. Perhaps this was already done for something like the default Visual Studio theme, but I'd like to know if there are any publicly available studies out there, and what they found.


title: Are you allowed to manage your own time and if so, do you sometimes abuse this?

text: The title is a bit vague so let me elaborate: I develop both hardware and software, and I'm in a position where I get a list of 'large' tasks/projects to do but not on a regular basis. Sometimes there's 10 new things to do in one month, other times months pass by without any real deadlines. This gets combined with 'small' tasks/projects/bugs that are extremely urgent. Basically no one but me is in a good position to decide how much time I spend on what, and when I do that: the basic philosophy is 'you do whatever you want, whenever you want, just make sure the things that are urgent or have a deadline are done in time'. Firstly I'd like to hear from others if they are working in a similar environment? The reason I'm asking is that I do not know many other programmers in person, and the ones I do talk to are more in a typical '9 to 5' job and their time is rather managed by, erm, managers. Secondly, for those that are in a such a situation, did you ever find yourself spending huge amounts of time on something that was not really necessary, hereby kind of abusing your freedom? I'll give some examples: about a year ago I spent at least a month on writing a build server application, only to abandon it last month in favour of Hudson. Which again took several days to setup. Sometimes I find myself losing huge amounts of time refactoring a core library for the xth time although it's not really needed. Once I spent weeks studying the ins and outs of digital filters, while the actual task was making a basic bandpass filter that anyone could probably do in a day or so. Then I changed my mind and went with an analog implementation after all. Please share similar stories.


title: Most flexible UI Framework for Windows endpoint?

text: I am tasked with designing and implementing a flexible UI solution for deployment across a series of "kiosk"-ed Windows endpoints. There is some debate about what is the considered to be the best technology solution for the actual UI itself. The requirements are:   * Must be hardware accelerated   * Must play WMV video (for licensing reasons)   * Must be skinnable/themeable.   * Must support off-screen rendering.


title: How to deal with bad versioned software as SCM

text: I have been asked to be the SCM (Software Configuration Manager) in my company. I've read online documentation to learn what SCM is, what SCM does, etc. Currently, the company works with a version control system (Bazaar), so the software is versioned correctly, but there are old programs that are not well versioned (some of them not versioned at all), some of them are in CVS, the old version control system used at first, but they are not updated. I'm asking for your help, based on experience more than theoretical information, to know how to deal with this, how to be a good SCM even with all these issues.


title: What programming jobs would be best for a mathematician?

text: I'm a math professor that is losing his job, and I'm trying to gain programming skills, since academic jobs are scarce these days. Are there particular types of programming jobs that I should try to work towards, in order to leverage my math Ph.D? What particular skills should I try to obtain for those jobs? **Update, 6 months later:** For those that are curious, I went the certification route, and it worked for me. I learned Java, then studied for the SCJP test, then obtained a job that is technically an internship, but is full time and pays comparably to being a math professor at a private school with tough finances. I recommend certifications for anyone without a CS degree or IT experience, it is the fastest and cheapest way to get _something_ objective on your resume.


title: What do you wish language designers paid attention to?

text: The purpose of this question is not to assemble a laundry list of programming language features that you can't live without, or wish was in your main language of choice. The purpose of this question is to bring to light corners of languge design most language designers might not think about. So, instead of thinking about language feature X, think a little more philisophically. One of my biases, and perhaps it might be controversial, is that the softer side of engineering--the whys and what fors--are many times more important than the more concrete side. For example, Ruby was designed with a stated goal of improving developer happiness. While your opinions may be mixed on whether it delivered or not, the fact that was a goal means that some of the choices in language design were influenced by that philosophy. **Please do not post:**   * Syntax flame wars. Let's face it, we have our preferences, and syntax is important as it pertains to language design. I just want to avoid epic battles of the nature of emacs vs. VI (which a great number of people these days know nothing about).   * "Any language that doesn't have feature X doesn't deserve to exist" type comments. There is at least one reason for all programming languages to exist--good or bad. **Please _do_ post:**   * Philisophical ideas that language designers seem to miss.   * Technical concepts that seem to be poorly implemented more often than not. Please do provide an example of the pain it causes and if you have any ideas of how you would prefer it to function.   * Things you wish were in the platform's common library but seldom are. One the same token, things that usually are in a common library that you wish were not.   * Conceptual features such as built in test/assertion/contract/error handling support that you wish all programming languages would implement properly--and define properly. My hope is that this will be a fun and stimulating topic. **Edit:** Clarified what I mean by Syntax Flame Wars. I'm not trying to avoid all discussion of syntax, particularly because syntax is a fundamental part of program language design.


title: OOP in C: which of these two approaches is closer to a cannonical solution?

text: Here are the two approaches to writing OOP (as in "we have objects and we can instantiate any number of them, each having it's own private data"). The language is C and the platform is embedded bare-metal. Simply, which is better. Is any of the two approaches sensible at all? Or, is there a third, canonical, way to do this in C? ## Approach I: Module.c               struct inputs{};     struct outputs{};     struct scratchpad{};     struct module{         struct inputs i;         struct outputs o;         struct scratchpad private;     }      main.c               main(){         struct module obj;         module_init(obj);         module_do_fancy_stuff(obj);     }      ## Approach II: Module.c               #define OBJ_COUNT 5     struct inputs{};     struct outputs{};     struct scratchpad{};     struct module{         struct inputs i;         struct outputs o;         struct scratchpad private;     }          static struct module obj[OBJ_COUNT];      main.c               #define COOL_MODULE 3     #BORING_MODULE 4     main(){         module_init();         module_do_fancy_stuff(COOL_MODULE);     }


title: Why doesn't VB.NET allow unnamed, one-line objects to be used?

text: Why isn't this allowed in VB.NET:               New SqlCommand("some string", someSqlConnection).ExecuteNonQuery()      Why would the language have been designed to require that this be used instead:               Dim com As New SqlCommand("some string", someSqlConnection)     com.ExecuteNonQuery()      It doesn't seem to me like it would have taken much time at all to implement. Am I wrong? Is there some theoretical advantage this would give a language? **EDIT** Please read: I thought this language feature was not supported in VB.NET. I had forgotten that I had used it in the past, and so when lines like the first one above would break, I did not expect there would be a work-around like in the accepted answer. ...Although, looking back at it again, there seems to be trouble doing this when it's off by itself on a line of code, and not used as a function argument or something. I bet that's probably part of why I originally posted this. I wonder why this in particular wouldn't be allowed, but I'm asking a question on SO to see if there's a similar work-around for that... This is _not_ a question about how to use unnamed objects on a single line; this was a question about why a language designer would intentionally choose to forgo such a feature in a language like this. Was there a lingual advantage to not allowing this feature, or would it just take unexpectedly long to implement? There was a misunderstanding, but that does not change the conceptual nature of the original question, and it does not change the fact that it was searching for a logical reason to omit such a feature. The bottom line is this: This is a site about "conceptual questions about software development". This almost immediately implies trace amounts of opinion, subjectiveness, etc - as specifically noted in the very same flag this question was put under. The rule is to not push it too far, and my question did not. Please remove the flag. Thank you.


title: Optimal organizational structure for IT?

text: There are many approaches to how to structure a company's IT shop to better fit the needs of the core business. In my scenario, developing web and mobile access is central to the the needs of the organization of which I am thinking. It is structured such that development is done by one group of worker bees, another for maintenance, another still for testing, etc. etc. It seems this structure tends to lend itself to adversarial relationships because each area has its own measure of what success is: Development --> Time To Market   Maintenance --> Stability of the environment   Testing --> Making sure they don't get spanked if something goes wrong. There are many other organizational groups (for lack of a better term) for analysts, project managers, designers, etc. In a perfect world, these groups would create checks and balances against one another, but in the end priority invariably gets placed on TTM, sometimes to the detriment of the other players. This creates a lot of tension whenever releases come because an attitude of 'throwing code over the wall' prevails as the MO. What other organizational structures have you observed in industry that better lend themselves to a greater sense of cohesiveness amongst the players?


title: Most effective way to increase programmer salary besides just doing your job?

text: If you have the time and resources, what would be the most effective way to increase your salary as a full-time _programmer_ , outside of just doing your job? By "salary" here, I mean salary (adjusted for location cost-of-living) coming from a _single_ programming job.


title: Help finding good documentation for C/C++?

text: I have programmed in Java, PHP, C# and a little bit in C in an OS course I have taken recently in college. For all of these languages, I've found decent documentation except C. I couldn't find a good source for it. Any thoughts ?


title: How does a non-technical manager add value to team of self-motivated software developers?

text: I am seeing a lot of programmers turning away from management and administration roles. They want to build stuff. And as a result, a lot of these positions are filled by non-technical people. I fail to see how they add value. Is scheduling meetings, booking offsites and other administrative work enough to justify their role? **Edit:** Thanks for the wonderful answers. I do know that administration details are important, but that is why we have a dedicated HR team, recruiting teams and other teams dedicated to support developers. This is different from a non-technical manager being in a important position.


title: Help in deciding on approach/language for Web App

text: I have a personal project - a web application I wanted to develop - but I'm confused on which route to take. I know a little programming, and have dabbled in Pascal, C, HTML, CSS and Actionscript (for Flash). And I don't mind learning a new language (PHP, Python, mySQL, etc). I am not under any time constraint. **About the App:** The best I can describe it is as a kind of expert system (but not AI) that needs to find the best workflow for a process, given a set of initial and final parameters. E.g. a 'capsule' of data must pass through many 'tools' or 'environments' to reach a desired output - something like a very complicated car wash. Let's say there are many tools that can be used at various stages in the process. I have estimated there are at least 500 tools as of now, and it is bound to grow in the future as newer tools are introduced. Existing tools will also have version updates. Each tool, on average, has at least 100 properties that define the tool. Some of them have as high as 1000 unique properties. Some of these tools are linked to each other - e.g if one tool is selected, there are only n tools that can correspond to it for the next step in the process. I also have the problem of 'matching' the tools for analysis. E.g. Tool A might have only three fixed rpms - 100, 200 and 500, but Tool B might have rpms from 20 to 2000. I'm not sure how I can construct a database without spelling out each number, as in the example above. The total number of tools needed for the process can be defined at the beginning, however, it will change as the application becomes more complex in the future. I plan to address every contingency in the process. The idea is - if the user inputs the initial parameters and the desired outcome (another set of parameters), the app must find the 'best' path - sort of like a decision tree. The best path can be the fastest, cheapest, etc. I would like the user to choose what is best for him/her. Unfortunately, parameters might change, relationships might change (but not regularly) - the 'rules' I will be using might be revised for better accuracy in prediction. I also need to track each user's path and solutions' for future reference (but no personal details except username and email address for logging in). Maybe when the app is up and running, I'd like to make it more democratic, with users contributing to refining the logic/rules involved. If possible, I would also like the app to output a graphical flowchart at the end showing the workflow with all tools grouped in an easy to understand layout. **My questions:**   1. Will the app be better served with a relational DB like mySQL or an Object database?   2. Can I make this work with PHP+AJAX+CSS+mySQL? Is there a better alternative? I would prefer free programs - I intend this app to be free, but I might want to make it commercial later on. I need this program to run on any device that can connect to the internet, including tablets and mobiles, etc.   3. Do I need a framework? CodeIgniter/Symfony vs Django/ZOPE? Which is the best way for me to begin, considering I might have to scale it up in the future - with more data, more users simultaneously logged in, and more algorithms? I don't want to change solutions later on - if I have to invest time and effort I'd rather do it the right way from the beginning. I would appreciate any help in getting started. Thank you in advance.


title: What does it mean to "promote" a file?

text: I hear this term around the office, and know it's relevant to software development lifecycle. What does "promote" mean? Context: e.g. to promote a file.


title: Where to show copyright messages?

text: In my Android application, I am using a couple of open source libraries. The only requirement these libraries have is that I must show their respective copyright notices in my application. I am trying to understand where would one typically display third-party copyrights. I could probably create a menu item "About" and display an about dialog box that has all the copyrights listed. However, I would appreciate your feedback on what the standard practice is.


title: Why most people change from being a contractor to full time at my companies, but not the other way around?

text: I have seen most people changed from being a contractor to being a full time employee, but not the other way around. And that happened in startups that had maybe 20% chance of IPO or being acquired, and another that had maybe a 50% chance. As far as I know, the rate (even for a 3 year experience graphics designer, or a programmer), can be $75 to $80 an hour. While a programmer with 15 years of experience may get $120,000 per year. So, the programmer with 15 years of programming experience earns $10,000 per month. At the same time, the programmer with 3 year of experience or the graphics designer will get $14,000 per month ($80 x 22 days x 8 hours). I know I have to buy my own insurance, but I can't imagine buying those for $4,000 each month... maybe $200, $300 at most. I probably need to pay Social Security (FICA) both way (myself and as self-employed = $210 x 2), but still, each month there will be extra $3,000 of income. So is the above calculation correct? But most often, I do see contractors wanting or becoming full time, but not full time employees becoming a contractor. Does somebody know what the reason is?


title: Flexible / Dynamic object creation or Alternative to list of lists

text: I have a xlsx file, that has some tabs with different data. I want to be able to save each row of a tab in a list. The first thing that comes to mind is a list of lists, but I was wondering if there is another way. I'd like to save that information in a object, with all its benefits, but can't think of a way to generate/create such diverse objects on the fly. The data in the xlsx is diverse and ideally the program is agnostic of any content. So instead of e.g. create a list for each row, than put that list in another list for each tab and each tab in another list, I'd like to store the information that each row represents in a single object and just have a list of different objects. The question can be summarized as : **What is an alternative to list of lists ?** A small graphic to visualize the problem :               +--------------------------------------------------------------------+     |LIST                                                                |     |                                                                    |     |    +------------------+ +------------------+ +-----------------+   |     |    | Class1           | | Class2           | | Class3          |   |     |    |------------------| |------------------| |-----------------|   |     |    | var1             | | var1             | | var5            |   |     |    | var2             | | var2             | | var6            |   |     |... | var3             | |                  | | var7            |...|     |    |                  | |                  | |                 |   |     |    |                  | |                  | |                 |   |     |    |                  | |                  | |                 |   |     |    |                  | |                  | |                 |   |     |    +------------------+ +------------------+ +-----------------+   |     |                                                                    |     +--------------------------------------------------------------------+


title: Handling one code base for multiple clients, with their own custom code

text: I am working on a CMS, in which we have multiple clients that use it, so the code is stored on their servers. Each client has the default code (user manager, pages manager etc), but every client also has it's own set of code (themes, scripts, custom modules). I am trying to figure out a way to maintain an up-to-date code base for all the clients without having to make every single change to the core to every single client. We are using GitHub for version control, so I was think of having all the clients as different branches, but how can I keep the core up to date with the master? Am I think about this all wrong? What are my options?


title: Plugin naming based on GPL v2

text: I'm programming a plugin for a software under GPL v2. I'm using an unique name for my plugin, but I'm considering to rename it. I would like to take another plugin's name which has been abandoned and isn't currently being developed. Am I allowed to take up that name without asking for permission from the author beforehand?


title: Is excessive indirection and/or redundant encapsulation a recognized concept?

text: I'm curious if there's a series of tendencies or anti-patterns when programming whereby a developer will always locally re-wrap external dependencies when consuming them. A slightly less vague example might be say when consuming an implementation of an interface or abstract, and mapping every touch-point locally before interacting with them. Like an overcomplicated take on composition. Given my example, would the interface not be reliable enough and any change to it never be surmountable any any level of indirection? Is this a good or a bad practice? Can it ever go too far? Does it have a proper name?


title: How much Ruby should I learn before moving to Rails?

text: Just a quick question.. I can never get a definitive answer when googling this, either. Some people say you can learn Rails without knowing any Ruby, but at some point you'll run into a brick wall and wish you knew Ruby and will have to go back to learn it..and some say to learn the "basics" of Ruby before learning Rails and it will make your life that much easier.. My current knowledge is low. I'm not a beginner, but I'm not pro, either. I went through the Learn Python The Hard Way online book in about a month, but I stopped once I got to the OOP side of Python (I know booleans, elif/if/else/statements, for loops, while loops, functions) I agree with learning the "basics" of Ruby before learning Rails, but what exactly are the "basics" of Ruby? Would I need to learn the whole OOP side of Ruby before I went on to Rails? Or would I just need to learn the Ruby syntax up to where I learned Python (booleans, elif/if/else/statements, for loops, while loops, functions) before I went on to Rails? Thanks!


title: Should state machine with synonym states be shown explicitly?

text: I am new to state machine modeling and while trying to model a system, I have a question. An example will explain it better: Considering a system that does calling (probably a customized cell phone device) with possible states: **idle->calling->signal-dropping->handle->call ended** **idle->calling->OS problem->handle->call ended** **idle->calling->battery drained->handle->call ended** **idle->calling->some other problem->handle->call ended** Above example is in form state1->transition1->state2->transition2->state3 Question is: Is there any significance of these intermediate states? Should they be shown/ modeled explicitly in UML or even programming? **Note:** It would be helpful if anyone can mention (some existing if applicable) technical term used to describe this scenario


title: What are the advantages of myBatis over Hibernate?

text: I've done some research on my own and understand the basic concept. But some insights can only be gained through actual experience. What are the advantages of myBatis that would make it worth learning a new framework?   In what case would you avoid using it?


title: Why is it called a memory leak?

text: I am a hobbyist programmer, bit of a stickler for terminology, currently learning C and recently came across the concept of _Memory Leak_. Now, I do understand what it means. Dynamic memory allocated to a program is not returned by the program. But where does the term ' _leak_ ' come from? Is it coming from the fact that other programs cannot access the dynamic memory, since one is already hogging it, and thus total memory available from the OS to the heap is reduced and therefore " _leaked_ " to the one hogging it? Basically, are we see the memory leak from the OS's perspective? And therefore saying that it is leaked to the program?


title: Technical example of modeling a domain with OOD?

text: Considering favoring composition over inheritance and looking at various design patterns there are multiple approaches to modeling a domain. Say you have some Entities which are very similar in some respects, yet differ widely when it comes to technical implementations. To try portray the scenario here is the classic car example.               (Vehicles)     Car     Truck     Van      From a user perspective, they are all pretty much the same (all vehicles). From a **DDD** perspective, car, truck, van all share certain common state (number of tires, engine, ...) and certain behaviors (steering, changing speed, ...). However, they also have various state and behavior that is unique such as the Truck's bed, the van's internal storage, or the cars 5 seats. As time progresses there will be a fair amount of change. Validation would be different for certain things, and similar for others. Change speed, steer, etc. are similar, yet pull trailer is optional and even that differs between e.g. the Van and Truck. How would you design this to cope with change, yet remain DRY and adhering to the **DDD** mindset? Please explain how you would go about it (pseudo code?) and mention any design patterns or strategies you would try implement to model this (simple, yet dynamic) domain and which OO principles are being applied etc.


title: Understanding Tarjan's Bridge-finding algorithm

text: Tarjan's algorithm for finding bridges in a graph is found here: http://en.wikipedia.org/wiki/Bridge_(graph_theory)#Tarjan.27s_Bridge- finding_algorithm. However, I don't understand the condition for checking if an edge is a bridge. I get that L(w) = w is a necessary condition, but I think that the condition for H(w) < w + ND(w) is redundant, since you're always guaranteed for that to be true (when doing the pre-order traversal, all the vertices in the subtree of w are visited consecutively and are numbered consecutively, and H(W) has to be in the subtree of w, making H(W) < w + ND(W) always true). So I'm curious if the H(W) < w + ND(W) condition is even necessary, and if so, can you provide an example case where it is needed?


title: acceptance test driven development in c++

text: Was put on hold at stack overflow: hopefully it has value here. I want to use a BDD / TDD / ATDD approach in c++. However I really want to emphasize vertical slices of end to end functionality rather than unit tests. There are plenty of unit testing frameworks. How would you go about in c++ authoring an approach that emulates a user story based testing framework. If you can avoid reinventing the wheel great otherwise i have no idea how to go about writing one from scratch. An example from another language would be specflow. The specific question is - if someone has done it lets use their work - otherwise how would you go about writing a framework like specflow in c++?


title: For professional designing company, what is the key to design an app elegantly?

text: I am coding and found it's pretty hard to come up with an elegant design for my app at the first attempt.   * First time I'm only about 40% happy, then I refactor it to code the same app a second time (almost start from scratch).   * Second time coding, I'm only happy about 60% happy, so I refactor it once more to code the same app a third time (not start from scratch but I made a lot of changes).   * Third time coding, I'm only happy about 80%. Here I am quite happy but I think if I can start over I can do much better and it should be very solid. But I am running out of time now. So I just leave it like it is. 80% Happy.  So my key word is " **to keep re-factoring** ". But this is my point of view as an indie developer so I don't know how a design company would design an application. Suppose I give my idea to a professional designing company, will they keep refactoring like that many times to achieve an elegant design? Or because they are a big design company, are they able to design everything well at the first attempt? Do you work for a software design company? If you do then how does the professional designing company design applications elegantly?


title: How to devise instruction set of a stack based machine?

text: Stack based virtual machines like CLR and JVM has different set of instructions. Is there any theory behind devising the instruction set while creating a virtual machine? e.g. there are JVM instruction sets to load constants from 0-5 onto the stack               iconst_0     iconst_1     iconst_2     iconst_3     iconst_4     iconst_5      whereas in CLR there are instruction set to load number from 0 to 8 onto the stack as follows               ldc.i4.0     ldc.i4.1     ldc.i4.2     ldc.i4.3     ldc.i4.4     ldc.i4.5     ldc.i4.6     ldc.i4.7     ldc.i4.8      why there is no ldc.i4.9 and if ldc.i4 is there why we need the above opcodes? And there are others like these. I am eager to know what is the reason behind this difference between opcodes of different VMs? Is there any specific theory to devise these opcodes or it is totally driven by the characteristics of the VM itself or depends on the high-level language constructs?


Why is HTML/Javascript minification beneficial when the HTTP protocol already supports gzip data compression? I realize that Javascript/HTML minification has the potential to significantly reduce the size of Javascript/HTML files by removing unnecessary whitespace, and perhaps renaming variables to a few letters each, but doesn't the LZW algorithm do _especially_ well when there are many repeated characters (e.g. lots of whitespace?) I realize that some Javascript minification tools do more than just reduce size. Google's closure compiler, for example, also tries to improve code performance by inlining functions and doing other analyses. But the _primary_ purpose of Javascript minification is usually to reduce file size. I also realize there are other reasons you might want to minify aside from performace, such as code obfuscation. But again, that reason is not usually emphasized as much as performance gain and file size reduction. For example, Closure Compiler is not advertised as an obfuscation tool, but as a code size reducer and download-speed enhancer. So, how much performance do you really gain from Javascript/HTML minification when you're already _significantly_ reducing file size with gzip compression?


title: After how much line of code a function should be break down?

text: While working on existing code base, I usually come across procedures that contain **Abusive use of IF and Switch statements**. The procedures consist of **overwhelming code** , which I think require re-factoring badly. The situation gets worse when I identify that some of these are **recursive** as well. But this is always a matter of debate as the **code is working fine** and no one wants to wake up the dragon. But, everyone accepts it is very expensive code to manage. I am wondering if are any recommendations to determine if a particular Method is a culprit and needs a revisit/rewrite , so that it can broken down or polymophized in an effective manner. Are there any Metrics (like no. of lines in procedure) that can be used to identify such segment of code. The checklist or advice to convince everyone, will be great!


title: Why is the formal definition of Big O notation formulated as such?

text: Consider the formal definition: > f(n) = O(g(n)) Why is it not: > f(n) = O(f(n)) or > f(n) = O(c*f(n)) since for the Big O analysis, `f(n)=2n` and `g(n)=n` are identical? I am confused by the function `f(n)` using another function. * * * ### Update Why isn' t the definition as follows: > f(n) <= c*abs(g(n)) What does the formal `O(g(x))` add to the definition? It seems like it overcomplicates things.


title: Why do some embedded projects shun cross-compiling?

text: As I've been getting into embedded systems I've noticed that some projects (Arch Arm and OpenBSD for example) frown upon cross compiling. What is the reasoning for this? Is a cross-compiled binary somehow different from a natively compiled one? OpenBSD suggests that building on the hardware ensures that the system is fully functional (and also self-hosting) and that makes complete sense. But do people actually develop and compile kernel drivers on the hardware they are developing for? It sounds very time consuming. **From OpenBSD FAQ:** "Cross-compiling tools are in the system, for use by developers bringing up a new platform. However, they are not maintained for general use." -http://www.openbsd.org/faq/faq5.html#ProbXComp I'll see if I can hunt down the IRC log where a developer from ArchLinux Arm told me that they don't cross compile, though they seem to have updated their info on cross-compiling with DistCC: http://archlinuxarm.org/developers/distcc-cross-compiling


title: How to create a cool user interface for an excel file in java or C#?

text: I have an excel file with many sheets and relations between theme (ie, formulas that relates sheets to each other). I wanna create the user interface for this excel file.in other words I wanna create desktop application that has many tabs and menus and user by selecting tabs or menus,sees corresponding sheet from excel file in the form (in the application interface) and can data entries and see the results in other tabs from other sheets.also I wanna create cool ui for the application. How I can do this? Note: I am using Eclipse-jee-indigo for java and Microsoft visual studio 2010 for C#. Microsoft visual studio has also toolbox to create GUI for C# applications. and also there are many GUI designer like jgoodies as eclipse plugin and dotnetbar for C#.


title: Best Practices when extending a project

text: I have to extend a web application for a customer, there is no documentation of the current app, no analysis and even worse, there is no technical support or management. The client gives me a list of his expectations and nothing more. What's best practice to begin such a project?


title: Search technique - multiple hits, prioritise results

text: I have developed a search algorithm, which basically matches records on 3 different criteria types. Name, Address, and Keyword(s). "doh" , will find:   * Name: doh    * Address: re    * Keywords: me * * *   * Name: re   * Address: doh    * Keywords: me * * *   * Name: re   * Address: me   * Keywords: doh Now, when two or more records have a match, I am basically prioritising a single found entity, by means of checking how many times it was found. My problem is, a single query will always only find one record, even it it matches on more than one criteria, so no prioritization can take place. I am currently building a single query, including all the keywords, for all 3 criteria fields. (Multiple `AND / OR` statements) My current query looks like this: **Search Term:** something somewhere shiny **Formulated Query:**               select * from table where ((cl_address LIKE @something OR cl_name LIKE @something     OR cl_key_words LIKE @something) OR (cl_address LIKE @somewhere OR cl_name LIKE     @somewhere OR cl_key_words LIKE @somewhere) OR (cl_address LIKE @shiny OR cl_name LIKE      @shiny OR cl_key_words LIKE @shiny))      To solve this, I would have to run a query for every criteria, for every keyword, for every address field, for every name... This can result in multiple of 10 queries per search... although it "would" work... How do the big boys do this? P.S. The above is my own brain child... and not based on anything other than my own logic.. which may, or may not, be flawed :-)


title: Is it a row or a record (or a tuple)

text: 1. If I look at a database table for editing - is it made up of rows or records?   2. If I write some sql and then look at the result is this made up of the same elements as the answer to 1.?   3. Is it the case that they are all rows but in very specific circumstances they are also records? * * * **EDIT**   A recent article by Itzik Ben-Gan prompted my question and I see quite a **_discussion on dba.stackexchange_**. In that article Aaron Bertrand brought up the same Itzik quote from his "Training Kit (Exam 70-461): Querying Microsoft SQL Server 2012" > As an example of incorrect terms in T-SQL, people often use the terms > “field” and “record” to refer to what T-SQL calls “column” and “row,” > respectively. Fields and records are physical. Fields are what you have in > user interfaces in client applications, and records are what you have in > files and cursors. Tables are logical, and they have logical rows and > columns.


title: Why can't a User Story be attached to more than one Feature?

text: I'm using Features to document the features as we originally communicated them to our client at proposal stage. I now want to create User Stories that relate to the features so that I can easily map our stories back to the proposal. Many of the stories naturally map across features, but Team Foundation Server (TFS) doesn't let me give a Story more than one Parent feature. Is this because I'm "doing it wrong" or is it more a limitation of TFS at the moment?


title: What are arguments for Commercial Off the shelf (COTS) products?

text: * Why should a company invest in a Commercial Off the shelf (COTS) product?   * Is it the cost of in-house development, support or are there other reasons to not buy an COTS product?  By Commercial Off the shelf (COTS) products I mean products such as SharePoint, SAP, MS Dynamics. Not Word/Excel/Outlook. By company I refer to a large enterprise.


title: Is a programmer professionality bound to the language?

text: I hear people saying that _"a true programmer is not bound to a programming language, because programming goes beyond that"_ , and albeit agreeing on the premise, i consider my professionality pretty bound to the languages i know. So i would say that this statement is practically false. Before this question goes closed, what is your opinion?


title: Are programmers tied to their code?

text: Assuming you are working for a company or in a team of developers, is the code bound to the person who did it? When someone develops a particular functionality or an area of the application, is this person the only one who can, is allowed or is just able to make changes to it? I personally think that a well-done piece of code or program should be easily modified by any programmers, but what about what you see in your environment? At my work, I'd say that the majority of the code can be modified by anyone (that's what coding standards are for right?). There are some things though that are 'property' of some coworkers like the module that handles the pay or some important functionality of the production module (we are developing an ERP system). What about your work place? Am I the only one living this?


title: Grid Game Algorithm

text: Problem Link - http://www.iarcs.org.in/inoi/2009/zco2009/zco2009-1a.php You have to find the path with the maximum weight, from the top-left cell to the bottom-right cell. It could've been solved with a simple Dynamic Programming approach, if it were not for the special condition - you are allowed at most one move that can be either to the left or up. How do I now approach the problem with this special case? Also, I'm looking for a time-efficient approach. Thanks!


title: Why are .NET ports called Iron*?

text: The C program Prog when ported to Java would be called JProg, a port to C++ would be Prog++ and a port to Python would be called PyProg. These names are all quite obvious. But the C# port would be called IronProg, which strikes me as strange. Why is it that programs ported to Visual Basic or C# are often called Iron*? Examples: IronPython, IronScheme, IronRuby, etc.


title: Do you find references invisible when you scan code, and are there any coding guidelines for their usage?

text: I have developed a habit of using safe C++ constructs where possible, but there is one place where I'm always not sure if it's better to use references or resort to good ol' pointers. Example code:               int FillFancyPointer(char *&ptr)     {         ptr = NULL;              char *tmp_ptr = static_cast<char*>(calloc(...));         if(!ptr)             return -1;             ptr = tmp_ptr;        return 0;     }      Later in code:               char *ptr = nullptr;     if(FillFancyPointer(ptr)>=0 && ptr)        Nice();      The problem with this, IMHO, is that the ptr appears to be read only variable when looking at the code, while in reality it is modified. The COM approach `ISmthn *ptr;`, `CoCreate(..., &ptr)` seems more pronounced. But it's also more error prone, as there is this `**` stuff everywhere. Come to think of it, output variables like `std::string` will also be masked with such approach. `int Foo(const string &in, string &inout)` Do you find references confusing in such places?


title: Online stores service design

text: I am designing an online store service app with rails. Everyone who wants to make his/her own store can do it with this app by just signing up and choosing a domain. I want to make it as SaaS as it can be. Should I copy all store's files every time someone creates a new shop, or can I somehow keep these files in one place and just let every new store access them?


title: How to structure integration tests per environment

text: I have a set of integration tests written using MSTest. I want to deploy my application to various environments and run my integration tests on that environment. There are certain configuration values that change per environment which are not contained in a config file. I am delivering a COM component on a legacy machine that doesn't support per application config files. I had thought to use TestCategories to split the tests into their various environments, and only running the tests in the appropriate category. However, I am running into difficulties when attempting to set up my test dependencies with the appropriate configuration values. For instance, I have the following code in my test class:               Private Property ObjectToBeTested as BusinessObject          Protected Sub New()         ObjectToBeTested = New BusinessObject("URL to my web service.")     End Sub      Then my tests are split up like this:               <TestMethod()>     <TestCategory("DEV")>     Public Sub MyDevTest()         ' code here     End Sub          <TestMethod()>     <TestCategory("SIT")>     Public Sub MySitTest()         ' code here     End Sub      But doing it this way I have to change my URL and recompile for each environment I want to test in. I'm trying to figure out a better approach. I've thought to somehow use ClassInitialization, but I can't determine if I'm in a DEV or SIT test at that point. I'd like to have the initialization take place once at the class level based on the environment I'm in. Thoughts?


title: Quantum computers and Turing Machine

text: As far as I know, a Turing Machine is the widely used model in computational theory to know whether something could be computed and if computed can they can be computed in finite time (P, NP, NPSpace). But I have the following doubts:   1. Is a Turing Machine essentially a black-box model where a set of inputs give a set of outputs such that there could be no interaction during computation? By no interaction, I mean that during computation the variables wouldn't be altered by an external factor.   2. As an extension to the above question, are non-deterministic functions Turing complete?   3. Is Turing Machine an efficient model for Quantum Computing? Going by what I have learned so far, my answers are:   1. Turing Machines cannot handle interaction and random behavior and it's not guaranteed even by Turing in his original paper.    2. Non-deterministic functions may bring Turing machines to a halt.   3. No since Turing machines cannot efficiently support the superposition of bits. **Note** I am not well-versed in either Computational Theory or Quantum Computing. So a lot of links and some beginner's stuff would be a lot helpful and reading this article inspired this question.


title: Is it normal for developers to suggest feature ideas to product owners?

text: I've started working as a developer fairly recently, having worked as a systems administrator before. My understanding of how a software development team using Agile functions is that the "what we need to implement" communication happens mostly in one direction, from the product owner to the developers. Developers can express their concerns to the product owner about technical debt, but coming up with feature ideas should not be one of their main responsibilities. The company I'm working at has a different view. To them, developers should not only go to the product owners of their own team to suggest feature ideas, but also to the product owners of other teams if they think they have something to contribute to that team's product. The idea is that we're all one big Team <company name>, and all developers should use their expertise to push features they think will be useful. Is such an approach "normal", for lack of a better word? Am I being too passive, should I take the initiative and start pushing ideas to product owners? Conversely, has the company got it completely wrong and I should look for employment elsewhere?


title: Is it appropriate to offer a "finders' fee" to existing staff when looking for new staff?

text: A lot of big companies use recruiters to find new hires, and there's obviously an associated cost. Existing staff are likely to know people looking for work through their professional networks. The company could potentially save significant money if they found people this way. Obviously there are conflict-of-interest concerns to consider, but in general, **do you think it's appropriate for a company to offer a finders' fee for referring new hires?**


title: Using "off-paradigm" coding practices in an existing codebase

text: Let's assume, for a second, that you're "the boss", or architect, or whatever position would permit you the authority to decide on the following question: You work on a product that's existed for a number of years and it's developed entirely in an imperative style/language. Let's also say that there is a feature or subsystem to be implemented that would benefit from a functional language/approach. A hypothetical example might be that the product is implemented in C# and the subsystem/feature could be implemented in F#. So your dev, who's a proficient F# developer, comes to you and says "I want to write this subsystem/feature in F#". Do you say yes, or no? Why or why not?


title: What kind of degree do I need to become a mobile application developer?

text: I am interested in changing careers and becoming a mobile app developer. I've been trying to teach myself how to build mobile apps using HTML5, jQuery Mobile, and appmobi. I really want to become a mobile application developer, but need some guidance as to what kind of degree and/or certificate I should get in order to get a good job. I already have an undergraduate degree - Bachelors of Science in Experimental Psychology.


How useful is UML if you are a developer working alone in a project?


title: Which layers should reflect the domain language (if a domain language can strictly exist)?

text: This question relates to a one I asked earlier: http://stackoverflow.com/questions/5448574/under-what-conditions-could-we- justify-an-attempt-to-introduce-a-one-size-fits-al When re-reading "Domain-Driven Design: Tackling Complexity in the Heart of Software" by Eric Evans, I noticed that the possibility of achieving a common terminology (domain language) is taken for granted. Where does a domain language begin? Which code layers (or whatever the grouping) should reflect this domain language?


title: What are the advantages of using eScrum?

text: Why should I use this software instead of, say, Microsoft Project? What kind of level of familarisation with TFS does it demand? Is there anything similar I could use with SVN instead?


title: If an "either/or" algorithm is "Boolean", what's a "zero, one, or many" algorithm?

text: In programming what do you call a choice that is not Boolean? ie. a Boolean condition is a true/false, either-or possibility. What do you call a condition with one or more possibilities? And, is there any difference if the condition is zero or more versus one or more? Thanks! \--EDIT-- To add some clarity: Specifically I'm having a hard time when describing certain types of algorithms to non-programers. I'm a hobbyist programmer so I lack a lot of the vocabulary that comes with a computer science degree. If I present a user with an "either-or" choice, I find the users understand what I mean if I call this a "boolean" choice, even if it has more than two possibilities. For example: "Pick a color: red, yellow, green, or blue." If I have something that's a "one or more" choice I don't know what to call that. For example: "Select any colors that you like: red, yellow, green, blue." How do you (knowledgeable programmers) refer to these kinds of choices when you talk about them? \-- SECOND EDIT -- As was pointed out in the comments I shouldn't even be saying "Boolean", I should be saying "Binary." That makes perfect sense... So, is there such a thing as "polynary"?


title: IT Consulting from US and German VAT Tax

text: I'm an independent IT consultant in the US, and I just completed some work for a German company, all done remotely from the US. I've sent them an invoice, but they are now asking if I have a VAT registration ID, which I don't have of course not being in Europe. Do I have to do anything about the German VAT tax? Is it up to the company I worked for to sort this out?


title: Is outsourcing (offshoring) disloyal?

text: I ask this from everyone's perspective. If you are in America and you outsource to offshore programmers, are you disloyal to your countrymen? If you are in India and you outsource to offshore programmers, are you disloyal to your countrymen? This question applies to all programmers and people in a position to hire programmers. I happen to be American, and so for me this means outsourcing to other countries like India and Mexico. With unemployment so high here at home, am I being disloyal to my fellow programmers, my countrymen, by outsourcing to other countries? This is a real dillema for me. Yes, either way I am providing for someone's family (either the American's or the Indian's). But if I outsource to offshore programmers, am I contributing to the problems here at home? As my business grows, hiring questions like this are becoming more urgent for me to figure out. I want to do the right thing. Also note that this question is _NOT_ asking "Is outsourcing effective". This question is "all things being equally effective, is it disloyal" . . . Also note that disloyal might not be the best word, but you get my meaning. Feel free to edit or make suggestions to make this question better.


title: Is it ethical to duplicate user licenses if the same person is going to be using it?

text: I was talking with someone today and this discussion came up. Suppose you purchase some software and X user licenses for it. You then want to install another instance of the software, however the company tells you that you need to buy another X licenses to use the 2nd installation. Is it ethical to duplicate the licenses since the same X users are going to be using them? (the security on the program we were talking about is not very good) **EDIT** Licenses are per-concurrent-user. In this situation users would (generally) not be logged into both installations at once. Regardless, we would keep the number of users logged in between the two installations limited to the number of licenses we purchased.


title: Inheritance vs 'specification' by fields

text: I'm currently reading 'Head first design patterns', and already the first chapter threw some questions towards me. This chapter introduces the 'prefer composition over inheritance' design principle, by explaining the 'Strategy- Pattern'. My question isn't about the pattern, but about a much more 'simple' thing. In the book there is an abstract Duck class, from which a hand full of other duck classes are (like e.g. 'Rubber-' or 'Redhead-Duck') inheriting. All of these ducks got a 'display' and 'quack' method. The 'display' method is what should be differernt in every special duck class (because every duck looks different, as the book says).               abstract class Duck     {         public void display();         public void quack()         {             //Quack here         }     }          class RubberDuck extends Duck     {         @Override         public void display()         {             //Display a 'Rubber-Duck'         }     }          class RedheadDuck extends Duck     {         @Override         public void display()         {             //Display a 'Redhead-Duck'         }     }      But my question is: Wouldn't it make much more sense to have a field inside a (non-abstract) Duck class, which contains the displaying information (a picture or a 3D-model for example) rather than inheriting from an abstract duck class?               class Duck     {         private String duckName;         private Picture duckPicture;              public Duck(String name, Picture picture)         {             this.duckName = name;             this.duckPicture = picture;         }              public void quack()         {             //Quack here         }         public void display()         {             //Show duck here, according to the 'duckPicture' field         }              //More methods here, maybe a getter for the 'duckName' field     }      What do you think about this? Does it make sense to have a abstract duck class and inherit from it or would you prefer my second attempt?