title: Why did the team at LMAX use Java and design the architecture to avoid GC at all cost?

text: Why did the team at LMAX design the LMAX Disruptor in Java but all their design points to minimizing GC use? If one does not want to have GC run then why use a garbage collected language? Their optimizations, the level of hardware knowledge and the thought they put are just awesome but why Java? I'm not against Java or anything, but why a GC language? Why not use something like D or any other language without GC but allows efficient code? Is it that the team is most familiar with Java or does Java possess some unique advantage that I am not seeing? Say they develop it using D with manual memory management, what would be the difference? They would have to think low level (which they already are), but they can squeeze the best performance out of the system as it's native.


title: OOP and relational databases

text: I see a lot of talk in the OOP world about principles and laws such as **Open/Close** and **Loose Coupling** , I can understand how they are so high valued, However I seem to have ran into a problem with applying these principles and laws once I start to include relational databases. For example purposes, if I have a application which we are able to separate well into multiple components( **Open/Close** design) and allow them to work with each other when if needed, I start to run into problems when trying to enforce **referential integrity**. If I enforce a relational setup, and enforce integrity through foreign keys and so on, the tables become dependent on each other, gradually my OOP application logic starts to fall apart and become one big system. I can of course remove all references to tables, but then I risk making data redundant and start to repeat code/data, which then goes against the Don't Repeat Yourself principle. Have you came across such problems before? If so how did you handle it? Perhaps there is a way to achieve both referential integrity and OOP open/close components. Thanks


title: What are the non-technical reasons that make Object-Relational Mapping tools (ORMs) so difficult to write?

text: I know the technical pitfalls of writing an ORM are pretty well-known nowadays, but what are some non-technical factors (e.g., Scope) that make it difficult to writing a good ORM? EDIT: I have already read the technical reasons for why ORMs are so difficult to write from this Stackoverflow post: http://stackoverflow.com/questions/404083/is-orm-still-the-vietnam-of- computer-science


title: What skills in game development are common in other software development areas?

text: I am a game dev who was working in the game-industry and then ... got laid off. Ever since then, life has been stressful! During this time, I have met so many other devs who have also been laid off irrespective of the number of years they have been in the game. There just aren't many opportunities for game development where I live. I can't think of a domain/place where I can use my game development skills. I know graphics/simulation/visualization is huge, but I can't think straight and am left clueless where to go from here. What are some of the domains/companies where I can use my skills? What skills are common between game development and other areas of software development?


title: How do you deal with design in Scrum?

text: How do you deal with design in Scrum? Do you still have well written design documents for each scrum iteration? Do you just do design notes featuring UML diagrams? Or do you just have well commented code? Each iteration may involve changing design so I just wanted to know how people capture this so new developers have an easy job of understanding the domain and getting on board as rapidly as possible.


title: What should I expect from my first programming job?

text: I just got hired for my first programming job! I am 25 and have been using Java academically for 6 years. Now that I have been hired I am nervous that my skills will not be what the employer expects. I am afraid I will be assigned to a project and have to ask lots of questions that my coworkers will feel are amateur. Is this a rational fear? What were your first programming job experiences? What should I expect? What advice could you give me? Thanks.


title: Creating system diagrams for a small app

text: I am learning system design (on my own) and still I am not clear on a few things. Assume there is a simple application with a front-end and a database for storing of the data. In the system architecture diagram, will there be only two parts (UI and DB) or should I include some UI modules for calculations, for example? And what about hardware devices that the system is using? To give a more precise example: I have an application that is used by two types of users (one has limited access). This app uses a DB and its modules are working with an external hardware device. I am not sure how should I start with the system diagram.


title: Well designed / high-quality open source software

text: I'm taking a software design class where I should choose an open source software to analyze from the Software Design point of view. It has to be a big project: not less then 100,000 lines of code. I would really like to choose a software that is very well designed and architected to have good insights on good software design. By good design I mean things like meaningful classes and architecture, good use of (design) patterns, good use of abstraction, good organization of components, high cohesion and low coupling between components, etc... Do you have any software to suggest me? Note that the software just need to have a good design, the design does not need to be documented! :) It does not need to be an application for the end user... It can also be a library, a tool, etc...


title: Data model - inheritance

text: I just started working on a project where I am trying to implement some backend logic which includes creating a data model for the given problem. Here is a problem I came across and I am curious what approach would be more suitable for tackling it. **Model:** There are various users in the system with different rights and structures but there is a very simple inheritance between them. There is a basic `user` that can browse and view some data, psot comments etc. Than, there is a `member` who can do everything the `user` can + something more and they share the basic data structures + `member` has its own. And there is a `producer` which is again just an extension of `member`. Each `user` can (but does not have to) be a `member` and each `member` can (but does not have to) be a `producer`. 1) My current idea: Create table `user` and tables `member` and `producer` which would reference each other using user's id. There would be 0 to 1 relationship between these tables:               USER {     id     username     email etc..     }          MEMBER {     userid     some_member_attributes     }          PRODUCER {     userid     some_producer_attributes     }      The advantage is, that it would save me a lot of NULL values in a single table and it feels somehow natural to me. The disadvatage is that I would have to query three different tables every time I would like to get some data from a `producer`. 2) The other possibility is implementing this as a one table with attributes `isMember` and `isProducer`. But again, this will result in a lot of NULL values since most of the users wont be `producers`. And its not very typical to have many 0 to 1 relationships in one model, I think... What do you suggest? I hope its not an off-topic here, I am just trying to get this right so I wont have to reimplement is a dozen times in future. Thanks for any tips!


title: The place of UI design when estimating and elaborating user stories

text: Our company is trying to follow Agile methodologies when it comes to estimating and prioritizing any new development work. The reading I've done makes this concept appear great so we are trying to give it a good crack at making it work for us and hence help with providing a better solution at the end of the day for our customer. A problem I have had recently is the position of UI design during the estimation of User stories. We kicked off a new project discussing what was required from a functional point of view and getting a set of user stories written down to be verified by the user. Our BA then asked us to estimate these stories. I went, hang on. Many of these stories might vary depending on the complexity of the UI design. However the BA wasn't ready to discuss UI just yet as she needed estimates so she could plan the sprints and get a costing for the project. So my main question is: > Where does UI design fit into the process between writing user stories and > estimation. Or, should it even fit in and just be a part of the development > work? Secondary question > How does agile fit into fixed price quotes for new work (based on your > estimations on the entire user stories set), and how then do you ensure you > deliver what you said as far as the user stories go against the quote given > i.e. a story is bigger than you thought so blows out My concerns around our process:   1. I can't estimate accurately enough at this stage of the process as some elements are missing i.e. UI. It's a new project for a new client so heading into some uncertain waters.   2. Some features are just too unknown to estimate (Do I need to just delve deeper into the murkiness to clear the waters to remove the unknowns??)  BA needs (as expressed to me)   1. Wants to have estimates so they can determine how many sprints this project will take   2. Wants to have estimates so they can determine the scope and cost of the project so that they can give it to the customer as a quote.


title: How do you typically become chief software engineer in a company?

text: I was under the impression that you start in a programming job, do a good job, demonstrate willingness, get sent to a bunch of internships by the employer, and make your way up until you are given responsibility of an entire project. But a friend of mine told me that you also need at least a Masters' degree to be considered for that job. Is that true? How do people typically get to be in that role? PS notice I said "typically". I want to hear the general case, not private cases about someone you know.


title: What to do when you're faced with a problem that you can't solve quickly?

text: I'm a beginner learning Java and after reading the docs I'm trying to solve some of the problems at codingbat.com. Some I managed to solve pretty quickly in a matter of seconds but some not quite. The problems themselves are easy (example http://codingbat.com/prob/p126212) but I sometimes have a hard time finding the solutions. In part because I think of the best possible solution and automatically discard the ones that might work but aren't so elegant and in part because I can't find the right algorithm. This is either due to my inexperience (I have used PHP for web development for about 2 months so I'm not a total beginner - even worked with one framework to build a website) or due to my inability to think of a good algorithm. I normally don't look at the solutions. I sometimes get stuck even for 1 1/5 hours at simple problems and some of them I eventually solve but some I can't so I eventually look at the solution. Is it normal/good/bad to concentrate this long if I find a problem I can't solve? I might overreact but should this be so hard for me? Is there such thing as not being able to think of algorithms even with much learning and reading? Thank you all in advance.


title: Unit Testing For Different Environments

text: How does one do unit testing for multiple environments that behave differently? Here is my problem. I have a PHP class for which I'd like to create unit tests. The class provides shortcuts for manipulating folders. On Linux, you can set the folder permissions without a problem, on Windows, you can't at all. Knowing this, what is the best practice for creating a unit test for this class? The test suite could be run on either Windows or Linux, but if you test the folder settings on Windows, the test will fail. Do you just live with the failing test, make it conditional on the OS, omit testing it altogether, or something else?


title: How to maintain user relationship when user unfollows another user

text: I have a table of user relationship which stores who follows whom, the table structure is as follows               -id     -follower     -following      when someone follows any other user, I add a record with follower user id and id of user he is following, now my question=> When user wants to unfollow that user, I have decided rather than deleting the record I can add another column `break` at the end of this table, which I will set to `true` when user wants to unfollow, this way I can maintain consistency in the records, that is there wont be any gap like 1,2,4,7,8,9,15 if I delete records. If I dont delete the record, I can use it if that user want to follow that user again in future I can set break column of that record to `false` and the relationship will exist again..what do you guys think should I use this approach or I should delete the record? Tell me if the approach is good or there could be any issues associated with it and also tell me if there is any better way you know. Thanks


title: What will be a good python script (or your favorite language goes here) to test a system's performance and capabilities?

text: Let's say you're in a computer store looking at 10 laptops, you want to really compare the system's capabilities. What will be an efficient "your fav language goes here" script that will allow you to do this? As an example, when I go to the store I usually open a macbook and a pro's terminal and write an equation in python, iterate it a million or so times, and time them. I like to compare the difference in time. What would be an ideal and simple script that can efficiently compare systems?


title: Learning a new language and framework, should I spike a project, or first ground myself in the language fundamentals?

text: I've got substantial J2EE experience, have worked with Grails, and am comfortable with several languages (Perl, PHP, Smalltalk). I've decided to try a new project using Ruby on Rails. For those who've decided to migrate to a new technology stack, how do you make the transition? Do you learn the details of Ruby first (I've done a few tutorials, and feel like I've got a decent enough grasp of the language to start doing some basic work) or do you do a full Ruby on Rails tutorial, and expand your knowledge from there. I'm leaning towards the latter approach because I feel like I can delve into details of the language as I encounter them. For those who work in Ruby on Rails, how did you learn, and which resources do you recommend?


title: Syndication feeds and show I bother with providing anything other than RSS 2

text: I'm creating a CMS and have lots of legacy code from other applications. I'm wondering should I bother providing other syndication formats except rss 2? I'm inclined to say no but was wondering what other peoples opinions were.


title: Can a non-programmer successfully run a software company?

text: Back in 2006, one Joel Spolsky made the following comment: > Watching non-programmers trying to run software companies is like watching > someone who doesn't know how to surf trying to surf. Overall the article is a great read (definitely take the time to read through it). Out of curiosity, **I would like to hear the experiences of folks here** who have seen programmers adopt the mantle and do a great (or rubbish) job, and the same for non-programmers who find themselves herding programmers (worse than herding cats I've heard). In short, what is the concensus of opinion on this matter?


title: Benefits of using XML builder vs templating language like ERB?

text: I'm doing a lot of work with XML, our legacy XML generators use the ruby template language ERB to create the XML files. I've been experimenting with Nokogiri and the builder model of creating XML, but I seem to be able to accomplish everything I want using both methods. So, what should I be taking into account when choosing one common method going forward? What are the benefits of using a builder method to construct the XML vs a template language? One that I can think of is the builder method(nokogiri) provides methods for do much more than creating the file, such as searching and rearranging, etc. So if I use the builder method I can have a common tool for doing all xml related tasks.


title: Single Responsibility principle VS KISS principle

text: Let's assume the modeling of `User` model in a context of a social network. User concept is composed of two notions:   * Authentication elements like userName/Password/Email etc...   * Extra data information sometimes called "User profile" like firstName, birthday, pictures etc.. At first glance, this analysis involves separation of tasks/responsibilities if we want to keep SRP. However, typically in the case of a social network, **userName may be seen as a pure information belonging to a user's profile rather than a pure element of authentication.** Thus, there is three ways, according to me, to model the `User` concept. First, the whole in one class:   `User` (userName, password, email, firstName, birthday, picture etc...) Second, a one-to-one relationship between `User` and `UserProfile`:   `User`(userName, password, email) `UserProfile`(firstName, birthday, picture etc...) Third, a one-to-one but with a redundancy of the common fields (being as focused on authentication as a visible user information on the website):   `User`(userName, password, email)   `UserProfile`(userName, firstName, birthday, picture etc...) Why repetition here? Of course for consitency and at the same time to avoid joins in cases of relational database when one want to retrieve each Use's profile data. What is a good practice to model these both concepts? **Where should I place`userName` field?** **Dilemma being: keeping KISS (Keep it simple stupid!) or SRP ;)**


title: Would it be ok if I decide to write all my Ruby as if it were Haskell?

text: Given that Ruby has good list operation capabilities in-built - reduce, map, select, collect etc. It has Procs, Blocks and Lambdas, and has nice iteration support (the `each` family), would it be a bad design decision if I attempt to write all my Ruby stuff in the most pure-functional way possible? Escpecially for code that has little or no I/O (thus less obvious side-effects)? I've been learning Haskell (called the 'real' Hacker's language), and am in love with it's way of doing things - I love Ruby, but think it can be even more fun when more Haskell spirit flows into it (well, didn't Ruby borrow / learn lots from it in the first place?) Constructive guidance is welcome...


title: Determine Programming Language Used for Project Based on Source Code

text: Is there an easy way to determine which programming languages were used in a project assuming you have access to the source code? I have been programming for quite some time, so I can recognize most of the major programming language by syntax or file extension, but I realized that I could not answer this fairly simple question (A problem I often ask myself when dealing with unfamiliar open source codebases). I understand that you could examine each file extension and Google it to determine whether it belongs to a particular programming language. However, this seems tedious (examining every file extension for a large project) and I am guessing there might be a better way.


title: How is the JVM and Java's WORA different from other high level languages?

text: In the Java world, we often talk about the JVM, and when Java was new it had the supposedly killer feature of "Write Once, Run Anywhere." From the way people talk and write, this seems different from the way that Python, for example, works. Yet I've not been aware of any way that Python code that I've written would work differently on another machine. (Though I haven't written that much Python.) So what am I missing? How is the JVM different from a Python interpreter? Is there a way that Python lacks Java's platform independence? Or is this just a cultural difference?


title: Using php functions, reserved words as local identifiers

text: I'm thinking of some of the array functions. "key", "each", "pos", "range". These are often very useful as local identifiers! I have also seen code that (ab)uses $return, $list, $array, $string. What are other PHP programmers views on this? Local identifiers only! I wouldn't use them as members or method names of a class, even less global variables.


title: If you had more freedom and flexibility, what would you change in your employment contract?

text: For example, code ownership/authorship rights, non-compete terms, vacation/holidays, working hours, termination notices from any of the sides, etc.


title: Permission to reuse iOS sample code in commercial app?

text: Do we have permission to re-use iOS sample code from the apple developer website in a commercial app? Are we allowed to use it with modifications? Not sure of how to interpret all the legalese on the source. Obviously there's an "All rights reserved..." at the end, but there also a > "Apple grants you a personal, non-exclusive license, under Apple's > copyrights in this original Apple software (theApple Software"), to use, > reproduce, modify > and redistribute the Apple Software, with or without > modifications, in source and/or binary forms; provided that if you > redistribute the Apple Software in its entirety and without modifications, > you must retain this notice and the following text and disclaimers in all > such redistributions of the Apple Software."


title: Communicating details of method result?

text: I have code like this (pseudocode)               foreach(Box box in boxes)     {         if(boxFilter.PassesFilter(box))         {           // do something useful         }         else         {           Log.Log(format("Box %s was rejected", box.BoxId))         }     }      But now I'm thinking I'd like the log message to have more information such as "Box 1 rejected because too tall" or 'Box 549 rejected: 25" height exceeds Max height of 24"'. What's the best idiom to get this information into the log? Do I have to create a `FilterResult` object that is returned from the `PassesFilter` method? Or I guess I could also throw an exception and catch it and log it? Or something else? I happen to be using C++. **Update** In addition to logging I might want to also present a message to the user in the UI.


title: What is the proper way to distinguish between keywords and identifiers?

text: I'm aware that most modern languages use reserved words to prevent things like keywords from being used as identifiers. Reserved words aside, let's assume a language that allows keywords to be used as identifiers. (For example, in Ruby a keyword can be used as a method name). During compilation, how would you deal with this ambiguity? The lexing phase doesn't seem like a good fit because it would have to consider the tokens around it. The parsing phase also doesn't seem like a good fit since ideally the parser would work with tokens that are _unambiguous_. If I had to design it myself, I suppose I would have the lexer yield an ambiguous token, then have another level that considers the ambiguous token in the context of the tokens around it, (e.g. does the ambiguous token follow a `def` keyword? Then it must be an identifier.) Then, I would hand the unambiguous tokens to the parser. **In languages that allow keywords to be used as identifiers, what is the standard way for the compiler to tell them apart?**


title: Bugs that can be avoided with coding standards

text: I am looking for statistics (or estimations) that backup the claim that coding standards help reduce bugs. Hard-numbers would be nice, although I haven't had much look finding any. I've even looked at bug tracking for various open- source projects, but have not been very successful finding what I need. Does anyone out there know of any place I might be able to find this? Or do any of you contribute to any open-source projects that have had bugs that may have been avoided with better coding standards?


title: Eclipse runs my java program 6 times faster... Can I achieve this performance without using it?

text: I've written a java program that generates all repetitive permutations based on the characters and the length given. When I execute my code in Eclipse, it generates a file with 1,000,000 permutations in only 15 seconds. Yet if I run the program on the same machine in the command prompt using "java permutation" It takes 1 minute 35 seconds to generate the same 1M permutations.. Why is this? And is there anyway I can get this type of performance without using eclipse? Edit: Added Java VisualVM results www.craftboom.co.uk/jvm.png - The CPU usage is higher when running in eclipse. Both CPU and memory usage seem to drop to 0 ocassionally in the shell o_O EDIT2: Turns out it is a problem printing to the screen. Didn't mention it in my original post, but the program prints each permutation to the console.. Commented that out and saved to a file instead.. now running equally fast in both shell and eclipse. :-) Thanks to all for replies.


title: How to handle the problem of modified encrypted files

text: I have a simple encryption/decryption application that I am testing to learn more about security. I found out that if the user modifies the encrypted file, then decryption fails because the hashing algorithm doesn't generate back the original content. What are the common practices that deal with the problem of encrypted files modified by users either intentionally or unintentionally? The only thing I can think of is timestamp checking, but I am not sure how useful that is. About my last statement, I guess I am not sure if there is a way to trick the OS so that the new timestamp is set back to the exact old time stamp although the content is modified.


I read that the definition of NP-complete is : These are the hardest problems in NP. Such a problem is NP-hard and in NP How do we know if a problem is hardest in NP, and no harder problem exists. I understand that let's assume that somehow magically we know that a problem L is hardest in NP and then we can find out more hardest problems H if we can reduce H to L and vice versa.But my question is how does it all begin? How do we know 1 hardest problem to begin with? Also, to be able to say that something is hardest (or any extreme), we need to know all possible problems in NP and then argue about the hardest.. How do we know all possible NP problems? Is this where turing machine comes useful and by using representation of output string in form of 1 and 0 in output tape, we can theoretically talk about all possible NP problems. I understand that I may not have been able to articulate my question well - due to confusion. Thanks,


title: Why don't research papers that mention custom software release the source code?

text: Is there a reason why the source code of software mentioned in research papers is not released? I understand that research papers are more about the general idea of accomplishing something than implementation details, but I don't get why they don't release the code. For example, this paper ends with: > Results > > The human line drawing system is implemented through the Qt framework in C++ > using OpenGL, and runs on a 2.00 GHz Intel dual core processor workstation > without any additional hardware assistance. We can interactively draw lines > while the system synthesizes the new path and texture. Do they keep the source code closed intentionally because of a monetization they intend to make with it, or because of copyright ?


title: Benefits of a leaderless team in Scrum

text: Scrum advocates assume that a team without a designated team leader (as it is in Scrum) is more effective than a team with a designated leader (as in traditional hierarchy). Although I can understand this point of view, I am not entirely certain that's the case. In Scrum teams leaders always emerge. Power vacuums get filled. So if the organization already recognizes certain people as talented leaders, why not assign them an official leadership role in the first place?


title: Is there a pattern for subscribing to fired events/messages at specific intervals?

text: I'm not sure if this a common scenario or not, but I have a need along the following lines: I have an object (I'll call it node) and this object has methods X, Y, and Z. I want to be able to have subscribers be notified if the methods are called in a specific order with specific timing (a range of time would be ideal). For instance:   1. Node.X() get called    2. Node.Z() is called 5 to 7 milliseconds latter   3. Node.X() is called 1 to 2 milliseconds after that   4. Node.Y() is called 2 milliseconds seconds after that.   5. Finally, An event calling a subscriber to this sequence is fired. Now, in this example I am simply using parameter-less methods, but in real life I'd need to be more specific about the contents of the parameters (I'd be looking for specific messages). For reference I am using C# .net 4. Are there any frameworks/patterns/libraries that exist out there that are built for doing this?


title: How do you combat programming fatigue?

text: Not fatigue as in 'I need sleep' but fatigue as in 'I just can't be bothered anymore' which usually sets in when you hit roadblocks in whatever project you're working on, generally the closer you get to deadlines. It can be in work projects or personal projects, but it's something I keep hitting more and more lately. I'll get an idea, get into working on it, have a few really good days and make progress, then just some niggly things will trip me up, I can't get things working the way you want, I've hit limitations in the framework, I've got problems I can't find documentation for, etc. and it just gets too frustrating. Or am I alone in this?


title: Brain picking during job interview

text: Recently, I had a job interview at a big Silicon Valley company for a senior software developer/R&D position. I had several technical phone screens, an all day on-site interview and more technical phone screens for another position later. The interviews went really well, I have a PhD and working experience in the area I was applying for yet no offer was made. So far, so good. It was an interesting experience, I am employed, absolutely no hard feelings about this. Some of the interviewers asked really detailed questions to the point of being suspicious about new technologies I have been working on. These technologies are still in development and have not come to market yet. I know some major hardware/software companies are working on this too. I have had many interviews before and based on my former interviewing experience and the impression some of the interviewers left behind, I know now all this company wanted from me is to extract some ideas about what I did in this field. Remember, I am referring to a R&D position, not the standard software developer stuff. Has anybody encountered this situation so far? And how did you deal with it? I am not so much concerned about "stealing" ideas but more about being tricked into showing up for an interview when there is no intension to hire anyway. I am considering refusing technical interviews in the future and instead proposing a trial period in which the company can easily reconsider its hiring decision.


title: How much time a week do you spend on extracurricular programming?

text: Background: I'm a microsoft DBA/IT type person by day, an iOS and Mac developer by night. I have one app in the App Store and another one in the works. I try to spend as much time as possible working on my two apps, but with a new daughter and other (non computer) hobbies, I find it hard to spend more than a few hours every week programming. I'm wondering how this compares to other developers. I see a lot of apps out there written by single developers who don't do iOS development as their main job. Are they spending 4 hours a night working on their projects, or do they just plug away for a year or two before releasing anything?


What's more important: To write programs fast or to write fast programs? According to: http://math.stackexchange.com/questions/17478/how-quickly-with- better-tool it is better to write fast programs, but I wanted to ask this Q here to get the general gist of what you're thinking on this subject. Of course I'm taking as a given that all programs have to be correct etc. etc.


title: How to create scalable & side-effect free integration tests?

text: In my current project, I am having a hard time coming up with a good solution to create scalable integration tests that have no side effects. A little clarification on the side effect free property: it is mostly about the database; there shouldn't be any changes in the database after the tests are completed (state should be preserved). Maybe scalability and state preservation don't come together, but I really want to push for a better solution. Here is a typical integration test (these tests touch the database layer):               public class OrderTests {              List<Order> ordersToDelete = new ArrayList<Order>();               public testOrderCreation() {             Order order = new Order();             assertTrue(order.save());             orderToDelete.add(order);         }              public testOrderComparison() {             Order order = new Order();             Order order2 = new Order();             assertFalse(order.isEqual(order2);             orderToDelete.add(order);             orderToDelete.add(order2);         }         // More tests              public teardown() {              for(Order order : ordersToDelete)                  order.delete();         }     }      As one might imagine, this approach yields tests that are extremely slow. And, when applied to the whole integration tests, it takes around 5 seconds to test only a small portion of the system. I can imagine this number going up when the coverage is increased. **What would be another approach for writing such tests?** One alternative I can think of is having kind of global variables (within a class) and all test methods share this variable. As a result, only few orders get created & deleted; resulting in faster tests. However, I think this introduces a bigger problem; the tests are no longer isolated and it gets more and more difficult to understand & analyze them. It might just be that integration tests are not meant to be run as often as unit tests; therefore low performance might be acceptable for those. In any case, it would be great to know if someone came up with alternatives for improving scalability.


title: Indirection: Readability vs Performance

text: (I see there are a lot of similar questions, but answers are not really what I am interested at.) The thing that is bugging me is indirection. If I'm writing something, I do tend to inline as much stuff as possible. I might be less strict about it in compiled language hoping that compiler will do all the inlining for me. Still adding layers of indirection feels to me like "I'll just add some more burden onto user in runtime so that I could have nicer code here" - something that could be solved with either a comment or a different design (which I would actually prefer but it would take some more time). Seeing a small function that is used only once I have to actually fight the urge to inline it. Having a multitude of single-use classes makes me want to create a different (and usually totally procedure-oriented) solution. How bad is that? How many layers of indirection are actually OK to have?


title: Using Type Parameter (or not)

text: Effective Java provides 2 ways to implement `swap`:               // Two possible declarations for the swap method      public static <E> void swap(List<E> list, int i, int j);      public static void swap(List<?> list, int i, int j);      Then, Mr. Bloch says: > Which of these two declarations is preferable, and why? In a public API, the > second is better because it's simpler. You pass in a list—any list—and the > method swaps the indexed elements. There is no type parameter to worry > about. As a rule, if a type parameter appears only once in a method > declaration, replace it with a wildcard. It appears that `swapNoWildCard` could be used rather than the `swap` and `swapHelper` method. Mr. Bloch explains the reasoning for using the 2nd signature above.               public static <E> void swapNoWildcard(List<E> list, int i, int j) {         E e = list.set(j, list.get(i));         list.set(i, e);     }          public static void swap(List<?> list, int i, int j) {         swapHelper(list, i, j);     }          private static <E> void swapHelper(List<E> list, int i, int j) {         E e = list.set(j, list.get(i));         list.set(i, e);     }      However, is this debatable given the fact that `swapNoWildCard` is almost half the # of lines of code compared to implementing the other 2 methods? Why is it so useful to leave out the type parameter?


title: Writing tests for two methods that share functionality

text: I'm writing some tests for a NodeJS module, but this question can apply for any language / platform. I've got the following situation:               // in moduleA.js          exports.foo = function (var1, var2) {         // do something to var1 and var2 here              baz(var1, var2);     };          exports.bar = function (var1, var2) {         // do something completely different to var1 and var2 here              baz(var1, var2);     };          function baz(var1, var2) {         // do something to var1 and var2 yet again that both foo and bar need              moduleB.doSomething(var1, var2);     }      So, both `foo` and `bar` are public methods of `moduleA`. They've got some specific functionality (they do different things to `var1` and `var2`) but also some shared functionality (to keep things DRY I've moved it into a private method, `baz`) and then they both call a public method on `moduleB`. I've stubbed out `moduleB` so I know exactly what's going on after `foo` and `bar` have been called. I'm writing tests for `foo` and `bar`'s specific functionality but I'm not 100% sure how to approach testing the shared functionality in `baz`. It seems to me I've got three options:   * write identical tests for both `foo` and `bar` that test for the things in `baz`   * write a single test for `foo` and not write the same test for `bar` since know that `baz` works   * expose `baz` as another public method for the module and test it separately. I'm leaning towards the first option, but I feel I might be missing something.


title: How are hybrid VB6/.Net applications functioning in the Real World?

text: I am maintaining a VB6 application and we are studying how to migrate to .Net We are considering doing this gradually by implementing new features in COM visible .Net classes and migrating existing functionality slowly. I found some instructive 'Hello World' examples about how to do this and it works fine with our App. But how is the real world behaviour of these hybrid applications? Are they stable, maintainable? Particular of our program is that more users on the same computer will use it by switching user accounts. EDIT: The VB6 app reads data from a USB connection and stores it in an Access database. The user can call up various views on the data. The data is cached in a hardware device, so interuptions in the reading of it are not fatal.


title: What is the current state of Google's Dart programming language?

text: Dart has been out for ages (in internet years), but judging by Google Trends , it hasn't gotten much hype, and the fact that it only works in Chrome doesn't help either. Nonetheless, Chrome is gaining market share every day, which lends itself to a better view on Dart. What is the big picture now? What state is the language in? Do people regard highly of it? Market share? Web App showcase? Some feature implementations that make you go "I _have_ to use it"?


title: How to improve and start client interaction

text: How to remove hesitation of interacting with client ? As a Devloper i want to develop my career but this require the better Client Interaction,but as now i haven't done any major client interaction , and i want to do major client interaction, how i can proceed in this way ?


title: Why aren't user-defined operators more common?

text: One feature I miss in from functional languages is the idea that operators are just functions, so adding a custom operator is often as simple as adding a function. Many procedural languages allow operator overloads, so in some sense operators are still functions (this is very true in D where the operator is passed as a string in a template parameter). It seems that where operator overloading is allowed, it is often trivial to add additional, custom operators. I found this blog post, which argues that custom operators don't work nicely with infix notation because of precedence rules, but the author gives several solutions to this problem. I looked around and couldn't find any procedural languages that support custom operators in the language. There are hacks (such as macros in C++), but that's hardly the same as language support. **Since this feature is pretty trivial to implement, why isn't it more common?** I understand that it can lead to some ugly code, but that hasn't stopped language designers in the past from adding useful features that can be easily abused (macros, ternary operator, unsafe pointers). Actual use cases:   * Implement missing operators (e.g. Lua doesn't have bitwise operators)   * Mimic D's `~` (array concatenation)   * DSLs   * Use `|` as Unix pipe-style syntax sugar (using coroutines/generators) I'm also interested in languages that **do** allow custom operators, but I'm more interested in **why** it has been excluded. I thought about forking a scripting language to add user-defined operators, but stopped myself when I realized that I haven't seen it anywhere, so there's probably a good reason why language designers smarter than me haven't allowed it.


title: Is software design important to programmers?

text: I am studying software engineering, just finished the requirements course and going for more. I don't know how important software design is (in real world and actual projects) in later SDLC phases. As I read on the internet a lot of development teams like less documentation or design, and more coding. This makes my major worthless (in the real world). I am very good at programming and I like it but its not my main thing. I would like to hear from people about their experience with this, about a software engineer's actual role in real-world projects, and about how projects usually go?


title: How do I create an environment where fixing tests is seen as a priority?

text: I am a software engineer at a medium sized company. We have a fairly robust testing platform running on TeamCity. It does unit tests on every checkin, and a daily unit test/BVT run. The problem is - we have a great deal of broken unit tests. Quite often, I bring up the pointlessness of unit tests if they are constantly breaking and unmaintained. Being unable to see if a change has caused a regression removes most of the value of a unit testing platform. I would like to get a seed planted that will create a culture of good habits - fixing tests when they're broken, seeing them as valuable, prioritizing the fixing of tests along with other work. I've tried bribery (baked goods!), just plain asking, and speaking to team leads. Everyone says that it's a good idea, but I see to be the only one doing anything about it. What is the best way to get started on encouraging others to fix their tests, and prioritize test fixing within their sprints? If there is a less subjective way to ask this, I would be happy to accept any tips.


title: How to go about training IComparable to a team?

text: I (am just a developer) am tasked with training my team on a technique or technology. I zeroed upon System Interfaces, IComparable and IEquatable to be specific. How does one go about teaching (even if it is 1 hour), what an IComparable is and where we can use it by giving them an example. However, I am not entirely sure whether that would make my team to understand and start using IComparable. In my project, however, I do have a Discount class and there are instances where I have to merge two lists of Discounts. Now, that would be a really good instance of where IEquatable would be helpful when I do the merge wouldn't it? I had the following template for training.   * Introduction: Why does one need IComparable? (And, I could not get an answer that I can use for teaching).    * Structure of IComparable (Again, what else can I talk about other than CompareTo method).    * Sample Code   * Where we can use that in our project   * Questions.


title: Why is Python slower than Java but faster than PHP

text: I have many times seen various benchmarks that show how a bunch of languages perform on a given task. Always these benchmarks reveal that Python is slower then Java and faster than PHP. And I wonder why is that the case.   * Java, Python, and PHP run inside a virtual machine   * All three languages convert their programs into their custom byte codes that run **on top of** OS -- so none is running natively   * Both Java and Python can be "complied" (`.pyc` for Python) but the `__main__` module for Python is not compiled Python and PHP are dynamically typed and Java statically -- is this the reason Java is faster, and if so, please explain how that affects speed. And, even if the dynamic-vs-static argument is correct, this does not explain why PHP is slower than Python -- because both are dynamic languages. You can see some benchmarks here and here, and here


title: Why are inheritance and polymorphism so widely used?

text: The more I learn about different programming paradigms, such as functional programming, the more I begin to question the wisdom of OOP concepts like inheritance and polymorphism. I first learned about inheritance and polymorphism in school, and at the time polymorphism seemed like a wonderful way to write generic code that allowed for easy extensibility. But in the face of duck typing (both dynamic and static) and functional features such as higher-order functions, I've begun to look at inheritance and polymorphism as imposing an unnecessary restriction based on a fragile set of relationships between objects. The general idea behind polymorphism is that you write a function once, and later you can add new functionality to your program without changing the original function - all you need to do is create another derived class which implements the necessary methods. But this is a lot simpler to achieve through duck typing, whether it's in a dynamic language like Python, or a static language like C++. As an example, consider the following Python function, followed by its static C++ equivalent:               def foo(obj):        obj.doSomething()          template <class Obj>     void foo(Obj& obj)     {        obj.doSomething();     }      The OOP equivalent would be something like the following Java code:               public void foo(DoSomethingable obj)     {       obj.doSomething();     }      The major difference, of course, is that the Java version requires the creation of an interface or an inheritance hierarchy before it will work. The Java version thus involves more work, and is less flexible. Additionally, I find that most real-world inheritance hierarchies are somewhat unstable. We've all seen the contrived examples of Shapes and Animals, but in the real world, as business requirements change and new features are added, it's difficult to get any work done before you need to really stretch the "is-a" relationship between sub-classes, or else remodel/refactor your hierarchy to include further base-classes or interfaces in order to accommodate new requirements. With duck typing, you don't need to worry about modeling anything - you just worry about the _functionality_ you need. Yet, inheritance and polymorphism are so popular that I doubt it would be much of an exaggeration to call them the dominant strategy for extensibility and code reuse. So why are inheritance and polymorphism so wildly successful? Am I overlooking some serious advantages that inheritance/polymorphism have over duck typing?


title: How does the use of a rules engine impact the design, implementation, and performance of an application?

text: I'm interested in the ability of rules engines to:   * launch and iterate over business driven logic   * have "business users" perform the actual modification of those rules rather than developers   * comprehend the business rules in general Also, does using a rules engine impact the quality of an application? Does the use of a rules engine change if you were deploying to a 1-machine setup vs. your architecture vs. a multi-tier cloud-based distributed architecture using thousands of machines? How would it be different?


title: How can I get programmers to stop writing code vulnerable to SQL injection?

text: Sometimes you get busy and delegate small tasks to junior programmers. But if you don't pay close enough attention you find yourself with this kind of code in production:               class DivtoggleController extends Zend_Controller_Action {              public function closeAction() {             /* ... code removed for brevity ... */                  $req = $this->getRequest();             $formData = $req->getPost();                  $d = $formData['div'];             $i = $formData['id'];                  $dm = new Model_DivtoggleManager();             $rs = $dm->setDivToggleById($d, $i);              }          }               class Model_DivtoggleManager extends Zend_Db_Table {              public function setDivToggleById($div, $id) {             $result = $this->getAdapter()->query(                "update div_toggle set " . $div . "=1 where id=" . $id             );         }          }      So, given that I have removed the authentication / session management logic for brevity, who can tell me what possible problem there might be with this sample?


title: How to keep management out of our development process

text: I'm a software engineer in an software development team. The last 3 years we worked for an internal customer on a new product. Now this product is finished we're going to work on major new features for existing products. For a particular feature, product management have guessed it takes 150 hours to develop. Together with our project manager we have created a very detailed plan and we come to an effort of 300 hours. Yesterday we discussed this and they think we have grossly overestimated things. In our planning we estimated hours for writing unit tests, their idea is to dump them to save time. The decision has not been made yet and I will defend this planning and the unit tests if needed. But what I really don't like here is that management is interfering with our development process. How do I keep them out of our development process? And what arguments could I use to keep the unit testing in place (besides quality and long term time saving)? As a side note our company has 3 engineering teams and the team I'm in delivers their software on time (give or take a 10% margin). While the other teams always deliver late, mostly due to underestimation in planning. They only plan the coding and not the management, testing and handling around it.


title: Why are custom PDF download options preferred over ctrl+p?

text: Why do I, as a developer, have to go through so much trouble developing PDF download options for my clients when everyone in the world can simply hit Ctrl+P and life is good? The current issue I'm working on is dealing with Google Charts, so I'm not stating that offering PDF downloads in general is relatively difficult. On the contrary, particular cases are more trouble than they seem to be worth. See also: `@media print {}` Update: With a little research, I was able to find a perfectly workable solution. "Just hit Ctrl+P" now sounds like a ridiculous thing to say. Thanks everyone for your input. If you're interested to know what I decided to do, I realized that Google Charts are output as SVG markup and I think I should be able to use TCPDF to render them in a PDF document.


title: Formalizing programmers errors

text: Every one of us make errors leading to bugs. Once I wanted to start logging my errors for future analysis, probably mentioning project title, approximate time spent and the most important, the type of error. For example when I copy- pasted a fragment about 'x' and replaced every occurrence of 'x' with 'y' and forgot to replace a tiny piece, this goes to 'copy-paste error'. The usefulness of this approach depends on whether I can formalize my errors at all and probably minimizing the number of types to choose from. Otherwise I would start postponing, ignoring and so on so make this system useless. Are there existing research in this area, probably a known minimum set of errors? Maybe some of you already tried to implement something like this and succeeded/failed?


title: I hate one of our coding standards and it drives me insane, how to process it?

text: **Disclaimer** : Not as exaggerated as the title suggests, but it still makes me uncomfortable. I'm just going to express honestly, so take it with a grain of salt. Just pretend that I'm talking about _that_ coding standard that you don't like working with. **Edit** : The fact that I don't like it, doesn't mean I don't use it or enforce it. * * * I decided to ask this question in the spirit of how to get over a standard you don't like, not to get help on how to better argue how it can be changed (although any comments regarding this last part is appreciated). Besides, I work in a big company and such a change of something that has lived for so long and that matters so little is unlikely. The standard is the opening-curly-brace-on-dedicated-line standard:               somefunction()     {         //...     }      Instead of the ***clearly superior*** (note the joking/frustrated tone):               somefunction(){         //...     }      My personal arguments against the standard:   * **It bloats code** : extra unnecessary lines   * **Harder to type** : although probably this is just me struggling with the standard, I know one extra keystroke isn't that bad.   * **Not easier to read** : I start reading a function declaration, if statement, or any other scope-stacking statement and I already don't have to look for an opening brace. Nested blocks with this standard just make me angry for some reason.   * **Used by people who come from a Microsoft IDE background** : I think there should be an argumented reason (or more) behind a standard, not just take it in by paradigm. Their arguments (and my way of internally retorting to them):   * **Easier to read because you can see where blocks start and end right away** : I cannot understand this, what good is the block if you don't know what it is owned by, so then you have to read backwards.   * **I used it in a Microsoft IDE and I liked it** : Uhh... ok?   * **It is in the standard** : _*cringes*_ Am I the only one that struggles with an opinionated stance against a specific standard?, how have you gotten over these?, what is your opinion on what this particular standard should be (just for fun)?


title: Should all public methods in an abstract class be marked virtual?

text: I recently had to update an abstract base class on some OSS that I was using so that it was more testable by making them virtual (I could not use an interface as it combined two). This got me thinking whether I should mark all of the methods that I needed virtual, or if I should mark every public method/property virtual. I _generally_ agree with Roy Osherove that every method should be made virtual, but I came across this article that got me thinking about whether this was necessary or not. I am going to limit this down to abstract classes for simplicity, however (whether all concrete public methods should be virtual is especially debatable, I am sure). I could see where you might want to allow a sub-class to use a method, but not want it overriding the implementation. However, as long as you trust that Liskov's Substitution Principle will be followed, then why would you not allow it to be overriden? By marking it abstract, you are forcing a certain override anyway, so, it seems to me that all public methods inside of an abstract class should indeed be marked virtual. However, I wanted to ask in case there was something I might not be thinking. Should all public methods within an abstract class be made virtual?


title: How to increase the efficiency of an Immutable Queue in java?

text: I have been developing an Immutable queue in java, but the version I have developed is supposedly slow and I have been suggested to create a faster version of the same and I have no idea as to how to accomplish that.               import java.util.ArrayList;     import java.util.List;     import java.util.NoSuchElementException;     public class ImmutableQueueImpl<E> implements ImmutableQueue<E>     {              private List<E> queue;         public ImmutableQueueImpl()         {            queue=new ArrayList<E>();         }              public ImmutableQueueImpl(List<E> queue)         {            this.queue=queue;         }              public ImmutableQueue<E> enqueue(E e)         {                 if(e==null) throw new IllegalArgumentException();                 List<E> clone = new ArrayList<E>(queue);                 clone.add(e);                 return new ImmutableQueueImpl<E>(clone);         }              public ImmutableQueue<E> dequeue()         {                 if(queue.isEmpty())                 {                   throw new NoSuchElementException();                 }                 List<E> clone = new ArrayList<E>(queue);                 clone.remove(0);                 return new ImmutableQueueImpl<E>(clone);         }              public E peek()         {                 if(queue.isEmpty()) throw new NoSuchElementException();                 return queue.get(0);         }               public int size()     {         return queue.size();     }     }      Please suggest any improvements in the implementation or the libraries used . We remove elements from immutable lists all the time and dequeue is just a special case of that. The point is that the result is not really the element, but another immutable list without it. The point of this design is mutation safety and way better in parallelized settings than mutable data structures.


title: Enterprise Wide Keys

text: I have for a long time been working on an ODS as well as Data Warehouse. Both are integrating a wide variety of data sources from stove pipe applications. One of the uses of the ODS is to provide data to other stove pipe applications. Imagine one app maintains a database of personnel, and another app manages tracking sales. Occasionally the Sales app may need to have a drop down of personnel that someone can pick from, say to credit a particular employee with a sale/commission. The Sales application can query the ODS to get the list of personnel. This allows the Personnel app to change its data structure, and the ODS modifies the ETL process to adapt to that change. Thus all the other apps consuming that data will not be impacted by the change. The Sales app will need to save a PersonnelID to that sale/commission record in its own database. However, the next time the ODS is refreshed, if it is using a full load technique, the key will change. Since the PersonnelID stored in the Sales database is a separate database, there is no straight forward way to cascade that change. This creates a challenge where any changes made to the ODS have to be made very carefully, and may even limit certain designs because external applications are depending on those keys to never change. I would usually avoid exposing keys to users, but in this case it seems necessary to allow external apps to reference enterprise wide entities in their own applications. The same goes for lookup tables that are available in the ODS, where a lookup table has keys and text. After a full load of the ODS I can ensure the keys satisfy referential integrity within the database, but not with external databases utilizing those keys. Since there are some parts of the ODS currently coded as a full load, which would cause keys to be regenerated, I would need to recode that ETL to be incremental, so that external databases can reference those keys without fear of them changing. What techniques are used when you have an enterprise wide data source, and other applications consume that data and need to store foreign keys referencing entities in that data? How do you decouple the foreign key references as much as possible without complicating the access to that data? Currently I am using table valued functions to provide access to data. I chose this approach because it allows parameters, joins, and decouples access to underlying tables that may change later.


title: In Ruby, change global in thread safe block

text: In Ruby, I have a use case for a few common configuration options, e.g. NOOP, TRACE, SILENT. Right now I am using local vars instead of globals and passing them around all over the place and it's a pain. I be perfectly happy to use globals for these, if I could run a block where the globals can be temporarily changed and then reverted back. e.g.                global_configure(:TRACE=>true) do        ...      end      But how can I make that block of code thread safe, so that other threads can't change the globals on it?


title: Extracting data from log files

text: I will be extracting certain bits from log files using regular expressions to filter out bit of data. Initially I was going to do this with Python. I later started to think about the fastest way I can perform this task. This lead me to parallel programming. I remember hearing somewhere that Python can't be truly parallel. I'm by far an expert programmer. I have been playing with Java for a bit and I was considering parallel programming in Java to perform this task. I was wondering what would be the fastest way to perform this task?


title: What is a Spring AOP 'advice'?

text: As the question states. What is an 'advice'? More importantly, what does it even mean (semantics)? What's the etymology of 'advice' in the Spring context?


title: Presentation VS Application layer in DDD

text: I have trouble drawing a clear line between Presentation and Application layer in Domain Driven Design. Where should Controllers, Views, Layouts, Javascript and CSS files go? Is it in the Application or the Presentation layer? And if they go all together in the same layer, what contains the other one? Is it empty?


title: Best solution to run a Linux sandbox on my Windows machine?

text: I'd like to develop some node.js on my windows machine by using a virtual linux server that runs as a program and that I would access through ssh. I'd like this virtual linux instance to access the network as well. Is there any solution available? Preferably free ones.


title: Splitting 1 large object into 2 tightly-coupled ones - good, bad?

text: I have a complex object (call it BusinessLogic) which provides an RPC interface to semi-trusted users. The functions in the RPC interface have to decide which procedure to call, check authorisation for that function, perform some argument checking, and then call private functions to carry out the required functionality, and then return results to the caller. I decided to implement this by having the RPC functions in a separate stateless object (call it AppInterface), to separate out the concerns somewhat, so that BusinessLogic just moves its own data around and AppInterface decides which methods on BusinessLogic to call to implement the functionality it exposes. This works very well for the most part. However it feels a bit wrong to me. The BusinessLogic object has benefited from not having to worry about authorisation, argument checking, etc, which is good. But since the AppInterface implements all of its functionality in terms of BusinessLogic, it can just be a thin wrapper for some procedures (which makes me question its necessity) and is a complex wrapper in other procedures (which makes me wonder whether that complexity should be pushed back into the BusinessLogic, given that the BusinessLogic has all of the information needed to perform the task). It also means that AppInterface needs access to methods in BusinessLogic that would otherwise be private as nothing else uses them; think friend functions in C++. Finally, it means I can't effectively unit-test AppInterface without using a full BusinessLogic object as that is the only practical way to get valid output. I am happy to leave the system as it is, as it works, but I am curious as to whether there are obvious improvements I can make to such a system. (For what it's worth, I am using Python 2.7, in a primarily object-oriented style.)


title: Is CSS resizing of images still a bad idea?

text: It's always been looked at that using width/height attributes on images which aren't what the original image actual is is a bad idea. It could mean pixalated images or download sizes bigger than nessary. But, is this still an issue? I wouldn't suggest up-sizing photos, but downsizing shouldn't be an issue provided that its not too much of a difference from the original and keeping to scale. For example, I have a photo that is 600x400 and I stick a width of 400px on it. Most modern browser scale the image down and it looks like rendering is still decent. So, what is everyones view on this?


title: Better name for existsByUserNameAndPassword()

text: I wonder if there is a better name for a DB API function called `existsByUserNameAndPassword()` which returns boolean. There are more function called like this: `existsByOldId()`... It sounds a little bit unperfect... Is there a better concept for naming "exists" functions? I want to keep the "exists" somehow. To use this functions in a very speakable context like:               if ($DB->existsByUserNameAndPassword($name, $password)) {         // ...     }


title: Unit testing invalid inputs; ArgumentException vs. Custom Exception

text: In unit tested code I often have multiple checks on the arguments on any method before the actual "work" of the method is begun:               public void DoSomething(string test)     {        if (string.IsNullEmptyOrWhiteSpace(test))        {            throw new ArgumentException("Test must not be empty", "test");        }     }      In my corresponding test for this method I'll do the following:               [Test]     [ExpectedException(typeof(ArgumentException),         Message = "Parameter name: test",         MatchType = MatchType.Contains)]     public void TestNullInput()     {         var classToTest = new ClassToTest();         classToTest.DoSomething(null);     }      I'm thinking that this is quite a bad way to go about doing the test, however, as it relies on a specific named parameter (which does not necessarily hold true after any refactoring), as well as the format of the message of an ArgumentException. Another option might be to create a custom exception for this, some form of "TestWasNullOrEmptyException", but this also seems fairly awkward, as there will be many many different exceptions throughout the solution, each used to indicate only the absence/invalidity of a parameter. I am wondering if anyone else has dealt with this issue, and whether I'm simply going about my input validation tests the wrong way of it there's a more elegant solution. EDIT: This is C# code, and I'm using NUnit/Rhino Mocks.


title: Requirement gathering and use cases examples

text: I've heard a lot about requirement gathering and use cases in theory, but in practice often happens that we ask ourselves "should we include this? should this be a use case? in which language should we write this particular requirement" and so on. These questions are mainly because of lack of practice, and since we cannot go picking projects to "learn in practice" it's a little bit hard to get used to the kind of thinking we need in the process of gathering requirements for a new app. In that case, is there some place where can I find real life examples of requirements gathering and application of use cases? I've found some books, but they are mainly focused on teams and I work alone, so it becomes a little confusing.


title: what are your web application server side layering design rules and the best practices you like to apply?

text: A web application is often designed to be layered. Typically there would be a Repository (Dao) layer, a Service layer and a Control (web handling) layer. The Control layer uses the Service layer which in turn uses the Repository layer. Often you'll see the Control layer using the Repository layer directly. Also quite prevalent is Services using other Services. Quite often all Services inherit from a base service class which will contain all references to all Repository components. So my question is really how and why do you design your serverside application (in terms of layers) and what rules do you apply to them? What are the generally accepted justifications for these layers and these rules? What rules do you see that should be considered 'bad practice'? What rules do you considered essential? Have you tried anything new in this area that worked?


title: Documentation often ommits to specify which flavour of regular expression to use, so is there a default flavour that we should all be familiar with?

text: Often I come across documentation that says "use a regular expression here" I have to spend quite some time digging around trying to work out _which regular expression_ format they are expecting. As far as I can tell, there are many types of regular expression. But, at my last place of work I was made to feel stupid when I suggested adding some text to our User Documentation to specify _the type_ of regular expression to be used. When someone says "a regular expression" what is _the_ regular expression syntax most people expect and where is it documented? Update: I was prompted to single-out some examples - but no disrespect to these great projects:   * eregi docs page is not particularly helpful in explaining expected syntax.   * Nor can I easily work out the syntax expected here if i just land on the page from a search.   * No explicit mention of the regular expression pattern expected by `PatternExpectation()` on the SimpleTest page.    * etc. etc.   * here is a highly voted SO answer that seems to assume there is only one flavour of regular expressions.


title: Object orientated data structures in database driven applications

text: I've started working for a company that maintains a small/medium sized commercial website. The website is written in c# asp.net, and uses SQL Server as a database. The structure of the code is very messy at the moment (for instance, ~5000 line `Utility.cs` file) so I want to move towards a better design on the asp.net side of the application. I'm trying to figure out the right way to do this. My basic plan is to create a class for every logically distinct item in the application (mostly mapping 1-1 to database tables, but sometimes N-1 or 1-N). Then, I plan to have some static factory methods to instantiate these classes by querying the database. The developer should be able to manipulate the resultant object, and then use a `UpdateDatabase()` method to save the changes to the database. For example, here is how an `Email` object would work:               public class Email {         Guid userId;         Guid emailId;         String emailValueInitial = null;         Sting emailValueNew = null;              private Email();              public static Email RetrieveEmail(Guid UserId, Guid EmailId) {             // .. query             return new Email(UserId,EmailId,emailValueInitial);                     }              public String EmailValue {              get {                 if (emailValueNew == null) return emailValueInitial;                 else return emailValueNew;                          }             set {                 emailValueNew = value;             }         }              public bool Update() {            // .. update database with value of emailValueNew or do nothing if it hasn't             // been changed         }          }      Notes:   * I could update the database whenever a field is changed, but this is obviously inefficient.   * I don't know what to do in the event that the developer wants to insert a `null` value into the database - I suppose I need different concepts for 'null as variable not yet used' vs 'null as database value null'. The above is a simple case. I'd also need some way of knowing about many-one relationships in tables. For instance, a User could work like this:               public class User {         Guid userId;              public Emails emails = new Emails(userId);              private User(); // etc..              public RetrieveUser();         public CreateUser();              public Update();     }          public class Emails {         List<Email> emails = new List<Email>();              Guid userId;              public Emails(Guid userId); // etc..              public bool CreateEmail(); // its convinient to create/delete from here         public bool DeleteEmail(); // as I can enforce, say, minimum 1 email per user     }      * * * These above are my first thoughts on how to solve this problem, but I've never done anything like this before, and I don't know what problems I might come across. I want to make a system that will be scaleable and easy to develop as we take on more programmers, so its really important to get the initial design correct. What kind of design should I use in an object-orientated language to best represent and link with a database? What are important things to consider? Is there existing literature on this subject, or important libraries/constructs I have neglected?


title: What does well written, readable tests look like?

text: Doing unit testing for the first time at a large scale, I find myself writing a lot of repetitive unit tests for my business logic. Sure, to create complete test suites I need to test all possibilities but readability feels compromised doing what I do - as shown in the psuedocode below. **How would a well written, readable test suit look like?**               describe "UserEntity" ->       it "valid name validates"         ...       it "invalid name doesnt validate"         ...            it "valid list of followers validate"         ..


What's the difference between a stream and a queue? They both have the concept of an ordered set of elements, but tend to have different implementations and a different vocabulary of 'insert'/'extract' (streams) vs. 'enqueue'/'dequeue' (queue). Are these interchangable? Do they suggest different concepts or patterns? If so, what are the differences?


title: Looking for design pattern to represent shared state in music sequencer

text: I like to give lots of context, but also to state the basic question up top as concisely as possible. Feel free to read a little or a lot. I'm working on a music sequencer, and have been happy so far to be using a publish/subscribe approach to help decouple the major components of the application, which has helped testing and refactoring. However I'm wondering how components can share awareness of certain state without all adding a dependency on some new singleton OR abusing (published) events to each cache their own copies of this state. The specific example is the "playhead"; this and another example are explained below. Up until now, a playhead has been trivially represented as an instance of the immutable Timecode class, which has a measure, beat, and tick (essentially sub-beat unit). Components can subscribe to "beat" events and grab its timecode to update their internal "playhead" property. But as I get into other functionality like editing, I see components that track the playhead will also want to track the SequenceEvents active at the playhead time (e.g. notes). Also I need to add functionality for a "step region" which is a time segment (say, 1 measure), similar to the playhead but not a single moment in time, that components will similarly need to track. I've been stumped as to how to represent such objects in my application without introducing tighter coupling. The current approach where components listen for events does not seem a good fit. Right now, the Sequencer component emits a "beat" event which subscribers can use to update their playheads. Enhancing this event to include SequenceEvent data for notes, etc. smells bad as events typically are meant to be transient and consumed as they occur, not so that event consumers can update private state. Especially when that private state would be identical in each consumer. Also, other events than "beat" could signal a change of the playhead, e.g. the user clicks on another part of the score. If not events, any other approach seems to have multiple components dependent on some new "playhead" component, with bidirectional binding (that is, several components could both detect changes to the playhead and set its state). Even using dependency injection to reduce the dependencies for the sake of testing, this feels wrong to me. In case even more context helps illustrate the problem, read on... The app currently has several immutable data types that larger components may be dependent on (or may use without knowing their type): Timecode, SequenceEvent, Meter, Tempo, Stret (string/fret object), Pitch. Larger components which do NOT have construction-time dependencies include:   * Sequence: Represents a score, can be queried to iterate or random access sequence events.   * Sequencer: Handles playback and timing, currently emits the "beat" and "note" events.    * ScoreView: Renders a sequence as tablature (sheet music), and visually shows the playhead.    * NeckView: Shows a guitar neck with actively playing notes.    * GUI: This contains a number of simpler controls, including clock displays that update with the playhead. This component also instantiates ScoreView and NeckView components, but does not wire them to each other in any way.  All run-time "wiring" is internal to components, via PubSub.subscribe('eventName', handler). PubSub has pros and cons, but this has worked well to a point. However some cases where this approach breaks down are: 1) The guitar neck should show "static" markers for currently "selected" notes, in addition to playing active markers that animate when notes are played. This requires tracking state of which notes (strets) have start times at the current playhead. 2) Clicking on the guitar neck should toggle (add/remove) notes from the active sequence at the current playhead position. This would also be updated in the score view. 3) A new feature allows a "step region", which allows stepping through the score in increments like whole measures. So the current step could be larger than a single time point, and the neck and score views should be able to display static markers for all notes within the step region. This seems to be a duplicate of the same problem that applies to the playhead. Yet another approach that smells bad is to have these new entities all managed/owned by the Sequencer component, and have it publish events specifically like "playheadUpdated" and "stepRegionUpdated" that contain all the necessary data. This seems bad again because of the misuse of events to update redundant state in several components. This might be mitigated if the event referenced an immutable (or at least, not subject to change) object (e.g. for "playhead state"), maybe it would be less bad. But this approach still has the problem that other components cannot change the playhead or step region without publishing a request for the Sequencer to handle this change. Seems very wrong. Maybe others have solved this exact type of problem more elegantly than I'm thinking. Any pointers are appreciated.


title: Why do higher level languages have neither xor nor nand short-circuit operators?

text: While many higher level languages have bitwise (exclusive or) and bitwise (exclusive and), for instance C, C++, Java, etc. I'm curious why the ( _vastly more useful_ ) logical short-circuit operators don't have this functionality? Is it simply due to the capacity of being able to concatenate logic through use of "not"? This question is mainly to do with the language design considerations....


title: Should I leave href empty when implementing click events via jQuery?

text: Is it preferable to have `#` in a link's `href` attribute when I am implementing the `click` event via jQuery, or is it ok to leave `href` empty? i.e.                     vs                     When I'm doing               $("#myLink").on('click', function() {        // do ajaxy stuff     });      Although I understand the click event could be on a span or other such element I'm interested in this case for particular best practices when using an `a` tag.


What is the name of book that offers guidance on when to use each verb for a method call? For example, I might use GetApples() to return a list of Apple instances; or I might use BindApples(IControl control) if I want to bind these apples to a dropdown list. What book would suggest when you use Get or Bind as part of a method name?


title: Data Persistency, patterns and approaches

text: Data persistency has recently become a really grip for me, especially how long to maintain database connectivity and how many connections are feasible for a given request. I've been using .NET; however, this is a generic question related to any lanaguage. From a .NET perspective, I'm connecting to database using EF4 and for a given website page I might create 6 connection per-request to render a page. The page might consist of news, stock prices, etc, and needs to be constantly updated. I've recently been looking at unit-of-work (i.e. per request) approach. So basically when a request starts, if required a database connection is opened and destroyed upon end of the request. I'm not convinced it's the best approach yet. I'm looking for opinions and experience on it.


title: How can a Mac or Unix owner fix/develop webpages for IE6/IE7?

text: I work on Debian and before Debian I was on Ubuntu. In my previous job, we simply ignored IE6, but at my present job a page must work flawlessly for IE6 onwards. The one wayout for me is to set up a Windows VM but that doesn't help every time. Consider this, if I was a freelance consultant and didn't want to or have enough money to buy licenses for every possible Windows version how could I deliver a web page that worked for IE6/IE7?


title: Would you refactor this and if so, would you charge your client?

text: I am working on a freelance job at home. The client wants me to write some new functionality for his CMS, but it is taking me a lot of time to figure out what the code is doing, because it is written in a very unreadable style. Below is just an example of what I mean. The previous programmer made extensive use of anonymous functions, of eval(), he uses deeply nested ternary operators, he didn't indent code, didn't use comments, and he uses funny constructions like misusing the behaviour of logical operators || and && for creating if/else conditions (the second condition of && only gets tested if the first one is true, opening the possibility to use && as an if/else construction). All in all it's insane code and it's costing me a lot of time to find out how the current code works.               return ($this->main->context != "ajax" || in_array($this->type, $this->definition->ajax)) ? eval('return method_exists($this,"Show'.ucfirst($this->type).'") ? $this->Show'.ucfirst($this->type).'('.(count($args) ? join(",",array_map(create_function('$a','return (is_numeric($a) || preg_match("/^array/",$a)) ? $a : "\"".$a."\"";'),$args)) : "").') : null;') : '';      Would you refactor this code and how would you handle this sort of thing with your client, I mean financially?


title: What build tools do not depend on java (or Ruby)?

text: I'm wondering what generic build tools out there include their binary run- times and do not depend on another environment not shipped with them. For example, ANT requires Java, Rake requires Ruby, etc.. would be great if talking about also target-platform-agnostic tools, where I'd just give whatever command for building, whatever command for testing, etc.. and can then define my artifacts in CI or so. Would see something like that useful for building .NET projects (say, on both Windows .NET and Mono), and Node JS projects especially. I do not want to install Java and / or Ruby if what I want is a .NET build or a Node JS build. This is a bit of general awareness question not an exact problem I'm facing, that's why it's here not on StackOverflow. **Update:** To explain a bit more, what I'm after is the build script that would run MSBuild for compiling for example ( in .NET, and then maybe several Node/NPM commands in Node, etc..), and then have the rest build/test steps, instead of setting these all in MSBuild (again, in .NET case, also, wondering if there is equivalent story in Node). **Update2:** My target is being able to have a developer on a vanilla machine to just clone the code without installing any dependencies except the platform the code targets be it .NET/Mono or Node (not even Java, Ruby, or Python) and still be able to build and run tests.


title: Print bottom view of a binary tree

text: For a binary tree we define horizontal distance as follows:                   Horizontal distance(hd) of root = 0         If you go left then hd = hd(of its parent)-1, and          if you go right then hd = hd(of its parent)+1.      The bottom view of a tree then consists of all the nodes of the tree, where there is no node with the same `hd` and a greater level. (There may be multiple such nodes for a given value of `hd`. In this case all of them belong to the bottom view.) I'm looking for an algorithm that outputs the bottom view of a tree. * * * Examples: Suppose the binary tree is:                        1             /  \            2    3           / \  / \          4   5 6  7                 \                  8      Bottom view of the tree is: 4 2 5 6 8 7                   Ok so for the first example,         Horizontal distance of node with value 1: 0, level = 1         Horizontal distance of node with value 2: 0 - 1 = -1, level = 2         Horizontal distance of node with value 3: 0 + 1 = 1, level = 2         Horizontal distance of node with value 4: -1 - 1 = -2, level = 3         Horizontal distance of node with value 5: -1 + 1 = 0, level = 3         Horizontal distance of node with value 6: 1 - 1 = 0, level = 3         Horizontal distance of node with value 7: 1 + 1 = 2, level = 3         Horizontal distance of node with value 8: 0 + 1 = 1, level = 4              So for each vertical line that is for hd=0, print those nodes which appear in the last level of that line.         So for hd = -2, print 4         for hd = -1, print 2         for hd = 0, print 5 and 6 because they both appear in the last level of that vertical line         for hd = 1, print 8         for hd = 2, print 7      One more example for reference :                        1           /     \         2         3        / \       / \       4   5     6     7       / \ / \   / \    / \     8  9 10 11 12 13 14 15           So the output for this will be : 8 4 9 10 12 5 6 11 13 14 7 15               Similarly for this example     hd of node with value 1: 0, , level = 1     hd of node with value 2: -1, level = 2     hd of node with value 3: 1, level = 2     hd of node with value 4: -2, level = 3     hd of node with value 5: 0, , level = 3     hd of node with value 6: 0, level = 3     hd of node with value 7: 2, level = 3     hd of node with value 8: -3, level = 4     hd of node with value 9: -1, level = 4     hd of node with value 10: -1, level = 4     hd of node with value 11: 1, level = 4     hd of node with value 12: -1, level = 4     hd of node with value 13: 1, level = 4     hd of node with value 14: 1, level = 4     hd of node with value 15: 3, level = 4          So, the output will be:     hd = -3, print 8     hd = -2, print 4     hd = -1, print 9 10 12     hd = 0, print 5 6     hd = 1, print 11 13 14     hd = 2, print 7     hd = 3, print 15           So the ouput will be:     8 4 9 10 12 5 6 11 13 14 7 15      * * * I already know a method in which I can do it using a lot of extra space (a map, and a 1-D array for storing the level of the last element in that vertical line) and with time complexity of $O(N \log N)$. And this is the implementation of this method:               #include <iostream>     #include <cstdio>     #include <map>     #include <vector>          using namespace std;          struct Node{            int data;            struct Node *left, *right;     };          Node* newNode(int data)     {         Node *temp = new Node;         temp->data = data;         temp->left = temp->right = NULL;         return temp;     }          int height(Node *node)     {         if(node == NULL)                 return 0;         else{              int lh = height(node->left);              int rh = height(node->right);                   if(lh > rh)                    return (lh+1);              else                    return (rh+1);         }     }          void printBottom(Node *node, int level, int hd, int min, map< int, vector<int> >& visited, int lev[], int l)     {          if(node == NULL)                  return;          if(level == 1){                   if(lev[hd-min] == 0 || lev[hd-min] == l){                           lev[hd-min] = l;                           visited[hd-min].push_back(node->data);                   }          }          else if(level > 1)          {               printBottom(node->left, level-1, hd-1, min, visited, lev, l);               printBottom(node->right, level-1, hd+1, min, visited, lev, l);          }     }          void findMinMax(Node *node, int *min, int *max, int hd)     {          if(node == NULL)                  return;               if(hd < *min)               *min = hd;          else if(hd > *max)               *max = hd;               findMinMax(node->left, min, max, hd-1);          findMinMax(node->right, min, max, hd+1);     }          int main()     {         Node *root = newNode(1);         root->left = newNode(2);         root->right = newNode(3);         root->left->left = newNode(4);         root->left->right = newNode(5);         root->right->left = newNode(6);         root->right->right = newNode(7);         root->left->left->left = newNode(8);         root->left->left->right = newNode(9);         root->left->right->left = newNode(10);         root->left->right->right = newNode(11);         root->right->left->left = newNode(12);         root->right->left->right = newNode(13);         root->right->right->left = newNode(14);         root->right->right->right = newNode(15);              int min = 0, max = 0;              findMinMax(root, &min, &max, 0);              int lev[max-min+1];         map < int, vector<int> > visited;         map< int,vector<int> > :: iterator it;              for(int i = 0; i < max-min+1; i++)                 lev[i] = 0;              int h = height(root);              for (int i=h; i>0; i--){             printBottom(root, i, 0, min, visited, lev, i);         }              for(it = visited.begin() ; it != visited.end() ; it++) {             for(int i=0 ; i < it->second.size() ; i++) {                 cout << it->second[i] << " ";             }         }              return 0;     }      I am seeking help to do this in more optimized way, which used less space or time. Is there any other efficient method for this problem?


title: Invalid data returned, which HttpCode to return?

text: My web application calls a third party API. If I successfully call the API but invalid data is returned which cannot be processed by my system what is the most appropriate HttpCode to return to the user calling me?   * 500, I'm not convinced. Although it was an internal error it's due to external factors   * 503, Perhaps, although very vague   * 400, 4XX errors are usually related to the client contacting our server and so could be misleading. Which is the most appropriate response to return to my client?


title: Is it considered "conveying" if I share modified LGPL v3 code on GitHub?

text: It is critical to know what constitutes "conveying" under LGPL v3. I am considering creating some software based on LGPL v3. The software will be used to run a web application. Now I wonder whether the "conveying" clauses would get activated if I published the modified code on GitHub to the public. I understand that none of you are lawyers so IANAL is implied. I also understand that I could contact the developers of the LGPL software and ask for a different license.


title: How do I determine how many numbers are in a floating point number system?

text: I'm trying to make floating point number systems a bit more intuitive for myself. There are a few things I am confused about, and I think the best way to clear up my confusions would be for someone could guide me through one question: How many numbers are there in a floating point number system (Given the base, precision, max exponent, and min exponent)? This is what I am thinking: I figure that the maximum possible number (realmax) divided by the smallest possible number (realmin) would give all of the possible positive numbers. Part of me also believes I could divide realmax by the smallest increment, machine epsilon (eps), to figure out how many numbers there are. Just looking at the differences in magnitude between eps (10^-16 for IEEE double precision) and realmin (10^-308), however, tells me this isn't true at all. I can't think of an intuition for why! So the problem I am facing is determining the correct formula for realmax and realmin. The answer I get using my textbook's formulas differ radically from the one I got with wikipedia's formula. Help!


title: IPv4 to IPv6. where is IPv5?

text: As all of us know that after IPv4 it came IPv6. How this transition happened? I just want to know was there any IPv5 also? or there is any other logic in naming this version of IP as IPv6?


title: Should I use simple socket programming to communicate between 2 threads?

text: Is it a good idea to communicate between 2 threads using sockets in Java? What I am trying to achieve is Inter-process communication using socket programming/RPC mechanism.


title: How to manage a virtual group in a company?

text: I have worked as a software engineer for more than 6 years. Recently, my boss has asked me to build and manage a virtual team. While I'm glad I can do some management work, I don't think it will be easy to do the management. My team members are only part-time on this project, they come from several teams, and their direct manager is not me. They want to be given technical work but my boss wants us to organize some activities. I'm trying to work out how to balance these two conflicting requirements. Overall, my team manages several parts of an internal BBS which features topics about innovation. Unfortunately, the BBS is not very popular and few colleagues want to spend more than a second on it. They say that they are too busy, but more likely it is an excuse, probably because the BBS is not user- friendly. I don't know why BBS is so important. However, my boss likes the BBS and want my team to make it better. Personally, I don't know why this BBS is so important. Overall, I need some guidance about how to approach this.