title: Unit-testing databases: test all possible permutations of read and write to table?

text: I am testing a resource management class that is interacting with a database or a file system, or a combination of both. I was wandering if it is the norm to test **all possible permutations** of read and write for all columns of a data-set when a database is involved. What I mean is: Database table of test case:               +----------------------+----------------------+----------------------+----------------------+     | users                                                                                |     +----------------------+----------------------+----------------------+----------------------+     |       user_id        |      user_name       |      user_email      |      user_role       |     +----------------------+----------------------+----------------------+----------------------+     |          1           |      A New Name      | email@provider.com   |          1           |     +----------------------+----------------------+----------------------+----------------------+     |          2           |   A different name   | address@domain.com   |          1           |     +----------------------+----------------------+----------------------+----------------------+      I could envision something different going wrong in the abstraction layer, updating the first record but no others, updating the second record, but not the fourth, or any of other permutation or combination. Is it the norm to write tests for all those scenarios (if I am thinking this through correctly it would be 4! = 24 cases, right)? Now if I want to retrieve columns, I again could imagine something going wrong only retrieving the first and the fourth column, just the third, or all possible permutations of that. Now what if write and read is mixed, first a read, then a write, then a read. Maybe a write to one column, a read of three columns, then a read of one, or any other permutation. Very soon there are potentially thousands of test cases... Am I over thinking this and should I just test what I am actually encountering, or is it the norm to do due diligence and test all of this. I am asking because database access is causing my test suites to balloon in execution time. Edit: In case this wasn't clear, I am not trying to test if the database is doing what it should be, but if my abstraction layer behaves as intended.


title: Error handling - Should a program fail on errors or silently ignore them

text: I'm writing a simple little program to transmit MIDI over a network. I know that the program will encounter transmission problems and / or other exception situations that I won't be able to predict. For the exception handling, I see two approaches. Should I write the program so that it:   * fails with a bang when something goes wrong **_or_**   * should it just ignore the error and continue, at the expense of data integrity? Which approach would a user reasonably expect?   Is there a better way of handling exceptions? Additionally, should my decision about handling exceptions be affected by whether or not I am dealing with a network connection (ie. something where I can reasonably expect to have problems come up)?


title: What does Jamie Zawinski's Law mean?

text: I need a proper explaination of Jamie Zawinski's Law of Software Envelopment: > Every program attempts to expand until it can read mail. Those programs > which cannot so expand are replaced by ones which can.


title: Is there any good reason for someone who knows Python to learn Perl?

text: Reading the answers to Python vs. Perl in ten years time here on SE, most people seem to say go with Python. I agree (sorry Perl fans ;-) ). I already know Python, and I think it is a very good language, sure, as any programming language it _does_ come with its defects, but when I tried Perl I just didn't like it nearly as much as I liked Python. I "know" C, Python, Java and Scheme and have toyed with several other languages. Now, is there any good reason for me to learn Perl? **What is Perl "better" at than Python?** I do (hobby) application development and am learning some systems development as well (mostly programming for the Linux kernel). I'm pretty sure Perl is not fundamentally enough different from what I know this far to broaden my mind too greatly either (I would probably do better by focusing on Haskell, Scala, Forth or something like that for that purpose).


title: Beginning development of a C++ project

text: I study in software engineering and this year a new association at my university is opening a robotic submarine club. It's a new club and they needed software guys for micro-controllers manipulation, gui output and other software oriented requirements. I've been accepted to the club and there is nothing established right now. Although the language might not matter on a higher level we are working in C++ under a UNIX system. Since I have to set up the base I'd like to have input from people with experience on starting up big projects with collaboration in mind. Obviously we want this to scale nicely over the years and have a solid API for the future students who will replace the older ones. So to make my question more precise, I'm looking for tips on setting this up and perhaps books that could help me. I'm comfortable on implementation in C++ and I've done some analysis and conceptual OO courses too. It's really just that I've never had the chance to start up on something bigger than a 2-3 man group with SVN. I don't know either if there is a similar JUnit system and perhaps maintenance system that works well for C++ that I could set up for the team(I've used maven with trac in Java). This is an opportunity for me and the others because we have a green flag on using any of the latest technology and best practices, so I would like to exploit that and learn a thing or two about software management that I wouldn't normally learn in a company with a system already in place.


title: Is it best practice to have a file only of "includes/requires"?

text: I have 5-10 files on one server that all catch XMLRPC-PHP requests. There's about 20 lines of `require_once` in each one that are all the same. It'd make life simpler for me to create a separate file that only has the `requires` and `require` that in my XMLRPC files. Is this best practice, or does it open up issues that I don't know about?


title: Can I distribute open-source software that uses the syntax/interface of a proprietary program (Stata)?

text: Stata is a proprietary statistical program used largely by economists. I want to write a basic multiple regression package that uses the same commands as Stata, e.g., `regress var1 var2 var3, robust if var4[_n - 1] < .` Is it legal (in the US) to distribute source code that does this under an open-source license? In other words, does any IP protection apply to the command syntax used by proprietary software?


title: If an entity is composed, is it still a god object?

text: I am working on a system to configure hardware. Unfortunately, there is tons of variety in the hardware, which means there's a wide variety of capabilities and configurations depending on _what_ specific hardware the software connects to. To deal with this, we're using a Component Based Entity design where the "hardware" class itself is a very thin container for components that are composed at runtime based on what capabilities/configuration are available. This works great, and the design itself has worked well elsewhere (particularly in games). The problem is that **all** this software does is configure the hardware. As such, _almost all_ of the code is a component of the hardware instance. While the consumer only ever works against the strongly typed interfaces for the components, it could be argued that the class that represents an instance of the hardware is a God Object. If you want to do anything to/with the hardware, you query an interface and work with it. So, even if the components of an object are modular and decoupled well, is their container a God Object and the downsides associated with the anti- pattern?


title: Why is it not standard to implement abstraction layers for the file system?

text: I have been taught to access databases through abstraction layers. I was wondering why it is not also standard practice to access the file system through an abstraction layer? It seems to me unit testing would become much simpler, since mocking the filesystem is often a pain and poorly supported by some languages.


title: Best way to rename existing unique field names in database?

text: I have a database table that contains `id, filename, userId`   * id is unique identifier   * filename should also be unique   * table may contain >10000 records > When a user uploads a file it should be entered in database with given > rules:   1. If there is no record with same filename, it should be _added as it is_ (Ex. **foobar.pdf** )   2. If there is _record with same filename_ , it should be _added as uploadedName(2).ext_ ( **foobar(2).pdf** )   3. If there are n records with same base filename ( _foobar_ ), it should be _added as uploadedName(n+1).ext_ ( **foobar(20).pdf** )   4. Now if _foobar(2).pdf_ is uploaded, it should be added as **foobar(2)(2).pdf** & so on > This pattern needs to be followed because the file is already being uploaded > at client side using ajax before sending the details to server and the file > hosting service follows the above rules to name the files. * * * _**My solution:_**   1. maintain a file that contains all the names and the number of times it has occurred.   2. if a filename that exists in file is entered, increase occurrence count and new name is generated, else add to it to file   3. if the new name generated is in database, add it to file and generate new name


title: How do I handle a user story that I complete, but with compromise and need to revisit?

text: I have just fulfilled (is that a good term?) two user stories out of a new project backlog I have just built. These are user registration and password reset, both requiring mail. I need to implement a substitute mail component because my initial choice, and a normally reliable one, wasn't working. Because I was focused on delivering the user stories, not debugging the mail component, I swapped it out to deliver working code at sprint end. Do I now log a new support issue for the mailer, or 're-insert' these stories into the backlog? If I do the latter, am I not introducing too much tech detail into user stories?


title: elevator algorithm and implementation

text: I wanted to know how (real) elevators work. But, so far, I could not find much material about the algorithms they use, nor software (if any) for simulation. Could anybody give me references for that?


title: Are there any standard for exchanging rules rather than data?

text: Just out of curiosity. There are many open standards for data exchange, as well as standards for exchanging code (jsonp, for example). But are there any standards for exchanging formulas/rules, for them to be executed on different platforms?


title: Does following TDD inevitably lead to DI?

text: I learned to do Test Driven Development (TDD), Dependency Injection (DI) and Inversion of Control (IoC) all at the same time. When I write code using TDD I always end up using DI in my class's constructors. I am wondering if this is because of how I learned to do TDD, or if this is a natural side-effect of TDD. So my question is this: Does following TDD principals and writing unit tests that do not depend on external services inevitably lead to DI?


title: Best tool to privately share code with members of a team?

text: I'm getting into freelance web design and I have a team of several people. I was wondering what is the best tool (preferably free) to share code with other members of the team, allow them to edit it etc. A way for us all to work fluidly.


title: Code and intellectual property

text: Years ago I developed a website in Flash for one of my clients. I was in charge of code/animation and also maintaining Hosting and Domain. I also have a basic contract with my client and in the contract it does not mention who is the owner for the code. My Client (ex client) decided suddenly to work with a different company, so they moved the website without asking my permission and left me with unpaid bills for hosting and domain registration. Now the website is running on the same name but with a different extension, the website is managed by my competitor. The other company probably used some SWF Decompiler and uploaded the entire website on the new domain. My question:   * Even if in our contract it is not mentioned who the owner of the code/website, I would like to know if I have some right on the code/website I developed?   * Do you now any international regulation on this matter (I'm in Europe)? If you like please share your opinion or similar story on this, I would appreciate it.


title: Is functional programming just different, or is it actually really tougher?

text: Is functional programming just _different_ , or is it actually really _tougher_? Say someone who have never learned programming at all before, and is taught functional programming. vs someone who have never learned programming at all before, and is taught imperative programming. which will he find tougher? or the same? My question: say the problem now is to camel-case an input, such that `qwe_asd_zxc_rty_fgh_vbn` becomes `qweAsdZxcRtyFghVbn` The procedural way is:   1. split it along the `_`   2. loop through the array skipping the first item   3. for each entry we capitalise the first letter   4. join the results together The functional way is:   1. if cannot find `_` return `input`   2. cut the `input` along the first `_` (such that we get `qwe` and `asd_zxc_rty_gfh_cvb`)   3. capitalise the first letter of `head` and concat that with `f(tail)` Ok if you have a _functional-background_ AND have substantial experience in procedural-programming, I would like to ask: will it take you longer to figure out the procedural way or will it take longer for you to figure out the functional way? If you have a _procedural-background_ but have many years of experience with functional-programming, I would like to ask the same question: will it take you longer to figure out the procedural way or will it take longer for you to figure out the functional way?


title: Anyone know about webs.com?

text: I have a friend who created a website with web.com which use to be called freewebs.com. He also has his domain name registered through them as well. Are theses one of those dangerous sites to stay away from or is he going to be okay for now?


title: Service Method to Use for Uploading Large Chunks of Data

text: I have a need to be able to provide a web-based service to upload large amounts of data that would come in as chunks as large as 10,000 lines of 950 byte records, which is 9.5 MB. I've gotten advice that I shouldn't use web services (aspx) because MS has deprecated this, and I've also been told that WCF services aren't designed to be used for this purpose either (although this seems odd). FWIW, I've tried both WS and WCF and have run into size issues, and even though some solutions claim to fix this, I've not found any settings in either case that enable me to upload anything larger than 4 MB. The question is, if not WS and also not WCF, what else is there? I am trying to replace a number of different applications that all use FTP to upload data to a mainframe accounting system, and so for this question, FTP is not the answer. Unless the answer is that I need to abandon a service-based solution and stick with FTP.


title: Can I bundle my JavaScript code with an MIT licensed code and keep my code unaffected from the MIT license?

text: Can I bundle my proprietary JavaScript code with MIT licensed libraries (e.g. JQuery, AngularJS) into the same file, distribute it via HTTP but disallow my users to use my own code as an MIT licensed code? This way I could minimize the number of browser requests, and reduce errors due to network errors. I don't want to let my users copy, modify and reuse my own code outside of my website.


title: Is there any value in writing unit tests for code that already works when inheriting applications?

text: Obviously some old applications can't be or is extremely difficult to unit test because of the way it was written in the first place. But in places, like some helper methods which could probably be unit tested, should I bother writing unit tests for them? I mean, they could be written like a dog, but however complexly fragile the logic, the test of time has proved that it works the way it should. Should I only bother to unit test if I'm say re-factoring it or should I write unit tests for them whenever I have the time? Is there any value in doing this? Take into account also that the method definition may be vague, and I may need to research what some of the methods should actually do in given conditions.


title: Preferred location for installing user guides, sample documents on Windows?

text: By default, the installer for my product copies files to the **Users\Username\AppData\local\MyProduct** directory (though the user can change this during installation, of course). I want to bundle some other files with product - documentation, sample spreadsheets (it includes an Excel add-in) etc. It doesn't seem appropriate to copy these additional files to **AppData** because it's a hidden folder that users shouldn't really muck about with. I could, of course, create a new sub-folder in the user's Documents directory and stick the files in there but as I haven't asked their permission to do this it seems impolite. So - any suggestions as to an easily accessible location to put these files in?


title: Are MSDN licenses transferrable? How about if they have expired?

text: I have a coworker who will likely be leaving the company soon. An msdn subscription (Premium I believe) was purchased for him - but I believe it was more than 1 year ago. Is this license transferrable to me when he leaves the company?


title: Finding the lowest average Hamming distance when the order of the strings matter

text: I have a sequence of binary strings that I want to find a match for among a set of longer sequences of binary strings. A match means that the compared sequence gives the lowest average Hamming distance when all elements in the shorter sequence have been matched against a sequence in one of the longer sets. Let me try to explain with an example. I have a set of video frames that have been hashed using a perceptual hashing algorithm so that the video frames that look the same has roughly the same hash. I want to match a short video clip against a set of longer videos, to see if the clip is contained in one of these. This means that I need to find out where the sequence of the hashed frames in the short video has the lowest average Hamming distance when compared with the long videos. The short video is the sub strings Sub1, Sub2 and Sub3, and I want to match them against the hashes of the long videos in Src. The clue here is that the strings need to match in the specific order that they are given in, e.g. that Sub1 always has to match the element before Sub2, and Sub2 always has to match the element before Sub3. In this example it would map thusly: Sub1-Src3, Sub2-Src4 and Sub3-Src5. So the question is this: **is there an algorithm for finding the lowest average Hamming distance when the order of the elements compared matter?** The naïve approach to compare the substring sequence to every source string won't cut it of course, so I need something that preferably can match a (much) shorter sub string to a set of million of elements. I have looked at MVP- trees, BK-trees and similar, but everything seems to only take into account one binary string and not a sequence of them.               Sub1: 100111011111011101     Sub2: 110111000010010100     Sub3: 111111010110101101          Src1: 001011010001010110     Src2: 010111101000111001     Src3: 101111001110011101     Src4: 010111100011010101     Src5: 001111010110111101     Src6: 101011111111010101      I have added a calculation of the examples below. (The Hamming distances aren't correct, but it doesn't matter)               **Run 1.**     dist(Sub1, Src1) = 8     dist(Sub2, Src2) = 10     dist(Sub3, Src3) = 12     average = 10          **Run 2.**     dist(Sub1, Src2) = 10     dist(Sub2, Src3) = 12     dist(Sub3, Src4) = 10     average = 11          **Run 3.**     dist(Sub1, Src3) = 7     dist(Sub2, Src4) = 6     dist(Sub3, Src5) = 10     average = 8          **Run 4.**     dist(Sub1, Src3) = 10     dist(Sub2, Src4) = 4     dist(Sub3, Src5) = 2     average = 5      So the winner here is sequence 4 with an average distance of 5.


title: what is a efficient way to find repeating decimal

text: I am trying to find a efficient algorithm in Java to find the repeating decimal part of two integers `a` and `b` where `a/b`. eg. 5/7 = 0.714258 714258.... I currently only know of the long division method.


title: How do I convince the IT department to relax Antivirus settings on my PC

text: I've been given a relatively decent new laptop at Work. I really thought it would help speeding development up, especially build times and the like. The problem is that our company runs Mcafee antivirus and it is slowing my machine down to a halt. My harddrive is almost always active even when I'm doing nothing. It seems to be doing some kind of real time scan. I run no antivirus at home and haven't had any problems in years as I know not to do anything stupid like download attachments that I'm not expecting etc. Also, the corporate firewall is pretty strict so I believe that would make it even harder to obtain a virus. How would you convince the IT department to relax AV settings for you? edit: As many people have pointed out, the chance of getting them to turn it off is slim to non so I've changed the subject from disable to relaxing settings.


title: Ways of marking changes being made to a file

text: I am looking for a lightweight way to notate changes made to a file. The obvious answer to this is a version control system. But this is more robust than necessary for what I would like to do. All I want is the functionality to compare an edited file to its original in a lightweight manner.


title: how to deal with controller mutations

text: During development process, things are constantly changing (especially in early phases). Requirements change, UI changes, everything changes. Pages that clearly belonged to specific controller, mutated to something completely different in the future. For example. Lets say that we have website for managing Projects. One page of the website was dedicated to managing existing, and inviting new members of specific project. Naturally, I created members controller nested under projects which had proper responsibility. Later in the development, it turned out that it was the only page that was "configuring the project" in some way, so additional functionalities were added to it:   * editing project description   * setting project as a default   * ... In other words, this page changed its primary responsibility from managing project members to managing project itself. Ideally, this page should be moved to "edit" action of "projects" controller. That would mean that all request and controller specs need to refactored too. Is it worth the effort? Should it be done? Personally, I am really starting to dislike the 1-1 relationship between views and controllers. Its common situation that we have 1 page (view) that handles 2 or more different resources. I think we should have views completely decoupled from controllers, but rails is giving us hard time to achieve this. I know that AJAX can be used to solve this issue, but I consider it an improvisation. Is there some other kind of architecture (other than MVC) that decouples views from controllers?


title: Technical Support Developer position with a Software Engineering degree

text: I've received a job offer from a company for a technical support developer. I originally had an interview lined up with them for a C# Developer role but this was filled internally before my interview. I am feeling under a lot of pressure to take this role because of the economy and since it'll be my first role since graduating. The reason for this post though... will I be hurting my chances of becoming a fully fledged software developer in the near future? The job will involve mostly bug fixing and testing with skills required such as C#, ASP.net, MVC, Javascript. As far as I'm aware, there'll be no pure development. There will be chance to progress to new roles in the business but I'm unsure of the time frame. I would be grateful to hear from anyone who has been in similar positions.


title: Finding and managing a group of testers

text: I am about to release a piece of software that will be licensed with the **GPLv3** (the project itself is "for fun" and has no commercial dimension in it). The software is intended to help designing digital clocks and I know the core functionality works as - beside having unit tests - I used it for designing a couple of clocks myself. Yet, before getting the software advertised on hackers and makers sites, I would like to get a few voluntary testers... trying to use it and reporting any problems. The only tests I did so far in my life were with fellow programmers or with the customers. So I would appreciate input from the community on:   1. **Where to find voluntary testers** (is there a well-known website that escaped my googling perhaps?)   2. **How to brief them** (fellow programmers and clients know a great deal on the software they are going to test... should I try to brief in depth these "unknown" testers or should I contrarily try to let them "on their own"?)   3. **How to structure the tests** (I'm not asking what to ask them to do here, but if I should structure my test in some specific way: for example in more phases, like having one group to make a test, then fix bugs, then having a second group test again... or collecting data in a particular way [e.g. with a questionnaire with scores rather than with free-form e-mails])   4. **How to give maximum visibility to their contribution** (Again: I can't afford to invest _also_ money on this project, but I would be happy to give them as much glory as I can to them! The focus of the test would be primarily **usability** (Does the GUI make sense? Is the workflow easy to follow? Are there unexpected behaviours?). But of course any bug that should emerge in the core functionality would definitively receive all my attention too! Thanks in advance for your advice and time.


title: What's the best way to get up to speed with Java?

text: I'm a software developer that just switched teams so I shall write code in Java now. Last time I wrote something in the language was in programming 101 at uni (I was already an amateur coder back then). So what is the best book/tutorial to get up to speed with Java? Where's the _Java - the good parts_? Learn you some Java for great good? _Learn Java the hard way_? Or is it too enterprisey for that kind of passion...?


title: Why would a developer create a public class that has all static properties?

text: A previous developer has a couple public classes that do not inherit from any other classes but are filled with static properties. Is this another way of creating a struct or enum? Is this an older or newer technique of housing static data to be referenced? I find it odd/different to see a class built in this way but am wondering what other fellow programmers thoughts or feelings are about what this coder was trying to accomplish. This is a made up example of what I am seeing...                   public class CashRegister         {             public static decimal OneDollarBill             {                 get { return (decimal)1; }             }                  public static decimal TenDollarBill             {                 get { return (decimal)10; }             }         }


title: Does it make sense to sanitize email form input?

text: So, I'm expending this email submission form script for a client and saw something rather strange to my experience. As you can see below, the original programmer has sanitised the user input. Is this a good practice or does this makes sense at all?               // Build Message Body from Web Form Input      foreach ($_POST as $Field=>$Value)         $MsgBody .= "$Field: $Value\n";      $MsgBody .= "\n" . @gethostbyaddr($_SERVER["REMOTE_ADDR"]) . "\n" .         $_SERVER["HTTP_USER_AGENT"];      $MsgBody = htmlspecialchars($MsgBody, ENT_NOQUOTES);  //make safe      Thanks everyone!


title: Why are /// comment blocks important?

text: Someone once said we should prefix all our methods with the `/// <summary>` comment blocks (C#) and I am wondering if that is true or not. I started to use them and found they annoyed me quite a bit, so stopped using them except for libraries and static methods. They're bulky and I'm always forgetting to update them. Do you recommend using them? Why? **EDIT** : I normally use `//` comments all the time, it's just the `/// <summary>` blocks I was wondering about


title: Which library/framework did you ditch as being too complex for the problem it is solving?

text: ... and coded the functionality "manually"? As a rather metaphorical example, you'd hardly need a library for solving quadratic equations, although such libraries do exist and someone takes them seriously. As a more questionable case, depending on the circumstances I may ditch jQuery (for example when I don't need to support some stone age browsers): it does simplify some things but it adds another layer of complexity and unreliability to DOM. And overusing jQuery leads to absurd problems, such as one seen recently on SO: how do I assign an empty href to an `a` tag with jQuery? Turned out it was a HTML question, not even JavaScript. Another absurd case and yet non-obvious for many is using some templating engine/language built on top of another templating system: PHP. Third level of templating anyone? And another one: _sometimes_ just spitting out XML with (figurally) `printf` is far easier than doing it with some monstrous XML engine. Any other cases from your experience?


title: What would happen if you defined your system's CSV delimiter as being a quotation mark?

text: Title says it all. If the CSV's system delimiter was `"` (as opposed to a comma or pipe or other common alternatives), how would anything deal with it? The crux of the matter is of course that by definition, CSV will surround any values containing the delimiter with quotation marks, and will convert all quotation marks to double quotation marks. Would the result be parse-able? (Inspired by an answer in Most common "Y2K-style" bugs today?) ![System Delimiter \(which drives excel, databases, etc\)](http://i.stack.imgur.com/lWhbO.png)


title: How can I send a signal to a program via external hardware

text: I am trying to find a piece of hardware that will signal a program to start a timer when it is moving and stop when it stops. The hardware can just be a ball that moves and is connected to the computer through USB, I was thinking of something similar to the way a mouse would work. For the programing I would like to use c# or possibly ActionScript with adobe air. I am a web developer and have not had any experience with hardware or drivers and would appreciate any ideas on where to start. Maybe there is some piece of simple hardware out there that I can use to send signals to the computer or some literature of articles for beginners that you can point me to. Thanks in advance


title: Are niche job boards effective?

text: There are number of job openings each day and also there are number of job seekers actively looking for job everyday. Still it is challenging to find right candidate for a job. It gets even more challenging and surprising when both the employer and the candidate are active seekers, but could not connect each other. There are very niche job sites that focus on specific technologies. Are these places more effective at connecting employers with qualified candidates than the more conventional and less focused job sites?


title: How could I avoid a distributed deadlock during a mutual connection between two nodes?

text: Suppose we have two peer nodes: the first node can send a connection request to the second one, but also the second one can send a connection request to the first one. How to avoid a double connection between the two nodes? To resolve this issue, it would be sufficient to make sequential the operations performed for creating inbound or outbound TCP connections. This means that each node should process sequentially each new connection creation operation, both for incoming connections and for outgoing connections. In this way, maintaining a list of connected nodes, before accepting a new incoming connection from a node or before sending a connection request to a node, it will be sufficient to check if this node is already present in the list. In order to make sequential the operations of creating connections, it is sufficient to perform a _lock_ on the list of connected nodes: in fact, for each new connection, the identifier of the new connected node is added to this list. However, I wonder if this approach can cause _distributed deadlock_ :   * the first node could send a connection request to the second one;   * the second node could send a connection request to the first one;   * assuming that the two connection requests are not asynchronous, both nodes lock any incoming connection requests. How could I solve this problem? **UPDATE:** However, I still have to lock on the list every time a new (incoming or outgoing) connection is created, since other threads may access this list, then the problem of deadlock would still remain. **UPDATE 2:** Based on your advice I wrote an algorithm to prevent mutual acceptance of a login request. Since each node is a peer, it could have a _client routine_ to send new connection requests and a _server routine_ to accept incoming connections.               ClientSideLoginRoutine() {         for each (address in cache) {             lock (neighbors_table) {                 if (neighbors_table.contains(address)) {                     // there is already a neighbor with the same address                     continue;                 }                 neighbors_table.add(address, status: CONNECTING);                  } // end lock                  // ...             // The node tries to establish a TCP connection with the remote address             // and perform the login procedure by sending its listening address (IP and port).             boolean login_result = // ...             // ...                  if (login_result)                 lock (neighbors_table)                     neighbors_table.add(address, status: CONNECTED);              } // end for     }          ServerSideLoginRoutine(remoteListeningAddress) {         // ...         // initialization of data structures needed for communication (queues, etc)         // ...              lock(neighbors_table) {             if(neighbors_table.contains(remoteAddress) && its status is CONNECTING) {                 // In this case, the client-side on the same node has already                 // initiated the procedure of logging in to the remote node.                      if (myListeningAddress < remoteListeningAddress) {                     refusesLogin();                     return;                 }             }             neighbors_table.add(remoteListeningAddress, status: CONNECTED);              } // end lock     }      **Example:** The IP:port of node A is A:7001 - The IP:port of node B is B:8001. Suppose that the node A has sent a login request to the node B:8001. In this case, the node A calls the login routine by sending by sending its own listening address (A:7001). As a consequence, the neighbors_table of node A contains the address of the remote node (B:8001): this address is associated with the CONNECTING state. Node A is waiting for node B accept or deny the login request. Meanwhile, the node B also may have sent a connection request to the address of node A (A:7001), then node A may be processing the request of the node B. So, the neighbors_table of node B contains the address of the remote node (A:7001): this address is associated with the CONNECTING state. Node B is waiting for node A accept or deny the login request. If the server side of node A rejects the request from B:8001, then I must be sure that server side of node B will accept the request from A:7001. Similarly, if the server side of node B rejects the request from A:7001, then I must be sure that server side of node A will accept the request from B:8001. According to the "small address" rule, in this case the node A will reject the login request by the node B, while node B will accept the request from node A. What do you think about that?


title: Scrum on very short projects?

text: I'm using Scrum and really liking it. However, my shop finds itself in projects where the duration of the development effort is two or four weeks. We've already modified the sprint length to two weeks, and everyone here says "it'll be Scrum, just with one and a half sprints." I don't think we can get a lot of value from one and a half sprints. How can we get the benefits of an iterative development process with only one, two, or one-and-a-half iterations?


title: What is the effect of creating unit tests during development on time to develop as well as time spent in maintenance activities?

text: I'm a consultant and I am going to introduce unit tests to all developers at my client site. My goal is to ensure that all new applications should have unit tests for all classes created. The client has a problem with high maintenance costs from fixing bugs in their existing applications. Their applications have a life span from between 5-15 years in which they continuously add new features. I'm quite confident that they will benefit greatly from starting with unit tests. I'm interested in the effect of unit tests on the time and cost of development:   * How much time will writing unit tests as part of the development process add?   * How much time will be saved in maintenance activities (testing and debugging) by having good unit tests?


title: How important do you think IE-friendliness is?

text: I think most web developers will agree that it is often easier getting something to work well in most browsers, but not as much in IE. I was wondering: When designing/developing a website, how important do you think IE-friendliness is? I mean, how worth it is it to bust yourself trying to make a website that works perfectly in major browsers work the same in IE?


title: iPhone, iPad & XCode 4 - Noob question

text: I'm new just about everything 'Apple' with the exception of owning an iPhone and iPad for over a year. I have 15+ years on Wintel platforms w/ C/C++/C# experience, so Obj-C doesn't scare me. I recently purchased a Mac Book Pro and have XCode 4, but I've noticed most online tutorials (at least that I can find) are still geared for XCode 3.x. My question, does anyone know of any online tutorials (text or video) geared around XCode 4? The only ones I'm aware of are on developer.apple.com. While good, those seem to assume you're transitioning from XCode 3.x. Thanks [Edit] - Adding a link, and will try to keep this current for other readers.   * Standford's


title: Data/Object Design Problem

text: **Goal:** I'm trying to figure out the best way to model/design and then implement a "user" feature in a system. **Background:** I am designing an on-line access request system, so our company can use a web- based method for users to request access to various software systems. Since the system is all about the "user", the user is the focal point of the system. So, a User can request access to a system. Then, the User's Manager will approve/reject the request. After that, the System Owner will approve/reject the request. Then it's the System Admin who approves/rejects, and finally the Security Administrator approves/rejects and adds them to the appropriate Active Directory group so they have access to the target Active Directory- driven application (not this application). **Problem:** I see all entities that represent a User as a core (set of) class(es) in the system. The User object is straight-forward - just pass their Windows login to Active Directory (AD) via an LDAP query and get their info and load it into an object. In an LDAP query, if there are other Users that report to them (a user's manager is stored in our AD), then this "user" is not only a User in this system but also a Manager. If this User is also in the database as a System Owner, they are also a System Owner. **So Far:** (Assume a Manager is someone with at least one direct report assigned to them in AD.) I've considered a single User object, with properties such as IsManager or IsSystemOwner. However, should I construct an object hierarchy where (for example) a Manager class inherits from User? There are quirks with this, because a System Owner could inherit from User or Manager. Not all system owners are managers. However, Managers, System Owners, System Admins, and Security Admins are all Users, because they can be requesting access to some software system where there role in this system is only as a User. Here is an overview of "is a" for all of the user entities:   * A User can request access to some other software system in this system.   * A Manager is a User.   * A System Owner is a User.   * A System Admin is a User.   * A Security Admin is a User (but unlikely to be, due to our organization).   * A Manager may be a System Owner, but not always.   * A System Owner may be a Manager, but not always.   * A System Admin may be a Manager, but not always.   * A System Admin may be a System Owner, but not likely.   * A Security Admin may be a Manager, but not always.   * A Security Admin may be a System Owner, but not likely. Some additional info:   * I don't anticipate Security Admins to be using the system as a User to request access, but it's always a possibility.   * A Manager may create an access request on behalf of one of their employees (to revoke access to a fired employee, for example)   * All employees in the Windows domain will have access to this site. I assume that I will have some Active Directory groups created for System Admins and Security Admins, as the users in these groups will not be dynamic, rather, users in one team are Sys Admins and users in another team are Security Admins.   * The System Owner is subject to changed and will be stored in the database, along with the option to designate an alternate approver when on vacation, etc.   * I may need a Manager to have an alternate approver, but I didn't plan on storing all users on the domain in the database! This seems like it's so easy to model on paper, but getting it into good, flexible code is stumping me. All suggestions are welcome. EDIT: Based on Karl's feedback, I have this prototype model. Does it look solid from an OOP perspective, based on my intended use?               Public Class MyCustomUserObject              Public Property LoginID As String         Public Property FirstName As String         Public Property LastName As String         Public Property EmailAddress As String              Public Property Roles As List(Of Role)              Public Function IsManager() As Boolean             ' If List(Of Role) contains an object of type ManagerRole, then True, else False.         End Function              Public Function IsSystemOwner(systemName As String) As Boolean             ' If List(Of Role) contains an object of type SystemOwnerRole with matching name             ' in SystemOwnerRole.SoftwareSystems, then True, else False.         End Function              Public Function IsSystemAdministrator(systemName As String) As Boolean             ' If List(Of Role) contains an object of type SystemAdministratorRole with matching name             ' in SystemAdministratorRole.SoftwareSystems, then True, else False.         End Function              Public Function IsSecurityAdministrator() As Boolean             Return My.User.IsInRole("My Active Directory group name for Security Admins")         End Function          End Class          Public Class SoftwareSystem              Public Property ID As String         Public Property Name As String          End Class          Public MustInherit Class Role              Public Property DesignatedApproverLoginID As String          End Class          Public Class ManagerRole         Inherits Role              Public Property Subordinates As List(Of AafUser)         ' Or this, with a List of login IDs?         ' Public Property Subordinates As List(Of String)          End Class          Public Class SystemOwnerRole         Inherits Role              Public Property SoftwareSystems As List(Of SoftwareSystem)          End Class          Public Class SystemAdministratorRole         Inherits Role              Public Property SoftwareSystems As List(Of SoftwareSystem)          End Class          Public Class SecurityAdministratorRole         Inherits Role              ' Explictly a Security Admin for all Software Systems.          End Class


title: What tools do you use to stay focused?

text: This is related, but I'm thinking about something more like a chastity belt for keeping me from checking programmers.SE or my email every time I compile. Rather advice like "go take a walk and you'll feel more like coding", I just need something to augment my weak constitution - a net nanny for my geek fetish I guess. I'll take my answer off the air and I promise not to check programmers.SE for at least a day.


title: Do you start migrating your Swing project to JavaFX

text: I have a 4 years old project which is written in Swing + SwingX. Currently, it is still alive and still kicking. However, as more GUI related feature requests coming in (For instance, a sortable tree table), I start to feel the difficulty in fulling the requests. This is true especially since there isn't any active development going around SwingX project. Also, I can hardly find any good, yet actively maintained/ developed/ evolving GUI Java framework. I was wondering, do any of the Swing developers feel the same thing? Have you start to migrate your Swing project to a much more active developed GUI framework, like JavaFX?


title: Should your client be able to view your project management board?

text: We're making a bespoke software for our client and use Codebase for our project management. Is it a good idea to let our client view our project management board? The advantages that we thought of are that this would enhance the cooperation between the client and the dev team, following agile practices. He would essentially become part of our team. It would also reduce communication overhead and make sure we're on the same page. The client could track the progression of the system and make suggestions along the way on the user stories. In addition, he could submit bugs or feature requests. The disadvantages that we though of are that some aspects of the board might be too technical to the client. He would suggest changes to the user stories too often and he might view some content that we normally wouldn't want our client to see. For example, when we compromise on technology or functionality, the client might question that and insist on doing things one way or the other.


title: Understanding and developing web services

text: This question is in conjuction with **How would you approach developing a Hotel Reservation System?** The solution to a system with different interfaces (or clients I should say) is to go with developing a Web service and have other systems interact with it. I never had the requirement for developing a Web service so I am bit short on it. All I understand is that **A web service is a system or application that performs some operations which may include modifying, sending or receiving data over a network using HTTP protocol**. (Let me know if the understanding is wrong) Now, from the other question it's clearly understood that I need to develop a web service but I have no idea as to how should I go about it. My language of choice is C# and .NET Framework. **Question** : How do we develop a webservice and which tools, technology and framework should I use for the same using C# language? **Question** : How can I interact with this from a desktop WPF application, website and mobile app.


title: Is it acceptable that after reading a certain technology in a book, you put it in your resume as a skill?

text: I am a junior IT person and I am a bit short on experience and I am diploma graduate so which makes me lack knowledge in the eyes of the human resource department. so what I do is I read technical books like AJAX, SOA, RUBY and stuff like that. Now is it alright if I put that on my resume as a skill of mine without the expensive, somewhat unnecessary, almost boring formal education with them certificates to prove your knowledge?


title: Moving from mock to real objects?

text: I'm like doing TDD so I started everything mocking objects, creating interface, stubbing, great. The design seems to work, now I'll implement the stuff, a lot of the code used in the stubs are going to be reused in my real implementation yay! Now should I duplicate the tests to use the real object implementation (but keeping the mocks object of the sensitive stuff like Database and "services" that are out of my context (http calls, etc...)) Or just change the mocks and stubs of the actual tests to use the real objects....... So the question is that, keep two tests or replace the stubs, mocks? And after that, I should keep designing with the mocks, stubs or just go with real objects? _(Just making myself clear I'll keep the mock object of the sensitive stuff like database and services that are out of my context, in both situations.)_ EDIT               [Fact]     public void Change_status()     {         var dbContext = MockRepository.GenerateStub<IDbContext>();         var repository = MockRepository.GenerateMock<IRepository<Foo>>();              var predicate = MockRepository.GenerateStub<Func<Foo, bool>>();         repository.Expect(x => x.Get(predicate)).Return(_foo).Repeat.Once();         dbContext.Expect(x => x.Commit());              var ctl = MockRepository.GenerateStub<IFooCtl>();         ctl.Stub(x => x.RejectRequest(_fooView)).WhenCalled(delegate         {             var foo = repository.Get(predicate);             foo.Status = Status.Rejected;             _fooView.Status = Status.Rejected.ToString();              }).Return(true);              ctl.RejectRequest(_fooView);              repository.VerifyAllExpectations();         dbContext.VerifyAllExpectations();         Assert.True(_fooView.Status == "Rejected");         Assert.True(result.Count() == 1);     }      This is a test, where I mock the repository, context and stub the facade. So what I'm trying to say is if I should change the stub of the facade to use the "real" code so this should be tested as               [Fact]     public void Change_status()     {         var dbContext = MockRepository.GenerateStub<IDbContext>();         var repository = MockRepository.GenerateMock<IRepository<Foo>>();              var predicate = MockRepository.GenerateStub<Func<Foo, bool>>();         repository.Expect(x => x.Get(predicate)).Return(_foo).Repeat.Once();         dbContext.Expect(x => x.Commit());              var ctl = new FooCtl(loanRepository, happyLoanDbContext);         var result = ctl.RejectRequest(_loanView);              repository.VerifyAllExpectations();         dbContext.VerifyAllExpectations();         Assert.True(_result);     }      Or if I should leave everything mocking and stubbing that tests the designs and create new ones that tests the implementation. EDIT Thanks for all your answer, I think I understand it better, I must know which is my SUT and test that, no mock or stub the SUT just the components that will help the SUT to pass the test


title: Is running "milli"-benchmarks a good idea?

text: I just came across the Caliper project and it looks very nice. Reading the introduction to microbenchmarks, one gets the feeling that the developers would not suggest to use the framework if the benchmark takes longer than a second or so. I looked at the code and it looks like a RuntimeOutOfRangeException is actually thrown if a scenario takes longer than 10s to execute. Could you explain to me what the problems are with running larger benchmarks? My motivation for using Caliper was to compare two join-algorithm implementations. Those will definitely run for quite some time and will do some disk IO, yet running the entire database would make it hard to do the comparison, because the configuration of the algorithms and the visualization of the results would be a pain.


title: What am I missing from my CI stack?

text: Right now, the current deploy process at my work is based around tagging from the trunk and switching various PHP web sites for clients on our QA and Production servers. While this is simple from the technical level, it becomes really tedious when you have over a dozen updates to a dozen different sites that need to go out in one day. Towards this end, I'm implementing the following stack:   * SVN   * Hudson   * Capistrano And it will work like this:   1. Code goes into `svn`   2. `svn` post-commit hook triggers `hudson`   3. `hudson` runs a `capistrano` script to deploy to the dev server   4. project managers check out the dev server, and if the bug is fixed, they go into `hudson` and promote the build   5. `hudson` runs a post-promotion script which tags and deploys the code to whatever server is specified by the promotion Capistrano (along with the symfony framework) will be used to migrate the databases. Am I missing anything here? I've never done anything more complicated than subversion before, so that's why I'm asking.


title: Pros and Cons of Joint Application Design

text: I was asked to lead "JAD sessions", which I've heard of before, but never facilated before; at least in name, they appear just to be a fancy name for stakeholder workshops. My experience has been that "group think" and "follow the leader" are common issues with this approach, but trying to stay open to the concept. Based on what I'm able to tell the phrase has been around since the 1980s, so clearly it's no "silver bullet". What are the key pros and cons of this approach?


title: programmer meta skills

text: I used to think that my ability to create clever algorithms or my comfort with the languages I work in would determine my success as a programmer, but after a dose of real world development, I realized that these skills aren't nearly as valuable as the ability to choose the right tools for the job, to communicate with a team effectively, to decide when to use something out of a box vs. write your own version, and to have patience when trying alternatives until your high level of excellence is met or exceeded. I was wondering what other 'meta' skills people think are useful for a programmer/software engineer to have and how important they are _relative_ to the technical skills. This is NOT the same as simply asking what soft skills will help make a good programmer. More importantly, when looking to hire someone, how can you test for these better indicators of success (most interview questions I see are still just testing technical ability). Also, does anyone know of any books or blogs which focus on these meta skills? Thanks.


title: How to properly license open source software

text: I have a project I've been working on which I would like to push into a new, public Github repository as open source. After searching on StackExchange for the right license to use I've settled on the BSD license. My question is: now what? Do I just need to copy the BSD license text into a file called LICENSE in the root of my repository and call it good? Is that the general rule for how all open source licenses work? Or do I need to notify some other organization that I'm using this license so I can 'enforce' it if necessary?


title: Where can I learn the most up-to-date standard for HTML and CSS?

text: I'm looking to learn updated HTML/CSS in preparation for HTML5. Since I am new to this it's hard for me to know which websites are teaching old HTML coding styles and which are teaching the good one. Does anyone know of some websites that fit my criteria?


Are there standard practices when writing a spec for a software development project? Is there a specific format to follow? Also, does the developer or the client write this up? If the dev, is this billable?


title: Where do you draw the line between quantity and quality?

text: My manager has talked with me and says that the quality of my work is excellent, but I need to step up the quantity of how much I crank out. I've only been working for a couple of years, so I still feel like I have a lot to learn. Which route do I take (or is there another?): Quantity: If they want crap, I can give them lots of it. Quality: Ignore the request, and hope that my productivity will increase with experience.


title: 3D Secure MPI providers - suitable for multiple third party payment systems?

text: Long time user of SO, and figured this is the best place to ask this question. I am currently consolidating our eCommerce payment clearing systems into one Asp.Net MVC website that will work like PayPal but for our own websites. The businesses within the group have different rules as to the payment provider that is to be used throughout the world and, at present, we currently integrate with Servebase, Moneris and PayPal. Thus, I have an architecture that allows new providers to be written and plugged in through a single extensibility point. In the future I am likely to have to support 3D Secure, which complicates matters significantly; not only because of the additional web workflow but because each provider appears to recommend it's own MPI provider/solution for the 3D Secure process. Assuming that all three of these payment providers appear to offer the same kind of 3D Secure hooks (I'm seeing similar parameters in all of their APIs), do you think I'm going to be able to use a single MPI to manage the 3D Secure process for all or do you think I'm going to have to have a different 3D Secure implementation for each of my providers? For example, PayPal recommend using Cardinal Centinel for 3D Secure - so let's say I get a single account for them, what are the chances I'll be able to reuse it for Moneris or Servebase, say. Is the 3D Secure system a 'standard' (using the term loosely there!) that is simply being echoed by these other payment providers? It doesn't matter if you know nothing of the other APIs I mention here - i.e. Moneris, Servebase - if you've had any experience similar to mine I would appreciate any thoughts.


title: How to apply design patterns in this scenario

text: I want to use design patterns for the following scenario. How to? I have classes named Person, Employee and Customer and all of them have their own save, update, get and delete methods. Employee and Customer classes are derived from person. What may be the best way to code?


title: How to organize cross platform js/web application?

text: My friend and I are working on an application that already works for Windows 8 and is written in Javascript, HTML, and CSS. Our desire is to make it cross platform for areas like windows mobile, chrome, firefox, and android. So, our directory structure looks like this:               .     ├SomeApp.sln         // Visual Studio solution file     ├SomeApp.suo         // other Visual Studio related file     ├SomeApp.v11.suo     // other Visual Studio related file     ├deploy.py           // Deployment script for apache     ├Makefile            // For things like building the desktop version     │                    // and for testing/linting/deploying     conf     ├── apache.conf     SomeApp     ├── AppPackages     ├── bin     │   ├── Debug     │   └── Release     ├── bld     │   ├── Debug     │   └── Release     ├── css     ├── images     ├── js     │   └── lib     ├── pages     ├── promo images     └── strings         // i18n language files         ├── ar         ├── bg         ├── cs         ├── da         ├── de         ├── el         ├── en-US         ├── es         ├── fr         ├── he         ├── hr         ├── hu         ├── it         ├── ja         ├── ko         ├── nb         ├── nl         ├── pl         ├── pt         ├── ro         ├── ru         ├── sv         ├── tr         ├── uk      I added things like the deploy script and the make file... but I'm really at a loss on how to organize a project like this. Would I create directories like this?               .     ├──browserExtension/        │  ├── build/           // put makefile here?                │  ├── conf/            // put apache conf here?                │  ├── chrome/           │  ├── firefox/     ├──web/                  // normal web page      ├──windows/                     │  ├── WindowsMobile8/           │  └── Windows8/        // put existing solution files here?     ├──mobile/            │  ├── android/     └──common/        ├── css/        ├── js/        │   └── test/        └── html/      Is there a good example of a project that's already been successful doing this that I can follow?


title: Should my source code be in UTF-8?

text: I feel that often you don't really choose what format your code is in. I mean most of my tools in the past have decided for me. Or I haven't really even thought about it. I was using TextPad on windows the other day and as I was saving a file, it prompted me about ASCII, UTF-8/16, Unicode etc etc... I am assuming that almost all code written is ASCII, but why should it be ASCII? Should we actually be using UTF-8 files now for source code, and why? I'd imagine this might be useful on multi-lingual teams. Are there standards associated with how multilingual teams name variables/functions/etc?


title: OOP - Modeling a Chat

text: When modeling a chat, should a chat object receive messages or a message be sent to a chat object? I'm not sure whether there is a definitive answer but maybe someone can point out benefits of one over the other. ` message.send(chat); ` VS. ` chat.sendMessage(message); `


title: Any tips how to successfully job hunt?

text: I have been looking for a job for more than 3 weeks and have applied for about 30 vacancies. From all of these I only received few calls from recruitment agencies which didn't propose anything special. One of them just forwarded my CV to the employee and another suggested me to fix my current CV. I made some changes to CV which they didn't like and resent it back. No reply since. I feel frustrated and worried. First of all I don't like that everything vacancy should go through recruitment agency. Even if I want to apply directly I cannot find any name or any lead which company is recruiting. Secondly I don't see any reason why nobody replies back. My cover letter is in plain text and CV is made in Latex. Everything is crafted by all suggestion I have read over the internet and one very interesting book "The Google Resume". What I am doing wrong? Is there any tips how to search direct jobs? Particularly I am interested in UK job market. P.S. I am using http://www.simplyhired.co.uk/ which I believe is the best site because it accumulates from all it job boards.


title: How to simulate inner join on very large files in java (without running out of memory)

text: I am trying to simulate SQL joins using java and very large text files (INNER, RIGHT OUTER and LEFT OUTER). The files have already been sorted using an external sort routine. The issue I have is I am trying to find the most efficient way to deal with the INNER join part of the algorithm. Right now I am using two Lists to store the lines that have the same key and iterate through the set of lines in the right file once for every line in the left file (provided the keys still match). In other words, the join key is not unique in each file so would need to account for the Cartesian product situations ...               left_01, 1     left_02, 1     right_01, 1     right_02, 1     right_03, 1          left_01 joins to right_01 using key 1     left_01 joins to right_02 using key 1     left_01 joins to right_03 using key 1     left_02 joins to right_01 using key 1     left_02 joins to right_02 using key 1     left_02 joins to right_03 using key 1      My concern is one of memory. I will run out of memory if i use the approach below but still want the inner join part to work fairly quickly. What is the best approach to deal with the INNER join part keeping in mind that these files may potentially be huge               public class Joiner {            private void join(BufferedReader left, BufferedReader right, BufferedWriter output) throws Throwable {              BufferedReader _left = left;         BufferedReader _right = right;         BufferedWriter _output = output;         Record _leftRecord;         Record _rightRecord;              _leftRecord = read(_left);         _rightRecord = read(_right);              while( _leftRecord != null && _rightRecord != null ) {                if( _leftRecord.getKey() < _rightRecord.getKey() ) {             write(_output, _leftRecord, null);             _leftRecord = read(_left);           }           else if( _leftRecord.getKey() > _rightRecord.getKey() ) {             write(_output, null, _rightRecord);             _rightRecord = read(_right);           }           else {             List<Record> leftList = new ArrayList<Record>();             List<Record> rightList = new ArrayList<Record>();                  _leftRecord = readRecords(leftList, _leftRecord, _left);             _rightRecord = readRecords(rightList, _rightRecord, _right);                  for( Record equalKeyLeftRecord : leftList ){               for( Record equalKeyRightRecord : rightList ){                 write(_output, equalKeyLeftRecord, equalKeyRightRecord);               }             }           }         }              if( _leftRecord != null ) {           write(_output, _leftRecord, null);           _leftRecord = read(_left);           while(_leftRecord != null) {             write(_output, _leftRecord, null);             _leftRecord = read(_left);                   }         }         else {             if( _rightRecord != null ) {             write(_output, null, _rightRecord);             _rightRecord = read(_right);             while(_rightRecord != null) {               write(_output, null, _rightRecord);               _rightRecord = read(_right);             }           }              }         _left.close();         _right.close();         _output.flush();         _output.close();       }            private Record read(BufferedReader reader) throws Throwable {         Record record = null;              String data = reader.readLine();         if( data != null ) {           record = new Record(data.split("\t"));         }         return record;       }            private Record readRecords(List<Record> list, Record record, BufferedReader reader) throws Throwable {         int key = record.getKey();         list.add(record);         record = read(reader);         while( record != null && record.getKey() == key) {           list.add(record);           record = read(reader);         }         return record;           }            private void write(BufferedWriter writer, Record left, Record right) throws Throwable {            String leftKey = (left == null ? "null" : Integer.toString(left.getKey()));         String leftData = (left == null ? "null" : left.getData());         String rightKey = (right == null ? "null" : Integer.toString(right.getKey()));         String rightData = (right == null ? "null" : right.getData());              writer.write("[" + leftKey + "][" + leftData + "][" + rightKey + "][" + rightData + "]\n");       }            public static void main(String[] args) {             try {                    BufferedReader leftReader = new BufferedReader(new FileReader("LEFT.DAT"));               BufferedReader rightReader = new BufferedReader(new FileReader("RIGHT.DAT"));               BufferedWriter output = new BufferedWriter(new FileWriter("OUTPUT.DAT"));                Joiner joiner = new Joiner();           joiner.join(leftReader, rightReader, output);         }              catch (Throwable e) {           e.printStackTrace();         }       }     }      After applying the ideas from the proposed answer, I changed the loop to this               private void join(RandomAccessFile left, RandomAccessFile right, BufferedWriter output) throws Throwable {              long _pointer = 0;              RandomAccessFile _left = left;         RandomAccessFile _right = right;              BufferedWriter _output = output;              Record _leftRecord;         Record _rightRecord;              _leftRecord = read(_left);         _rightRecord = read(_right);              while( _leftRecord != null && _rightRecord != null ) {                  if( _leftRecord.getKey() < _rightRecord.getKey() ) {                 write(_output, _leftRecord, null);                 _leftRecord = read(_left);             }             else if( _leftRecord.getKey() > _rightRecord.getKey() ) {                 write(_output, null, _rightRecord);                              _pointer = _right.getFilePointer();                 _rightRecord = read(_right);             }             else {                           long _tempPointer = 0;                 int key = _leftRecord.getKey();                                                                          while( _leftRecord != null && _leftRecord.getKey() == key ) {                     _right.seek(_pointer);                     _rightRecord = read(_right);                     while( _rightRecord != null && _rightRecord.getKey() == key ) {                         write(_output, _leftRecord, _rightRecord );                         _tempPointer = _right.getFilePointer();                         _rightRecord = read(_right);                      }                     _leftRecord = read(_left);                 }                 _pointer = _tempPointer;             }         }              if( _leftRecord != null ) {             write(_output, _leftRecord, null);             _leftRecord = read(_left);             while(_leftRecord != null) {                 write(_output, _leftRecord, null);                 _leftRecord = read(_left);                           }         }         else {               if( _rightRecord != null ) {                 write(_output, null, _rightRecord);                 _rightRecord = read(_right);                 while(_rightRecord != null) {                     write(_output, null, _rightRecord);                     _rightRecord = read(_right);                 }             }                    }         _left.close();         _right.close();         _output.flush();         _output.close();     }      _UPDATE_ While this approach worked, it was terribly slow and so I have modified this to create files as buffers and this works very well. Here is the update ...               private long getMaxBufferedLines(File file) throws Throwable {         long freeBytes = Runtime.getRuntime().freeMemory() / 2;              return (freeBytes / (file.length() / getLineCount(file)));     }          private void join(File left, File right, File output, JoinType joinType) throws Throwable {              BufferedReader leftFile = new BufferedReader(new FileReader(left));         BufferedReader rightFile = new BufferedReader(new FileReader(right));         BufferedWriter outputFile = new BufferedWriter(new FileWriter(output));         long maxBufferedLines = getMaxBufferedLines(right);              Record leftRecord;         Record rightRecord;              leftRecord = read(leftFile);         rightRecord = read(rightFile);              while( leftRecord != null && rightRecord != null ) {                  if( leftRecord.getKey().compareTo(rightRecord.getKey()) < 0) {                 if( joinType == JoinType.LeftOuterJoin                          || joinType == JoinType.LeftExclusiveJoin                         || joinType == JoinType.FullExclusiveJoin                         || joinType == JoinType.FullOuterJoin ) {                      write(outputFile, leftRecord, null);                 }                 leftRecord = read(leftFile);             }             else if( leftRecord.getKey().compareTo(rightRecord.getKey()) > 0 ) {                 if( joinType == JoinType.RightOuterJoin                          || joinType == JoinType.RightExclusiveJoin                         || joinType == JoinType.FullExclusiveJoin                         || joinType == JoinType.FullOuterJoin ) {                     write(outputFile, null, rightRecord);                 }                 rightRecord = read(rightFile);             }             else if( leftRecord.getKey().compareTo(rightRecord.getKey()) == 0 ) {                 String key = leftRecord.getKey();                  List<File> rightRecordFileList = new ArrayList<File>();                 List<Record> rightRecordList = new ArrayList<Record>();                 rightRecordList.add(rightRecord);                 rightRecord = consume(key, rightFile, rightRecordList, rightRecordFileList, maxBufferedLines);                      while( leftRecord != null && leftRecord.getKey().compareTo(key) == 0 ) {                     processRightRecords(outputFile, leftRecord, rightRecordFileList, rightRecordList, joinType);                     leftRecord = read(leftFile);                 }                      // need a dispose for deleting files in list             }             else {                 throw new Exception("DATA IS NOT SORTED");             }         }              if( leftRecord != null ) {             if( joinType == JoinType.LeftOuterJoin                      || joinType == JoinType.LeftExclusiveJoin                     || joinType == JoinType.FullExclusiveJoin                     || joinType == JoinType.FullOuterJoin ) {                 write(outputFile, leftRecord, null);             }             leftRecord = read(leftFile);             while(leftRecord != null) {                 if( joinType == JoinType.LeftOuterJoin                          || joinType == JoinType.LeftExclusiveJoin                         || joinType == JoinType.FullExclusiveJoin                         || joinType == JoinType.FullOuterJoin ) {                     write(outputFile, leftRecord, null);                 }                 leftRecord = read(leftFile);                           }         }         else {               if( rightRecord != null ) {                 if( joinType == JoinType.RightOuterJoin                          || joinType == JoinType.RightExclusiveJoin                         || joinType == JoinType.FullExclusiveJoin                         || joinType == JoinType.FullOuterJoin ) {                     write(outputFile, null, rightRecord);                 }                 rightRecord = read(rightFile);                 while(rightRecord != null) {                     if( joinType == JoinType.RightOuterJoin                              || joinType == JoinType.RightExclusiveJoin                             || joinType == JoinType.FullExclusiveJoin                             || joinType == JoinType.FullOuterJoin ) {                         write(outputFile, null, rightRecord);                     }                     rightRecord = read(rightFile);                 }             }                    }         leftFile.close();         rightFile.close();         outputFile.flush();         outputFile.close();     }          public void processRightRecords(BufferedWriter outputFile, Record leftRecord, List<File> rightFiles, List<Record> rightRecords, JoinType joinType) throws Throwable {              for(File rightFile : rightFiles) {             BufferedReader rightReader = new BufferedReader(new FileReader(rightFile));             Record rightRecord = read(rightReader);             while(rightRecord != null){                      if( joinType == JoinType.LeftOuterJoin                          || joinType == JoinType.RightOuterJoin                         || joinType == JoinType.FullOuterJoin                         || joinType == JoinType.InnerJoin ) {                                         write(outputFile, leftRecord, rightRecord);                 }                 rightRecord = read(rightReader);             }             rightReader.close();         }              for(Record rightRecord : rightRecords) {             if( joinType == JoinType.LeftOuterJoin                      || joinType == JoinType.RightOuterJoin                     || joinType == JoinType.FullOuterJoin                     || joinType == JoinType.InnerJoin ) {                                     write(outputFile, leftRecord, rightRecord);             }         }     }          /**      * consume all records having key (either to a single list or multiple files) each file will       * store a buffer full of data. The right record returned represents the outside flow (key is       * already positioned to next one or null) so we can't use this record in below while loop or       * within this block in general when comparing current key. The trick is to keep consuming       * from a List. When it becomes empty, re-fill it from the next file until all files have       * been consumed (and the last node in the list is read). The next outside iteration will be       * ready to be processed (either it will be null or it points to the next biggest key      * @throws Throwable       *       */     private Record consume(String key, BufferedReader reader, List<Record> records, List<File> files, long bufferMaxRecordLines ) throws Throwable {         boolean processComplete = false;         Record record = records.get(records.size() - 1);              while(!processComplete){             long recordCount = records.size();             if( record.getKey().compareTo(key) == 0 ){                 record = read(reader);                                 while( record != null && record.getKey().compareTo(key) == 0 && recordCount < bufferMaxRecordLines ) {                     records.add(record);                     recordCount++;                     record = read(reader);                 }             }             processComplete = true;             // if record is null, we are done             if( record != null ) {                      // if the key has changed, we are done                 if( record.getKey().compareTo(key) == 0 ) {                          // Same key means we have exhausted the buffer.                     // Dump entire buffer into a file. The list of file                      // pointers will keep track of the files ...                                         processComplete = false;                     dumpBufferToFile(records, files);                     records.clear();                     records.add(record);                 }             }         }         return record;     }          /**      * Dump all records in List of Record objects to a file. Then, add that       * file to List of File objects      *       * NEED TO PLACE A LIMIT ON NUMBER OF FILE POINTERS (check size of file list)      *       * @param records      * @param files      * @throws Throwable       */     private void dumpBufferToFile(List<Record> records, List<File> files) throws Throwable {         String prefix = "joiner_" + files.size() + 1;         String suffix = ".dat";         File file = File.createTempFile(prefix, suffix, new File("cache"));         BufferedWriter writer = new BufferedWriter(new FileWriter(file));                     for( Record record : records ) {             writer.write( record.dump() );         }              files.add(file);         writer.flush();         writer.close();     }


title: What is the best use case for selenium?

text: I've been trying to develop web applications while at the same time creating the testing. I understand unit testing, I can declare a test method and test specific methods in my application. But I don't see what is the best way to use selenium web driver for testing. I tried to test the a specific site for broken links or broken images and I had to use an external http connection library since selenium doesn't provide header results etc. It is very slow to traverse a whole site. While you can just pass the URL to W3C link checker and you're done. Are most developers creating a class for each page and testing individual ui elements since traversing the whole site is a lot more complicated. What are the benefits selenium brings or ui testing that can't be tested for with unit testing?


title: How do you wrestle the DRY principle with configs?

text: For instance, lets say we have an nginx config pointing at foo1, foo2, and foo3, as well as a haproxy config pointing at foo1, foo2, and foo3, and finally, a deployment tool pointing at the same respective servers. How does one reconcile this? Build some sort of configuration generator for nginx and haproxy based on the hosts? It seems as though this would make grepping difficult and potentially hinder readability of the configuration files in general.


title: Handling contacts imported from users email account

text: In my web application, I give the user the option to import all of his/her contacts from their email account, and then send out invites to all of these accounts or map the user to the existing accounts based on emails. Now the question, is once all of these contacts are imported, would it be right to save these contacts back for repeated reminders, etc.? I am quite confused here because that is the way all of the sites operate, but would that not be violation of data privacy? Is there an algorithm for this?


title: How to make .exe file from html5 css application?

text: I would like to make windows desktop application using HTML5, JavaScript and CSS. I am trying   * tidesdk   * XULRunner   * appjs I read the documentations of these technologies. But I didn't see how to export the application as a .exe package. I want to write an application in HTML and JavaScript and export to an exe file. How can I do that?


title: What tricks/tips do you use for innovation?

text: I am looking for a few ideas on how to change a highly conventional work culture to be more innovated in their approached to problem solving. I've come across this article and am looking for more specific and practical ways that we as developers can help each other think outside of the box. I've constructed a simple formula of how to energize innovation in my everyday development. (Please critique this for improvement) Input External Data/Info -> Creates New Ideas/Concepts -> Communicates/Shares Ideas -> Trusts Others -> Risks Trials -> Innovation Happens What are some of your attitudes, thought processes, and behaviors towards approaching a challenging problem in way that would be considered innovative?


title: "My stuff" vs. "Your stuff" in UI texts

text: When refering to a users stuff should you use _My_ or _Your_ , for example: > My Cart | My Account | My Wishlist Or > Your Cart | Your Account | Your Wishlist I found this article that argues for the use of _your_. It says flikr does this. It also says MySpace and MyYahoo are wrong. I also noticed today that Amazon uses the term _Your_. However, I have heard they are the masters at testing variations and finding the best one, so what you see on their site might be the best variation, or simply something they are currently testing. I personally like the way _my_ looks better, but thats just my opinion. What do you think? What will hever the better impact on customers? Does it really even matter?


title: Should I store log files in version control

text: The log files in question are metrics log files. One of them is a project file produced by SourceMonitor, to which I regularly add checkpoints to chart the progress of projects.


title: How should you deal with a popular project that you no longer want to maintain?

text: I am the maintainer of a project which has a large non-technical userbase. I've been maintaining it for about 4 years now and adding new features as they've been requested. I'd like to move on to other projects now and stop developing for this application. Because of the non-technical nature of the users, there have been very few code contributions in the past. I don't believe I will be able to find anyone else to take over the project in my stead. Bugs, issues, feature requests - these are still coming in. I am still responding to emails for help, as I am not sure if I should ignore them, tell them that I'm not working on the application, or if I should respond to emails in only certain cases. What is the best way to 'abandon' this project, but still let users use the application?


title: Manage feature set of one app on multiple platforms/codebases

text: So I develop an app that is for both Android and iOS. From time to time changes occur when working on one version that need to implemented on the other. I find it tedious to keep track of these changes so I don't forget them later. I'm just curious as to what other workflows you guys use when managing a single feature set to be implemented in various projects. Thanks


title: How to explain to your colleages to stop creating packages and classes named "Utils"?

text: In most of the projects at work it will eventually show up a package, a class (or multiple packages and classes) named "Utils", where every kind of function is dumped into. It becomes excruciating harder and harder to navigate the project without a properly named structure. I have tried to ask to stop using "Utils". When I find it if and the change to the codebase is small I normally refractor it and remove them, but they always end on showing up cluttering the code. So do you know any strategy to make them stop doing this? Or am I just being a nagger?


title: When should code favour optimization over readability and ease-of-use?

text: I am in the process of designing a small library, where one of my design goals is that _the API should be as close to the domain language as possible_. While working on the design, I've noticed that there are some cases in the code where a more intuitive, readable attribute/method call requires some functionally unnecessary encapsulation. Since the final product will not necessarily require high performance, I am unconcerned about making the decision to favour ease-of-use in my current project over the most efficient implementation of the code in question. I know not to assume readability and ease-of-use are paramount in all expected use-cases, such as when performance is required. I would like to know if there are more general reasons that argue for a design preferring more efficient implementations—even if only marginally so?


title: Languages with similar features to JavaFX Script

text: I just completed a small project in JavaFX, only finding that it has been declared dead by Oracle. JavaFX Script actually seemed to be a pretty interesting language with some neat features for its domain, particularly with bind for data binding and on replace for triggered events. These features actually make the language very useful for small, quick, RIA type apps, which leads to my question: **Are there any _mainstream_ languages with features similar to bind and on replace?** After working with JavaFX, I got some ideas for some small personal (academic) projects that could take advantage of these features, but I would prefer to not start anything new in a language considered extinct by its owners.


title: Software design methods for Java or any other programming language

text: I'm junior programmer and I would like to know how professionals write their code or which steps they follow when they are creating new software. I mean, which steps they follow, which programming methodology, software architecture design application software, etc. I would like to find a tutorial where they explain from the beginning which steps I have to follow from The Idea I have in my mind to the final version of the application in any language. Or perhaps how is your programming steps or rules that you used to follow. Because everytime I want to create the an application I spend few time on the design and a lot of time coding (I know, that's not good).


title: What features are helpful when performing remote debugging / diagnostics?

text: Obviously, the easiest way to solve a bug is to be able to reproduce it in- house. However, sometimes that is not practical. For starters, users are often not very good at providing you with useful information. > Customer Service: "what seems to be the issue?"   >  User: "It crashed!" To further compound that, sometimes the bug only occurs under certain environmentally conditions that can not be adequately replicated in-house. With that in mind, it is important to build some sort of diagnostic framework into your product. **What types of built-in diagnostic tools have you used or seen used?** Logging seems to be the predominate method, which makes sense. We have a fairly sophisticated logging frame work in place with different levels of verbosity and the ability to filter on specific modules (actually we can filter down to the granularity of a single file). Error logs are placed strategically to manufacture a pretty good representation of a stack trace when an error occurs. We don't have the luxury of 10 million terabytes of disk space since I work on embedded platforms, so we have two ways of getting them off the system: a serial port and a syslog server. However, an issue we run into sometimes is actually getting the user to turn the logs on. Our current framework often requires some user interaction.


title: Data structure supporting the following operations

text: I'm looking for a data structure for working with a set of data which is most efficient to do the following :   1. Check whether an item has been categorized or not. (The categorized and uncategorized set are disjoint sets).   2. Get the category of an item.   3. Get all the items in a particular category.   4. Get all the uncategorized items.   5. Remove a particular item from the data set. I was thinking of having a `Dictionary<String, Set<String>>` to hold all the items in a given category, but that doesn't solve 2.


title: Is wrapping a third party code the only solution to unit test its consumers?

text: I'm doing unit testing and in one of my classes I need to send a mail from one of the methods, so using constructor injection I inject an instance of `Zend_Mail` class which is in Zend framework. Now some people argue that if a library is stable enough and won't change often then there is no need to wrap it. So assuming that `Zend_Mail` is stable and won't change and it fits my needs entirely, then I won't need a wrapper for it. Now take a look at my class `Logger` that depends on `Zend_Mail`:               class Logger{         private $mailer;             function __construct(Zend_Mail $mail){             $this->mail=$mail;         }            function toBeTestedFunction(){           //Some code           $this->mail->setTo('some value');           $this->mail->setSubject('some value');           $this->mail->setBody('some value');           $this->mail->send();          //Some        }             }      However, Unit testing demands that I test one component at a time, so I need to mock the `Zend_Mail` class. In addition I'm violating the **Dependency Inversion** principle as my `Logger` class now depends on concretion not abstraction. Now how can I test `Logger` in isolation without wrapping `Zend_Mail`?! The code is in PHP, but answers doesn't have to be. This is more of a design issue than a language specific feature


title: Server OS/Software Requirements For asp.NET Framework 4.0

text: **The Background:**   Me and my colleague are opening a new website design & development company. We have designed and implemented a website on Microsoft Visual Studio 2010 using Web forms in .NET Framework 4. Because I was new to asp.NET at the time, I wasn't sure what Database to use. Therefore I created a new "Microsoft SQL Server Database File" and added all the tables etc. I then worked with this configuration until the website was complete. The website works like a dream in Visual Studio. **The Problem:**   We were supposed to be buying a server from a local source that cannot be named, and this server was supposed to have Microsoft SQL server 2005 for the database, and I'm assuming IIS to configure the server and handle requests etc (please keep in mind that my knowledge of servers is limited) And this company were going to configure everything blah blah blah, get everything set up so all we have to do is put our website on it, and life is sweet. The problem is, this company have messed us about, told us this and that and it turns out they're very unreliable and untrustworthy. We've already spent a large sum of money with them and they are dragging their feet giving us the money back, saying what we asked is impossible, that we cant have SQL running on an old server yada yada yada. **The Question:**   I have an asp.NET website with a SQL server database ( .mdf file, if that helps anything ) and we need to know what do we need to get it on the internet. we've considered buying our own computer, putting MS server software on it, installing SQL server 2005, installing IIS and running it off that. But we don't know what to do or how to do it. Before all this server hastle kicked off, i tried installing a copy of IIS on my computer, and hosting it from there as a test to get me used to the software, however I tried multiple tutorials, and all sorts and could not get our website to host! There may be examples of this all over the internet but i cannot find an answer. I dont understand most of the things people are talking about on these articals. I know I've rambled, But basically. I just need to know HOW to put an asp.NET application on the internet, and what minimum requirements I need. Do i even need SQL server software on my server? or is that purely for interacting with the sql database?


title: An intern interview with Microsoft

text: I'm currently in my second year(Computer Science and Mathematics). In two days I have an interview on campus with Microsoft. I'm a bit nervous, because this will be my first in person interview. I have done reviewed basic things like linked list and binary trees. I am not really sure what kinds of questions I'll be asked. Has anyone been to such interview? If so what's it like? What kinds of questions will I be asked? Any help/suggestions will be much appreciated! Also can someone provide me with a list of things I ought to know for the interview?


title: Open source engagement as a professional reference

text: if one commits his or her time to an open source project, he or she may be invest a substantial amount of time without getting paid. As much as altruism is appreciable, I wonder whether it "counts" as an activity which can be shown and is valued in job applications. If the company is worth your time and working power, which it should be in my honest opinion. So I wonder whether there is something like a common practice in open source projects for this matters. Say, something like > Mr. Martin has been working on our project for five years and has > contributed this and that,[...] I we wish him very best for his future. > > Mr. ChiefofProject I think this is a just concern. Do have experiences you can share?


title: 12 year old son interested in Android programming

text: So, my 12 year old son is interested in programming for Android. He's never done a real program before, but he did play briefly with Alice. I'm trying to figure out what the best way to introduce him to programming would be, and more specifically, if it would be better for him to just jump into Android programming, or if I should have him do Java first. Any suggestions?


title: Does 'consider returning Null Object' apply to a DAO read method?

text: I was looking for an answer to the question of what a DAO should return when a search ends up to be for an entity that does not exist. There are some generic previous questions related to returning null, but I am looking for an answer specifically in the context of the DAO retrieve scenario.       To be clear, when I say _Null Object_ I am referring to the Null Object pattern. In the Java space, Josh Bloch recommends an empty collection solution in the book _Effective Java_ (See Item 43) which provides an very good introduction to the problem/solution.    Despite being aware of Bloch's advice when I first wrote this question I considered returning null appropriate in a read/retrieval scenario. I'm in good company making a mistake with nulls.


title: How mature is PyPy?

text: I am trying to determine the maturity of PyPy by other means than reading the opinion of the developers. Therefore, I am interested in hearing about any high-profile mission-critical projects using PyPy. All other indicators of maturity seem fine. I am just missing this one before I decide on utilizing it for my main project.


title: Rules of thumb regarding breaking into sub-projects

text: We are building a Game Client and Server, our system is broken into four major projects: (Client and Server, Shared Interfaces, Source Art). In addition, both client and server have a set of libraries where we put shared code for client and server respectively. As you can imagine this leads to a lot of projects, I count 12 projects in the entire source. My questions are; What are the good rules of thumb regarding when to keep code in one project versus breaking it into sub projects. No one likes a large monolithic project but lots of small projects also add a lot of overhead. Should all projects be branched and released in lock-step to keep things simple (one current version number for all) or should library projects be branched and released separately only when they change. This will lead to complex map of compatible versions. I know there is no absolute answer for these questions but what are the known best practices when deciding and/or good reference material to read up on this subject?