title: Product Owner and automated tests

text: One of the claims of BDD-style development is that it bridges the gap between Product Owner and developers: the Product Owner writes a story, which can be converted in an equivalent automated test "frame" that should eventually pass. What I would like to hear is how to keep bridging the gap after that: once there are automated tests in place, how do you help the Product Owner review them? Or is it enough for the Product Owner to know that the test passes, without looking at the test code itself? In short, how intimate should the Product Owner be with the actual tests implemented, and how do you keep him/her productively involved with the tests beyond the initial story writing? The reason behind this question is double. First, between the paper story and the implementation details, some assumptions may sneak in, and having the author of the story review the test can be invaluable. On the other hand, the implementation introduces quite a bit of noise, too, and requires the PO to become fairly technical (read code, run tests). Is the test implementation a "developer's detail", or is it fair to request the PO to become a bit of a developer in this area? Then, in most case, the PO can actually validate the test without the automated test, by simply using the application. However, some stories are "headless" and can only be verified via code, so unless the PO knows how to read and run tests, he/she will never be able to state that he verified the story complete.


title: Single-Tenant Databases - creating and updating new tenants via PHP

text: We've built a single-tenant webapp in PHP and as it stands each hosted 'site' has its own database. However we need to be able to run a script to create their database, assign a mysql user, and insert the default sql. Now, we've got the database and user stuff working fine, its just the importing of the SQL. From what I can tell, PHP quite simply sucks when it comes to handling sql files, so storing a 'template' sql file seems to be out of the question. My next thought was maybe storing a live database which is then cloned, giving the site its pre-populated database, however I cant see how this would work. At the same time, I'd rather not 'hard code' the table creations into PHP as if we perform any updates we want to be able to update the SQL direct from our backend control panel. Surely there has to be a logical way of handling creations and updates on a multi-tenant SaaS?


title: How to update dependency during runtime in my .NET application?

text: I have a server-client application. Sometimes the server is updated which requires some DLLs in the client to be updated as well (The DLLs are the dependencies of the main executable). For now, we have to close the client, manually deploy the DLLs, and then start the client again. This is kind of an inconvenience because the client is an automated application, so normally it doesn't need any user intervention. Is it possible for this to be done automatically without restart or user intervention? Like, the client would download the latest DLL, and replace the current one?


title: Is a code review which uses only code comments a good idea?

text: ## Preconditions   * Team uses DVCS   * IDE supports comments parsing (like TODO and etc.)   * Tools like CodeCollaborator are expensive for budget   * Tools like gerrit are too complex for install or not usable ## Workflow   * Author publishes somewhere on central repo feature branch   * Reviewer fetch it and start review   * In case of some question/issue reviewer create comment with special label, like "REV". Such label MUST not be in production code -- only on review stage:              $somevar = 123;     // REV Why do echo this here?     echo $somevar;        * When reviewer finish post comments -- it just commits with stupid message "comments" and pushes back   * Author pulls feature branch back and answer comments in similar way or improve code and push it back   * When "REV" comments have gone we can think, that review has successfully finished.   * Author interactively rebases feature branch, squashes it to remove those "comment" commits and now is ready to merge feature to develop or make any action that usualy could be after successful internal review ## IDE support I know, that custom comment tags are possible in eclipse & netbeans. Sure it also should be in blablaStorm family. ![Example of custom filtered task-from-comments in eclipse](http://i.stack.imgur.com/Iq6wo.png) ## Questions   1. Do you think this methodology is viable?   2. Do you know something similar?   3. What can be improved in it?


title: SDLC approach for small size projects

text: For small size projects, is it worth following the SDLC? is SCRUM/agile development a better approach? **Edit** : The project I have in mind is a small change but it will affect multiple layers/parts of the application, so there will be 2 or 3 developers involved each from a different team, then the code will be integrated at a later step. Thanks.


title: Does condition coverage subsume edge coverage?

text: I'm a little bit confused about code coverage criteria; especially condition and edge coverage. As stated in this book, edge coverage does not subsume condition coverage; BUT my lecture material defines condition coverage in the following way: _Edge Coverage Criterion:_ Select a test set `T` such that, by executing a program `P` for each `d` in `T`, each edge of `P`‘s control flow graph is traversed at least once _Condition Coverage Criterion:_ Select a test set `T` such that, by executing `P` for each element in `T`, each edge of `P`‘s control flow graph is traversed, and all possible values of the constituents of compound boolean conditions are exercised at least once. So, the first part of the definition of condition coverage is obviously the same as the whole definition of edge coverage. Hence, I thought condition coverage implies edge coverage ... Is the definition broken? What's correct?


title: If every instance of a type is to be random, how should the Random generator object be stored?

text: It seems to me that this is often encountered in practice and I was wondering if there is a design pattern for the following: Suppose I have a class that represents a card:               public class Hand {         private static Random rng;         private Rank rank;         private Suit suit;         public Hand() {             if (prng == null)                 prng = new Random();             }             //more stuff         }     }      Every time I instantiate a Card, I want a random card. Doing it the above way wastes one comparison to null per instantiation. If I create a static field and allocate it in the deceleration:               private static Random rng = new Random();      a new Random object gets instantiated every time - also not very efficient. If I pass the Random object into the constructor, I violate "tell, don't ask." Perhaps there is another suggestion, but so far, I think the best way is the null check.


title: Asterisks in Multi-line comments

text: Using Visual Studio 2012 with C#, when I write multi-line comments, VS automatically begins each line with an asterisk, like this:               /*      *      *      */      I was just curious if this was the case in programming languages other than C#, or if there was a specific reason for this template.


title: Is use of finally clause for doing work after return bad style/dangerous?

text: As part of writing an Iterator, I found myself writing the following piece of code (stripping error handling)               public T next() {       try {         return next;       } finally {         next = fetcher.fetchNext(next);       }     }      finding it slightly easier to read than               public T next() {       T tmp = next;       next = fetcher.fetchNext(next);       return tmp;     }      I know it's a simple example, where the difference in readability may not be that overwhelming, but I'm interested in the general opinion as to whether it is bad to use try-finally in cases like this where there are no exceptions involved, or if it is actually preferred when it simplifies the code. If it's bad: why? Style, performance, pitfalls, ...? **Conclusion** Thanks you all your answers! I guess the conclusion (at least for me) is that the first example might have been more readable if it was a common pattern, but that it isn't. Therefore the confusion introduced by using a construct outside of it's purpose, along with possibly obfuscated exception flow, will outweigh any simplifications.


title: Portability: Python's C/C++ libraries/extensions vs JRuby's Java libraries

text: I've had some discussion with colleagues who chose to go with JRuby along the following line of argumentation: JRuby can make use of anything that is available in Java, ergo such programs are more portable bc Java is more portable. Arguably, the breadth, capability and speed of C/C++ libraries that have been wrapped for Python is still better than what is available in Java. But since this is C/C++, all the problems with portability reappear this way - or so their argument went. Have you ever had such a problem? that is, problem with portability of Python's extensions? Personally, I have never found this to be a problem, but YMMV, while theoretically and potentially this is a problem. I'm curious of your experiences.


title: What problem domain is LINQ made for?

text: Each time I see a question posted on Stack Overflow on C#, I see at least one or two answers posted that solve a problem with LINQ. Usually people with very high reputation seem to use LINQ like pros. So my question is, **what problem domain is LINQ supposed to be used for?** Also on side notes: Are there any purposes in which it should be avoided? Does the size of dataset affect the performance of LINQ queries?


title: Are developers a stakeholder in a system

text: Are developers of a product considered stakeholders?


title: Optimal movie schedule

text: Let's say Mr. A goes to cinema and he gets a movie schedule. There are N movies on the program today (1 < N < 50) and for every movie the time of the start and the time of the end are given in minutes. Mr. A wants to see as much minutes of movies as possible. But, there is one rule in the cinema: If a movie starts, you can't watch it. In other word if Mr. A watches Movie 1 and in meantime Movie 2 starts, Mr. A can't watch it. Find the maximum number of minutes that Mr. A can spend watching movies. * * * At first I sorted the movies according to their starting time. Then I made a NxN matrix and fill it with false values. Now if Movie X and Movie Y intersect, i.e play in the same time even just for a minute, then Matrix[X][Y] and Matrix [Y][X] get true value. Then I check the case when every movie is in the optimal solution. I put them into vector. Now using recursion I check every possible combination. If Movie X doens't have an intersection with every movie of the vector, I put into the vector, since there will be no intersection and then I move on to the next movie. And so on. This algorithm works, but I think that it's too much time-consuming and as I want to say it's "modified brute-force". Is there any better way to reach the optimal solution. NOTE: We are interested only about the maximum numbers of minutes, not in the maximum number of movies. At the end the program should print the maximum number of minutes, not a list of the movies Mr. A should watch.


title: Iterating calculations - children of children of children

text: I would like to move some business logic out of my application and into a stored procedure or function. I am willing to change rdbms as the system is being updated/re-written. Right now it's Access 97 (see why it's being updated?) but a while ago when I last looked, SQLserver couldn't handle it either. At least I couldn't see how. The basic problem is this- An assembly gets used, and the use is logged. I need to apply the use to the sub-assemblies, and their sub-assemblies, and so on until I end up at the elemental parts of the assembly. Maybe four or five levels deep. Knowing how many parts were made per hour I calculate how many "uses" each part received. The tricky bit is that the sub-assemblies can be changed out during the usage. For example, a machine runs for 40 hours, and the tooling sub-assembly is changed four times. Sometimes the clamp bolt on the tooling is changed but the tooling sub-assembly is not. I have the on and off timestamps when things - sub-assemblies and/or parts - were installed and removed, and what they were installed on in a history table. Currently I have code that calculates how many parts were made by the machine, and then looks for any sub-assemblies installed on the machine and calculates how many parts each installed assembly made, then looks at things installed on that until I run out of children. Surely some rdbms has come along since Access 97 that can do such a thing? Thanks!


title: Can anyone recommend a toolchain-agnostic way of declaring and documenting inter-package build dependencies?

text: I currently have a project at my hand that I'll leave soon (PhD work) and should be left in an understandable form since it is likely to be taken up, though it is not known yet by whom and when. Therefore, I'd like to leave at least some documentation how it is built. The project consists of 7 packages, each of which is an independent source code package whose compilation only depends on libraries and headers from other packages. The whole build process revolves around open source standards, i.e. each project is built by autoconf and automake, is Debian-ized and the interpackage dependencies are declared in the Debian packages and checked in configure scripts. However, this feels like a quite specific way of specifying a quite general problem. It is likely that the next maintainer would want to build the software with a Windows GUI thingy that doesn't know anything about autoconf or Debian. I'd like to leave more rigid documentation in this case than a bunch of comments in the assorted INSTALL files and the Build-Depends/Depends declarations in the Debian files. Is there any toolchain-agnostic established language or standard to document packaging and build order? Bonus points if the actual build system specifications (like Debian Build-Depends) could be generated from that.


title: Anti-depressant and programming: does it reduce your thinking and focusing abilities?

text: I wanted to ask your opinion on anti-depressants, since I took them daily for 3 years now, but I can't be sure if I'm less perfomant with them or without, since I never withdrawed. I'm still at school at the age of 25, still having some motivation problems (for example I can't get used to do something at school if I don't think it will teach me something), but I'm quite motivated to work in the video-game field, since I have some personnal projects in mind. I know C++ programming etc, I'm still learning techniques, but do you think I should try more to do my project instead of just following the work I'm assigned to ? Have you had experience with depression or anti-depressants ? How did it affect your work ? Do you think that being depressed or half-depressed can improve creativity ? Do you feel it has affected the way you end up writing your algorithms ? EDITED


title: return nhibernate entity from web api?

text: Is it a good idea to return nHibernate Entity from WebApi? For simple entity I tried to use this but what about complex entities. How will lazy loading be handled in that case?


title: How do you learn a new programming language?

text: I am C++ developer with some good experience on it. When I try to learn a new language ( have tried Java, C#, python, perl till now) I usually pickup a book and try to read it. But the problem with this is that these books typically start with some very basic programming concepts such as loops, operators etc and it starts to get very boring soon. Also, I feel I would get only theoeritcal knowledge without any practical knowledge on writing the code. So my question is how do you tacke these situations? do you just skip the chapters if its explaining something basic? also, do you have some standard set of programs that you will try to write in every new programming language you try to learn?


title: What is an effective way to familiarize yourself with a new application in a new language?

text: > **Possible Duplicate:**   >  How do I pick up a new language quickly, given I know several others? I started a new job working on an application I'm vaguely familar with, and it's in PERL! I come from a PHP and Java background, so while I understand the basics, there are lot of nuances in PERL that make it troublesome. _updated_ < Im supposed to be a UI developer, but the smallness of the office requires me to learn and do a lot more than just javascript. So that was slightly unexpected in some aspects and I'm just thinking about what approach to take with this > / _updated_ So far I've been sifting through the code to understand what each part does, printed out copies of code and try to lookup APIs I'm not familiar with, and so I dunno how effective this process is -- I feel like it's gonna take some time -- and I dont want my new employers to feel like I'm not being productive. Anyone have some ideas or approaches for this kind of situation? I read some of the questions about learning new languages, but I'm curious to see if anyone's had experience with this with PERL.


title: How do I pick up a new language quickly, given I know several others?

text: One type of question that keeps coming up on Programmers.SE is how to learn a specific language, given you know several others (usually through a lot of experience or education). In some cases, however, one might need to get up to speed quickly for a job, or for personal development, or even to check out a hot new platform. In your experience, what general strategies have you used to pick up a new language quickly? Are there specific aspects of a language you try to focus on when starting cold? What _types_ of resources do you find helpful in this process?


title: How would you react if someone told you your code is a mess?

text: I am a good programmer, or so I thought before. I always love to program. And I want to learn many things about programming to make me a better programmer. I studied programming for 1 year and now I am working as a programmer for almost 2 years. So in short, I have almost 3 years programming experience. Our team is composed of 5 programmers, and 4 of us are new, 1 has more than 3 year experience. We've been working for a program for almost a year now and nobody ever review my code and I was given a page to work with. We never had a code review and we are all new so we don't know what is a clean code looks like. I think programmers learn by themselves? We deployed our program to the program without thorough testing. Now it is tight and we need an approval and code review first before we make changes with the code. For the first time, someone reviews my code and he says it is a mess. I feel so sad and hurt. I really love programming and making them say something like that really hurts me. I really want to improve myself. But it seems like I'm not a genius programmer like in the movies. Can you give me advise on how to be better? Have you ever experience something criticizing your code and you feel really hurt? What do you do on those events.


title: C programming in Windows 7

text: Which is the best book and what are the best tools for C programming in Windows 7? Would using C in any way hinder me when it comes to using the Windows API as opposed to using C++ or C#? I would like to use C, because it seems to me that object-oriented programming is bad for performance and the abstraction seems only counter-productive if the right people are doing the programming. I will mostly do GUIs and background services that do a lot of networking, possibly at OSI Layer 2, and public key + cascaded symmetric key cryptograpy. Also, the core of the programs (excluding any that deal directly with OSI Layer 2) should be portable to Android.


title: How a VB6 programmer can update his skills and get qualified for the current job opportunities in the USA?

text: I'm going to the U.S.A. and was wondering how I can get a job there. I've been a developer for 3 years. Well, I've been working on big projects like the core banking system of one of the biggest banks of the country and I'm quiet good at programming and problem solving skills in general. But unfortunately these projects were developed using VB6 and I haven't been able to update my skills. I have a background in C# but I'm not proficient in it. So VB6 is the only language that I'm good enough to get a job. And I'm pretty sure that's not gonna help me to find a job in the US. So how Should I update my skills to be qualified for a windows application developer? Should I go to college or something like that? I'm in a bad situation and I have no idea what to do. Any help from you would mean a lot to me and is hugely appreciated. Thanks in advance. Edit: Basile, Graham, spaceknarf and tgkprog thanks for sharing your knowledge with me.


title: Releasing open-source software including Apache2 and LGPL libraries?

text: I am writing software (in Java) using three libraries:   * Library A, licensed under **MIT license**   * Library B, licensed under **Apache License, Version 2.0**   * Library C, licensed under **LGPLv3** I would like to make my software publicly available under the MIT license. I'm going to include all libraries in **source** and binary form (jar), including the their **original licenses** and **copyright notices**. I put a **LICENSE** file at the root of my project with the MIT license. I believe this should cover all requirements of MIT and LGPLv3, but I'm wondering about the NOTICE file mentioned in the Apache license. > If the Work includes a "NOTICE" text file as part of its distribution, then > any Derivative Works that You distribute must include a readable copy of the > attribution notices contained within such NOTICE file, excluding those > notices that do not pertain to any part of the Derivative Works, in at least > one of the following places: within a NOTICE text file distributed as part > of the Derivative Works; within the Source form or documentation, if > provided along with the Derivative Works; or, within a display generated by > the Derivative Works, if and wherever such third-party notices normally > appear. The contents of the NOTICE file are for informational purposes only > and do not modify the License. You may add Your own attribution notices > within Derivative Works that You distribute, alongside or as an addendum to > the NOTICE text from the Work, provided that such additional attribution > notices cannot be construed as modifying the License. http://www.apache.org/licenses/LICENSE-2.0.html Does this simply mean that I have to include the NOTICE files that come with the library, or do I have to write my own NOTICE file mentioning the libraries and their copyrights? Second, are there any other requirements that I may have missed? Finally, let's suppose I'm also using Library D, licensed under **GPLv3**. How does that change the situation? I understand that in this case I would have to release my project under GPLv3. Any other implications? Please understand that I'm a student and I cannot afford a lawyer. :)


title: Programmatically manipulate expressions accounting for operator precedance

text: There are times when an expression becomes confusing because of implicit operator precedence. Take this Python expression:               a, b, c, d = range(4)     e = a + b // c << d >> a ** b or a + c * d // c % c      With other languages it can become even more convoluted. Suffice to say, an experienced developer may do a double-take at code like this and add some parenthesis to clarify whats going on. While this is something you can do manually, It risks some human error, I'm curious if there are existing solutions which make the operator precedence explicit by adding parenthesis (Am not so fussed about the exact language, anything with in-fix operators is fine). Though not my aim, one could (for example), take some obfuscated code from http://www.ioccc.org and get a little closer to having something understandable. * * * _Note, for the purpose of this question, I'm not worried about non- communicative behavior of floating point operations in some languages._


title: Create Primary Interop Assemblies or generate them?

text: I've never seen this question answered definitively: If you are maintaining a COM DLL that can be used by a .NET program, is it best to:   1. Import the COM DLL into each project, which generates an Interop assembly for each project? or   2. Generate the Primary Interop Assembly with TLBIMP every time the COM DLL is compiled? or   3. Write the Primary Interop Assembly in C# and compile that every time the COM DLL is compiled? I would like to do either number 2 or number 3. Number 2 sounds compelling, but I cannot see how you set the _AssemblyTitleAttribute_ (and other such attributes); I would assume you use custom attributes in the IDL which TLBIMP would pick up.


title: Unit-testing of inherently random/non-deterministic algorithms

text: My current project, succinctly, involves the creation of "constrainably-random events". I'm basically generating a schedule of inspections. Some of them are based on strict schedule constraints; you perform an inspection once a week on Friday at 10:00AM. Other inspections are "random"; there are basic configurable requirements such as "an inspection must occur 3 times per week", "the inspection must happen between the hours of 9AM-9PM", and "there should not be two inspections within the same 8-hour period", but within whatever constraints were configured for a particular set of inspections, the resulting dates and times should not be predictable. Unit tests and TDD, IMO, have great value in this system as they can be used to incrementally build it while its full set of requirements is still incomplete, and make sure I'm not "over-engineering" it to do things I don't currently know I need. The strict schedules were a piece-o'-cake to TDD. However, I'm finding it difficult to really define what I'm testing when I write tests for the random portion of the system. I can assert that all times produced by the scheduler must fall within the constraints, but I could implement an algorithm that passes all such tests without the actual times being very "random". In fact that's exactly what's happened; I found an issue where the times, though not predictable exactly, fell into a small subset of the allowable date/time ranges. The algorithm still passed all assertions I felt I could reasonably make, and I could not design an automated test that would fail in that situation, but pass when given "more random" results. I had to demonstrate the problem was solved by restructuring some existing tests to repeat themselves a number of times, and visually check that the times generated fell within the full allowable range. Does anyone have any tips for designing tests that should expect non- deterministic behavior? **EDIT:** Thanks to all for the suggestions. The main opinion seems to be that **I need a deterministic test in order to get deterministic, repeatable, assertable results**. Makes sense. I created a set of "sandbox" tests that contain candidate algorithms for the constraining process (the process by which a byte array that could be any long becomes a long between a min and max). I then run that code through a FOR loop that gives the algorithm several known byte arrays (values from 1 to 10,000,000 just to start) and has the algorithm constrain each to a value between 1009 and 7919 (I'm using prime numbers to ensure an algorithm wouldn't pass by some serendipitous GCF between the input and output ranges). The resulting constrained values are counted and a histogram produced. To "pass", all inputs must be reflected within the histogram (sanity to ensure we didn't "lose" any), and the difference between any two buckets in the histogram cannot be greater than 2 (it should really be <= 1, but stay tuned). The winning algorithm, if any, can be cut and pasted directly into production code and a permanent test put in place for regression. Here's the code:                   private void TestConstraintAlgorithm(int min, int max, Func<byte[], long, long, long> constraintAlgorithm)         {             var histogram = new int[max-min+1];             for (int i = 1; i <= 10000000; i++)             {                 //This is the stand-in for the PRNG; produces a known byte array                 var buffer = BitConverter.GetBytes((long)i);                      long result = constraintAlgorithm(buffer, min, max);                      histogram[result - min]++;             }                  var minCount = -1;             var maxCount = -1;             var total = 0;             for (int i = 0; i < histogram.Length; i++)             {                 Console.WriteLine("{0}: {1}".FormatWith(i + min, histogram[i]));                 if (minCount == -1 || minCount > histogram[i])                     minCount = histogram[i];                 if (maxCount == -1 || maxCount < histogram[i])                     maxCount = histogram[i];                 total += histogram[i];             }                  Assert.AreEqual(10000000, total);             Assert.LessOrEqual(maxCount - minCount, 2);         }              [Test, Explicit("sandbox, does not test production code")]         public void TestRandomizerDistributionMSBRejection()         {             TestConstraintAlgorithm(1009, 7919, ConstrainByMSBRejection);         }              private long ConstrainByMSBRejection(byte[] buffer, long min, long max)         {             //Strip the sign bit (if any) off the most significant byte, before converting to long             buffer[buffer.Length-1] &= 0x7f;             var orig = BitConverter.ToInt64(buffer, 0);             var result = orig;             //Apply a bitmask to the value, removing the MSB on each loop until it falls in the range.             var mask = long.MaxValue;             while (result > max - min)             {                 mask >>= 1;                 result &= mask;             }             result += min;                  return result;         }              [Test, Explicit("sandbox, does not test production code")]         public void TestRandomizerDistributionLSBRejection()         {             TestConstraintAlgorithm(1009, 7919, ConstrainByLSBRejection);         }              private long ConstrainByLSBRejection(byte[] buffer, long min, long max)         {             //Strip the sign bit (if any) off the most significant byte, before converting to long             buffer[buffer.Length - 1] &= 0x7f;             var orig = BitConverter.ToInt64(buffer, 0);             var result = orig;                  //Bit-shift the number 1 place to the right until it falls within the range             while (result > max - min)                 result >>= 1;                  result += min;             return result;         }              [Test, Explicit("sandbox, does not test production code")]         public void TestRandomizerDistributionModulus()         {             TestConstraintAlgorithm(1009, 7919, ConstrainByModulo);         }              private long ConstrainByModulo(byte[] buffer, long min, long max)         {             buffer[buffer.Length - 1] &= 0x7f;             var result = BitConverter.ToInt64(buffer, 0);                  //Modulo divide the value by the range to produce a value that falls within it.             result %= max - min + 1;                  result += min;             return result;         }      ... and here's the results: ![enter image description here](http://i.stack.imgur.com/RBnT5.png) LSB rejection (bit-shifting the number until it falls within the range) was TERRIBLE, for a very easy-to-explain reason; when you divide any number by 2 until it's less than a maximum, you quit as soon as it is, and for any non- trivial range, that will bias the results towards the upper third (as was seen in the detailed results of the histogram). This was exactly the behavior I saw from the finished dates; all of the times were in the afternoon, on very specific days. MSB rejection (removing the most significant bit off the number one at a time until it's within the range) is better, but again, because you're chopping off very large numbers with each bit, it's not evenly distributed; you're unlikely to get numbers in the upper and lower ends, so you get a bias toward the middle third. That might benefit someone looking to "normalize" random data into a bell-ish curve, but a sum of two or more smaller random numbers (similar to throwing dice) would give you a more natural curve. For my purposes, it fails. The only one that passed this test was to constrain by modulo division, which also turned out to be the fastest of the three. Modulo will, by its definition, produce as even a distribution as possible given the available inputs.


title: Interesting questions about Behaviour-Driven Development

text: For my master thesis at Software Engineering, I want to investigate in the new development technique BDD (Behaviour-Driven Development). In my opinion this technique could really improve on customer satisfaction, code coverage and bugs because of the force of executable specifications and the customer- understandable language. For my thesis however, I struggle with the way I am going to validate that BDD could work better in certain circumstances. At the company I work during my study, work is still mostly done in a traditional, iterative way, where it sometimes is hard to change requirements after the requirements elicitation stage. My question is, are there any people who already did projects with BDD, what are their experiences and have you ever felt something about BDD that you would want to investigate in, commencing on the above paragraphs? This could help me a lot with constructing my research question. Thanks in advance!


title: how to get accepted at a big company like google

text: I'm 18 Years old; I started teaching myself programming when I was twelve. I've developed many projects in PHP, Javascript, Ruby, Ruby on Rails. I know a very little about C, C++, Objective C and extending PHP with extensions created in C Programming Language. Now I'm working as a freelance Web Developer with a very low salary :(, My Dream is to get a good career with very high salary so I thought of Big Companies like Google Or Microsoft. My Question is How to get Accepted on those big Companies ? What Pre-requests they want And do you need to finish collage education ?


title: Spreadsheet or writing an application?

text: When would you keep simple to medium-complex personal calculations in a spread sheet (Excel etc) and when would you write a small program or script for it? For example when you want to calculate what size of mortgage you can afford to buy a house. I could create a spreadsheet and have a nice tabular representation. On the other hand, if i would write a small script in a nice language (in my case Haskell), i'd have the security of a nice type system, preventing typos etc. What are the pro/cons in your opinion?


title: Different ways to generate the latest int type primary foreign key in code

text: I am new to sql. I have added 2 new tables in database. The primary key of first is a foreign key in the other. The type of the keys is integer. Now I want to generate the keys in the code and assign it to new data so that the association between different rows of the tables is right. How do I ensure uniqueness of keys and also get the latest key from the db so that there are no errors while saving. If I had used guids then I would have assigned a new guid to the primary key and then assigned the same to the foreign key in the other table. Also there are multiple clients and one server which is saving the data. The data to be inserted in both the tables is decided in the c# code and is not derived from the row inserted in the primary table. Even if get the id in db then also the relation between the rows should be stored in some form from the code because after that it is lost.


title: Are these signs of a bad developer?

text: I used to blame changing specifications from clients for code rot, not realising that business models do change and it's my job to develop in an adaptable way. I now see that as a sign of a bad developer (I've changed!). But now I see other 'whinges' in myself. A few times recently I've found myself saying 'it's like trying to fit a square peg in a round hole', and also I find myself blaming client indecision for a project not progressing. Are there signs I should look out for where I should change my attitude? Is the client always right, or am I sometimes justified in getting frustrated?


I'm thinking about something I've read in a book: "A well designed system is a testable system" and I'm wondering why it is so. Certainly, a system that is much tested is probably well designed. Build from the ground up on test-first principles and assuming basic competence, it is hard to imagine a very bad design. But the statement reverses the idea: that a well designed system is testable. Why? Is it because good tests are small and simple by default, so making good tests on a bad design (where bad design usually means large and complex classes) is more difficult? Or that it is hard to, say, test a single aspect of a class in isolation when the class in question is a god class?


title: How to map TFS to two local directories

text: I am working with a web application, using TFS. Every time I build the site it takes an unproductivly long time to start up again. I would like to have a second mapping of the site on my c drive, where I would only get latest and build once a day, so this version would always be fast. This would be like a "readonly" directory as I wouldn't personally make any edits to it. Please let me know if this possible, or if you have any alternative.


title: Verify 0 or 2+ sub sections in a section

text: There is a rule in writing: When you break a section into subsections, typically it should have more than one subsection. This goes back to the old high school composition rules: if you have an A. section you also need a B. section. To check a chapter of a book I'm writing in LaTeX I do this:               $ egrep -h '^\\(chapter|(sub)*section)\**{' CHAPTERFILE.tex | sed -e 's/\*{/{/g'                    \chapter{My Chapter}     \section{Topic}     \subsection{Subtopic}     \subsection{Another Subtopic}     \subsection{Subtopic the Third}     \section{More}     \subsection{More more}     \subsection{Less is more}     \section{Odyssey}     \subsection{Marge and Homer}     \subsubsection{Bart}     \subsubsection{Lisa}     \subsubsection{Maggie}     \subsection{Example}     \section{Lore}     \section{Data}      What is an efficient algorithm to verify the rule has been obeyed? This rule goes for sub sections in a section, subsub sections in a subsection, and so on. (Though in my case there are no subsubsub sections) Thanks to Bart's advice, here is the code I created. It is hacky in places but it is simple and found bugs in my LaTeX files:               #!/usr/bin/env python          import sys     import fileinput          TOKENS = [         ['\chapter', 0],         ['\section', 1],         ['\subsection', 2],         ['\subsubsection', 3],         ['\subsubsubsection', 4],         ]          def getlevel(line):       """Report the line's level (number of subsections)."""       for token, level in TOKENS:         if line.startswith(token):           return level       raise Exception()          def store(lst, level, value):       """Store value in the level'th position."""       while len(lst) < level:         lst.append('EMPTY')       return lst[:level] + [value]          def segments():       """Read the input text, yield lists of segments."""       path = []       last_level = 0       for line in fileinput.input():         value = line[line.index('{') + 1 : line.index('}')]         path = store(path, getlevel(line), value)         yield path          def get_tree(segs):       """Build a tree out of segment lists returned by generator segs"""       tree = {}       for s in segs():         t = tree         for i in s:           t = t.setdefault(i, {})       return tree          def audit(t):       """Audit: Leafs are ok, nodes are ok if they have >1 children."""       error = False       for k, v in t.items():         if audit(v):           error = True         if len(v) == 1:           print 'ERROR: part with only one subpart: %s' % (k, )           error = True       return error          def main():       tree = get_tree(segments)       if audit(tree):         return 1          if __name__ == '__main__':       sys.exit(main())


title: What are the drawbacks of elastic tabstops?

text: Look here: a typical holy war on tabs vs spaces. Now look here: elastic tabstops. All problems solved, and a bunch of very useful new behaviours added. ![elastic tabstops](http://i.stack.imgur.com/60RvQ.gif) Are elastic tabstops even mentioned in that tabs vs spaces discussion? Why not? Are there drawbacks to the elastic tabstop idea so serious that nobody has ever implemented them in a popular editor? **EDIT** : I apologise for putting too much emphasis on "why aren't they mentioned". That wasn't really what I intended; _that_ question is possibly even off topic. What I really mean is, what are the biggest drawbacks of this that prevent wider adoption of an obviously beneficial idea? (in an ideal world where everything supports it already) (Turns out there's already a request on the Microsoft Connect for a Visual Studio implementation of elastic tabstops, and a request in Eclipse too. Plus there's a question asking about other editors that implement elastic tabstops)


title: Proper OO design for State and Command

text: I'm working (a bit) on a (turn-based strategy) game. There are two classes relevant for the question:   * `State`: This is an immutable class, which exposes all its fields (either via getters or another way, as I felt appropriate). The state is a bit complicated, so I decomposed it into several classes in the package `...state`   * `Command`: This is an abstract immutable class with a couple of subclasses like `MoveCommand(Field from, Field to)`, `PassCommand()`, `BidCommand(int amount)`, etc. in the package `...command`. All of fields have public getters. I need one of the two methods   * `State Command.applyTo(State)` or   * `State State.apply(Command)` returning the new state (obtained by applying the command to the state). Using the first method looks better at the first sight, since it dispatches to different implementations of `applyTo` in the subclasses of `Command`. Unfortunately, it forces me to fiddle with the many details of `State` in the class `Command`. In order to make it work, I need something like `MutableState`, or `State.Builder`, or a many-args constructor of `State`, or whatever. Using the second method looks ugly, as it'd force me to use `instanceof` (or some other ugly way to simulate the virtual method dispatch). OTOH, it would concentrate the working with `State` in the class itself. So I think the first method is the way to go. With `Command` and `State` each in its own package it means that `MutableState` (or whatever gets used for building the resulting `State`) need to be a public class since there are no `friend`s in Java. No real problem, but not nice, is it? So what is the proper design?


title: Why atoms/symbols?

text: Why do programming languages like Ruby use symbols? I understand that String manipulation is much slower than using a lookup table as well as the idea that Strings are reallocated in memory no matter if it is the same or different as one used previously, but can't interpreters compensate for this? It would seem like an interpreter still has to parse the word that you typed in order to match it to a symbol, so why not just do the same with a string object? For instance, why doesn't the compiler take:               myHash["myKey"] = ...      and treat it as               myHash[:myKey] = ...      behind the scenes, anyways? Even if the key is dynamic - it's an interpreter, so should it not know what the key is going to be before it finds the value and still treat the string key as a symbol? eg.:               concatMe = "Key"     myHash["my" + concatMe] = ...      How come an interpreter can't still treat this as               myHash[:myKey]      If it knows what               "my" + concatMe      is _before_ it finds the value by key?


title: How similar is Android/smartphone development to Android/other-platform development?

text: The more I program on the Android for smartphones platform the more I like. The way they made task management and inter-task messaging clean and easy is a treat (e.g. - AsyncTask, broadcasters, receivers, etc.). How similar is Android development on other platforms, for example tablets or later Android based TVs, to Android for smartphones? How compatible is code developed to run on the Android (phone) emulator to Android code running on other hardware platforms. If I write a lot of cool code for an Android smart phone, how much of it will I have to tweak/reinvent to get it to run on other Android platforms? That leads to a huge question concerining Android (phone) UI widget portability. Does code that uses those objects run unmodified on other Android platforms? If not, how much effort is it to make Android code cross-hardware platform portable? If the code is fairly portable, I think programming for the Android O/S on a table or regular Android PC if they gain popularity would be an excellent experience. If any of you have done Android programming on smart phones and on other hardware platforms, I'd love to hear what your experiences have been.


title: What are the use cases for these relationship types?

text: # Use Case What are the use cases for creating a **one-to-one** relationship where the parent points to the child compared to a child pointing to the parent? If there is no difference, is one preferred over the other? ## Example               +---------+     +-------+       +--------+     +----------+     + Parent  +     + Child +       + Parent +     + Child    +     +---------+     +-------+  vs.  +--------+     +----------+     + idChild + --> + id    +       + id     + <-- + idParent +     +---------+     +-------+       +--------+     +----------+      I suspect that you'd choose between these relationships depending on which entity is used first in the application. i.e. If the parent object always appears before the child object, then the relationship should be mapped from the parent to child.


title: Logging page/session ID in an inner module

text: We have a C# ORM module that generates queries. It logs generated queries and other information into the error/trace file. It is used by our web application. Most of our queries are generated dynamically (based on dynamic business rules and user interactions) which we have little control over. Obviously the ORM module is completely decoupled from the web application, and therefore completely unaware of web sessions, page hits etc. The downside is that the log entries it generates cannot be traced back to the original page hit. When we notice a non-performant query in the log, we cannot easily determine which page hit generates that query. How can I keep the ORM module decoupled from the web application, but still allow it to log enough relevant information for me to correlate each log entry to a session/page hit? (I know we can pass the logger object around, and the logger object can preserve that session information. However, some of these function calls are nested 10 levels deep, so passing the logger around is cumbersome).


title: Why were default and static methods added to interfaces in Java 8 when we already had abstract classes?

text: In Java 8, interfaces can contain implemented methods, static methods, and the so-called "default" methods (which the implementing classes do not need to override). In my (probably naive) view, there was no need to violate interfaces like this. Interfaces have always been a contract you must fulfill, and this is a very simple and pure concept. Now it is a mix of several things. In my opinion:   1. static methods do not belong to interfaces. They belong to utility classes.   2. "default" methods shouldn't have been allowed in interfaces at all. You could always use an abstract class for this purpose.  In short: Before Java 8:   * You could use abstract and regular classes to provide static and default methods. The role of interfaces is clear.   * All the methods in an interface should be overriden by implementing classes.   * You can't add a new method in an interface without modifying all the implementations, but this is actually a good thing. After Java 8:   * There's virtually no difference between an interface and an abstract class (other than multiple inheritance). In fact you can emulate a regular class with an interface.   * When programming the implementations, programmers may forget to override the default methods.   * There is a compilation error if a class tries to implement two or more interfaces having a default method with the same signature.   * By adding a default method to an interface, every implementing class automatically inherits this behavior. Some of these classes might have not been designed with that new functionality in mind, and this can cause problems. For instance, if someone adds a new default method `default void foo()` to an interface `Ix`, then the class `Cx` implementing `Ix` and having a private `foo` method with the same signature does not compile. What are the main reasons for such major changes, and what new benefits (if any) do they add?


title: Two closely related projects -- Two repositories or one?

text: ### Background I am coding two closely related Java projects. The first project is Single Facility Simulator, which simulates a very simple supply chain with a single facility. The second project is Supply Chain Simulator, which simulates more complex supply chain networks, i.e. multiple facilities arranged as a graph with directed edges between some pairs of facilities. The first project is a "toy" project in the sense that I am using it to test and refine the high-level design of the project. The second project is the "real" project that I am interested in for work purposes. The high-level design of the two projects is the same, although there are some differences, for example a `Demand` object in the "toy" project only needs to generate a demand value per time period, whereas a `Demand` object in the "real" project needs to generate a demand value per facility per time period. ### Question Currently, the "toy" project lives in its own Git repository. As I begin implementing the "real" project, should I fork the "toy" project, or should I implement the "real" project as different packages in the same space as the "toy" project?


title: Mail Server Caching

text: I'm currently working on a web mail client. When a user logs in, I'm fetching all the mails from the INBOX from the beginning of time. As expected this is pretty darn slow. I'm planning to implement some sort of a filtering/caching technique and was looking for some ideas. If I fetch all the message numbers, trim them and sort them in a descending order, will I have messages from the the last message received to the first? Also, would it be preferable to store mails in a intermediate database and fetch them from there?


title: Best way to reference static database data in code?

text: Many applications include 'static data': data that doesn't really change during the lifetime of the application. For example, you might have a list of Sales Areas that is likely to be a fixed list for the foreseeable future. It isn't uncommon to find this static data in a database table (often because you want to refer to it in the foreign keys of other tables). A simple example table will have an Id to use as a primary key and a Description. For example, your SalesArea table will have (at least) a SalesAreaId column and a SalesAreaDescription column. Now, in code you might not want to treat each row of the table the same. For example, you might want to set a default Sales Area on some screens, provide different figures for some areas, or restrict what users can do in other areas. What is the best way to refer to this static data in code? Why?   1. Hard-code the descriptions in your code. Use this to look up the SalesAreaId from the database when you need it.   2. Hard-code the IDs in your code. Use this to look up the SalesAreaDescription when you need it.   3. Add a column to the table for each purpose, e.g. an "IsDefaultOnProductLaunchScreen" column and so on (there could be lots of these).   4. Something else. Are there any other special considerations I should make when dealing with static database data? For example, giving these tables a special name?


title: Increase motivation in Our Project's Wiki with achievements?

text: We are currently running a mediawiki for our developers, and most developers are not adding entries if they find something to document. Instead they mail it to a list containing all developers, and most often I add the entries. I just thought adding something like score, achievements, badges or similar could add motivation, but I cannot find a extension for media wiki. Is there such an extension? Is one of these recommended? Funny fact: Currently I think the StackExchange system would fit much better but we need it internally ;)


title: How to set stretch goals for a development team

text: We are looking at bringing on five college interns for the summer to help out with some development projects. Each one will be given a fairly stand-alone project that we are hoping he will be able to complete. However, we would like to provide some incentive for exceptional work, be it exceptional quality or exceptional productivity. Also, it should be something quantitative, not subjective. That way we can give them a goal beyond "make your boss happy and get a prize". Also, we prefer it to be something that will encourage them to work together, something they can achieve as a group. Finally, it should be something kind of fun, to lead up to a reward at the end of the summer. We are looking for something inspirational to encourage them to achieve more, not a metric to hold over their heads come review time. How do you inspire a dev team?


title: Is it wise to be going back and forth between two programming languages?

text: I have been writing quite a lot of PHP for nearly two years. Now I am doing .NET (mainly c#) development. However, sometimes I go back and do some php. My main question is, is it wise for me to continue doing this or should I continue development in C#? Would this harm me in the long run (mind you my main goal is not to be a jack o all trades) or is it a good practice to be doing?


title: Is there a good idiom for handling an in-line startActivityForResult

text: I have a bunch of Java code that looks something like this.               //Global     boolean something_result;     Monitor something_monitor;          // Some class on worker thread     Intent intent = new Intent("android.something.ENABLE");     Global.something_enabled = false;     Global.something_monitor = new Monitor();     currentActivity.startActivityForResult(intent, 1234);     something_monitor.Wait();     this.enabled = (Global.something_result = OK);          // Some Activity on UI thread     protected void onActivityResult(int code, int result, Intent data) {         if(code == 1234) {             Global.something_result = result;             Global.something_monitor.Signal();         }     }      The idea is that the worker thread can do something in an Activity and wait for the result. It works just fine, but there are bits of code in three different places, it's a lot of code to do not much, some cases are rather more complicated and it gets replicated for each different thing you want to do. It's also error prone because it's potentially subject to threading issues. This is basically what `await` is designed to do for you. Is there a well- known idiom or technique to do this safely and with better encapsulation? Although the context is very much Java on Android, it's much more about a usable idiom for tackling this kind of threading issue that I'm interested in.


title: When is my code auto GPL'ed?

text: I'm currently working with Wordpress (GPL). I understood basically when you write a plugin/module/etc. it becomes GPL since it's considered dependent of Wordpress.   But on the contrary images and css from themes, are not due to be GPL (they are considered independent data files that could have meaning even without Wordpress)   And that just blurs things a little bit for me. What if I create a mathematical library non GPL. Then I create a Wordpress plugin that use that library?   Will it makes my library GPL? Would it means I cannot bundle them together? Not even put them on a single zip file? What if my library is a Web service? And what if the web service is self hosted? May I bundle it with the plugin code altogether? If I can't make any kind of bundle without GPL being propagated, how comes one can bundle a theme (feat. css + images) for Wordpress?


title: Testing applications with statistical features

text: > **Possible Duplicate:**   >  How should I test randomness? Are their some techniques described for testing applications that have as a requirement some statistical or probabilistic features? They may for example use some random number generators and the customer may wish certain distribution etc. How would software companies test that the statistical requirements are satisfied?


title: How to test a random-generating feature in application?

text: > **Possible Duplicate:**   >  How should I test randomness? One of the features to be developed in our application was allowing user to click a button which will choose an element at random out of (normally 5-10) values registered in the database. The randomness doesn't need to be secure or scientifically uniform, but we do need it to be somehow unpredictable and not noticeably biased to one of the value. Any suggestion how to write a good unit test and functional test for this feature?


title: What did they call Object-Oriented Programming before Alan Kay invented the term?

text: Alan Kay claims that "I made up the term "object-oriented", and I can tell you I did not have C++ in mind." What he had in mind, of course, was Smalltalk. But he did not make up object-oriented programming itself; he got the basic ideas from Simula. So if the term hadn't been invented yet, what did they originally call object-oriented programming in Simula?


title: Web application using JSF-Front end and node.js-Back end

text: I'm planning to build a eCommerce web application(similar to http://zovi.com/) using JSF 1.2 and node.js. All front end components will be jsf components binding to backing bean. I want to achieve real time functionality ( such as displaying **Today's hot sellers** , **Customers who viewed this item also viewed** such patterns) using node.js. And all data retrievals from database(MySQL)should be accomplished using node and display in JSF components. I'm confused in how to bind data that i get from node to corresponding managed bean property(since i bound it to corresponding JSF component). **For example** on load I've to retrieve data using node.js and populate datatable component and also i should update backing bean. Is it possible with out using any web services like REST Hope you understand this context. Please suggest some solutions. And I heard performance of Node.js is efficient only for small web applications not for Enterprise level. Is my approach correct??


title: Request / Reply , how should one initiate the actual sending of the transmission?

text: I'm working on Language level interfaces to web API's. These libraries are of course built around existing HTTP Request/Reply interfaces. I see myself as having a few options submit method on the request object e.g               my $req = Request->new( ... );          my $response = $req->submit; # returns response          my $res2     = $req->submit; # sends the same request again      lazy request accessor               my $req = Request->new( ... );          my $response = $req->response; # returns a reference to the response          my $res2     = $req->response; # doesn't send again, just returns the reference          $req->clear_response;          # clears the response value          my $res3     = $req->response; # sends again because no response exists      These are the 2 options I'm thinking of. I have seen more examples of the former but I'm not sure if there's a reason why. Do you have any preferences on which style interface? or are there other ways I'm not thinking of? Overall I'm trying to discern what the best API is to retrieve the response.


title: Twitter in app browser + user agent string

text: Recently (I believe some weeks ago) with the latest update of the Twitter app for iOS, all links found inside tweets are opened in Twitter's build-in browser. My question is how to find Twitter's browser agent so I can display custom messages. For example: If browser is Twitter's in-app browser then display a custom message via HTML+PHP. It seems that there is no known agent available. Any help would be appreciate.


title: What design route should I take?

text: So I've taken on a project at work that I'm having a hard time attacking, and I'd love some feedback and suggestions. I work for an online retail store where we have an old, +7k-line script that we use to create various product feeds (mostly for CSEs like Google Products, Pricegrabber, etc). It's become a complete mess, mostly because each feed is slightly different and because there is almost no separation of concerns. I've been tasked with refactoring it, a task I volunteered for with gusto, and pretty soon I need to come up with a design. My main goal is to have a system that's easy to maintain, and easy to add new feeds as needed. If performance suffers a bit that's not a huge concern, though increasing performance would be great if it doesn't interfere with the first two goals. Until now, most of what I've worked on has been fairly linear and imperative; data comes in at the top and goes out at the bottom. But because of the various feeds with various needs, I wonder if an object-oriented approach would be beneficial. OO programming is still a bit of a mystery to me, so this problem has been a bit difficult to attack. My basic idea is as follows; objects exist for each main concern (images, product descriptions, file handling, etc). Then, each feed has an object (perhaps implementing an abstract class) that talks to the other objects, asking for the information it needs. For instance, the Pricegrabber object feeds the Image object a list of products along with some parameters (maximum image size, etc) and the Image object returns a list of products with corresponding image urls. This way, the Pricegrabber object doesn't know or care how the Image object finds its urls, or what mysql tables the Image object used or created; it just enters a list of products and gets a list of image urls. Pricegrabber does this with every main object until the feed file is created. Main questions:   * Does this design pattern make sense? Is there a better pattern I could use?   * Does OO seem like overkill for what I'm trying to accomplish?   * While we normally use Perl for our reports, would it be worth it to use PHP instead? If so, why? (I'd love to use Python or Ruby but IT has put the kabosh on that).


title: A class with only methods

text: What's the name for a class that has only methods? There are no fields/properties. Just two methods with the ability to parse some file in two ways. I have named the class Parser, but it just doesn't seem right to have a class do only that. Or? Should it be in a class ? EDIT: Dummy Example               class Parser     {          public int parseMethod1(string file)          {              //parse & return          }               public string[] parseMethod2(string file)          {              //parse & return          }     }      How could I write an interface `IParser` which allowed me to have a subclass only implement one of the methods?


title: Understanding special Scala syntax

text: I can understand this:               List("one word", "another word") unzip (_ span (_ != ' '))      But don't get what's happening here **below** in the `span`. `span` takes a predicate and I think the braces can be omitted as `span` is used inline and has only one parameter but why isn't there any `_` and what is `' '.!=`               List("one word", "another word") unzip (_ span ' '.!=)


title: Do I need to learn python first to understand the part 2 of the book Test Driven development?

text: It seems like Python is used as a coding language for part 2 of Kent Beck's book Test Driven Development. I have read the first part of that book and started appreciating the value of TDD . First part was easy to understand as the examples were in Java and that is the only language that I have worked on. How should I prepare myself to go about reading the second part of the book? What value will it provide? I do not plan to write a testing framework myself. Can I skip this entirely and go to the third section?


title: Is there a modern replacement for a mutation testing tool like Jester for Java?

text: > “Why just think your tests are good when you can know for sure? Sometimes > Jester tells me my tests are airtight, but sometimes the changes it finds > come as a bolt out of the blue. Highly recommended.” - Kent Beck But I see that there is not even a tag called " _Jester_ " in stackoverflow. So what is the modern replacement for _Jester_ ,if any ? How can one be sure that unit tests written are rock solid other than finding statistics from code coverage from tools like _Cobertura_ and _Clover_?


title: Can an issue tracking system be distributed?

text: I was thinking about issue tracking software like Redmine, Trac or even the one that is in Fossil and something hit me: Is there a reason why Redmine and Trac are not possible to be distributed? Or maybe it's possible and I just don't know how it's possible? If it's not possible, why? By distributed I mean like Facebook or Google or other applications that effectively runs on multiple hardware a the same time but share data.


title: Provide an OnChange event for an internal property which is controlled externally?

text: For fun and by request I am updating this ImageGrid component, a kind of listbox for images that has a `FileNames` property of type `TStrings`. For ease of writing, I have been misusing its `FileNames.Objects` property for bitmap storage. But since the `TStrings` type suggests that users of the component could or would want to use the `Objects` property for custom data, e.g. like `TListBox.Items`, I am rewriting the component to store the bitmaps elsewhere and leave `FileNames.Objects` untouched for unknown future usage. Now I am wondering whether to provide an `OnChange` event. And if so, whether to fire it when one or more `FileNames.Objects` changes. Trying to answer it myself, I dove in Delphi's own VCL and stumbled on:   * `TMemo`: has an `OnChange` event, but ignores `Lines.Objects`   * `TListBox`: has no `OnChange` event, but is capable of storing `Items.Objects`   * `TStringGrid`: has no `OnChange` event, but is capable of storing `Objects`, `Rows.Objects`, `Cols.Objects` So now I am somewhat puzzeled, because I cannot imagine Borland's developers didn't add events for several `Objects` properties out of ease. Sure, when a user changes a `FileNames.Object` in my component, he knows he does and could implement appropriate interaction himself. But wouldn't it be convenient when the component does automatically? What would you expect from this component in this regard?


title: How were the first compilers made?

text: I always wonder this, and perhaps I need a good history lesson on programming languages. But since most compilers nowadays are made in C, how were the very first compilers made (AKA before C) or were all the languages just interpreted? With that being said, I still don't understand how even the first assembly language was done, I understand what assembly language is but I don't see how they got the VERY first assembly language working (like, how did they make the first commands (like `mov R21`) or w/e set to the binary equivalent?


title: Are flag variables an absolute evil?

text: Are flag variables evil? Are the following kind of variables profoundly immoral and is it wicked to use them? > "boolean or integer variables that you assign a value in certain places then > down below you check then in orther to do something or not, like, for > example using `newItem = true` then some lines below `if (newItem ) then`"    I remember doing a couple of projects where I totally neglected using flags and ended up with better architecture/code; however, it is a common practice in other projects I work at, and when code grows and flags are added, IMHO code-spaghetti also grows. Would you say there are any cases where using flags is a good practice or even necessary?, or would you agree that using flags in code are... red flags and should be avoided/refactored; me, I just get by with doing functions/methods that check for states in real time instead.


title: Best way to notify the client in real time that their queue (e.g. SQS) job has finished?

text: **Current Scenario** Our application allows users to upload (Amazon S3) and manage their files through our interface. Currently those users can download the files directly from S3/Cloudfront through our application. **Adding a Zip feature** We would like to add a feature to the system that allows users to select multiple files at once and download them as a zip file. We would like the process to work in real time, so that when the user clicks the button to download a zip file, the system processes the request, compiles the zip, and returns the zip to the end user. While the process is running, the front-end will tell the user their request is processing, and when it is complete, it will prompt them to download the file. **Proposed Strategy** Our application is AWS cloud based, so my first instinct is to use Amazon SQS (but am open to other suggestions) to build a queue system to handle these requests. The flow would work like this:   1. User selects files and requests a zip file to be created.   2. Front-end sends a request to SQS with the files to be zipped, and the destination (on S3) where the final zip file will be stored.   3. The queue worker uses long polling to check for new SQS jobs. When a job is found, the worker downloads the files from S3, zips them up, and returns the finished zip file to the specified location on S3.   4. Now that the queue has finished processing, alert the client that their job is done and their file is ready for download. **Best Way to Handle Step 4?** This process appears to be a solid approach, and everything makes sense up until step 4. We are struggling with the best way to notify the end user in real-time that their job has finished and their file is ready for download. From my research I have seen three ways that people suggest:   1. Use pub/sub to create a socket for the job, and return the response when complete.     * From everything I have read, it is not best practice (and sometimes not possible) to create a large number of open pub/sub sockets/channels. In addition, how does SQS notify the open socket that the job is complete? This article regarding Amazon SNS looked promising at first, but they seem to infer that it is best practice to use a single SNS topic for the entire queue, not an SNS topic per job. This seems like a great approach if we were simply wanting to send an email to the user, letting them know their job has finished. However, I want to be able to update the user interface inside the web browser.   2. Continuous polling by the front-end server for the finished zip file on S3.     * If there are thousands of simultaneous jobs, this would create thousands of requests. This approach doesn't seem very scaleable, and could potentially cost money by extra S3 api calls.   3. Leave an open long-running request     * Due to the fact that if there are many jobs in the queue, the time taken to deliver the response could cause the request to time out. In addition this creates a lot of strain/wasted resources on the front-end web server. Again, not very scaleable. **My Question** Taking into account the points that I mentioned above, what is the best way to notify the front-end client that their job queue has finished and their file is ready to download? A great example of what I am trying to do is YouTube. When you upload a video to YouTube, their queue processes your video, and when it is complete, it notifies you that the video processing has finished. I am trying to replicate the same concept, except that in my scenario, I just want to the client to know when the zip file has been prepared and uploaded to S3. I'm aware of theoretical solutions, so please be specific. I am open to any suggestions, regardless if they use SQS or any of the technologies/methodologies I have listed. Pointing to any real-world code examples of this sort of thing would be a big bonus. Thank you in advance for your great help!


title: Example for explaining object-oriented concepts

text: What are some _good_ examples for illustrating the concepts of object-oriented programming? I'm talking about sample classes, classes that would have inheritance, overriding, etc. The only one I can ever think of is of animals. A base `Animal` class, with `Cow` that have a different `makeCry` method or something like that. It sucks. What do you guys use?


title: What is the relationship between the Dynamic Language Runtime and  C# 4.0?

text: Let's say I wanted to create a dynamic language compiler/interpreter, a Scheme interpreter perhaps, on the .NET platform as it exists today. Would I be better off using the Dynamic Language Runtime (DLR), or using C# 4.0 to implement my language's dynamic features? Or do I need both? I know that there has been other work done in this area, in particular with IronScheme and IronPython. Both of those languages use the DLR; I believe IronPython uses the most current version of the DLR (which is about a year old), while IronScheme uses an early, heavily modified fork of an early version of the DLR. But C# 4.0 was not available when these compilers were created. I've seen Rob Conery's work with Massive, using C# 4.0's dynamic features; it is quite impressive. But would C# hold up to the full-scale effort of a dynamic language compiler/intepreter? Are there features in the DLR that are missing from C#, or was the DLR essentially rolled into C# 4.0? Would I be missing any important features of the DLR if I just used C# 4.0 exclusively?


title: How to design a scalable notification system?

text: I need to write a notification system manager. Here is my requirements: I need to be able to send a Notification on different platforms, which may be totally different (for exemple, I need to be able to send either an SMS or an E-mail). Sometimes the notification may be the same for all recipients for a given platform, but sometimes it may be a notification per recipients (or several) per platform. Each notification can contain platform specific payload (for exemple an MMS can contains a sound or an image). The system need to be **scalable** , I need to be able to send a very large amount of notification without crashing either the application or the server. It is a two step process, first a customer may type a message and choose a platform to send to, and the notification(s) should be created to be processed either real-time either later. Then the system needs to send the notification to the platform provider. * * * For now, I end up with some though but I don't know how scalable it will be or if it is a good design. I've though of the following objects (in a pseudo language): a generic `Notification` object:               class Notification {         String                 $message;         Payload                $payload;         Collection<Recipient>  $recipients;     }      The problem with the following objects is what if I've 1.000.000 recipients ? Even if the `Recipient` object is very small, it'll take too much memory. I could also create one Notification per recipient, but some platform providers requires me to send it in batch, meaning I need to define one Notification with several Recipients. Each created notification could be stored in a persistent storage like a DB or Redis. Would it be a good it to aggregate this later to make sure it is scalable? On the second step, I need to process this notification. But how could I distinguish the notification to the right platform provider? Should I use an object like `MMSNotification` extending an `abstract Notification`? or something like `Notification.setType('MMS')`? To allow to process a lot of notification at the same time, I think a messaging queue system like RabbitMQ may be the right tool. Is it? It would allow me to queue a lot of notification and have several worker to pop notification and process them. But what if I need to batch the recipients as seen above? Then I imagine a `NotificationProcessor` object for which I could I add `NotificationHandler` each `NotificationHandler` would be in charge to connect the platform provider and perform notification. I can also use an `EventManager` to allow pluggable behavior. Any feedbacks or ideas? Thanks for giving your time. Note: _I'm used to work in PHP and it is likely the language of my choice._ * * * **Edit** _(according to morphunreal's answer)_   * How many messages per second are you sending (Define current/initial levels, define a maximum level that the system should handle before being re-designed)   * What hardware constraints does the system have (memory, cpu etc available to the system)   * How will hardware scale (ie, adding more servers, cloud computing etc) * * *   * What languages / systems will be generating notifications? It is on my own, I'm in charge to create the notification programmatically but constructed from an UI.   * Does the generator know the recipients of the message (?) or are they provided by some other means (ie, business rules for certain alert types go to certain recipients) It should be possible to create a notification for a specific recipients, a group of recipients (for example using a tag system), or for a whole platform.   * Are there business rules for adding CC/ BCC / Read receipts Yes. Note that this is really platform specific and the read or cc are not available on all platforms.   * Does the generator know the type of message it's sending (ie, SMS/ email) or is it based off the recipient It is based on the recipient, however, as the recipient is platform related, and platforms have different way to handle data, the UI is likely to be platform specific to allow to set up images, a sound or something.   * Does the generator require confirmation of messages being sent/received/read (async vs synchronous sending) Well the system should be error prone but we would like to handle the error to define a set of rule, for example, if the server is unreachable, the notification should be requeued for further process, but if the notification is incorrect (or has been defined as is by the platform provider) it should not be requeued but notified.   * Are there requirements to store a history of message sources / recipients (how long for?) Yes, we likely want to make some statistics and report. * Define Notification End Points * * *   * What services are being used to send messages? Depends, some are classical REST webservice, other are some exotic protocol, it is really up to the provider.   * What feedback / confirmation is provided (sync / async) Depends, some are synchronous and reply with an error while some other need to be pulled afterward to check for errors.   * Is it likely to add new end-points [even if so, does it even need to be abstracted] Yes, actually, our app is growing and we likely want to be able to add new provider, but it is a ratio of something like 1 or 2 per year.


title: Employers and Intellectual Property

text: I have heard of companies that require their developers to sign agreements that say _any_ code developed by that developer while they are employed there belongs to the company. I am extremely uncomfortable with that kind of agreement. How common is this practice?


title: What made jQuery so popular? What is offers that other JavaScript libraries don't?

text: According to W3Tech, this link, this link, this link, and many other sources, jQuery is really becoming what IE experienced in the world of web browsers (gaining more than 80% of the market for a period). I don't have the knowledge of any other JavaScript library like MooTools, YUI, etc. because when I started web development, jQuery was already ahead and I chose it. Are other libraries really that awful, or do they lack something jQuery exclusively has? What is the reason(s) behind this huge market share?


title: Dealing with 'dirty' Ruby on Rails client

text: I had to leave a startup about a month ago because of lack of funding. Basically, this client wanted an application to allow contractors to create, update, read, and delete yardsigns. Straight forward stuff, right? Not really. So today, I received a phone call from this same client claiming to have spoken with "someone who develops with the Ruby on Rails core team" and claimed that "developer" said that my code was "junk" and that there are no controllers and models, and that there's just ROR auto generated code (I assumed he meant 'scaffold'). It's not just "ROR" auto generated code. So the client now wants his money back and doesn't want to pay me the money he owes me. One of the controllers is just a simple create, show, delete, update, and I've included a "map" action for viewing the yardsigns (it's an app for contractors/homeowners -- the code was a day after developing but this is just one controller out of the rest of the app and is apart of the only commit I could retrieve. The rest of the code has since been deleted when my hard drive crashed a week ago so I don't have a full copy of the app myself atm). I also must tell you that he claims "the other developers ripped him off and left" which I now don't believe was the case. I believe they left because they were being taking advantage of. Am I in the wrong? I honestly don't know what to do here. Is this a case of a non technical client expecting "more lines of code" for his fairly simple/small application? What could I have added to please this client? I love to learn from my mistakes but I honestly don't think I've made any.


title: OCCI for non-web application

text: I am writing a non-web application (written in java) which will allocate cloud resources. I want to make it compatible with as many providers as possible. Is it wise to use OCCI interface? Will it be too complicated?


title: What should I do when I find sensitive information in version control?

text: Today I found what looked to be my supervisor's password in some code in version control. The password is to a database. He is very experienced and has explained before how to avoid having passwords in the source code. How should I handle this situation? Is there a best practice about preserving evidence of a security flaw, or should I remove such data as soon as I see it? Even if I remove the data in the current revision, there's still the revision history. Should I just alert my supervisor instead?


title: Using C++/Java to develop software and sell it

text: I know this question has been asked here before, and I also know that this website is for programming questions only, but please do make an exception, as none of the posts I've come across on this site, or others, have answered this question properly (there are too many ifs). I'm planning to develop a program which I intend to sell later. I'm trying to decide upon a language to code it with, and have narrowed down to C++ or Java. I've been through the GPL v2 and v3 licenses used for GNU's GCC and OpenJDK (yes, I can understand some amount of legal stuff, but clearly, not all of it). But there is one point upon which **everyone** is obscure (this should have been one of the first things answered, IMO): if I develop a program using C++/Java and compile it using GCC compiler or OpenJDK's compiler, can I sell it without having to place my program under GPL as well? As far as I can make out, I have full rights to assign any license to my program, but, there is a catch: it says in the license that I shouldn't link to any library that is under GPL. If so, I'll have to release my program under GPL. Now, I don't know what in C++/Java is considered a library, so if I use the normal stuff in C++ (iostream, list, map, etc. ) or the normal Java classes/interfaces available as part of the standard JDK 6 distribution (String, List, Map, etc.), does this constitute 'linking to the libraries'?


title: Coding dojos on regular basis

text: Do you find reasonable to practice coding dojos on a regular basis? I understand dojo may be a good starting point to introduce somebody to some approach but what is the point of making similar dojos regularly? So currently we have two teams which are working on real project written in TDD. One team wants to work on TDD-oriented dojos regularly and other prefers to practice it only on real tasks. Who is right?


title: Task ownership with Wordpress - CSS - Designer or Developer?

text: We have a dispute regarding who owns which tasks when it comes to the CSS on our live site. Our designer argues that he is not responsible to log-in to word press and modify the css or use ftp for any changes because that's not his job description while developer argues that since it is css, it belongs to designer and that he is to update the changes to the server and then compare and correct the output. I'd like experienced people working in professional development environment to put a light on this scenario. I'm not sure if this is the right place to ask this question, or is there a separate forum for business development or project management specific questions?


title: How should I structure a C# application that reads & writes binary data?

text: I have to read and write binary "chunks" of approximately 1Mb each. The data can come in the form of a stream or a in-memory `byte[]`. Normally I would use a `Struct` with a fixed layout, but there are a few properties of this binary data that are making this harder:   1. Byte 4 describes the "version" of the chunk   2. Byte 5 starts either as variable array of sub-chunks or as a human readable blob   3. Each sub-chunk has a version, and has a variable array of data within it.   4. The endian-ness of the data is inconsistent How should I structure a program that needs to handle binary data thats in this format?


title: What should developers test before submitting their work to testers?

text: Is there a checklist the developer must go over before passing their work to testers ? Also, what are the conditions/cases the developer must pay attention to ?


title: MEF & Circular dependencies in MonoDevelop / VS

text: (I think the problem described below is also affecting VS although I only tested it in MD) I have some trouble regarding circular dependencies. I know they are bad practice and should be avoided. In recent MonoDevelop Releases, you can't even create circular dependencies. However, I can't find an easy way out in the following Scenario: Application A uses the managed extensibility framework (MEF) to dynamically add functionality via Plugins, which can be developed by 3rd parties, and are loaded by just placing the .Dll into the bin/ folder (DirectoryCatalog in MEF terms). As I am the Developer of Application A, I ship some default Plugin(s) along with my application. Plugins may deliver LOTS of functionality to extend Application A, so I have every Plugin in a new .csproj Project. To develop a plugin, one (myself or any other 3rd party) must implement a class that implements an interface. The interface, lets call it Interface A, is defined in Application A and is less than 50 lines of code. Thus, Plugin A requires Application A as a dependency, because Interface A is defined in the Assembly of Application A. Since I want to use the Plugin A in my Application A, I add it as a reference, too. And voila, there is a cross reference between the two. I've come up with solutions, but I am not happy with them: 1) Create a seperate project and put ONLY the interface file in it. I dislike that because I don't see a 50line .cs to be a seperate project and consider this as "over-modularization" 2) Do not reference the Plugin at all within Application A (this is possible, as Application A only uses Interface A - the actual class instance is loaded by MEF). This, however, leaves me with some trouble: I cannot work on Application A and easily go to the code of Plugin A to fix sth. or add a feature which I often do - because I load core functionality into Plugins (one of the main goals of MEF is to allow modularization). I could however, start a 2nd instance of VS / MD. But this gets bad the more plugins I add, I will end up having 10 instances of IDEs open - I doubt any machine could handle this. So has anybody a recommendation on how to organize this correctly?


title: Best practice for shared files within multiple unit test fixtures

text: I was wondering what the general best practice is for when you have multiple unit test fixtures testing different things that use the same file paths. My test files are in a directory tree with certain rules so currently I am reusing directory macros in each file, i.e.               #define TYPE1FILE "Type1Files/"     #define TYPE2FILE "Type2Files/"          #define GENERIC_FILE "generic/"     #define SPECIAL_FILE "special/"          #define BAR1 TYPE1FILE GENERIC_FILE "/foo.txt"     #define BAR2 TYPE1FILE SPECIAL_FILE "/foo2.txt"     #define BAR3 TYPE2FILE GENERIC_FILE "/foo.txt"     #define BAR4 TYPE2FILE SPECIAL_FILE "/foo2.txt"      However, this is starting to cause duplication in multiple files because multiple test fixtures will use the same:               #define BAR1 TYPE1FILE GENERIC_FILE "/foo.txt"      if they both use the same file. Also, it seems like it may be better to give them some scope by using variables inside the fixture or at least within the file. I like being able to see a list of what files are being used for each test, but I am also considering moving the BAR defines all into a shared header file. I am not crazy about that idea because it will end up being a giant list of files without any indication of what is used where. Also it couples the test cases together more. Does anyone have any suggestions?


title: In my permissions API, how do I handle objects that don't exist?

text: Elgg is designing a permissions API loosely around the Activity Streams model. The user API could look (roughly) like:               function elgg_can($capability, $subject = null, $object = null, $target = null) { ... }        * `$capability` is a string   * `$subject` is a user object   * `$object` is the object acted upon   * `$target` is the context in which the action would take place E.g. Can the current user edit the title of an object?               if (elgg_can('edit title', $currentUser, $someObject)) {         ...     }      I'd like to know a good way to handle **asking for permission to create objects**. If the object doesn't yet exist, then the permissions system can't know anything about it, so there's a chicken-egg problem with a few obvious solutions:   1. Allow passing in a string in place of $object (e.g. the TypeName).   2. Put metadata about the object in the $capability. E.g. `elgg_can("create PageObject", $currentUser, null, $group)`.   3. Have the API user create the object then pass it into the API to decide if it should be allowed to continue existing. Am I missing another obvious solution? Are there permissions models similar to this (that one could reasonably call successful) that handle this?


title: What is volume in terms of databases?

text: I was reading a text. It said,               "Information presentation must be compatible with the response time needs of      systems. The response time should be short enough that the information  does not      lose its freshness and value but it should be long enough to reduce volume (and      costs) and reveal important trends that signal the need for action"      What does volume mean in it? Please help out. Thanks


title: Cover Flow license issues?

text: I want to implement the Cover Flow effect in my commercial application on Windows. Are there any license issues about it? Because I think it has been patented by Apple.


title: Should I bother with trying to come up with names for these?

text: If you were to run across code like this in your travels would the short names bother you?               let setPropertyAssignment =          parser {             let! a = setIdentifierName             let! b = propertyName             let! c = openParenthesis              let! d = propertySetParameterList             let! e = closeParenthesis              let! f = openCurlyBracket              let! g = functionBody             let! h = closeCurlyBracket             return Node(NodeType.PropertyAssignment, [a;b;c;d;e;f;g;h])         }      Here is the largest parser in the project:               let iterationStatement =          parser {             let! a = doKeyWord             let! b = statement             let! c = whileKeyWord             let! d = openParenthesis             let! e = expression             let! f = closeParenthesis             let! g = statementTerminator             let symbols = [a; b; c; d; e; f; g]             return Node(NodeType.IterationStatement, symbols)         } +++ parser {             let! a = whileKeyWord             let! b = openParenthesis             let! c = expression             let! d = closeParenthesis             let! e = statement             let symbols = [a; b; c; d; e]             return Node(NodeType.IterationStatement, symbols)         } +++ parser {             let! a = forKeyWord             let! b = openParenthesis             let! c = maybeOne expressionNoIn             let! d = semiColon             let! e = maybeOne expression             let! f = semiColon             let! g = maybeOne expression             let! h = closeParenthesis             let! i = statement             let symbols = [a;b] @ c @ [d] @ e @ [f] @ g @ [h;i]                           return Node(NodeType.IterationStatement, symbols)         } +++ parser {             let! a = forKeyWord             let! b = openParenthesis             let! c = varKeyWord             let! d = variableDeclarationListNoIn             let! e = semiColon             let! f = maybeOne expression             let! g = semiColon             let! h = maybeOne expression             let! i = closeParenthesis             let! j = statement             let symbols = [a;b;c;d;e] @ f @ [g] @ h @ [i;j]             return Node(NodeType.IterationStatement, symbols)         } +++ parser {             let! a = forKeyWord             let! b = openParenthesis             let! c = leftHandSideExpression             let! d = inKeyWord             let! e = expression             let! f = closeParenthesis             let! g = statement             let symbols = [a;b;c;d;e;f;g]                            return Node(NodeType.IterationStatement, symbols)         }  +++ parser {             let! a = forKeyWord             let! b = openParenthesis             let! a = varKeyWord             let! c = variableDeclarationNoIn             let! a = inKeyWord             let! c = expression             let! d = closeParenthesis             let! e = statement             let symbols = [a; b; c; d; e]             return Node(NodeType.IterationStatement, symbols)         }


title: Frontend development, where to start?

text: I've been stuck on the backend for years now, working on webservices, DBs, SDKs, APIs and all that jazz, and so that's an area that I have a decent grasp of, but I've absolutely no clue about how the frontend works. What's a good place to start for a backend monkey like me who wants to learn the best practices, latest technologies and the philosophy behind modern web page design and its interaction with the server? I want to be cool like all of the other javascript kids. Thanks!


title: Need a simple compact program to execute few commands

text: (On Windows 7 64 bit)... I am looking for a program, something similar to the default Windows Terminal, what I need it to do is: Load text from a given URL, split the code in two variables and then trigger a simple Windows command based on these two variables. Currently I am doing this with PHP ...               <?php      $my_vars = file_get_contents('http://site.com/data.txt');     list($var1, $var2) = explode($my_vars);     exec("my command $var1 $var2");     ?>       This does the job fine but I don't like having PHP installed on Windows for something as simple as this. I am looking for a more compact file that maybe can be triggered from command prompt and doesn't have many additional files or dependencies, I need it to run on 2-3 computers too.


title: Working on multiple things at work?

text: I was curious to know, if juggling between 2-3 projects at a time is a good or a common practice or not. When I say, 2-3 projects I mean:   1\. 1 primary project,   2\. 1 project with minor improvements/changes and   3\. 1 project which comes at times for bug fixes So essentially, I find my self generally working on 2 projects in parallel and sometimes the 3rd one comes in with a trivial fix. Is this a problem? Or I should be learning to work on multiple projects at any given time. My personal opinion is, this style of work might affect how detailed and in-depth you think about a project.