title: How to define the motion path of one object on a surface of the other one?

text: I have an uncommon problem. There are 2 3D objects, which are represented by arrays of vertices and triangles (.stl files). Each of them contains a big enough amount of vertices: 1-10 mln ones. The surfaces of these models are rough, and can contain different spikes or hollows. The aim is to determine path of one these objects, when it moves with contact on the surface of the other one. Moreover, the algorithm should consider how many degrees of freedom are available. In every case there are only 2 objects and one of them is fixed. Example, object `M1` moves on a surface of object `M2`, which is fixed. It's necessary to move M1 from point `A` to `B`. For M1 it's also available one more degree of freedom - along the axis (let's call it `AC`) perpendicular to `AB`. So, the path can be only the curve in the plane `(AC, AB)`. But due to this path, during the motion `M1` should always has at least one contact point. I tried to perform it with collision detection algorithm, but it seems it will be very complicated calculations for ordinary computers. Can anybody advise some algorithms, libraries or concepts how to perform this idea? P.S. I use C, C++ and Java.


title: Difference between planning a project vs. planning a product

text: I have read in numerous places that when developing a product you need to take a different approach to when you are developing a project (think "contract" work). Some differences are: 1) There is no definitive user, but a "user-base". 2) You need to develop the minimal marketable feature set. 3) Scheduling needs to be watched, as there is not often a fixed deadline it is possible for the product to run overtime (or for scope creep). I was wondering if there are people out there with experience in both, and if they could offer some input into any differences that they know of. Also if anybody could provide any tips/good references for how to deal with the differences I would be most appreciative.


title: Who created the idea(s) of the first loop constructs?

text: while (1) {           if (1+1==2) {                  print "Yes, you paid attention in Preschool!";           } else {                  print "Wait... I thought 1+1=2";           }      }      As a developer, we **all** have to use loops _very_ frequently. We know that. What I was wondering was, who thought of the idea to have loops? What language introduced loops? What was the first loop construct? Was it a `while` loop? A `for` loop? etc?


title: How to Deal with an out of touch "Project manager"

text: This "manager" is 70+ yrs old and a math genius. We were tasked with creating a web application. He loves SQL and stored procedures. He first created this in MS access. For the web app I had to take his DB migrate to SQL server. His first thought was to have a master stored procedure with a WAITFOR Handling requests from users. I eventually talked him out of that and use asp.net mvc. Then eventually use the asp.net membership. Now the web app is a mostly handles requests from the pages that is passed to stored procedures. It is all stored procedure driven. The business logic as well. What are the best arguments for not having the business logic not all in stored procedures?? How should I deal with this?? I am giving an abbreviated story of course. He is a genius part owner of the company all the other owners trust him because he is a genius. and quoting -"He gets things done. old school".


title: Web application without libraries | Relation to job postings

text: I have an application built without any libraries using PHP, JavaScript, HTML5, CSS, and mySQL that will support major modern browsers - IE, Safari, FF, Opera, and Chrome. One thing I've noticed is that most web jobs 90%+ ask for library experience of some sort. About 10 % do not... they focus more on the language then language-libraries. Why this lean toward libraries? I can understand that you don't want to have to re-write AES encryption algorithms and PHd level math things like that, but so much web development does not have any high level math at all. What is the difference between jobs that focus on library use vs. jobs that focus on language?


title: Is there much thought towards internal diagnosis testing within an enterprise application?

text: Imagine a discussion between four people - one a developer, one a manager, one a tester and one a deployment/operations type. The Manager is very angry as a system has fallen over after a new version of code was deployed into production. He is looking to point fingers. Operations person pleads ignorance - they followed the deployment steps exactly. Tester pleads ignorance - they have functionally tested code and it worked fine in test environment. Development person pleads ignorance - they provided good code, and claim that the system badly configured. This situation may seem familiar to some. There's always an excuse, some mistake made along the chain - from design to deployment - that allows a system to be upgraded but doesn't work as intended. What are the pros and cons of diagnosis testing - tests run built into the application (perhaps through a command line API or something) that would allow a system to check it's internal connections (database, middleware, filesystem etc) and confirm that everything it expects to work is correct? This is rather than relying on an external monitoring system that may not be configured in the same fashion as the application? (new release, different properties, looking at the wrong database etc) An example : I'm writing a class that interacts with a database. Within this class, I create a method that interacts with the database without affecting it, say a simple select query. In the constructor of this class, I pass to an observer a test based on the arguments passed into the constructor. This observer can be called to run all the tests it has at any time so as to test for the validity of the connection - even while the system is actually running.


title: Should if statments be in inner or outer method?

text: Which of these designs is better? What are the pros and cons of each? Which one would you use? Any other suggestions of how to deal with methods like is are appreciated. It is reasonable to assume that Draw() is the only place that the other draw methods are called from. This needs to expand to many more Draw* methods and Show* properties, not just the three shown here.               public void Draw()     {         if (ShowAxis)         {             DrawAxis();         }              if (ShowLegend)         {             DrawLegend();         }              if (ShowPoints && Points.Count > 0)         {             DrawPoints();         }     }          private void DrawAxis()     {         // Draw things.     }          private void DrawLegend()     {         // Draw things.     }          private void DrawPoints()     {         // Draw things.     }      Or               public void Draw()     {         DrawAxis();         DrawLegend();         DrawPoints();     }          private void DrawAxis()     {         if (!ShowAxis)         {             return;         }              // Draw things.     }          private void DrawLegend()     {         if (!ShowLegend)         {             return;         }              // Draw things.     }          private void DrawPoints()     {         if (!ShowPoints ||  Points.Count <= 0))         {             return;         }              // Draw things.     }


title: What is the relationship between OpenGL, GLX, DRI, and Mesa3D?

text: I am starting out doing some low-level 3D programming in Linux. I have a lot of experience using the higher level graphics API OpenInventor. I know it is not strictly necessary to be aware of how all these things fit together but I'm just curious. I know OpenGL is just a standard for graphics applications. Mesa3D seems to be an open source implementation of this standard. So where do GLX and DRI fit? Digging around on Wikipedia and all these websites, I've yet to find an explanation of exactly how it all goes together. Where does hardware acceleration happen? What do proprietary drivers have to do with this?


title: How can we unify business goals and technical goals?

text: ## Some background I work at a small startup: 4 devs, 1 designer, and 2 non-technical co- founders, one who provides funding, and the other who handles day-to-day management and sales. Our company produces mobile apps for target industries, and we've gotten a lot of lucky breaks lately. The outlook is good, and we're confident we can make this thing work. One reason is our product development team. Everyone on the team is passionate, driven, and has a great sense of what makes an awesome product. As a result, we've built some beautiful applications that we're all proud of. The other reason is the co-founders. Both have a brilliant business sense (one actually founded a multi-million dollar company already), and they have close ties in many of the industries we're trying to penetrate. Consequently, they've brought in some great business and continue to keep jobs in the pipeline. ## The problem The problem we can't seem to shake is how to bring these two awesome advantages together. On the business side, there is a huge pressure to deliver as fast as possible as _much_ as possible, whereas on the development side there is pressure to take your time, come up with the right solution, and pay attention to all the details. Lately these two sides have been butting heads a lot. Developers are demanding quality while managers are demanding quantity. How can we handle this? Both sides are correct. We can't survive as a company if we build terrible applications, but we also can't survive if we don't sell enough. So how should we go about making compromises? **Things we've done with little or no success:**   * Work more (well, it _did_ result in better quality and faster delivery, but the dev team has never been more stressed out before)   * Charge more (as a startup, we don't yet have the credibility to justify higher prices, so no one is willing to pay)   * Extend deadlines (if we charge the same, but take longer, we'll end up losing money) **Things we've done with some success:**   * Sacrifice pay to cut costs (everyone, from devs to management, is paid less than they could be making elsewhere. In return, however, we all have creative input and more flexibility and freedom, a typical startup trade off)   * Standardize project management (we recently started adhering to agile/scrum principles so we can base deadlines on actual velocity, not just arbitrary guesses)   * Hire more people (we used to have 2 developers and no designers, which really limited our bandwidth. However, as a startup we can only afford to hire a few extra people.) **Is there anything we're missing or doing wrong?** How is this handled at successful companies? Thanks in advance for any feedback :)


title: Good extension name for a war file with source

text: Is there a name for a Java Webapp's war that includes the source code? We will be using a webserver that accepts Java Web Projects with source code) uploaded into the docroot folder, so `docroot/admin.webapp.zip` would be the place to upload a webapp that handles `http://example.com/admin`. This way the compiled binaries and source code are together (and down the road, even the compiled code might not be there at all, but compiled on the first runtime). What are the most common file types for a webapp with source? If it means lining up with a standard, I would be glad to use a similar extension name and zip directory structure. If not, I will probably use something like `.web.zip`. I would just use `.zip`, but then the webserver would not know if it should serve out the zip or only use it as a webapp.


title: Code smells in Android?

text: This question arises from seeing code where I feel like something is wrong but I can't put my finger on it while developing Android. What are some red flags in Android development that says your application just may not be organized/programmed in the best way? What are some ways to fix these instances of code smell?


title: What is dependency of ASP.NET MVC on .NET Framework and how to use it with .NET 2.0?

text: When you download and install asp.net MVC, does it just add code to the .net framework class library? Or does it also modify the installed Visual Studio editions? Another question: If it is just adding code to the .net framework class library, why can it not be installed on top of .net 2.0?


title: Stop myself from over-complicating applications

text: Recently I worked on a fairly large project involving C# and MVVM. This application had around 160 projects in the solutions each seprarated into their own layers. As I have been working on this application for almost a year, building it from scratch as part of a team, I am now coming off that project and onto smaller more trivial projects. As I was beginning to develop a small in-house tool I found myself trying to mimic the larger applications structure and layering but in the end I just had a simple application with several DLLs which I know I wouldn't have done if I had not worked on that larger application before. I am just wondering if there are any techniques I can utilise to stop myself from turning a "code-behind" style trivial application into a full blown MVVM application? Or should I continue developing as I am and try to keep the unnecessary fluff out of the project?


title: Ruby/RoR development: desktop or server

text: Our company has started development of own systems "in-house". We already got couple of developers, who will be responsible for writing code in Ruby/RoR. We are currently discussing infrastructure, and I would like to ask: should we develop everything on local machines, then put it to test server and later to production, or develop everything on a development/test server, then publish it for testing and later to production? Just an update to the description above: under "local machines" I meant developers' desktops and this test/development server is a machine in our office.


title: How to modify the open-save-close life-cycle MapEditor class in a uDig Eclipse RCP

text: I am working on a uDig application. I have been trying to figure out how to modify the open-save-close life cycle of the MapEditor class created by uDig. The reason being I want to make sure that the asterisk does not display denoting a "dirty" editor, avoid the pop-up box that asks the user if they want to save the current map, and avoid having the old map open up again when the user starts the application up again. Any thoughts on how to accomplish this. Does anyone have any experience modifying the life cycle of an editorPart in Eclipse, particularly the uDig MapEditor? Thanks!


title: If I immerse myself in Dvorak, will I forget QWERTY?

text: From a few other questions here, it seems like the suggested route to learn Dvorak is just to do it, and while I have a couple weeks of vacation I'm using, it might be a good time to give it a whirl, so I'm not totally useless at 4 WPM when I go back to work. That said, in a few weeks would I severely damage my QWERTY knowledge or would it still be hanging around? Should I switch back to QWERTY occasionally while learning Dvorak?


title: Is there a name for the concept of a "cumulative checksum"?

text: Insofar as I understand it, tools like Git and Mercurial derive checksums from their data, and those checksums are used to derive other checksums used in aggregate, leading to a kind of accumulative checksumming (checksums being the input to other checksums), that ensures a high level of integrity. Is there a name for that, and if so, what is it? (Other than "accumulative checksumming" (which, according to Google, is not well used, or I just made up.) My Google foo is failing me here... Another way to put it, is there a name for the way a Git repository ensures its integrity? Sorry for the vagueness - grasping for terminology I sense should exist but I can't actually find.


title: Is working in ''Classic Asp'' good for me for the future?

text: I have completed my post graduation in Msc(comp sci)-2010. Is working in "Classic ASP" today good for me in the future? Because I am fresher and I have learned ASP.NET 3.5 version. Please let me know your thoughts on whether it really matters to my career that it is it's old technology.


title: Is Python Interpreted or Compiled?

text: This is just a wondering I had while reading about interpreted and compiled languages. **Ruby** is no doubt an interpreted language, since source code is compiled by an interpreter at the point of execution.   On the contrary **C** is a compiled language, as one have to compile the source code first according to the machine and then execute. This results is much faster execution. Now coming to **Python** :   * A python code ( **somefile.py** ) when imported creates a file ( **somefile.pyc** ) in the same directory. Let us say the import is done in a python shell or django module. After the import I change the code a bit and execute the imported functions again to find that it is still running the old code. This suggests that *.pyc files are compiled python files similar to executable created after compilation of a C file, though I can't execute *.pyc file directly.   * When the python file (somefile.py) is executed directly ( ./somefile.py or python somefile.py ) no .pyc file is created and the code is executed as is indicating interpreted behavior.  These suggest that a python code is compiled every time it is imported in a new process to crate a .pyc while it is interpreted when directly executed. So which type of language should I consider it as? Interpreted or Compiled? And how does its efficiency compare to interpreted and compiled languages? According to wiki's Interpreted Languages page it is listed as a language compiled to Virtual Machine Code, what is meant by that? ## Update Looking at the answers it seems that there cannot be a perfect answer to my questions. Languages are not **only interpreted** or **only compiled** , but there is a spectrum of possibilities between interpreting and compiling. Also, its not the languages which are interpreted or compiled, but rather their implementations either interpret or compile code.   I also found out about Just in time compilation From the answers by aufather, mipadi, Lenny222, ykombinator, comments and wiki I found out that in python's major implementations it is compiled to bytecode, which is a highly compressed and optimized representation and is machine code for a virtual machine, which is implemented not in hardware, but in the bytecode interpreter. As far as execution speed is concerned the various benchmarks cannot be perfect and depend on context and the task which is being performed. Please let me know if I am wrong in my interpretations.


title: Why use skins if we can handle server controls with CSS in ASP.Net?

text: The main difference between themes/skins and CSS are the HTML & Server Side Controls (SSC) only. We use skin files to format & cosmetics SSC which are not in HTML like `<asp:Label>`, `<asp:TextBox>` & `</asp:RadioButtonList>` etc... But what if we use the rendered HTML SSC in CSS instead skin files to handle `<asp:Label>` & `<asp:TextBox>` etc... ie: when SSC `<asp:TextBox>` rendered on browsers it shows `<input type="text">` so if we write following style in my CSS file instead Skin, it also works...               input[type=text], textarea, select {          outline: none;            padding: 3px 0px 3px 3px;         margin: 5px 1px 3px 0px;         border: 1px solid #cccccc;           background: #ffffff;         width: 150px;         color: #484848;         font-size:         12px;      }      So my question is, if we still can handle SSC with CSS do we really need skins? Or if I am missing anything please correct me, thanks.


title: SQL Server DBA - How to get a good one!

text: I'm a lone developer. I am currently developing an application which is seeing me get way way way out of my depth when it comes to SQL DBA'ing, and have come to realise that I should hire a DBA to help me (which has full support from the company). Problem is - who? This SO thread sees someone hire a DBA only to realise that they will probably cause more harm then good! Also, I have just had a bad experience with a ASP.NET/C# contractor that has let us down. So, can anyone out there on SO either... a) Offer their services. b) Forward me onto someone that could help. c) Give some tips on vetting a DBA. I know this isn't a recruitment site, so maybe some good answers for c) would be a benefit for other readers!! BTW: The database is SQL Server 2008. I'm running into performance issues (mainly timeouts) which I think would be sorted out by some proper indexing. I would also need the DBA to provide some sort of maintenance plan, and to review how our database will deal what we intend at throwing at it in the future!


title: One Service or Two Services for Parsing and Sending Emails

text: I have a bulk emailing service within the system which allows for a template to be used. When the mail is sent the template is parsed or run through a parser to replace tags with actual information. i.e "[Foo] has logged in" is parsed to "Bar has logged in" Is it better to have 1 service for sending and parsing emails (concurrently), or to have 2 services, one which only checks for pending emails and parses them, and another which only sends emails who have already been parsed?


title: How often do you expand your skill set?

text: In the ever changing world of programming, how often to you catch up on a new language or technology? I have heard it said that one should learn a new language yearly. Is that always true?


title: How can I use my coding skills for good?

text: By this autumn my two small websites should be generating around a total of $1200 a month with minimal/zero input which is enough to for me to live on comfortably enough. Rather than embark on another business venture, I would love to spend the next few years doing something genuinely good or that helps other people that need it. I want to spend 4 or 5 years dedicating my time to a worthy cause and do the most I can to help with the web development & programming skills that I already have. The problem is that I don't know where to start. I don't have an awesome idea of my own and am very sceptical of many large charities. Ideally I'd like to find a small project where everyone is unpaid and focused on helping. Are there any such small organisations? Does anyone have an idea for a project/website/app that can help people in need that they would like me to work on or work with them on? I know this isn't a typical StackOverflow 2+2=? type question and some of you will be itching to delete it but considering the philanthropic nature of the IT industry (just look at S.O. itself) this is very relevant question to many developers either now or at some point in their careers. Given the recent events in Japan this question is particularly relevant with many people looking for ways they can help others with the skills/time that they have available. Really looking forward to reading your thoughts/answers on this, thanks guys


title: Handling deleted users - separate or same table?

text: The scenario is that I've got an expanding set of users, and as time goes by, users will cancel their accounts which we currently mark as 'deleted' (with a flag) in the same table. If users with the same email address (that's how users log in) wish to create a new account, they can signup again, but a NEW account is created. (We have unique ids for every account, so email addresses can be duplicated amongst live and deleted ones). What I've noticed is that all across our system, in the normal course of things we **constantly** query the users table checking the user is not deleted, whereas what I'm thinking is that we dont need to do that at all...! [Clarification1: by 'constantly querying', I meant that we have queries which are like: '... FROM users WHERE isdeleted="0" AND ...'. For example, we may need to fetch all users registered for all meetings on a particular date, so in THAT query, we **also** have FROM users WHERE isdeleted="0" - does this make my point clearer?]               (1) continue keeping deleted users in the 'main' users table     (2) keep deleted users in a separate table (mostly required for historical         book-keeping)      What are the pros and cons of either approach?


title: Should generated documentation go in version control history?

text: I'm against compiled stuff going into version control, specially when it comes to compiled binaries, however, my principles are now in question after adding doxygen support for a project. Should the hundreds of files generated by doxygen go into version control?, what is the recommended practice here?, I think the ideal would be automating the process in a server that publishes that documentation at the same time, however, there is no such server now nor there will be for some time.


title: Open Source Ecommerce - OpenCart a good choice?

text: I am considering learning the ropes for an open source ecommerce package. I've played with opencart in the past and I basically want to get opinions on actually using it for clients. Make any suggestions you like, my priorities are: 1\. not worrying about checkout integration 2\. plugin writing 3\. theming, and premade theme availability I develop with php (oo), Javascript(with Jquery) and mySQL. In a nutshell, I want to know if Opencart makes checkout easy to do, whether the api's are kept up to date and how active the community is. Or alternatively, another opensource cart that makes checkout easier than opencart (a checkout wrapper is basically all I want - other features are bonuses). Thanks.


title: How you handle security/permission in enterprise app nowadays (mid 2011)?

text: what you people use to handle security issues, different security rules, permissions etc. Possible answers: 1) Security framework like Rhino security or any other. (pros/cons?)   2) Custom solution specific to the problem. (pros/cons?)   3) Other. (what? | pros/cons?) Feel free to elaborate on this topic. Best regards! PS: I will mark the answer with most votes as answer just for the rules...


title: How important is having a mentor or senior developer in the beginning of your career?

text: I just read this question asking how to determine if a senior developer's advice is bad and I realized that I couldn't really relate to his situation since I don't have a mentor. I also realized that I'm probably the most senior developer at the office, at least within my field. Which I suppose is remarkable considering that I'm only 22 and graduated from college a year ago. I realized that I make most of the design decisions and that I write my code however I feel like it. While I'm happy with that I feel like it would be good to be surrounded by superior developers that I could learn from. As it stands right now I'm mostly applying knowledge I've already acquired. Will not having a mentor at this point in my career have negative impacts later in my career?


title: Using web api or libraries

text: We currently have 1 domain and 4 subdomains using 5 different applications. We are programming in asp.net and we have 6 different solution project. 5 applications and 1 solution for shared back-end. Each application is deployed with its own dll + shared dll. Since we are looking to start using asp.net MVC, we are now interested in adding Rest WEB API. Plan is to replace one subdomain app (asp.net web forms) with MVC and instead of using libraries, we want to pull data from WEB API. My questions are 1) Is it worth changing the concept and use wep api instead of libraries to exchange data between our apps? 2) If so, should we create it as a new app (on new subdomain), or just a middle layer in MVC application exposing only methods we need for MVC app?


title: Physics Engine with Fixed-Point Positions

text: Fixed-point object locations allow for worlds which are much more scale-able. Using a 64-bit integer (per dimension), and 0.1 millimeter precision, a world can be created which is 100% numerically stable, and _12,000_ astronomical units across. I have been looking all over the internet, and I can't seem to find a physics engine which supports this. Is there a 3D physics engine in existence, which uses _fixed-point_ (i.e. Integer, hopefully int-64) values for entities' positions? It's for a really ambitious sci-fi game I'm working on.


title: Best practice for creating a 'global' config class used by numerous components

text: I have a large project with a driver part and about 5 libraries doing various associated tasks. Many of the libraries require access to 'global' configuration data which is read from a database at startup by the driver code. By driver I just mean the part which contains the main function. My idea on how to handle this was to create a config class with a static method to get the config items. Is this the best approach? How else could this be achieved? eg:               class config {      public:        static get_item(key);           private:        static values;     };      Is singleton design appropriate here?


title: How to implement a Theme for View Controllers in an iOS app?

text: I have an application, where font size, font type, color, background color, image and a lot of things change based on theme. I realised in the beginning itself that using enums to denote themes and then checking the theme everywhere was a horrible mistake. So I have two approaches now and I am confused which one to go with. Keep a Base View Controller for my app with default look and feel of the application and then create a subclass per theme. Or Create a Theme class which will provide theming information and then subclass it per theme and set the theme Object on the view controller and query theme object before applying the theme. Or There could be another approach I haven't thought about :)


title: Search and Replace in MVC

text: What would be a good MVC/OOP/GRASP/SOLID structure for a search/replace functionality. Methods: search/searchNext/replace/replaceAll. I'm interested only in the PHP arhitecture and how a professional developer would implement this in it's **OWN FRAMEWORK**. What names would you use for the classes? What subfolders would you used in your MODEL folder? How would you connect the MODELS/CONTROLLER? This is just a arhitecture question to understand better the principles of good OOP in practice. My current implementation is very simplistic using a service model:                /controller/SearchReplaceController.php      /models/services/SearchReplaceService.php      The problem with this is I know I'm breaking SRP in the service but I found this somehow acceptable. Also creating a service does not feel like the best solution for this.


title: Making two images move at different speeds in Java?

text: I am creating a basic game of space invaders. I am using a thread to animate the game and was wondering, how do I get the aliens the speed up going left and right without changing the speed of the ship you control below them? What is the easiest method? I am quite new to Java 2d and have only created two other more basic games.


title: Using sounds on distributable app - Copyright issue

text: I've created an app that has some sound file that I've downloaded from Macloops. The user can only listen these sound files (he can't create any new sound files using them) with the app. Now, I want to distribute the app over the internet and I'd like to know if I can do this legally. I've only found the following the Macloops' website about copyright : > Macloops membership disclaimer/terms & conditions. > > By joining the Macloops website, you are accepting these Terms and > Conditions. > > You accept that Macloops.com is part of Siliconbeats.com and you grant us > the right to send you occasional emails regarding our latest news and > developments. Your email address will not be sold to any mailing list > organizations and the content of our emails will be related to samples, > loops and music making resources that we have to offer. > > Whilst all reasonable efforts are made to ensure that all downloadable > material is virus free, we strongly recommend the use of professional virus > checking software. Playing sounds at excessive volumes can cause damage to > hearing. Use common sense when playing sounds and ensure that volume levels > are sensible. > > Macloops cannot be held responsible for injury or damage caused from use of > files and sounds. All members and nonmembers are totally responsible for ALL > Internet access charges. No exceptions are made. The period of membership > for all members is at the discretion of the site administrators. Macloops > reserves the right to deactivate or remove your account at any time. > Macloops cannot be held liable for any damage to hardware, software or > equipment resulting from the use of any files or sounds obtained directly or > indirectly from the Macloops website. > > By joining the Macloops website, you are accepting to be bound by these > Terms and Conditions. There is nothing about using the sound files. So am I allowed to distribute my app?


title: How would I combine 'Command' and 'Composite' to simulate a time delay?

text: As a learning exercise (I am not in school - just an old guy trying to learn something new), I am trying to write a logic gate simulation that incorporates propagation delay. The user should also be able to group gates together to create higher-level objects. I want to apply design patterns to my problem, but I am having a hard time. I am reading _Head First Design Patterns_ , and I see that the Command pattern is a good way to simulate electrical pulses through a circuit with a delay. I also see that the Composite pattern is a good way to simulate nested units. I just don't know how to mix the two. In other words, as I loop through my gates, I see that gate 'x' should fire. It has a 15 nanosecond delay, so I create a command with a time stamp of 15 ns from current game time. Where is the dispatcher? In the example of the diner, with the command being the 'Order', the waitress and the cook each dispatch the command and have the option of introducing a delay. If I have a 'composite' gate, does it also have its own dispatcher? Do I need to use a Singleton to manage the queue? I read what I could find, but I still need a push in the right direction:   * http://stackoverflow.com/questions/2015549/using-command-design-pattern   * http://stackoverflow.com/questions/12016314/client-server-command-design-pattern-with-variable-delays   * http://stackoverflow.com/questions/10560892/composite-of-commands-design-pattern   * http://stackoverflow.com/questions/8874705/how-can-i-calculate-propagation-delay-through-series-of-combinational-circuits-u


title: Unit Tests as a learning tool - a good idea?

text: I'm interested in ways and means for learning (a) programming language(s) efficiently. I believe that using Unit Test concepts and infrastructure early in that process is a good thing, even better than starting with "Hello world". Why: To write a decent program even for a toy/restricted problem in a new language, you'll have to master many heterogenous concepts (control flow & variables & IO ...), you are tempted to glance over details just to get your program 'to work'. Putting (your understanding of) the facts about the new language in assertions with good descriptions (=success messages) enforces thinking thru/clearness/precision. Grouping topics and adding assertions to such groups is much easier than incorporation features from the 2. chapter of your "Learning X" book to your chapter 1 program. Why not: 'Real' Unit Tests are meant to output "1234 tests ok; 1 failure: saveWorld() chokes on negative input"; 'didactic' Unit Tests should output relevant facts about the new language like               perl6 10-string.t     # ### p5chop     ...     ok 13 - p5chop( "cbä" ) returns "ä"     ok 14 - after that, victim is changed to "cb"     # ### (p6) chop     ...     ok 27 - (p6) chop( "cbä" ) returns chopped copy: "cb"     ok 18 - after that, victim is unchanged: "cbä"     # ### chomp     ...      So (mis?)using Unit Tests may be counterproductive - practicing actions while learning you wouldn't use professionally. How: Writing 'didactic' Unit Tests in languages with lightweight testing systems (Perl 5/6) is easy; (mis?)using more elaborate systems (JUnit, CppUnit) may be not worth the effort or not suitable for a person just starting with a new language. So   1. Is using Unit Tests as a learning tool a bad idea?   2. Can the Unit Test tool(s) of your favourite language(s) used didactically?   3. Should implementation details (eventually) be discussed here or over at stackoverflow.com?


title: Why isn't Java more widely used for game development?

text: I'm not a game developer or anything, but I know that Java is not very widely used for game development. Java should be fast enough for most games, so where's the catch? I can think of some reasons:   * Lack of game developers with expertice in Java   * Lack of good game development frameworks   * Programmers don't want to accept Java as a games programming language. Most only accept C++ as that?   * No support for game consoles (though the PC market still exists) It could of course be something else. Could someone who knows the business better than me explain why Java isn't getting momentum when it comes to game development?


title: Is re-defing idiomatic in clojure?

text: Simple example:               (def ticks 0)     (defn run-iteration []       (def ticks (inc ticks)))      Though the usual case involves things that don't change more than once every several hundred ms. How to do this idiomatically? Edit: and why is the idiomatic way idiomatic, and why is it good?


title: Interviewing someone for general unix skills

text: How would you test a developer that claims to have *nix shell experience (just to be clear, we don't want to test if someone can develop on *nix, only that they know their way around the command line). I was thinking about making them solve a problem of getting information out of log files, which would involve some basics like cat, grep, cut, ... combined with piping. What other basic knowledge would you ask for? Once again, this isn't for interviewing someone who will develop for *nix systems, and also not for *nix system admins, but just for regular developers that sometimes need to do some work on a *nix system.


title: "Open Source" licenses that do not allow source redistribution

text: I am starting to work on a new commercial software project that may use elements of "open source" code. I have been instructed to ensure that I only use code which is licensed for commercial use and although we _may_ decide to make it open source in the future it should be _required_ to be open source. So this clearly prohibits the use of any true copyleft licensed code. But this got me wondering; are there any standard "open source" software licenses that _allow_ commercial use, but _do not_ allow redistribution of source? I have intensionally used quotes around open source as I am aware that any licenses that fit this criteria cannot be compatible with the accepted OSI definition of open source.


title: How can I know when my application is too complex?

text: I'm currently working on my own project for an Android app, but then as time goes it feels like my app is concentrating more on another feature than what I had in mind when I first design the app. So I want to ask how we should know when our application is too complicated (for the user)? What should we do with it? Especially when we strongly think this new feature is important.


title: How to effectively (but minimally) *simulate* a distributed computing environment?

text: I am doing some personal research on Byzantine Faults. I am trying out algorithms from various research papers which present algorithms for consensus in distributed systems like this one. For this i need a small scale simulation environment of a distributed system. How do i approach this problem ?


title: Agile development deployment process. Where do QA and Business Owners test?

text: I've been reading up a lot lately on various web application deployment processes using SVN or GIT, with a view to redesigning how we currently deploy where I work. As is the way with many flavours of Agile, it's assumed that anything committed to master or trunk is production ready. Both GitHub and Etsy, http://codeascraft.etsy.com/2010/05/20/quantum-of-deployment/ say that they work on this basis (although Etsy actually have a staging environment). This process assumes all unit test and CI tests have been run. You run the tests locally and on CI and then commit to trunk. SO, at this point your code is **technically** sound. Your code may be technically correct, but user/functional testing may unearth more bugs, particularly when it comes to front end testing. My question is this. Where do QA and Business owners test the feature changes you have implemented? On your local development machine before you commit to trunk, or on a QA/staging machine? If you have a staging machine that runs off trunk, and you assume that all code committed to trunk is production ready ... eh .. then at what point is the code signed off and good to go into production from both a technical and business perspective? If you have only one staging machine, many developers and that is where the code is to be QA'd, then how can you deploy from trunk as many developer changes can be waiting for sign off. I'd be interested to hear how others have approached this?


title: To Press Onward or Not?

text: In the past week I've been meeting and speaking with someone who's interested in finding help on developing a game (built using php and mysql, with a little bit of javascript). I agreed to help out, however, now that I've seen the code and file organization, I don't know if it's feasible for anyone (not just myself) but the original writer to even decipher what's going on. Basically, there isn't any structure either to the files or to their code, it's just sort of strewn about as is. Every php file that didn't come from an external source is in the root and there is a little organization for other files types, but not much. Most of the code isn't indented or readable. I'm not trying to say it doesn't work, I've seen it work, it's just that I don't think anybody else could try to get a handle on what it does (and I don't want to sound like I'm ragging on the guy who wrote it, he told me that he really doesn't do much coding). Basically, my question is should I back out, or should I try to press onward? Does anyone have experience with working on a big-old-system that needs to be completely updated? Any thoughts? **Additional Information:** No, I don't have a contract yet, I've just looked at it thus far. My own feelings are that if I decide to press onward I'll end up rewriting the entire system (which is 113 php files in the root, plus several others located elsewhere in the system), and I don't know if I really want to continue, it's just that I feel like I said I would try to help out.


title: Pros and cons of namespaces vs include/require in PHP?

text: I recently started using namespaces in PHP. When I first saw them, I thought that their syntax was ugly and I'd never use them. However, I created an autoloader (spl_autoload_register) that makes it so that I never have to write an include/require statement again. I like namespaces, but is there any objective benefit over include/require statements, or are they the exact same method to accomplish the same goal?


title: Unit Testing and Asserting

text: Assume we have a method that validates an object before saving it to a DB. It returns back KVP something like:               public KeyValuePair<bool, List<FooErrorReason>> ValidateABar(Bar b)     {         var reasons = new List<FooErrorReason>();         if (string.IsNullOrEmpty(bar.Name))          {             reasons.Add(new FooErrorReason { PropName = "Name", Message = "The name was missing" };         }         if (string.IsNullOrEmpty(bar.OtherName))          {             reasons.Add(new FooErrorReason { PropName = "OtherName", Message = "The other name was missing" };         }         return new KeyValuePair<bool, List<FooErrorReason>(reasons.Count == 0, reasons);     }      So now I want to test that, for a missing bar.Name, the error is returned. My question is on the make up of the test, concerning what to `Assert`.               public void ValidateABar_Fails_For_Missing_Name()     {         //arrange         var b = new Bar { OtherName = "Other" };              //act         var result = ValidateABar(b);              //assert         Assert.IsFalse(result.Key);         Assert.AreEqual(1, result.Value.Count);         Assert.IsTrue(result.Value.Any(x => x.PropName.Equals("Name")));     }      I have 3 `Assert` calls and it has a whiff of code smell about it, but I can't quite convince myself either way. I'm asking myself 'What do you want to test?' and I do kind of feel that I should test that this failed, but failed specifically for the property of the test. Is it enough to just use               Assert.IsTrue(result.Value.Any(x => x.PropName.Equals("Name")));      Or should I also check that there are no other errors I have picked up along the way? Say for example someone added another validation rule without my knowing about it, I would think I would want my tests to tell me about this the next time I ran them. As an example, let's say someone changed the method as below:               public KeyValuePair<bool, List<FooErrorReason>> ValidateABar(Bar b)     {         var reasons = new List<FooErrorReason>();         if (string.IsNullOrEmpty(bar.Name))          {             reasons.Add(new FooErrorReason { PropName = "Name", Message = "The name was missing" };         }         if (string.IsNullOrEmpty(bar.OtherName))          {             reasons.Add(new FooErrorReason { PropName = "OtherName", Message = "The other name was missing" };         }              //added this!         if (string.IsNullOrEmpty(bar.ThirdName))          {             reasons.Add(new FooErrorReason { PropName = "ThirdName", Message = "The third name was missing" };         }         return new KeyValuePair<bool, List<FooErrorReason>(reasons.Count == 0, reasons);     }      The test would now fail and I would see that this rule had been added, and amend my test accordingly (and presumably write another test to cover the new rule). Am I taking the 'one Assert per test rule' too literally?


title: Which pattern is suitable to send multiple type of responses through REST web service?

text: I have bunch of REST style web services which support XML and JSON type responses. Now I have to modify existing web services such that they provide Protobuf type of responses. Developer who has developed these services has created three layers. `Service` layer, `DAO` layer and `Processing` layer. Service layer calls one of the method of processing layer and processing layer calls DAO methods and returns either JSON or XML type response (POJO) to the service. Service layer then sends back this POJO to client. For example, if service to add `list of items` is called then that code roughly looks as shown below:               @Path("/item")     class ShoppingItemService {         // annotations         public ItemAddResponse addList(/* parameters required for this method */) {             ItemProcessor processor = new ItemProcessor();             ItemAddResponse response = processor.process(/* pass some data to processing layer */);             return Response.ok().format("XML").build(response);         }     }      Here `ItemAddResponse` is already annotated with `JAXB` type annotations for `XML` response and other annotations for `JSON` response. I cannot reuse same `ItemAddResponse` because Protobuf generates its own classes using schema files. Processor class has all the business logic and If I want to add support for Protobuf then I have create new method in processor and copy-paste almost all the business logic, but just return object of protobuf generated class. This approach is time consuming and there atleast 50+ similar methods where I have to do copy-paste work. I want to avoid this and would like to design some elegant solution. I would like to know how can I add support for Protobuf with minimal amount of changes? I am reading `Head First Design patterns` book but this book is really huge and it will take lot of time to find proper design pattern. Is there any design pattern which can be useful in this type of situations? Thanks, Chandrashekhar


title: Qt (C++) vs. JavaFX: What is the relative size of each developer community?

text: I am deciding between Qt (in C++) and JavaFX for GUI development for an application with a complex back-end (the back-end will be written in C++). If I use JavaFX for the GUI, I will be using JNI to exchange data between the GUI and the C++ back-end. Except for one major issue, I would prefer to use Qt (C++) for the GUI, rather than JavaFX. The issue is that it is possible that JavaFX has a much larger developer community. On a related note, it will presumably be easier to transfer development of the application to other developers in the future if the GUI is built in JavaFX. (The quality of both of these GUI frameworks seems, on the whole, comparable; see, for example, JavaFX 2.0 and Qt for cross-platform application, Cross- platform desktop development, and Is using Java the proper language/platform for developing a GUI based accounting app?. If I'm mistaken, and in fact if the quality of one of these frameworks is clearly significantly higher than the other, that would become a major factor.) My impression from "the blogosphere", as well as from the fact that Qt is being actively maintained, is that Qt has a large following - though presumably the Java Swing community is larger (which will probably also be the case for the JavaFX community after some time has passed, since JavaFX is superseding Swing). My question is: How large of a user base (developer community) does Qt have, in comparison to JavaFX?


title: Should we still care about _escaped_fragment_ and alternate HTML generation for Single Page Applications?

text: A few months ago I started a project, which will have two parts – business client overview panel (AngularJS SPA) and public front-end (dynamic HTML with progressive enchancements via XHR). I'd really like to stop and throw away dynamic HTML and switch to AngularJS + API + static HTML combo (like in "panel") to avoid duplicate work in API resources and HTML templates. As this content will be public and should be indexed, I'm lost on current Google Search state. I'm not sure I wish to implement PhantomJS + nginx cache stack (to avoid DoS possibility via PhantomJS): ![SPA flowchart](http://i.imgur.com/jU1fYNm.png) (I apologize for possibly unreadable font size.) Have anyone of you deployed SPA-only site right now and can give any insights on how (if) Google indexes your site?


title: Design Pattern: A single class with multiple purposes, or multiple extended classes each with their own purpose in PHP

text: I'm working on a PHP framework called Carbon CMS. This framework will be used as base to build larger web applications on top of it. This framework should provide all kinds of interfaces such as database access, caching and so on.   Currently I'm working on the IO and file handling part of the framework. This question will be about the design pattern I should use, whether I should use a single, or multiple classes that extend each other. In this case, the question will be asked with file systems in mind, because this applies to the problem I'm having, and should make it easier to understand the question itself because an example is given. So keep in mind, that this design-pattern question also applies to other cases. My idea is to built a class, or multiple classes that reference to a file, directory or symbolic link on the file system by it's path. Then, these class(es) should also provide an interface to read/write files, to list directories and so on. Think of the `File` class in Java, or the `File`, `Dir` classes in Qt. The question I'm having is what kind of structure or design pattern I should use in this case. I could create a single `File` class that has all the functionality included, not just for files, but also for directories and symbolic link. But I could also create multiple classes, such as `Path`, `File`, `Directory` and `SymbolicLink`. So, there are two possible ways I can think of:   1. Using **a single** `File` **class**. This class holds the reference (path) to a file system entry such as a file or directory. This class includes functionality both for files, directories and symbolic links, such as reading/writing files or listing directory contents.   2. Using **multiple classes** , which extend each other. A `Path` class (or something similar) holds the reference (path) to the file system entry such as a file or directory. And only contains the basic functionality which could be used on all three different file system entry types (files, directories and symbolic links). Think of features such as `Path::isFile()`, `Path::getPath()` or `Path::exists()`. Then three other classes are used for the different file system entry types called `File`, `Directory` and `SymbolicLink`, all of these classes extend the `Path` class to implement it's basic functionality and the path reference. These three classes contain the functionality for that specific entry type. So, methods to read and write files would be found in the `File` class; `File::getContents();`, and a method to list the contents of a directory would be placed in the `Directory` class; `Directory::list();`. So, to clarify my question. Should I go for the first option, and create a single `File` class which handles everything regarding IO and file handling. Or should I go with the second option and create multiple classes. Where each class is for a specific type of file system entry (except the `Path` class, which will be used for all three types). Now, if going for the first option. Functions such as `listContents()` (to list directory contents) could easily be called on a path that references a file. It would be impossible to list the directory contents of a file, thus calls like this would return `null`, or something similar indicating the directory couldn't be listed. When using the second option, this would be a bit different. The `listContents()` method would only be available for `Directory` instances, and these instances should reference to a directory anyway. Of course, it would be possible that the referenced path doesn't exist, but that could be the case with both options. There are a few pro's and con's for both options. Here are some I can think of:   * Going for the first option, with a single class:       1. Casting instances isn't required to use entry specific operations when using `File`'s.     2. Creates one huge interface for everything, which makes it messier and allows certain operations to be used on incompatible file system entry types, such as listing directory contents on a file.   * Going for the second option, with multiple classes:       1. Casting instances, and instance type checking is required to use entry specific operations when using `Path`'s.     2. Creates a separate interface for each file system entry type, which makes it less messy, and also prevents the use of most operations on incompatible file system entry types. The framework will be open to the public and will be used by multiple people, thus I'm looking for the option that is the easiest to use, doesn't have a performance impact if possible and the option that suits this ground the best. Here's some sample code, to show off the very basic structure of both options.   When using a single class, with option one:               class File {         private $path;              public function __construct($path) {             $this->path = $path;         }              public function getPath() {             return $this->path;         }              public function getContents() {             // Return the contents of a file         }              public function listContents() {             // Return the contents of a directory         }     }      When using multiple classes, with option two:               class Path {         private $path;              public function __construct($path) {             $this->path = $path;         }              public function getPath() {             return $this->path;         }     }          class File extends Path {         public function getContents() {             // Return the contents of a file         }     }          class Directory extends Path {         public function listContents() {             // Return the contents of a directory         }     }      I should note that all the methods noted in this question, such as `Path::getPath();` or `Directory::listContents();` are non-static and have to be called on the instance of the class. Java uses a single `File` class, which would be similar to first option I gave with a single class. There are some classes available such as a `DirectoryIterator` but classes like this would be created anyway, and don't depend on the first or second option. On the other hand, Qt uses something similar to the second option I gave, as far as I know. So finally; What would be the best option, and why?


title: Do you really have to do BDD/TDD in a test first manner?

text: Even though I haven't been in a TDD or BDD project, or I have been in some that say they are doing TDD but are pretty far from it, these are things that I think about and really try to read as much as I can about. Back to the question. When you're doing BDD you should write your "test" first and make it fail, right? And then implement that feature or what you call it. But if you take this to the extreme couldn't this be some kind of top-down development? You're looking at your UI and says, "I would like to have this feature/behavior here". Then you fix your UI to implement that feature and the code that supports the UI. At this point you haven't implemented any business logic or data access logic, you have just implemented your behavior. What I'm aiming at instead of writing the test first you write your UI code first. In some cases it should result in the same code for the data access and business layer, since you use your UI code to define what your business needs to support. Of course you should complement this with tests that is used to make sure that the feature is working as it should in the feature. Any thoughts? **UPDATE:** Good answers and thoughts from everyone I think. Some of you have stated, in one way or another, that you need to write your test first otherwise it is development-driven. I definitely agree with that when talking about TDD, since your test should drive your development. But when talking about BDD I'm not as sure that you have to write your test first, isn't BDD all about defining your behavior first? I think that looking at the UI and say: "hey I want this behavior/functionality here", sound quite behavior- driven to me. I don't say you should skip all your test but you could use the top-down approach as the first step as defining your behavior. I do think that when you have taken that first step and maybe implemented the feature in the UI with some mockup data you should start defining your test that verifies that behavior.


title: How does Jump Point Search algorithm work and why is it so efficient?

text: While trying out the below applet, I saw that this path finding algorithm called Jump Point Search yields significantly faster result than A* and Dijkstra. http://qiao.github.io/PathFinding.js/visual/ **A*: 46 seconds** ![enter image description here](http://i.stack.imgur.com/aWWxp.jpg) **Dijkstra: 1 minute 39 seconds** ![enter image description here](http://i.stack.imgur.com/X9dV4.jpg) **Jump Point Search: Less than 3 seconds** ![enter image description here](http://i.stack.imgur.com/InNV0.jpg) Needless to say, I'm quite astounded at the result. From visual representation, Jump Point Search seems to be making a lot of random guesses (probably very intelligent ones) at finding the path (from the block selection at least), but I haven't yet found a test case where this algorithm yielded worse results than A* and Dijkstra. How does this algorithm work? How is it so efficient in comparison with A* and Dijkstra?


title: Show all definitions in Scheme?

text: I want to see all user-made definitions in a Scheme REPL, both loaded from files and entered at the REPL. Is there any way to "dump all definitions"? E.g. if there is:                   (define (plusone x) (+ 1 x))         (define (plustwo x) (+ 2 x))         (define (plusthree x) (+ 3 x))      then I want to see all of these definitions, but only those defined by the "user" - something like ",showmealldefs" or thelike. Can this be done, and if there is no general way, can this be done in Gambit-C? (I tried (apropos ""), and this is not what I mean.)


title: Why are constructors not inherited?

text: I am confused as to what the problems could be if a constructor was inherited from a base class. Cpp Primer Plus says, > Constructors are different from other class methods in that they create new > objects, _whereas other methods are invoked by existing objects_. **This is > one reason constructors aren’t inherited**. Inheritance means a derived > object can use a base-class method, but, in the case of constructors, the > object doesn’t exist until after the constructor has done its work. I understand the constructor is called before object construction is completed. How can it lead to problems if a child class inherits ( _By inheriting I mean the child class is able to override the parent class method etc. Not just accessing the parent class method_ ) the parent constructor? I understand there is no necessity of explicitly calling a constructor from within a code[not that I am aware of as yet.] except while creating objects. Even then you can do so using some mechanism to invoke the parent constuctor [ In cpp, using `::` or using `member initialiser list`, In java using `super`]. In Java there is an enforcement to call it in the 1st line, I understand that is to ensure the parent object is created first and then the child object construction proceeds. It can **overrride** it. But, I can't come up with situations where this can pose a problem. If the child does inherit the parent constructor what can go wrong? So is this just to keep away from inheriting unecessary functions. Or is there more to it?


title: "Final" Scheme REPL definitions: how to save them?

text: Is there a way to show and save all "final" definitions entered into a Scheme REPL into a text file? Say, if I have defined in the REPL:                   (define (increase x) (+ 1 x))         (define (multbytwo x) (* 3 x)) ; let us say this was an error         (define (multbytwo x) (* 2 x))      I want to save this into an .scm-file with the content:                   (define (increase x) (+ 1 x))         (define (multbytwo x) (* 2 x))        * i.e. the multbytwo function that got defined erraneously shall be "forgotten" due to re-definition. Is this possible?


title: Best way to store motion changes to reduce memory

text: I am comparing jpeg to jpeg in a constant 'video-stream'. i am using EMGU/OpenCV to compare each pixels at the byte level. There are 3 channels to each image (RGB). I had heard that it is common practice to store only the pixels that have changed between frames as a way of conserving memory space. But, if for instance/example I say EVERY pixel has changed (pls note i am using an exaggerated example to make my point and i would normally discard such large changes) then the resultant bytes saved is 3 times larger than the original jpeg. How can I store such motion changes efficiently?


title: Best Practices for calculating data in GIS-like web application

text: Let's assume that we have a simple GIS-like application, which presents (using Google Maps or anything similar) recorded tracks. Each track consists of points (data portions) with geo-data and additional information, like speed, altitude and similar attributes. Basing on these additional params, I want to calculate some extra information, like average speed. What kind of data should web client receive and on which side is it the best to perform necessary calculations:   * _client side_ : client receives (via AJAX) pure array of data (points with additional params) and all the calculations are done in Javascript in the browser,   * _server side_ : client receives content ready to be put in the proper places, like value of average speed, and all the calculations are done on server. Personally I was always choosing (somehow automatically)the first option, as I thought (correct me, if I'm wrong) this gives me more flexibility. But, right now, after reading some docs and pages, I can see clearly, that I may be wrong. So, what is the best practice in such situation?


title: Are GUIs ever programmed in DirectX for higher performance?

text: I've been researching GDI a little and on some websites I'm lead to believe it can hardly draw a few boxes, while on others it can easily be used in an interactive charting application. So I'm wondering what is used in applications like Excel where there can be a lot movement like scrolling through a large amount of data fast? Could DirectX be used and would it increase performance? Is it used?


title: How to write a program that diffs on hierarchy changes?

text: Why is it that diff programs work on a line-by-line basis instead of a hierarchal one? All code can be expressed in a hierarchy, even though it's not immediately apparent. Most of the data we work with is hierarchal as well. What are the potential issues with building a piece of software that can diff based on hierarchy?


title: Is it a performance hit to create threads that loop a lot to check for things?

text: This is a generic question that I've always wondered. **In general, is it intensive for a CPU to create threads that perform "while not true ..." loops or similar?** For example, suppose I do:               // pseudo-code     new Thread(function() {         while (!useHasDoneSomething) {             // do nothing...         }         alert("you did something!");     }      So it's just a piece of code that runs in a thread that waits for something to happen. For whatever reason I imagine that this would pressure the CPU. After all, even though it's just one little loop, it's re-running the loop the instant that a cycle is done. Wouldn't this mean that it's going through the cycle many times per millisecond? ... Per nanosecond!? The operating system will "handle" the program and the thread(s), right? But that's still an awful lot of attention to running a loop. If the CPU has nothing else to do, wouldn't it just focus on that loop, thereby _consuming all the idle time_? **What if I create 1000 threads that all do the same loop? How might that affect performance/CPU cycles?** Furthermore, is this how **events** function internally? When you're 'listening' for an event in Java, .NET, Javascript etc (such as a button press or a window resize), has a thread that loops been created?


title: Which operating systems book is good as a quick refresher?

text: I am preparing for a technical interview and need to review the basics of major operating systems concepts. We used Tanenbaum's Modern Operating Systems in school for our operating systems course, which is a good book, but too long to be reviewed in the course of a few days. For an example, I am looking for what Programming Interviews Exposed is to Weiss's Data Structures & Algorithm Analysis. Any suggestions?


title: Web Application Development Question

text: I checked all the relevant question's of my query and their answer's but my questions aren't exactly listed anywhere. Basically i have just one year of web development experience using joomla , HTML , PHP etc.I have had .NET Training during my academics and now i have a requirement for a professional type .NET web application for a client.Since i don't have .NET production experience i want to ask and discuss few question's and have an advice from the expert's. **Scenario and Scope of the Project** : I am required to develop a web application for hotel management in .NET with modules like   1. User management ( actually roles like , administrator , reservation counter user , restaurant user etc ) with limited functionalities for each user except for the admin.   2. Reservation Module ( includes reservation stuff , alloting room's etc )   3. Billing Module (Includes pending bills from all department's at the time fo guest check out )   4. Reporting Module ( I am confused with this module.i actually want to incorporate a graphical type of a view to show to the end user but i dont think i can get that done using crystal report's. **Your Suggestion for this module would definitely help** )   5. Rates Setup. So , now i want your suggestion as to what should i start first and their best practises ?   * Database Designing.    * GUI Designing.   * Coding. In my opinion , coding should be the last.isn't it ? Also , please advise on security issues too as this is a web application so this must be safe and secure.I wont be using a SSL Certificate so the application would have to run on http only. P.S we are two developer's both have same experience if you could also share about how we can distribute modules among each other and how we can work on the same application accessing it through two laptop's locally only ? Thanks a lot and please dont get my question locked , removed as i couldn't find a relevant answer so this cant be a duplicate one or its context it too large.The question's have been clearly mentioned.Thanks again.


title: Is it possible for an amateur to become a good programmer?

text: A professional full-time programmer can do a great job by continuously learning from their work. How can an amateur programmer train to become a good programmer? ** If you like to play music or sing, you can do it because it is your hobby and you are interested, and you can become a good singer or music player. But you do not need to become a professional singer or do singing for a living. Is this also true for programmers ? Any amateur programmer who is famous?


title: searching for a user given word in a webpage using c# and selenium

text: I am trying to develop a selenium application (using c# win forms). So, while the application starts, the users will enter an app name in the text box. I have many fields such as cost, validity etc corresponding to each app. Example webpage:               description  appname  cost  validity  xyzattribute     --------------------------------------------------     some desc     app1     10      30     someattribute      I want selenium to search the entire page for that given app name and if it finds any, I want selenium to retrieve all the attributes (cost, validity) and store those in a variable. How can I achieve this? Please note that none of these fields have a unique attribute (such as name/id/any other).


title: User Authentication & Session Management

text: One of the fundamental ways of handling user login authentication & session management is by storing variables in Session space plus setting some data in cookies on client computer while sometimes in database as well. I have been using this simpler technique in many of my academic as well as a few online projects. But I am a little unsure about it. Do security critical websites like Amazon, Gmail or Facebook use the very same technique for user login & session management or is there more to it than I have known? This could turn out to be a very general question but I'd really like to know if there are other or mix of multiple ways used (like at gmail, stackexchange or myspace) for handling user login authentication & session management in particular.


title: Mocking complex data operations in integration tests

text: We have some problems figuring out how to mock complex data and operations on it. First the problems with generating complex data: In one of our components we have really complex data structures where the logic of our classes is executed. Unfortunate there are some bugs, where it is necessary to use a big data model to reproduce the case in a unit or integration test. The first idea was to write a script which converts the model to executable code, with which the data can be generated. To show the complexity of the models, these converted models had 20000++ line of code per model. The problem with the first approach was, that we had some little mistakes in our script and every time we identified one we had to rewrite all models. That was no good idea. The second idea is to use the xml files in which they are saved. Before the test starts we use a class to convert the xml file to the model. The result is better than the first idea, but with this we will never have plain unit tests, because we always rely on the class used for the conversion. Has someone a better idea how to deal with this issue? The second problem is even harder to solve: Manipulation of this complex data. We have a integration test of another component and want to mock all its dependencies. Somehow we create the initial data used by the component (some kind of AST). Now we a syntax check component as a dependency. This component takes in the data and decorates the data. So in the end we have another manipulated AST in the test. Here we have no idea, how to mock this behavior of the syntax check. Best regards, Yggdrasil


title: Are there any empirical studies on the effect of different languages on software quality?

text: The proponents of functional programming languages assert that functional programming makes it easier to reason about code. Those in favor of statically typed languages say that their compilers catch enough errors to make up for the additional complexity of type systems. But everything I read on these topics is based on rational argument, not on empirical data. Are there any empirical studies on what effects the different categories of programming languages have on defect rates or other quality metrics? (The answers to this question seem to indicate that there are no such studies, at least not for the dynamic vs. static debate)


title: Should I include GPL'd OS Projects on my resume?

text: I've recently had a talk with someone about how to include open source projects on my resume. I wanted to include a project of mine where I'd invested a significant amount of code and time: ~40,000 Lines of code and 8 months. He recommended against it though since it was GPL'd, saying it could turn off recruiters since I might include my project (in part or whole) while working there and force the whole project to be OS. I just don't think thats a realistic problem though, but I'm not sure. So my question: Is it safe to include GPL'd OS projects on my resume, or will it just turn recruiter's off?


title: Why is there still case sensitivity in some programming languages?

text: I don't see any use for case sensitivity in a programming language, apart from obfuscating code. Why implement this in a programming language? **Update:** It looks like someone you know made a statement on this.


title: What to say when you don’t know the answer to an interview question?

text: When you have no clue about the question, how do you answer/act when you do not know the answer at all? Telling the truth is pretty obvious. But how could you try to transform this weakness into a strength?


title: How to get multiple open-source projects to use a standard way of doing something

text: **\- Problem** In the last couple weeks, I've used 3 different "repository" tools (listed in alphabetical order):   * gradle   * ivy   * maven I'm calling them "repository" tools because I've also used sbt \-- which fortunately uses ivy to manage it's cache or local repository. Each of these tools will create it's own repository. The defaults are:   * ~/.m2/repository for maven   * ~/.gradle/cache   * ~/.ivy2/cache Why can't they all use the same cache? **\- Goal** I'd like to change the world so that all three build tools could use the same cache. I'm looking for advice about issues I'm likely to run into and smart ways to get around them. By "use the same cache", I do **_not_** mean "retrieve from another build tool's cache". I mean " **retrieve from and _store in_** another build tool's cache". While I could go ahead and submit issues to the three projects, I know from experience (as a developer on an open source project), that if you want something done, you're best off getting it done yourself. Also, it seems like I need to get all 3 communities on board to some degree. **\- Question** **What is the recommended approach for getting this kind of thing done?** How do I approach the different communities? Do I work on patches for the 3 different projects, or would it be better off to create my own "interface" project that deals with these issues and have the 3 tools interface with that? Is this a standards question that I need to address on that front? Lastly, if I'm missing something and this _is_ possible (in an globally configurable fashion), then please let me know.


title: Is switch-case over enumeration bad practice?

text: I have an enumeration with the commands `Play`, `Stop` and `Pause` for a media player. In two classes I do a switch-case over the received commands. The player runs in a different thread and I deliver the commands in a command queue to the thread. If I generate class diagrams the enumeration has dependencies all over the place. Is there a nicer way to deal with the commands? If I would change/extend the enumeration, I would have to change several classes. (Its not super important to keep the player extensible, but I try to write nice software.)


title: Backbone and JavaScript

text: I have been programming in JavaScript for just a little over two years give or take, I am still in the intermediate part of the know-how spectrum. I have recently just discovered Backbone and I love its minimalist way, and the way it gives me freedom to decide how to architect my application, problem is that, that is the problem, finding the best or at least an optimal solution that work for a variety of problems across the board is hard. Particularly for applications with complex UI interactions (basically things that have lots of bells and whistles like Stack Exchange for example). My problem is not so much about architecture as such, but how to organize my components and views in a way that they can communicate with each other while remaining 'totally' unaware of the details of each others existence To this end I decided to combine the Module pattern (a representation of it at best) and three other event based patterns i.e Event Emitter, Pub-Sub and Promises (also representations not the ideal). I developed an application class called Itajs on top of Backbone to help me make sense or at least control my applications execution. The application class provides ways for defining modules called mediators, routes, and uses a single backbone router, it also provides a way of subscribing to commands and firing/publishing these commands, and I also added three optional components (Entities, Controllers and PageMakers). One thing I wanted for my applications was that their views should remain as minimal as possible and should only care about user interactions, so, they don't make any data requests, they just fire events (Event Emitters), and the controllers take care of handling the events, that is, if u do use controllers. The controllers should take care of creating and controlling the views and handling the events they emit, and also get data and implement the application logic, this logic could in turn, be passed down to the models (if you are religious about it), so that controllers just become glorified data accessors, The PageMakers are there to make pages just as their name suggest, I use them to respond to routing requests that are responsible for new pages. The Entities are responsible for loading collections and models and responding to data requests, they handle client-server comm. After doing all that I realized at some point I was going to need a way to synchronize my application components in a serialized manner, so I came up with what I call a strict promise, that means that we first set what it to happen when the promise is resolved or rejected, and then fire the promise which for my architecture is just a command. For Clarity if I didn't make sense here is a breakdown for a typical application execution that uses all the components   * Create Application Instance    * Load the Config,    * Load all Entities,    * Load all Mediators     at each Mediator       load Controllers, PageMakers and what not       subscribe to Commands and register Routes     End During application execution:               OnRoute:        Call a PageMaker page handler           Fire Creation and Loading of the different views through single commands              or           Create and Fire a Promise chain             Controllers Create Views, Register for Event Handling and fire response             command for action when completed,passing back a view or any other args              handlers may need      OnCommand: Do whatever it may be that the handler might be doing, just make sure that you don't get caught in endless recursion or cycle. Here is a paste bin link to Itajs and Simple Use case with a mediator. Itajs Example P.S Itajs uses backbone events and something that really made me smile was the fact backbone doesn't register duplicate handlers for events, so no worries for duplicate controller event handlers on the views. Also the Backbone Views extend Backbone Events and therefore are event emitters themselves So the question is, is this a solution that can work and am I implementing the details in the right way, particularly the promises or am I locking myself into the synchronous mode that I am trying to break out of?


title: Grammar: start: (a b)? a c; Input: a d. Which error correct at position 2? 1. expected "b", "c". OR expected "c"

text: I am writing a parser (a parser generator for PEGs) and am trying to figure out how to report errors. Grammar:               rule: (a b)? a c ;      Input:               a d      Question: Which error message correct at position 2 for given input?   1. expected "b", "c".   2. expected "c". So should it be taken into account that "b" was also expected at position? The 1st error (expected "b", "c") wants to say that the input `a b` was expected but because it optional it is only a possibility, not a requirement. I don't know possible is the same as expected or not? Which error message better and correct: The 1st or the 2nd version? Thanks for answers. ## Second Part In first case I define marker of `testing` as limit of position.               if(_inputPos > testing) {       _failure(_inputPos, _code[cp + {{OFFSET_RESULT}}]);     }      Limit moved in optional expressions:               OPTIONAL_EXPRESSION:     testing = _inputPos;      The "b" expression move `_inputPos` above the `testing` pos and add failure at `_inputPos`. In second case I can define marker of `testing` as boolean flag.               if(!testing) {       _failure(_inputPos, _code[cp + {{OFFSET_RESULT}}]);     }      The "b" expression in this case not add failure because it tested (inner for optional expression). What you think what is better and correct?   1. Testing defined as specific position and if expression above this position (_inputPos > testing) it add failure (even it inside optional expression).   2. Testing defined as flag and if this flag set that the failures not takes into account. After executing optional expression it restore (not reset!) previous value of testing (true or false). Also failures not takes into account if rule not fails. They only reported if parsing fails. ## Third Part This question raised because it related to two different problems. First problem: A Parsing Expression Grammar (PEG) describes input in only three atomic items:   * terminal symbol   * nonterminal symbol   * empty string The grammar doesn't use a lexer, hence the concept of a “token” does not apply here. Second problem: What is a grammar? Can two grammars be considered equal if they accept the same input but produce different result? Assume we have two grammars: Grammar 1               rule <- type? identifier      Grammar 2               rule <- type identifier / identifier      They both accept the same input but produce (in PEG) different result. Grammar 1 results:   * `{type: type, identifier: identifier}`   * `{type: null, identifier: identifier}` Grammar 2 results:   * `{type: type, identifier: identifier}`   * `{identifier: identifier}` Questions:   * Are both grammars equal?   * It is painless to do optimization of grammars? My answer on both questions is negative. No equal, Not painless. But you may ask. "But why this happens?". I can answer to you. "Because this is not a problem. This is a feature". In a PEG grammar each rule _always_ consists from these parts:   * ordered choice      * sequence        * expression And this explanation is the my answer on question "But why this happens?". Another problem. As a PEG does not have tokens, whitespace cannot be silently ignored in the lexer between tokens. Therefore whitespace has to be considered inside the grammar. Now look at this grammar (in short):               program    <- WHITESPACE expr EOF     expr       <- ruleX     ruleX      <- 'X' WHITESPACE     WHITESPACE <- ' '?     EOF        <- ! .      The first `WHITESPACE` is at the beginning, other `WHITESPACE (often) occurs at the end of a rule. In this case in PEG optional `WHITESPACE` must be assumed as expected. But `WHITESPACE` does not only mean space (`\x20`) but also other characters like `[\t\n\r]` and even comments. But the main rule of error messages is the following. > If it is not possible to display all expected elements (or not possible to > display at least one from all set of expected elements) then is more correct > to not display anything. More precisely required to display "unexpected" error mesage. So how would I display in a PEG's error message that `WHITESPACE` was expected?   * `Parser error: expected WHITESPACE`   * `Parser error: expected ' ', '\t', '\n' , 'r'` What about start characters of comments? They also may be part of `WHITESPACE` in some grammars. In this case optional WHITESPACE will be reject all other potential expected elements because not possible correctly to display WHITESPACE in error message because WHITESPACE is too complex to display. Is this good or bad? I think this is not bad and required some tricks to hide this nature of PEG parsers. And in my PEG parser I not assume that the inner expression at first position of optional (optional & zero_or_more) expression must be treated as expected. But all other inner (except at the first position) must treated as expected. Example 1:               List<int list; // type? ident      Here "List" is not at the first position in optional "type?". This failure is taken into account and reported as "expected '>'". This is because we don't skip `type` but enter into `type` and after really optional "List" we move position from first to next real "expected" (that already outside of testing position) element. "List" was in "testing" position. If inner expression (inside optional expression) "fits in the limitation" not continue at next position then it not assumed as the expected input. From this assumption has been asked main question. You must just take into account that we are talking about PEG parsers and their error messages.


title: Does a time estimate equal a promise in Scrum?

text: If an estimate is not a promise then as a product owner how can I deliver my projects without knowing how long it will take? Does a Scrum team work more efficiently if we treat time estimates as a promise? How much research (preparation, effort to understand the problem) in a story is enough to come up the right estimate? What about unexpected technical problems (problems that can really mess your initial estimates) that come up after you estimate your work?


title: WCF service to get an atom feed

text: I am very new to programming and my first task is to create a WCF service that will take an ATOM feed and expose it to my application. Now, I've read up on XML serialization and syndication but it doesn't seem to be what I need in my (lack of) experience. Here is a snippet of the feed. It's generated by a seedlist spi               <atom:generator version="1.2" lconn:version="4.5.0.0">     Seedlist Service Backend System</atom:generator>     <wplc:timestamp isPartial="false">AAABQtdnfpE=</wplc:timestamp>     <atom:category term="ContentSourceType/Wikis" scheme="com.ibm.wplc.taxonomy://feature_taxonomy"      label="Wikis"/>     <atom:title>Wikis : 0 entries of Seedlist WIKIS</atom:title>     <atom:updated>2013-12-09T13:49:13+01:00</atom:updated>      Do I need to create objects for all these elements? And what about these wplc elements?               <wplc:action do="update"/>     <wplc:fieldInfo id="FIELD_ENTRY_TYPE" name="item type"      description="item type - page, file or wiki" type="string"      contentSearchable="false" fieldSearchable="true"      parametric="false" returnable="true" sortable="false"      supportsExactMatch="false"/>     <wplc:fieldInfo id="FIELD_TAG" name="Tag"      description="Document tag" type="string"      contentSearchable="true" fieldSearchable="true"      parametric="false" returnable="true" sortable="false"      supportsExactMatch="true"/>      All the examples, tutorials and explanations I find are of simple xml files So can I just use XML Reader to achieve this? And if so, I need some help. Here is a sample WCF I found:               public class Service1 : IService1         {             public string GetData(string value)             {                 WebRequest request = WebRequest.Create("http://wheremyxmlis/file.xml");                 WebResponse response = request.GetResponse();                 Stream dataStream = response.GetResponseStream();                 XmlReader reader = XmlReader.Create("http://wheremyxmlis/file.xml");             reader = new XmlTextReader("http://wheremyxmlis.xml");                  try             {                           reader = new XmlTextReader("http://wheremyxmlis/file.xml");                                while (reader.Read())                 {                     switch (reader.NodeType)                     {                         case XmlNodeType.Element:                             Console.Write("<{0}>", reader.Name);                             break;                         case XmlNodeType.Text:                             Console.Write(reader.Value);                             break;                         case XmlNodeType.CDATA:                             Console.Write("<![CDATA[{0}]]>", reader.Value);                             break;                         case XmlNodeType.ProcessingInstruction:                             Console.Write("<?{0} {1}?>", reader.Name, reader.Value);                             break;                         case XmlNodeType.Comment:                             Console.Write("<!--{0}-->", reader.Value);                             break;                         case XmlNodeType.XmlDeclaration:                             Console.Write("<?xml version='1.0'?>");                             break;                         case XmlNodeType.Document:                             break;                         case XmlNodeType.DocumentType:                             Console.Write("<!DOCTYPE {0} [{1}]", reader.Name, reader.Value);                             break;                         case XmlNodeType.EntityReference:                             Console.Write(reader.Name);                             break;                         case XmlNodeType.EndElement:                             Console.Write("</{0}>", reader.Name);                             break;                     }                 }             }                  finally             {                 if (reader != null)                     reader.Close();                           response.Close();


title: How do freelancers know how much their work is worth?

text: I want to start a bit of freelancing in web development using ASP.NET MVC3 and PHP and I already have some people who are interested in hiring me, but I still can't figure out how much to charge for projects since I have never done it. For example how much would this site cost? Would it cost more if the author built it from scratch instead of using WordPress as the CMS? Or what about a simpler site like this? How much time spent is considered good/normal for building sites like these? And maybe some freelancers with experience can tell me what the usual requests are that they get from clients. What sites are the most in demand? I'm asking because I'm a student and I really can't work every day in a full- time job but I need the money so I guess a little freelancing would help me out.


title: return Trivial booleans?

text: I am writing a simple piece of code. Its a function that allowed the user to withdraw some money. There are some restrictions to this though.   1. The user can't withdraw more than the given withdraw limit.   2. The user cannot withdraw more money they that have.  The script will terminate if this happens, and let the users know. Otherwise they user can withdraw the money and the balance updates, they also get a confirmation message. Now my question is should I return `False` if they hit either case 1 or 2? And should I return `True` if the transactions completes successfully? I do not have any current plans where I will need the booleans from the function call. But I wonder is it good coding practice to return something in a case like where the function could take different paths. Some example code (Python):               limit = 500     balance = 5000          def withdraw_money(amount):         if amount > limit:  # above the limt             print('You cannot withdraw more than ${}'.format(balance))             return False         elif amount > balance:  # not enough money             print('Insuffecient funds')             return False         else:  # actually worked             balance -= amount             print('Your new balance is ${}'.format(balance))             return True


title: Interviewing: Company deals with huge amounts of data?

text: A company I'm going to interview with says they deal with huge amounts of data. How does one prepare for an interview where that fact is telegraphed beforehand as something that one really ought to ponder over? Should I memorize maximum file sizes for Ext4 file systems or something? Or just be aware of the need for the best possible algorithms... Thanks.


title: Should I be learning Linq, Direct SQL Commands (in .net), EF or other?

text: Basically, I have a very good knowledge of plain old SQL coming from Classic ASP programming. Over the past couple of months, I have been learning C# and today was my first full day at MVC 3 (Razor) which I am loving! I need to get back in to Databases and I know that writing SqlCommand everywhere is obviously outdated (although it is nice I can still do it!). I used to go to a great usergroup as an IT Pro and the developer stuff went completely over my head, however I do remember a few things which kept coming up such as LINQ... However, that was some time ago and now the same people on Twitter are saying how out dated it is. I have tried to do research on both and I am clueless as to what direction I should go in, or when to use one over another (if learning both is a good thing). I am more so confused as I thought EF was a part of the .Net Framework, however, reading through the quick start guide, I had to download a component using Nuget. ... Basically I am out of my depth here and just need some honest advice of where to go!


title: Discrete Math and Computing Course

text: I was recently admitted into a Computing and Software Systems program (basically software engineering) and one of the first courses I'll be taking is called _Mathematical Principles of Computing_. The course description: _"Integrating mathematical principles with detailed instruction in computer programming. Explores mathematical reasoning and discrete structures through object-oriented programming. Includes algorithm analysis, basic abstract data types, and data structures."_ I'm not a fan of math, but I've been doing well in all my math classes mostly A's and B's ever since I started two years ago, and I've been doing math every quarter - never took a quarter without math - so I've been doing it all in sequence without gaps. However, I'm worried about this class. I've read briefly on what discrete math is and from what my advisor told me, its connection with computer science is that it has alot to do with proving algorithms. One thing that my instructors briefly touched on and never went into detail was proving algorithms, and when I tried, I just wasn't very good at mathematical induction. It's one of the things that I ignored every time it showed up in a homework problem (usually in Calculus III which I'm finishing up right now). Questions:   1\. What can I expect from this class?   2\. How can I prepare myself for this class?   3\. Other tips? Thank you.


title: mistyping pattern data?

text: Can someone point me to data or research on the patterns of mistyping on a keyboard? For instance, I've noticed that google will sometimes auto-correct a word that I've mistyped because my hand was out of position and each key was shifted one to the right. I'm also interested words where there is a mis- coordination between both hands, such as `teh`, and any other misspellings that are artifacts of keyboards and manual dexterity. We're looking at some user-friendly auto-correct functions, and I want some data to help our team get an overview of the landscape and decide what we will and will not handle.