How to protect source code from remote developers?

My company is going to hire an external developer to create some new modules and fix some bugs in our PHP software. We have never hired an external developer by the hour before. How can we protect the source code? We are not comfortable giving out source code and were thinking that everything remained under a surveillance enabled VPN which external developer would log in to. Has anyone solved this problem before? If so, how? Edit: We want the developer to see/modify the code but under surveillance and on our machine remotely. Does anybody have a similar setup? Edit 2: NDA is just a formality. IMO, even people who are in favor of NDAs know that it'll do nothing to protect their property. Edit 3: Let me clarify that we aren't worried about the developer copying an algorithm or a solution from the code. Code is coming out of his brain, so naturally he is the creator and he can create that again. But our code is built over several years with tens of developers working on it. Let's say I hire an incompetent programmer by mistake, who steals our years of work and then sells it to the competitor. That can make us lose our cutting edge. I know this is rare, but such a threat has to be taken under consideration if you're in business. I'll make points of my comments so its easy for everyone to communicate:   1. Why NDA sucks? Take this scenario, if anyone is capable of suggesting a solution to this scenario I will consider the NDA effective. Ok, here goes: We hire 2 external developers, one of them sells our code as it is to someone else after a year. You are no longer in touch with any of the developers, how are you supposed to find out who ripped you off? NDA does provide a purpose, but you can't rely completely on that. At least we cannot.    2. I did not meant to offend anyone while I was posting this question, even though unintentionally I did. But again to people answering/commenting like 'I will never ever work with you' or that Men-in-black-gadget thingy: It's not about you, it's a thread about how feasible a given technical solution would be. And if anyone in this community has worked under such an environment.   3. About 'Trust', of course we won't hire anyone we do not trust. But is that it? Can't someone be deceitful at first? We all trusted a lot of politicians to run our country, did they not fail us ever? So, I'm saying 'trust' is a complete other layer of protection like NDA, and my question was not directed to it. My question is rather directed towards technical measures we can take to avoid such a thing from happening.


How to Protect Intellectual property violations from one's own team

I have an android app idea, I want to make the app along with a few batch- mates in my collage. (1) How do I make sure that these guys will not compromise the intellectual properties involved? In the sense that they will not leak out confidential information, new theories, new ideas, new features descriptions either freely on any medium or to some other company developing similar software. Also, these people will most likely have access to the entire source code (with comments) of the project, how do I make sure that in the future they will co- operate with me, (2) will not release any part of the code, (3) Will not freely release alpha versions containing features meant only for premium users. Also, (4) is there way to effectively work without granting them access to the entire source code? I am open to all kinds of answers: trust, technical, managerial - leadership, good friendship - relationship with collegues. UPDATE: We all live in India.


How to manage a Closed Source High-Risk Project?

I am currently planning to develop a J2EE website and wish to bring in 1 developer and 1 web designer to assist me. The project is a financial app within a niche market. I plan to keep the source closed. However, I fear that my would-be employees could easily copy the codebase and use it or sell it to a third party. The app development will take 4-6 months, perhaps more, and I may bring in additional employees after the app goes live. But how do I keep the source to myself. Are there techniques companies use to guard their source? I foresee disabling USB drives and DVD writers on my development machines, but uploading data or attaching the code in email would still be possible. My question is incomplete. But programmers who have been in my situation, please advice. How should I go about this? Building a team, maintaining code- secrecy,etc. I am looking forward to sign a secrecy contract with the employees if needed too. (Please add relevant tags) **Update** Thank you for all the answers. I certainly won't be disabling all USB ports and DVD writers now. But I think I should be logging activity(How exactly should I do that?) I am wary of scalpers who would join and then run off with the existing code. I haven't met any, but I have been advised to be wary of them. I would include a secrecy clause, but given this is a startup with almost no funding and in a highly competitive business niche with bigger players in the field, I doubt I would be able to detect or pursue any scalpers. How do I hire people I trust, when I don't know them personally. Their resume will be helpful but otherwise trust will develop only with time. But finally even if they do run away with the code, it is service that matters after the sale is made. So I am not really worried for the long term.


Iterators versus 'cursors' in Java

In Java, most people expect that each call to `Iterator.next()` will return a distinct object. This has led some of us to define an alternative model which we called a 'cursor'. (Note that others use the term 'cursor' to draw a different distinction.) The pattern of a cursor is:               class SomeCursor {         boolean hasNext();         void next();         type1 getItem1();         type2 getItem2();      }      In other words, it is perfectly clear that the same object evolves at each step in the iteration. The problem on my hand right now is to also support situations, like web services, in which we absolutely do want distinct objects so that we can ship a collection of them around. It pains me to imagine pairs of classes (a cursor and a bean) that have to be maintained in parallel, and I'm casting about for alternatives. Here's one idea, and I wonder if anyone else out there has seen a better one.   1. You make an interface consisting of the 'get' methods for an object with all the items in it.   2. You define the cursor as implementing that interface and also hasNext & next.   3. You dynamically create the bean objects using one of the major dynamic code-gen libs on the fly to create a class with the obvious fields and get methods, plus set methods if needed to make something like JAX-B happy. edit: for those who are not following, I recommend a read of http://lucene.apache.org/java/2_4_0/api/org/apache/lucene/analysis/TokenStream.html. Also compare with http://download.oracle.com/javase/6/docs/api/java/sql/ResultSet.html, which is an example of this 'cursor' approach. Note in Lucene an API that iterates over a sequence of objects, allow the caller to specify whether to deliver the new data to a new object or the same old object each time. Yes, it is possible to define an `Iterator<T>` that returns the same thing ever time, but we have concerns that people will use this as a gun to shoot their toes off. Thus the preference for the JDBC-ish pattern.


JSP vs templates

I did some research on using server side templates vs JSP, could not find information on it. Can someone please provide information on pros and cons using server side templates vs JSP and vice versa.


How to search for a tester?

As a freelance developer, a few times I tried to find some testers to be able to let them test my software/web applications. If I try to find them, it's because most of the customers are not intended to hire external testers and don't see why this can benefit to them, so products are UI-untested and buggy. I tried lots of things. Discussion boards for IT people, specific websites for people who search for a job. Every time I clearly precise that I'm looking for product testers. I completely failed to find anybody for this job. I found instead two types of people:   * Non IT people who try to qualify as testers, but don't have enough skills for that, and don't really know what testing is and how to do it,   * Programmers, who are skilled _as programmers_ , but not as testers, and who mostly don't understand neither what testing is about (or think it's the same thing as _code review_ , or it consists in _writing unit tests_ ). Of course, they submit general programmers resumes, where they describe their high experience in Assembler and C++, but don't tell anything about anything related to the job of a tester. What I'm doing wrong? Isn't it called "tester"? Is there at least a tester job, different from general programming job? Is there any precise requirement to require from each candidate which can eliminate non IT people and general programmers?


Is there a way to prevent the editing of HTML and CSS contents in a page using Firebug-like tools? I found that some users are editing some values in hidden fields and some contents which written between a div or span tag for gaining some profits. They are doing mostly by editing with help of tools like firebug. Is there any way to identify such modifications? The problem here is that the values they are editing is generated when the page is compiled. The page is developed in PHP. The editing is done mostly in between the tags.


What threading pratice is good 90% of the time?

Since my SO thread was closed i guess i can ask it here. What practice or practices are good 90% of the time when working with threading with multiple cores? Personally all i have done was share immutable classes and pass (copy) data to a queue to the destine thread. Note: This is for research and when i say 90% of the time i dont mean it is allowed to fail 10% of the time (thats ridiculous!) i mean 90% it is a good solution while the other 10% it is not so desirable due to implementation or efficiently reasons (or plainly another technique fits the problem domain a lot better).


Recruiters intentionally present one good candidate for an available job

Maybe they do it without realizing. The recruiter's goal is to fill the job as soon as possible. I even think they feel it is in their best interest that the candidate be qualified, so I'm not trying to knock recruiters. Aren't they better off presenting 3 candidates, but one clearly stands out? The last thing they want from their client is a need to extend the interview process because they can't decide. If the client doesn't like any of them, you just bring on your next good candidate. This way they hedge their bet a little. Any experience, insight or ever heard of a head-hunter admit this? Does it make sense? There has to be a reason why the choose such unqualified people. I've seen jobs posted that clearly state they want someone with a CS degree and the recruiter doesn't take it literally. I don't have a CS degree or Java experience and still they think I'm a possible fit. Edit: I'm asking this question because there are many posts that assume recruiters cannot recognize talent, but maybe it is not in their interest to recognize too many talented candidates and make it harder for clients to decide. Eliminate the confusion. There is one candidate. Make that person an offer. It's a win, win, win. Maybe this falls under the theory of Too Many Choices?


Combining 3rd party javascript libraries with my code, then using Closure Compiler

I'm using multiple third party javascript libraries in my website, and right now I'm keeping each third party library as a separate .js file, with its own `<script>` tag. But I would like to use the Closure Compiler with Advanced Optimizations. This requires that I either concatenate all the javascript in my website together or make a lot of modifications to my code. Obviously, I would prefer to simply concatenate all the javascript together then run it through Closure Compiler, but then where would I put the licenses and attribution for this code? Not only that, but the actual 3rd party code will be modified as it runs through the Compiler. All the third party libraries either use MIT, BSD, or CC0 1.0 Universal.


Forcing ExtJS application updates after deployment

I work on an ExtJS application with a Django backend, and we keep running into issues when we push new code. Our users seldom refresh their browsers, so after a code push we end up with users using the same (now outdated) version of our ExtJS application for days at a time instead of the new, updated version. How do other people deal with this issue? (I haven't found anything online about this, so I probably haven't found the right keywords yet.)


If statements in "generic" assembly?

I'm reading a relatively 'friendly' and simple book about compilers named "Let's Build A Compiler" (originally a series of articles). The compiler written in the book generates instructions in some assembly language (68000 assembly). Since I don't know this assembly language, I decided that my compiler will also generate 'assembly' instructions (e.g. `MOVE #4,D0` has the same meaning: "put the number 4 in register `D0`"), only they will be executed by a program I will write, instead of by a physical computer. A kind of "virtual machine". So far I think this shouldn't be a problem, but I have a question regarding this: What is a "generic" way to handle `if` statements in assembly? For example, what would be the simplest assembly translation for this code:               if(a>b){         // do stuff     }


What are good source control check-in strategies for large tasks?

The general rule is to keep check-ins small and check-in often. But sometimes the task requires large changes to the underlying framework. Then checking in before compeleting the task will break the project until you check in the finished work. So what strategies do people use to reduce the risk of losing work, or deciding something you are doing is the wrong approach, then changing your mind after removing the code and trying another approach? When I can, I'll check-in half done work commented out, or if it compiles and nothing is using new files I'll check them in. The larger the change the more likely I am to branch the project and then merge back when I have everything working again. Another option if the source control system allows is shelf sets, which are basically small branches. So when I finish for the day or come to a decision point, I'll shelve my changes, and then if something catastrophic happens, or I want to come back to that point, I can.


What's the worst technology decision you have ever seen?

This includes architecture decisions, platform choices or any situation where a such a bad choice led to negative consequences.


Design: Mixed XML / Relational or Pure Relational?

Is it acceptable to model a very complex object graph using XML in the database, but leave the rest of a system in relational tables? I'd like to gauge opinion on this as I've hit a bit of a conundrum. Many thanks ## \-------------------- **Background** I'm building a financial application which, although not at all large in terms of data storage ( <= tens of megabytes initially), will have a very complex data model. Specifically, users will be working within the context of a "Project" entity, which will contain various sub-entities and lists. The users will be able to add formulae to diverse parts of this object graph and they will be continuously recalculated in realtime. The complexity comes in two parts:   1. No matter where in the class hierarchy a formula is located, it will be able to reach any other part of the same parent project entity using a path-like syntax. This will include the results of other formulae, and I will be implementing all of this with an in-memory dependency tree on a middle tier.   2. I'd like all the formulae to have the same basic structure, metadata, etc. To accomplish this, all formulae will be represented by the same class structure in code, regardless of which part of the data graph they are attached to. I'd much rather have the whole thing in a document - it would mean much less time spent fussing with database design, and I'd be able to have a much richer object model for the same amount of effort. I'm worried though about relational integrity - I'd still want to store my static data in relational tables. **Technologies**   * SQL Server 2012.    * .Net 4.5 (via C#)    * Entity Framework (database first) on the middle tier   * Simple auto-generated DTOs over WCF for services   * WPF with Prism on the client. I've not considered NoSQL storage ideas, largely because I don't have enough experience of them for a project with tight timelines. I've also not considered Entity Framework code-first, for the same reason.


Removing elements of an 'at least one' association

let's assume - regardless from technology and programming languages - you have a type and the type has an association to another type. This association has the complexity of 'at least one' (1..n). How would you specify the behavior, when removing elements from this association based on a predicate? Say, the predicate fits to all elements, thus the removal would violate the 1..n constraint, would you remove all elements but one or would you rather not remove any element in this case (and have a transactional-like behavior)?


Should I use structure from a core library graphic toolkit in my domain?

In java (and many other programming language), there are often structure to deal with graphic element : Colour, Shape, etc. Those are most often in a UI toolkit and thus have a relatively strong coupling with UI element. Now, in the domain of my application, we often deal with colour, shape, etc, to display statistic information on an element. Right now all we do with it is display/save those element with little or no behaviour. Would it make sense to avoid "reinventing the wheel" and directly use the structures in `java.awt.*` or should I make my own element and avoid a coupling to this toolkit? Its not like those element are going away anytime soon (they are part of the core java library after all), but at the same time it feel weird to import `java.awt.*` server side. I have no problem using `java.util.List` everywhere. Should I feel different about those class? What would be the "recommended" practice in that case?


Overloaded high transaction SQL Server database Solutions

The current sql server database is overloaded and many transactions are failing. The powers that be have a proposed solution to build a separate database to handle/store transactions and then asynchronously insert them into the current system. Specifically persist new transactions to a new database then build routines to insert the data from the new database into the current/old database. I'm looking for best method to implement this solution... should I use a non- indexed table in the proposed new db for fast inserting, then use bulk inserting from newdb -> olddb to move the data back into the main database? Is this best done @ scheduled intervals or real time? I was also wondering if scaling up/out would help here (budget permitting)? My initial thought was to recommend purchasing a second server and configuring a cluster to reduce the load. To be honest I thought the web transactions would just timeout and not fail (but I guess that's ultimately the same)?


How do I go about data deduplication at scale?

I need to develop, or at least conceptualize a module that does _efficient_ data deduplication. Say we have millions of data records already. Insertion of another 100 mn records, making sure that there are no duplicate records in the resultant dataset, is what the module needs to do, at the top level. Now this may mean comparing on a field(s) that decides whether records are duplicate or not. But this approach, taken serially, is really naive, when we're talking millions of records. What do you think can a viable approach be? Hashing? using divide and conquer type algorithms to exploit parallelism? I have these in my head, but it really gets giddy at such scale. Also, please post any pointers to resources on the Web I can use - I could only find debates and vendors saying things about their db's "supreme data deduplication features". Thanks, Yati Sagade


Can you recommend a good test plan template?

Can you recommend a good test plan template for an agile testing team? I know there are templates for testing on the web and have already looked at some found by search engines, but I could really use something lightweight and something that has already been tried by skilled testers and is known to work well. Many templates I've seen give me the feeling that writing test documents is expected to be a third of the work that those testers are doing, but my team really prefers to use less documentation and more actual test writing. We use a wiki for documentation, so an approach that lends itself to living documents would be great. My hope is that using a more structured approach to test planning will increase the usefulness of my test plan while reducing the effort to create it by allowing me to think about the tests, and not the format and structure of the plan. My workplace does not have something already on hand, so whatever I start doing might be adopted by the company.


Choosing between two programmers: experience vs. passion

I am in a position where I have to hire a programmer and have the option of 2 candidates, the first has experience but he doesn't have a passion for coding and he says so while the second doesn't have the experience but he has the passion, he did well in the interview and is certified. We have the resources to train someone, but I really don't want to blow this process and hire someone who will be disappointing. Can anyone help me as to how to approach this situation?


What is a O(n) algorithm to solve this puzzle?

We are going to hold a meeting where everybody will speak in clockwise direction around a table. There are n people with n spots. Each person has a position preference (e.g. some want to go first, some last, etc). Everyone is seated randomly and cannot move from their position. How shall we compute the best starting position on the table to satisfy the most people? I have an O(n^2) solution: See how many people would be satisfied having assumed each of the positions 1..n as start positions; then return the position that gave the maximum value.


Data migration to a single shared SQL table

We have three internal web applications we use at my company. Unfortunately none of my predecessors had the foresight of sharing tables amongst those apps. It has become necessary to share some company data among the three internal web apps. As an example, each of the three websites have a `companies` table in their respective databases. _Website A Companies Table_               id | name     ---------     1  | Sprockleys Sprockets     2  | Goobers Gadgets     3  | Nancys Necklaces      _Website B Companies Table_               id | name     ---------     3  | Sprockleys Sprockets DENVER     22 | Gooburrs Gadgets     30 | Nancyies Necklaces      I want to somehow merge all of this data together into a single shared database table. Unfortunately the ID's of the companies do not match up at all and other tables have foreign keys that map products and users to those companies. What are some ideas for merging data like this?


What is the difference between APIs, Libraries, Runtime systems, and frameworks?

> **Possible Duplicate:**   >  Library vs. framework vs API? I am having hard times understanding what these concepts really mean. This software stack thing is very confusing. Can you please help me with this question, or if you can refer me to some article/book where I can learn in details about this software stack and how they interact together. I tried wikipedia but there is not enough explanations there and the confusion still exists.


How do I deal with global variables in existing legacy code (or, what's better, global hell or pattern hell)?

So... We have this fairly complex project (~10k LOC, but there's duplicated code so it's hard to tell) with hundreds of global variables. The project has more dependencies on other projects, and many other projects depend on it too. I have mostly inherited the responsibility to refactor just a part of this project by myself, an "enclosed section" of modules. None of the original developers remain. I have devised a way to structure the routines in classes (breaking up megamoths, forming some class hierarchies, a little Strategy here and there, nothing too fancy (I hope); the objective is to make it easier for other developers to add functionality and make it possible to add proper unit tests). My new classes provide calculations applied to currently-global arrays of data that are updated, and the calculations themselves need to maintain a state (a sum, the last value of the last processed vector, etc). You could see them as functors. I'm unsure on how to deal with globals, though. I don't think I will be able change all globals to non-global because of the dependencies to other modules, which I'm not going to refactor just now. Also, many of my new classes will need to share data. So, I can...   * For the globals that _are not shared_ between my new classes, leave them as they are. I was thinking of using a Registry, or at the very least use some #define's or other variables to limit scope and provide context wherever they're used.   * For the globals that _will be shared_ between my new classes, either make a base class with the references, or use a Singleton to pass them around, or a combination of both. I'm not sure if using these patterns will do more harm than good. So, my question is: **what's better, live with existing global variables or aggressively tune them with patterns like Singleton or Registry? Do you have any suggestions to these schemes, or have a better scheme?**


Why doesn't Visual Studio auto increment your version number?

This question asked how to auto update version number in VS 2010 : http://stackoverflow.com/questions/4025704/publishing-in-net-produces- application-files-myapp-someversionnumber-how-to-ge The answer was, You have to update both Assembly Version AND File version manually Shouldn't the version number increment each time I publish? Why should I do it manually? Is this is a conscious decision by MS to do it this way? What's the thinking behind having people manually update their own version number?


Design for creating a menu based on user type

**Problem**   I am building a PHP application which has a main menu, which in turn contains various "sections" or "subheadings" with various links. There are several user types such as SuperAdmin, Admin, Teacher, Student, etc, and each type should see a potentially different menu structure. It seems that my client would like to add more types down the line. Currently I have a huge if/elseif/... block that checks what user type you are and creates an array with arrays for all the sections, containing yet more arrays for each link (these arrays contain the url, class and caption of the url). It's about 700 lines long at the moment. As you can see, this is becoming quite complex and tiresome to get working. So what I've attempted to do is use some design patterns (of which my knowledge is not that amazing). **Failed attempts**   Firstly I attempted to create a few _Builder_ implementations: one for the link itsself, one for the "section", and finally one for the menu itself. Then I attempted implementing a _Strategy_ pattern to check current user type, and add links to sections and these sections to the menu. The final attempt was to serialize this menu object to the DB and just read it from there (as some user types can have dynamically configured sections/links) **The real question**   I have no clue whether my rationale is even remotely correct in this regard, because I've created and completely deleted all my code about 4 times now as it becomes complex to comprehend just what must go where. So I guess my actual question is this: **If you had to build this kind of implementation for menus (or anything where multiple objects are built into another object, and multiple objects of that type are built into yet another object), how would you go about it?** What patterns would be useful and how would one structure them to work together without killing your brain? Thanks!


Controller vs Model: Where do I put the processing of user input?

I'm new to MVC and I'm not using a framework (and I'm not going to). I'm designing my new web application using MVC. I have the user input received in Controller. Suppose I have form `data` and an `action` to do with it, which can be "insert", "delete" or "update". Must I have process that action in Controller or in the Model? That is: must I do:               # Controller     if (action == "insert") Model.insert(data)      or               # Controller     Model.process(data, action)          # Model.process     if (action == "insert") self.insert(data)      (language-agnostic example). What is the "MVC way" to do it?


how is ORM an example of message coupling?

In this slideshow on slide 26 it mentions ORM as an example of message coupling. How is that so? With an ORM, certain code will call the ORM via an API, but that sounds like "control coupling". Also the ORM's api will take parameters to specify what you want, but that sounds like data coupling. How is ORM an example of message coupling? maybe other examples of message coupling will help me understand.


How to find bottlenecks in an application?

I'm building an application with lots of components, a lot of which are third- party so I only know what I can get from their documentation. From time to time, by pure luck, I find out one of these components was pretty heavy and had an option to cache stuff. I can't stop thinking that if I weren't lucky, one of these components would end up killing the performance of my app and I wouldn't have a clue what to do. I would end up adding more hardware like an idiot. So how do you find these kind of bottlenecks? I mean I wouldn't have a nice report saying "this part is slow", like it happens with the database. For example, today I found that a serializer I was using was heavy and wasn't being cached. Are there repeatable steps I could have followed to discover that the serializer was slowing things down?


Connecting mobile apps to a web service; What is it called and where do I start?

I have some basic knowledge of iOS development and I want to now start connecting my apps to databases hosted on the internet, so that users will have access to remote / public data that pertains to my app. My problem is that after searching the internet for some advice, I realised I don't even know what this type of programming is called? From my perusing it doesn't even appear to have a common moniker, and this is making it really difficult for me to find any advice on how to even begin learning to connect my apps to a web database. So my questions are, what on earth is this discipline called? And, how can I get started in learning it?


Asp MVC section and partial views

I have a question regarding ASP sections and partial views. What ser the benefit of using one over another? Because if I have a menu, i guest that it could be both as a section, but also as a partial view. So what is the difference?


Creating a window to draw pixels in

I'm creating a fictional architecture and other fictional components for this computer/emulator. I'm facing an issue, this being the virtual display. I need to be able to create a Window in which my program has access to all pixels contained inside, this is to emulate video memory/access. For the best speed I was thinking the best way to do this is to use native system API and conditional compilation for cross platform support, but I don't know if this is the best option. So essentially I just need some sort of way to create a cross platform window in which I can draw pixels in. I'm writing in the D language but almost any solution in C can be translated to D with C linkage. Thanks for any help.


Indentation: is there any evidence to show whether 2 or 4 spaces is more readable?

At the company I work for, we're trying to standardize our development practices, and we want to make the right call regarding indentation. **Is there any empirical evidence (preferably research articles in HCI or something) which demonstrates the effect that whitespace can have on code readability?** Alternatively, I'd be interested in a study which evaluates various styles of indentation in code for use in a team environment, across editors, screen resolutions, and operating systems.


What are the pros and cons of Node.js?

I'm designing a web application that is locally focused on JSON objects to do all the data stuff (and after that I would pass it to a server to cloud synchronize). However, somebody in an answer from another question suggested me to use Node.js to up/download data directly formatted as JSON. I read some stuff at the developer's website, and they claim it's as a web server. However, I'm not sure if it's just a data server (which makes sense to me) or it could be a replacement to Apache (I would go for no). I'm aware that your answers depend on the needs of my application, so, to sum up: _it should be able to dispatch data from a database ([No]SQL, whichever) and synchronize it back when I choose (either in the background or by direct action). The client-side should store the data as a mid-step (before syncing and after downloading the stuff) in JSON. Eventually in the future, it should need to synchronize across a bunch of accounts at the same time (you know, team modifications, just like Google Docs and so)._ And now, back to the question: **Which are the pros and cons of Node.js?** I'm pretty sure that the direct use of JSON objects from the server to the client and the _pushing_ calls are pretty good reasons to choose Node.js. However, I'm not sure if security (either my code or the data itself) or concurrent connections are mature enough, or I should go for a typical Apache with PHP files querying a MySQL, and in the early future poll instead of push (or find a pushing server). I know the question may sound easy to answer if you're already on one side (just node, node+Apache, just Apache), but these days I'm from nowhere. Thanks for your answers, mates.


Case studies for successful service (project) based software development businesses without constant overtime from its employees

I work for an IT company that is primarily services (project) based rather than product based. All software engineers are salaried. The company has set new expectations that everyone should work 48 hours per week instead of 40. Note, this isn't occasional overtime due to crunches. This is the new 40. The reasoning is that this enables the company to provide benefits to its employees such as monetary incentives and training because the company is more profitable. more hours worked = more billable hours = larger profit I understand the need for profitability and the occasional crunch time and have put in the extra hours when it was needed and beneficial to the project. However, I am also very sensitive to work life balance and have raised my concerns about the the new expectation. My employer is open to other methods to increase profitability so I hold hope that we can turn things around before it becomes a horrible place to work. How does a services based company become more profitable without increasing the number of hours expected from it's salaried employees? Are there any case studies showing the pros and cons of consistent overtime? Are there any case studies for a successful service based business model (for software development companies) that does not require consistent overtime from its employees?


Duck checker in Python: does one exist?

Python uses duck-typing, rather than static type checking. But many of the same concerns ultimately apply: does an object have the desired methods and attributes? Do those attributes have valid, in-range values? Whether you're writing constraints in code, or writing test cases, or validating user input, or just debugging, inevitably _somewhere_ you'll need to verify that an object is still in a proper state--that it still "looks like a duck" and "quacks like a duck." In statically typed languages you can simply declare "`int x`", and anytime you create or mutate `x`, it will always be a valid `int`. **It seems feasible to decorate a Python object to ensure that it is valid under certain constraints, and that every time that object is mutated it is _still_ valid under those constraints.** Ideally there would be a simple declarative syntax to express "hasattr length and length is non-negative" (not in those words. Not unlike Rails validators, but less human-language and more programming- language). You could think of this as ad-hoc interface/type system, or you could think of it as an ever-present object-level unit test. **Does such a library exist to declare and validate constraint/duck-checking on Python-objects?** Is this an unreasonable tool to want? :) (Thanks!) * * * Contrived example:               rectangle = {'length': 5, 'width': 10}          # We live in a fictional universe where multiplication is super expensive.       # Therefore any time we multiply, we need to cache the results.          def area(rect):         if 'area' in rect:             return rect['area']         rect['area'] = rect['length'] * rect['width']         return rect['area']          print area(rectangle)     rectangle['length'] = 15     print area(rectangle) # compare expected vs. actual output!          # imagine the same thing with object attributes rather than dictionary keys.


Verification naming confusion

According to Martin Fowler classical article, there are two types of verification: state and behaviour verification. At the same time I often see people telling about implementation vs. behaviour verification. So I guess we speak about pretty same stuff here and "state" in the first classification is "behaviour" in the second; "behaviour" in the first equals to "implementation" in the second. What I don't like is that "behaviour" word appears in both namings but on contrary sides which causes a lot of confusion. Which naming do you prefer?


JavaScript Phone Screen

For a simple phone screen question we generally always ask about scoping rules. It's clearly one of the biggest gotchas of JavaScript. Out of everyone we ask almost everyone insists that in an if or for loop a variable is scoped to that block as opposed to the function. Is this an unreasonable question?


source code file system layout for 2 very similar projects (with git)

we're working on "two" android apps that are very similar; in fact, they're the same apps with different graphics and color schemes, slightly different configuration and one or two unique activities that are not in the other project - but the functionality is 95% the same. the plan was to work on one app until it is as complete as possible and then change the images and the other /res(ource) files. of course it's not that easy; we're still working on the shared code, and patching the same code in different projects (or repositories) is - in my opinion - out of the question. we're all using git and eclipse. is there the "definitive guide" about handling such a situation? my thoughts about it: ### three repositories rep1 for the unique files of application1, rep2 for the unique files of application2, and rep3 for the shared files. if there is a way to push files in one folder (the project folder) to different repositories ... i mean, cloning rep1 automatically pulls the files from rep1 AND rep3, and pushing automatically pushes files back into to the right rep? my teammates are suspicious; no one of us knows git very well and we're afraid of spending too much time repairing our dcvs mistakes. ### 2 repositories if the first option isn't possible, our plan was to have 2 repositories. rep1 for the complete app1 and rep2 only for the rep2-specific files. a build script would replace the files from app1 with those of app2. imo this is an "accidental overwrite" minefield, and i don't like it. but as long as we don't have a better solution, this is the way to go. ### eclipse maybe there is some kind of eclipse-specific hack that would make this painless? ### (edit) branching!? i don't have any experience with branching. but this be a possible solution? note: these are android projects; android demands a specific file layout. e.g. the name and structure of the "res" folder is pretty much fixed. this means that there are directories which contain files both app-dependent and shared files. i don't know if git can handle this.


Storing stop/start points in a database

Let's say I am storing start and stop points per user into a database table. For example... let's say in a chat system, a user only needs to see lines 24-293, and 500-512. (Let's say he logged off for the night, and was not present between lines 294-499). Saving each start and stop point as a discrete row would lead to a huge ballooning table, which isn't exactly ideal. I wouldn't be searching on these points, so indexing is not necessary. How would I save this kind of information in the database? I was thinking of saving it in JSON:               accountID   |   lines             1   |   [24,293,500,512]      Where each odd value denotes a start, and each even value denotes an end. My only worry is that highly active users will be joining and leaving a chat, and would quickly fill up the row if `lines` was of type VARCHAR. So perhaps `TEXT`, or even `LONGTEXT`. Am I heading down a path of hurt, or is this a viable method? Thanks in advance!


How to reach to the advanced level in SQL?

I think I have a good grasp of SQL and the most features it has, but sometimes when I've done some more advanced Reporting Services a fellow developer has helped me with some stuff and when I open some existing procedures in T-SQL I understand that I have some learning to do. I think I have focused more in later years at application code (C# and javascript mostly) and somehow my SQL skills aren't there where It should be. Because at work the most stuff is very database centric with procedures, so I think I need to get better at SQL. But when I google around about features and look in books about SQL I know the most stuff, but somehow getting better at SQL ain't so easy any more. Does anybody have any advice how to become an advanced SQL programmer? What books to pick up? By the way I work exclusively with SQL Server. I've done tons of basic procedures with inserts, updates, selects with joins and group by and so on. But doing bigger problems I've always done a more application-centric approach with arrays and collections, but sometimes (Reporting) there's no choice than do it in SQL and work with temporary tables and so on. I'm tempted to do cursors because then I can loop through everything but that kills database performance (how about looping through a half million rows with a cursor?).


Silent Crash of WPF/VB.net 2010 based application

I have an application built in WPF and VB.net. It works on several Windows XP computers that I've tested it on, however, my animator's computer doesn't seem to like it. At first, the program would work up to a certain point, where the program would play a video. However, as she was missing the codec to play the video, it threw an exception. We installed the codec, and now the program silently fails all together, without so much as an error message or crash notification. These are the prerequisites that are required. All of these are installed on her computer. Assume prereqs for these items are also installed.   * .NET 4 Framework    * SQL Server Compact Edition 2006   * Windows Media Player v. 11   * Theora DirectShow codec Her computer is running Windows XP Home Edition SP3. What is going on? How can we get this program working on her system?


Are today's general purpose languages at the right level of abstraction?

Today Uncle Bob Martin, a genuine hero, showed this video In this video Bob Martin claims that our programming languages are at the right level for our problems at this time. One of the reasons I get from this video as that Bob Martin sees us as detail managers and our problems are at the detail level. This is the first time I have to disagree with Bob Martin and was wondering what the people at programmers think about this. First there is a difference between MDA and MDE MDA in itself hasn't worked and I blame way to much formalisation at a level you can't formalize these kind of problems. MDE and MDD are still trying to prove themselves and in my mind show great promise. e.g. look at MetaEdit The detail still needs to be management in my mind, but you do so in one place (framework or generators) instead of at multiple places. Right for our kind of problems ? I think depends on what problems you look at. Do the current programming languages keep up with the current demands on time to market ? Are they good at bridging the business IT communication gap ? So what do you think ?


After an outsourced/offshored application is "completed", who will do the maintenance?

What is the typical arrangement for the maintenance of applications that are not developed in-house? Note: by maintenance, I mean bug fixes, optimizations, small modifications and future extensions.


Parameterless & Empty-Paren methods in Scala

I'm learning Scala at the moment via Odersky's Programming Scala (2nd). I'm upto chapter 10 where he starts introducing parameterless and empty-paren methods. I just can't get my head around it. So far, all I understand is that I should use empty-parens if a method has side-effects and parameterless methods otherwise. I can't figure out what is the advantage of this convention. I read the posts on Stack Exchange, but to be honest, when the posts start discussing this topic in some depth I was lost. I'm looking for a simple explanation of what are typical use cases for this language feature and what are the advantages to help me understand it better.


What's your view on using other people's code?

As per this question: I decided to implement the BitTorrent spec to make my own client/tracker. Now, I was going through the spec, I was about 70% done implementing the BEncoding when I found a link to an implementation of BEncoding in C# written by someone else. Normally, if I were working on production code, I'd use it as a reference to check my own work against, and a baseline to write some tests to run my code against, but I found myself thinking "I'm making this, it's a for-fun project with no deadlines; I should really implement it myself - I could learn a lot" but some voice in my head was saying "Why bother re-inventing the wheel? Take the code, work it so that it's you're style/naming convention and you're done." So I'm a bit conflicted. I ended up doing the latter, and some parts of it I found better than what I had written, but I almost feel like I 'cheated'. What's your take? Is it cheating myself? Perfectly normal? A missed opportunity to learn on my own? A good opportunity to have learned from someone else's example?


Are projects using frameworks not as good as projects using pure programming?

I've been a Rails developer for a year now (originally self taught), and am at the point where I want to improve. I've been reading books on how to improve the quality of my Ruby code (I read Design Patterns and Practical Object Oriented Design in Ruby). I'm trying to improve the quality of my code and to add to my portfolio, but I'm having trouble thinking of anything motivating to do with just Ruby since in my head it feels cooler or more usable to have a Sinatra app (I'm thinking about learning Sinatra) and a browser to interact with the app than having to run a pure ruby app through the console with `$ ruby my_app.rb` and have it spit out some info. I know the results are really similar, but still. My question is, do employers think lesser of projects that use frameworks than projects (Rails, Sinatra, etc) that are built from complete scratch (just the programming language itself)?


Is it bad to reuse other programmer's code libraries that can perform generic tasks?

Reusing large amount of helpful codes made by other programmers is very tempting for me. I specifically refer to codes that can perform generic tasks, such as Data Access Layer (DAL) codes. I am just beginning a project using a newly familiar language, and I don't think programming from scratch is feasible. I can understand the semantics and many other concepts of that language, it is just the case that maybe I'm too lazy to start over and wanted to dive in to the task of coding a specific business logic. So given that using a code library of others is perfectly legal, is it bad to acquire a large portion of somebody's work and use it as a foundation of mine?


Incorporating libs into module pattern

I have recently started using require.js (along with Backbone.js, jQuery, and a handful of other JavaScript libs) and I love the module pattern (here's a nice synopsis if you're unfamiliar: http://www.adequatelygood.com/2010/3/JavaScript-Module-Pattern-In-Depth). Something I'm running up against is best practices on incorporating libs that don't (out of the box) support the module pattern. For example, jQuery without modification is going to load into a global jQuery variable and that's that. Require.js recognizes this and provides an example project for download with a (slightly) modified version of jQuery to incorporate with a require.js project. This goes against everything I've ever learned about using external libs - never modify the source. I can list a ton of reasons. Regardless, this is not an approach I'm comfortable with. I have been using a mixed approach - wherein I build/load the "traditional" JS libraries in a "traditional" way (available in the global namespace) and then using the module pattern for all of my application code. This seems okay to me, but it bugs me because one of the real beauties of the module pattern (no globals) is getting perverted. Anyone else got a better solution to this problem?


Clearcase: Find out files checked in with the current snapshot view

If you have used clearcase before, then this question is for you. How do you determine all the files and their corresponding checkins?, given a snapshot view.


Which architecture should I choose for this project?

I have a project. The server which based on a phone PCI-board is responsible for received phone calls from the customer and then redirect the phone calls to the operators. ![enter image description here](http://i.stack.imgur.com/bQEMN.png) I have decided to code the server using c++ programming language and qt framework because the PCI-board SDK's interface is c/c++ originated and for the sake of portability. The server need to send the information of the the customer to the operator while ringing the operator and the ui interface of the operator client should be browser-based. Now the key problem is how could the server notify the operator that there is a phone call for he/she. One architecture I have considered is like this, ![enter image description here](http://i.stack.imgur.com/9PdY5.png) The operator browser client use ajax pooling the web server to check whether there is call to the client; the web server pooling the database server to check whether there is call; the desktop server(c++) wait for the phone calls and set the information in the database. The other operations such as hang up the phone call from the client, retransfer the phone call to the other operator also use this architecture. Then, is there any way other than pooling the server(js code `setInterval('getDail', 1000)`) to decide whether there is a call to the operator? Is this architecture feasible or should I use some terrific techniques that I do know such as web services,xml-rpc, soap??? * * * The Caller center is for 8~300 operators and the operators do not seperate geographically. Moreover, I have figured out that we need provide interface for customer programmer, so this thing is so called middleware? Then some new questions, how could we expose interface to customer, COM? Thanks in advance.


Performance analysis of C++ programs

How can I measure the performance of my C++ programs using C++? Specific metrics I want to measure are:   * Memory used ( **space** )   * Duration taken ( **time** )


What workflow do you use with asp.net web forms development and your design department

I work at a place that has a clear separation between designers and developers. We're a fairly new start-up and we're trying to figure out what would be the best workflow for our team. We're a small company with a total of about 11 employees, three of which are designers (they deal with the HTML, CSS, some jQuery), and three developers primarily working with ASP.NET Web Forms. I am one of the developers and don't have a knack for design, but I am comfortable enough with CSS and jquery/Javascript to understand the mechanics and whatnot. So, currently we wait for the designers to provide us with HTML structure clobbered together with server-side includes, js, jquery, css, etc. Typically we try to work around their stuff and begrudgingly try to keep their structure roughly the same with the consequence of forcing us to have a lot of hacks in place to work with it. Yes, this means using their Server-Side Includes mixed in with our .aspx pages, amongst other things that seem to go against the general asp.net web forms flow. There have been times when I have changed the includes into a user control and had their common HTML out in master pages, etc. All of which was consequently followed by a lot of barking from the design team. Their main complaint being that master pages and user controls make their maintenance of the site more difficult. I can see their point of view, and I wouldn't like it either if people messed with my workflow either, which I guess I am doing so with them. I have tried several times to approach them about moving site structure that complements the asp.net web forms environment we programmers are working with, but every time the subject of working with master pages comes up, the design team throws a near tantrum. Our current approach is simply forcing us to put together a lot of hacks and work-arounds so that it gels with their design and frankly it's getting frustrating and just adding more unnecessary technical dept to our projects. My question is simply this: what workflow works best for you and your design team? Do your designers know how to use master pages, etc. Is it unreasonable to have designers understand the mechanics of how master pages and user controls work, and in general how ASP.NET puts a page together? (I don't feel this is an unreasonable expectation of them...) So, what do you guys think?


Example of a javascript app using immutable data structures?

JavaScript is functional but not in a strict sense. It does not rely on immutable data and side-effect free functions. There are a few libs that provide immutable data structures, so I believe it should be possible to write a more strictly functional program using JavaScript. I know ClojureScript exists but I am not interested in transcompilation. Are there any open source projects that use JavaScript in a more strictly functional sense with nothing but immutable data? I am interested in whether this is practical in a language not built with this in mind.


How applicable would an Automata class be to professional development?

Would it be worth taking Automata over Databases or Networking assuming no immediate plans on a Masters degree in Computer Science? I'd assume I'd learn things in there that would somehow be real work applicable like complexity theory but is it more useful immediately out of school or better to do a course somewhere post baccalaureate and take something more obviously applicable in its place? I've limited slots left or I'd take all of them.


How should I plan and start a project?

Every time I start a project, I decide at crucial moments to completely change the core classes and get caught up in obscure errors. I try planning in advanced and usually start off on a good foot but then I go to it another day and decide I would like to do it 'another way'. Is there a standard, of sorts, when starting a project such as mapping out classes and starting with unit tests? What is a good convention when planning and starting a medium project. The last project and started was a projectile motion simulator - I know, predictable.


Is code pruning related to obfuscation?

From my research, many obfuscation/optimization packages include a feature called **pruning** where the software will remove dead code during processing. The following packages include both obfuscation and code pruning as a feature (to name a few):   * RedGate SmartAssembly (.NET)   * Preemtive Dotfuscator (.NET)   * Inquartos Obfuscator (.NET)   * ProGuard (Java) I see the common thread that both operations require scanning and analyzing an assembly, but I'm curious if the two features are or even could be fundamentally related. The reason I am asking is that we are considering disabling code pruning in our environment (unrelated issue), but our concern is that it could potentially decrease the effectiveness of the obfuscation process and thus protect our Intellectual Property less. Does or could code pruning influence obfuscation, and how?


Why is SQL known as a relation-based / functional language?

We're learning that most languages are classified as either of the two, "relation based" or "high level". I've never used SQL before, but from reading its syntax it seems more like the imperative/high-level syntax than functional/relation-based (Lisp, Haskell)?? Or it could just be that my interpretation of my professor's lecture notes is wrong... but it definitely lists SQL as one of the relation-based languages (as opposed to high level), and it equates relation-based with functional... or perhaps it's that I don't understand **why the fact that SQL deals with relational databases makes a functional language the way it should be implemented? (and why 'relation-based' equates with 'functional' when categorizing programming languages?)** Thanks :)


The C++ web stack, is there one?

Java would be jsps and servlets (or a framework such as Spring) running on the JVM and tomcat (or glassfish etc). C# would be asp and C# running on dot.net framework and IIS ? (I have no experience with this please correct and improve my terminology) Is there an equivalent for C++ ? I could happily call some C++ from a java servlet/controller but was wondering if there are existing frameworks and libraries out there specifically for creating business logic in C++ with a web front end.


Are there any good python libraries for programming GUI's on MAC and Windows?

Need a a toolset / framework that I can use to build GUI apps on both Mac and Windows, without too much stuffing around. Any obvious candidates?


How to learn & introduce scrum in small startup?

In a few months, a friend will establish his startup software company, and I will be the software architect with one additional developer. Though we have no real day-to-day experience with agile methods, I have read much "overview" type of material on them, and I firmly believe they are a good - if not the only - way to build software. So with this company, I want to go for iterative, agile development from day 1, preferably something light-weight. I was thinking of Scrum, but the question is: what is the best way for me and my colleagues to learn about it, to introduce it (which techniques when etc) and to evaluate whether we should keep it? Background which might be relevant: we're all experienced developers around the same age with similar professional mindset. We have worked together in the past and afterwards at several different companies, mostly with a Java/.NET focus. Some are a bit familiar with general ideas from the agile movement. In this startup, I have great power over tools, methods and process. The startup's product will be developed from scratch and could be classified as middleware. We have some "customer" contacts in the industry who could provide input as soon as we get to an alpha stage.


Am I permitted to use an LGPL library without releasing the source to the rest of my application, if I dynamically reference the library?

I am a bit confused as to what I am/am not allowed to do with a LGPL Library that I intend on using in a small scale commercial C++ Application that I am developing. My current understanding, although I don't know if I am correct, is that I am permitted use the library without releasing the source to the rest of my application if I dynamically reference the library. Does anyone know if this is correct? Are there any restrictions as to how I reference the library? Thank You! I am not a native English speaker and don't understand the licence entirely.


Non-english programming languages

Is there a definitive listing of programming languages which don't use English for the keywords and statements in the language code? For example, I know that Russians back in the Cold War were developing their own computers on their architecture. I'm interested if there is a listing of programming languages that are not English based?


Why are methods considered the class attributes in Python?

I read in a book that both _methods_ and _fields_ are considered the _attributes_ of a class in Python. However, recently I was told by a friend of mine that methods may **not** be considered the _attributes_ of a class. Then I decided to check this out again, and found this question mentioned on Wikipedia saying that this is a Python "tradition" to refer to methods as attributes, in contrast to other object-oriented programming languages. So my question is: why are methods considered the class atributes along with the fields in Python in contrast to other languages? Thank you!


Dynamically generating HTML and CSS

I find writing CSS by hand to be extremely tedious. Coming across a concept such as _fluid_ , makes me want to write all my websites so that the CSS resizes nicely and looks the same in different browsers. My question to you is: **Can my design be generated programmically?** e.g.:               #include <css>     #include <html>     #include <vector>     #include <string>          int main(void) {         HTML::HTML page;         page.title("my title");         page.heading.font(15);         std::vector<std::string> para = <vector of paragraphs>;              CSS::CSS layout;         layout.grid(2,2);         layout.fill(xcoords_as_percentage, ycoords_as_percentage);              page.use_css(layout);         for(int i=0; i<para.size() && y!=grid.y.size()+1; i++, x++) {             if(x==grid.x.size()) x=0, y++;             page.grid[x][y]=para[i];         }         page.header1("I am header1");         page.footer("I am page footer");         layout.order(page.header1[0], page.grid.all(), page.footer());              generate_html("index.html");         generate_css("layout.css");     }      This will allow me to concentrate on the actual contents, abstracting away from "Oh, IE7 doesn't support this option, so do this hack..." FYI: I am coding the actual site in Django (Python), so the HTML/CSS generator doesn't have to be in C++. I am aware of work being done in this direction in the C++ Wt framework


Claim to get my source code used GPL code

I'm running public web site based on Drupal. Drupal is GPL 2 or 3 licence. Of course I wrote custom code which interacts with Drupal code (modules). Can anybody write me an e-mail and ask for the source code of that my custom code? In other words, have I to publish that my code somewhere?


Processing csv files (alternative to business logic in DB)

We are working on a fulfillment system for an online book store. Everyday we receive tens of CSV files (about 90 files) with data about purchased orders.   **Example:**               OrderId    |    BookTitle    |    Quantity    |    Price    |    BuyerName    |    ...     1          |The hunger games |        1       |     10      |    John Doe     |    ...     1          | The Exorcist    |        2       |     25      |    John Doe     |    ...     2          |   Superman      |        1       |     5.5     |    Jane Nose    |    ...      **What we currently do:**   The data need to be translated to our domain to `Order` entity, `OrderItem` entity,...etc. We load the file into dummy tables then use very complex queries to populate the `Orders` table and `OrderItems` table. **Problem:**   All the business logic is in the database (in the queries) so unit testing them is a nightmare. In addition we were requested to change the database we are using (not exactly, but something terrifyingly similar) **What we tried:**   We are moving to a DDD approach where the domain model is the core of the application that holds all the logic and validation. We tried to parse the file line by line and create the respective entities and validate them accordingly then save them to the database.   This resulted in thousands of calls to the database and sometimes the server runs out of memory coz of the thousands of records (around 90 thousand record/file) in a single file. I know this domain is dead old and someone must have found a better way to handle such task. How do you process such huge files in your domain without suffering from performance? UPDATE   * We are using a MySql database with PHP and Apache.   * The CSV file is loaded into a dummy table using something similar to this:               load data local infile 'orders.csv' into table dummyOrders fields terminated by ','       enclosed by '"'       lines terminated by '\n'         (orderId, bookkTitle,Quantity, Price, BuyerName,...)


How to handle static-ish content from a CDN with authentication?

I have a website that allows user uploads of content. Part of the design, to date, involves storing the user content on a NAS that has been configured with a separate app pool in IIS that has scripting disabled, shorter lifespans, no cookies, etc for CDN-type behavior as a subdomain (static.domain.com vs. www.domain.com). I have complete control over this process and all the instances. The design decision behind this was to allow for cheaper storage of uploaded documents (instead of wwwroot or a DB) and help mitigate some security concerns by disallowing scripting. The concern I have now is that CDNs, and this setup, are by nature very permissive and do next to no checking or validation. Are there any _reasonably effective_ measures to discourage idle sharing of this user content? I know nothing will stop determined or malicious people, but I want to at least prevent this user content from being available at large to the general populous. All of the links to the content will be behind a paywall at the 'www' subdomain, but the content itself will be behind the 'static' subdomain. Ideas I had so far:   1. HTTP Referer checking    2. Obfuscated filenames (I know, I know...)    3. Cookie testing with URL rewrite? (IIS8)    4. ...    5. Ask stackexchange


xml serialization and deserialization complex situation

I'm considering passing xml back and forth for error messages but each error has different scenarios. one situation at hand is passing diffed text comparison while others are as simple as passing a text message. What kind of serialization/deserialization strategy could I use for such a scenario? The main issue with a scenario like this is that the object is different from case to case and there needs to be a mechanism for identifying what type it is. Serializing xml is pretty straight forward:   * http://stackoverflow.com/questions/11283040/deserialize-xml-string-to-complex-type   * http://stackoverflow.com/questions/1212742/xml-serialize-generic-list-of-serializable-objects Three sloppy ideas pop into my mind from the start:   1. Make some super class that contains every possibility of contained types.    2. Make some mechanism for reading the xml first to identify what's in it.    3. Use option 2 and convert the inner body xml to an object. A more elegant approach would be to implement some kind of Action pattern, where, once the object was identified you could create the proper action to take with it. Some ideas consist of the Action/Executor pattern or IoC:   * http://msdn.microsoft.com/en-us/library/cc984279.aspx   * http://msdn.microsoft.com/en-us/library/aa973811.aspx Here is an example pattern idea that runs parrallel to what I'm thinking:   * http://stackoverflow.com/questions/298976/is-there-a-better-alternative-than-this-to-switch-on-type Not for data persistence but for error handling by the client: The client decides how to handle the error once received based on the Action from a base library that takes place after deserialization. my considered xml format would be something like this: diff error:               <errorMessage>     The header is not correct               <diffErrorArray>     <diffItem message="NoChange">     <customMessage>Correct</customMessage>     <source>HeaderColumn1</source>     <destination>HeaderColumn1</destination>     </diffItem>          <diffItem message="Replace">     <customMessage>Changed</customMessage>     <source>HeaderColumn1</source>     <destination>Header_Column_1</destination>     </diffItem>          <diffItem message="AddDestination">     <customMessage>Unknown</customMessage>     <source></source>     <destination>Header_Column_1</destination>     </diffItem>          <diffItem message="DeleteSource">     <customMessage>Missing</customMessage>     <source>HeaderColumn2</source>     <destination></destination>     </diffItem>          </diffErrorArray>               </errorMessage>      string error:               <errorMessage>     Bad news          <stringErrorMessage>Something really bad happened.</stringErrorMessage>          </errorMessage>


Is it anti-pattern to mix unit test and web test?

It is a language agnostic question, e.g. I have a unit test like               # Unit test     User user = User.create('john');     assertEquals("User name is john", "john", user.getName());          # Web test start from here     goTo("/user/john");     assertTitleEquals("john");      Do you think it is an anti-pattern? Although I can write a full selenium test suites to do the same thing, but using the above code save much of my time (e.g. no more click('Login'); waitUntil etc, and I don't need to worry if my UI is changed at all, sound like it is a quick and more stable approach to test?


when to mock in unit testing

I am trying to write unit tests in javascript for an application made in nodejs. What I want to know is - Say there is a class Vehicles which is dependent on another class Roads.   1. Should I mock the Roads class and send it as a parameter to Vehicles for unit testing? OR Should I just create a new object and send it as a parameter to Vehicles?   2. If I change the Roads class I will have to change the mocking every where?   3. Should I use a factory to create mocked objects?


(Why) is it important that a unit test not test dependencies?

I understand the value of automated testing and use it wherever the problem is well-specified enough that I can come up with good test cases. I've noticed, though, that some people here and on StackOverflow emphasize testing **only** a unit, not its dependencies. Here I fail to see the benefit. Mocking/stubbing to avoid testing dependencies adds complexity to the tests. It adds artificial flexibility/decoupling requirements to your production code to support mocking. (I disagree with anyone who says this promotes good design. Writing extra code, introducing things like dependency injection frameworks, or otherwise adding complexity to your codebase to make things more flexible/pluggable/extensible/decoupled without a real use case is overengineering, not good design.) Secondly, testing dependencies means that critical low-level code that's used everywhere gets tested with inputs other than those that whoever wrote its tests explicitly thought of. I've found plenty of bugs in low-level functionality by running unit tests on high level functionality without mocking out the low-level functionality it depended on. Ideally these would have been found by the unit tests for the low-level functionality, but missed cases always happen. What's the other side to this? Is it really important that a unit test doesn't also test its dependencies? If so, why? Edit: I can understand the value of mocking _external dependencies_ like databases, networks, web services, etc. (Thanks to Anna Lear for motivating me to clarify this.) I was referring to _internal dependencies_ , i.e. other classes, static functions, etc. that don't have any direct external dependencies.


Does every ASP.NET Web Application has a Single Application Domain?

I am bit confused. Is there only one application domain for every single ASP.NET Web Application or there can be anywhere between 1 to 100 application domains present in a single application pool of a web application


How do you learn a language's standard framework/API/functionality?

I understand how to code. I know how to get around the basics of the languages I use regularly. I know how to write slightly-above-basic regular expressions, I can talk to databases, I can accept input, print output, handle files, etc. I'm more or less assured of my basic ability to spit out the source code for moderately complex program. My problem is that I never feel like it's enough. I feel like I only know a small portion of the standard library of my language, and that until I understand it all, at least in passing, I have no right to even try to get a job using it. I'm just out of (community/junior/whathaveyou) college, and my friends are getting jobs in the industry, but I still feel like a fake or a poser and that I'm just not good enough. Is there a decent marker for "I know enough" that I could use to assure myself that I can code? Should I take the fact that I'm at least capable of coding up a FizzBuzz as an indicator that it's alright to apply for things? How can I learn more of these standard libraries, frameworks, and/or APIs relatively easily? I code on a regular basis, I read books, but my knowledge still feels so shallow. HELP!


_variable - why that underscore at the beginning?

Sometimes I see people writing variable names like this: > int _variable; IMO That's really ugly. What's that about?


Most efficient way to store this collection of moduli and remainders?

I have a huge collection of different moduli and associated with each modulus a fairly large list of remainders. I want to store these values so that I can efficiently determine whether an integer is equivalent to any one of the remainders with respect to any of the moduli (it doesn't matter which, I just want a true/false return). I thought about storing these values as a linked-list of balanced binary trees, but I was wondering if there is a better way? **EDIT** Perhaps a little more detail would be helpful. As for the size of this structure, it will be holding about 10s of thousands of (prime-1) moduli and associated to each modulus will be a variable amount of remainders. Most moduli will only have one or two remainders associated to it, but a very rare few will have a couple hundred associated to it. This is part of a larger program which handles numbers with a couple thousand (decimal) digits. This program will benefit more from this table being as large as possible and being able to be searched quickly. Here's a small part of the dataset where the moduli are in parentheses and the remainders are comma separated:               (46) k = 20     (58) k = 15, 44         (70) k = 57             (102) k = 36, 87         (106) k = 66             (156) k = 20, 59, 98, 137          (190) k = 11, 30, 68, 87, 125, 144, 182      (430) k = 234     (520) k = 152, 282     (576) k = 2, 11, 20, 29, 38, 47, 56, 65, 74, ...(add 9 each time), 569      I had said that the moduli were prime, but I was wrong they are each one below a prime.


Track time spent on site

We are going to track user engagement (i.e. time spent on site, most viewed part/page of the system, etc). I don't see Google Analytics / MixPanel being able to do this, since we have to analyze based on factors only present in OUR backend (such as users who go to specific school, users who are a specific type, etc) - not the general stuff like Country, Gender, etc. I can think of a REALLY simple solution, but I am not sure if it is, serverwise, bad. You have a table that looks something like this:               CREATE TABLE `log` (       `id` int(11) unsigned NOT NULL AUTO_INCREMENT,       `uri` int(11) DEFAULT NULL,       `date` timestamp NULL DEFAULT CURRENT_TIMESTAMP,       `user` int(11) NOT NULL,       PRIMARY KEY (`id`)     ) ENGINE=InnoDB DEFAULT CHARSET=utf8;      And then whenever a page is loaded, a row is added to the "log" table, with current timestamp, the user id and the uri. Now I got the data I want, which is great. I can figure out when the user was last online and how many minutes people spend in average. BUT. Is this bad for the server? It is going to add a row each page load, which is a lot of rows, if you have 500 or 1000 active users. But will it matter? What are your thoughts?


Benefits of caching the count of items in a data structure versus on-demand calculation?

Given a data structure, I want to provide an API method `Size` which returns the number of items. I am vacillating between 2 approaches:   1. Maintain a count and increment/decrement it in response to Add/Delete calls respectively   2. Perform a traversal to calculate the count when `Size` is called. Approach #2 will take O(n) vs O(1) for approach #1. Other than performance, any other benefits of #1 over #2 ?


Generating PDF files using individual template components

**EDIT: Updated flow diagram to better explain the (likely unnecessary) complexity of what I'm doing.** * * * We at the company I work for are attempting to **create complex PDF files using Java iText** (the free version 2.1 line). The documents are **built piece-by-piece from individual "template" files** , which are added to the final document one after another using the `PdfStamper` class, as well as filled using AcroForms. ![Visual Example](http://i.stack.imgur.com/9pyck.png) The current design performs a loop which runs for each template that needs to be added in order (as well as the custom logic needed to fill each). In each iteration of the loop, it does the following:   1. Creates a `PdfReader` to open the template file   2. Creates a `PdfStamper` that reads from the `PdfReader` and writes to a "template buffer"   3. Fills AcroForm fields, as well as measures the height of the template by getting the location of an "end" `AcroField`.   4. Closes the `PdfReader` and `PdfStamper`   5. Creates a `PdfReader` to read a "working buffer" that stores the current final document in progress   6. Creates a `PdfStamper` that reads from the `PdfReader` and writes to a "storage buffer"   7. Closes the `PdfReader`, opens a new `PdfReader` to the "template buffer"   8. Imports the page from the "template buffer," adds it to the `ContentByte` of the `PdfStamper`   9. Closes the `PdfReader` and `PdfStamper`   10. Swaps the "storage buffer" with the "working buffer" in order to be ready to repeat. Here is a diagram visually explaining the above process, which is performed for each iteration of the "loop" that performs each template: ![Flow diagram](http://i.stack.imgur.com/FUSSn.png) However, as discovered through this Stack Overflow question (where example code can also be viewed) and the response by iText author Bruno Lowagie, this methodology of using the `PdfStamper` can cause significant issues. "Abusing" the `PdfStamper` by creating and closing the stamper too many times can cause corruptions in the resulting file that only effect some programs, generating a seemingly good document that may fail in certain contexts. **What is the alternative?** Mr. Lowagie's response suggests that there is a simpler or more direct way to use `PdfStamper`s, though I do not quite understand it myself yet. Could this be done using only a single stamper? Could it be done without using a rotating series of buffers?


Best practices / reasons for String constants in JavaScript

In static languages like Java/C#, I commonly make use of constants for strings or numbers, rather than insert them into the code alone. However, I tend to avoid this practice in JavaScript. More recently, as some other coders around me have taken this approach in JS, I decided I should probably solidify either my, or their, reasoning. There is no actual "const" declaration syntax in JavaScript. We usually just settle for an informal policy of not changing uppercase properties. But my opinion is usually to avoid them altogether, because most of their benefits are lost in JavaScript. In Java, a misspelt string will cause the program to fail when you try to run it, at which point you correct it and move on. Having a static checker where both instances are pointing to the same constant eliminates that problem, as it can be found at compile-time. But JavaScript will simply have that problem all over the place, as you're ALWAYS going to discover your spelling's correctness _at run-time_ :               Library = { doThing: function() }     setTimeout(function()       Liberry.doThing()       // No such object: Liberry     }, 0);      The best safeguard against this, usually, is "use strict". For developers that prefer it, I'm fine with them using that to find issues with undeclared variables more quickly. But my opinion has been that providing string constants for REST APIs, etc., doesn't actually safeguard you against anything. Another example:               CompanyAPI.constants.ENROLL_URL = "/rest/enroll";     CompanyAPI.constants.FIRST_NAME = "firstName";          ajax({url: CompanyAPI.constants.ENROLL_URL,     data: CompanyAPI.constants.FIRST_NAME     });     // vs.     ajax({url: "/rest/enroll",     data: "firstName"     });      ...You meant to write the above, but then made typos. Whoops.               ajax({url: CompanyAPI.constants.ENROL_URL,       data: CompanyAPI.constants.FIRS_NAME     });     // vs.     ajax({url: "/rest/enrol",       data: "firsName"     });      The constant-based one will still provide _undefined_ , while "firsName" is no better. To that end, I tend to just see this as a benefit of static languages, and not bother having a system to fix it (besides maybe starting to use "use strict" for debugging). Can some other people tell me what their preferred practice for string/integer constancy is? EDIT: To clarify, my preference is usually to put strings like "firstName" directly inline with no top-level constant declaration - the penalties for misspelling it are the same either way. Strings that might get long, like a REST URL, I'll tend to define at the top of the file.


Why should a builder be an inner class instead in it's own class file?

Many `Builder Pattern` examples make the `Builder` an inner class of the object it builds. This makes some sense since it indicates what the `Builder` builds. However, in static a static type language we know what the `Builder` builds. On the other hand if the `Builder` is an inner class, you _should_ know what class the `Builder` builds without looking inside of the `Builder`. Also, having the builder as an inner class reduces the number of imports since it can be referenced by the outer class--if you care about that. And then there are practical examples where the `Builder` is in the same package, but not an inner class, like `StringBuilder`. You know that the `Builder` _should_ build a `String` because it is named so. That being said, the only good reason I can think of for making a `Builder` an inner class is that you know what the class' `Builder` is without knowing it's name or relying on naming conventions. For example, if `StringBuilder` was an inner class of String I probably would have known it existed sooner than I did (speculative). Are there any other reasons to make the `Builder` an inner class or does it just come down to preference and ritual?


Simple avenues for dynamically building Windows executables

I'm trying to build a Firefox add-on which lets you create executable files which can be associated with a default program or added to the "Open With" list and possess its own icon. I was hoping to avoid having the add-on compile files into exes, but...   1. It does not seem batch files can have their own icons.   2. Although one can pass batch instructions to cmd.exe via shortcut (and shortcuts can have their own icons) and a shortcut can even accept arguments (as in dropping files onto it), one apparently cannot add shortcuts to the "Open with" menu (the Open With dialog treats the shortcut as equivalent to the referenced executable, in this case, .exe, and without the extra parameters). So, I'd like to know what other approaches might be available to me for building executables (or something that really functions like an executable) in a simple and transparent manner? I am leaning toward packaging an open- source batch-to-exe converter like http://sourceforge.net/projects/bat2exe/ (though I'd really hope to find one which itself can be controlled via command line) so I can build a batch file programmatically and then turn it into a full-blown executable with icon. **UPDATE** The primary reason I want to do this is for the sake of https://github.com/brettz9/webappfind . WebAppFind lets you open desktop files (while you are on your desktop) into web applications and currently comes with pre-built executables which can be associated with a given file extension (to work with Open With or as a default handler). These executables will be used to call Firefox (and my add-on, WebAppFind) with certain flags that allow WebAppFind to open the file in a web app (as determined by other factors like a filetypes.json file in the same directory as the file or a previously registered protocol handler correlated to the file extension, as explained at the repo). However, what I cannot pre-build into the executable are all possible configuration directive combinations a user might wish to supply to the add-on or, more importantly, the specific Firefox profile in which they wish the app (with desktop file) to load. The ability to open a web app in any profile can allow for web apps to work more like executables--they get their own icon in the task bar, they don't have to force the user to load a bunch of tabs or add-ons if, e.g., they just want to have open in a separate process their local HTML file in a JavaScript-based WYSIWYG HTML editor or their SVG file in an SVG-edit web app (And I also don't want users to have to go through the trouble of associating an icon with the exe manually.)


What is the difference between requirements Elicitation and Requirements Analysis in the real world?

My question aim to draw a fine line between Requirements Elicitation and Requirements Analysis. What is the difference between these two?


How to reconcile my support of open-source software and need to feed and house myself?

I have a bit of a dilemma and wanted to get some other developers' opinions on it and maybe some guidance. So I have created a 2D game for Android from the ground up, learning and re factoring as I went along. I did it for the experience, and have been proud of the results. I released it for free as ad supported with AdMob not really expecting much out of it, but curious to see what would happen. Its been a few of months now since release, and it has become very popular (>250k downloads!). Additionally, the ad revenue is great and is driving me to make more good games and even allowing me to work less so that I can focus on my own works. When I originally began working on the game, I was pretty new to concurrency and completely new to Android (had Java experience though). The standard advice I got for starting an Android game was to look at the sample games from Google (Snake, Lunar Lander, ...) so I did. In my opinion, these Android sample games from Google are decent to see in general what your code should look like, but not actually all that great to follow. This is because some of their features don't work (saving game state), the concurrency is both unexplained and cumbersome (there is no real separation between the game thread and the UI thread since they sync lock each other out all the time and the UI thread runs game thread code). This made it difficult for me as a newbie to concurrency to understand how it was organized and what was really running what code. **Here is my dilemma:** After spending this past few months slowly improving my code, I feel that it could be very beneficial to developers who are in the same position that I was in when I started. (Since it is not a complex game, but clearly coded in my opinion.) I want to open up the source so that others can learn from it but don't want to lose my ad revenue stream, which, if I did open the source, I fear I would when people released versions with the ad stripped, or minor tweaks that would fragment my audience, etc. I am a CS undergrad major in college and this money is giving me the freedom to work less at summer job, thus giving me the time and will to work on more of my own projects and improving my own skills while still paying the bills. So what do I do? Open the source at personal sacrifice for the greater good, or keep it closed and be a sort of hypocritical supporter of open source?


Which Provides a better Foundation Java or .Net (C#, ASP.NET)?

I am not asking this question to start arguments (people often consider Java and .Net as religions) but which provides a better foundation and helps to gain real programming skills (of Computer Science and Web Development), I have worked with ASP.NET and C# but most of my time spends on Dragging and Dropping i am a C++ programmer and Drag and Drop irritates me.I haven't tried Java so i want to ask is Java also like .Net family (Drag and Drop)?


What alternative is better to diagram this scenario?

I was creating and discussing a class diagram with a partner of mine. To simplify things, I've modify the real domain we're working on and made up the following diagram: ![one](http://i.stack.imgur.com/8Q7WX.png) Basically, a company works on constructions that are quite different one from each other but are still constructions. Note I've added one field for each class but there should be many more. Now, I thought this was the way to go but my partner told me that if in the future new construction classes appear we would have to modify the Company class, which is correct. So the new proposed class diagram would be this: ![two](http://i.stack.imgur.com/C2cCj.png) Now I've been wondering:   1. Should the fact that in no place of the application will there be mixed lists of planes and bridges affect the design in any way?   2. When we have to list only planes for a company, how are we supposed to distinguish them from the other elements in the list without checking for their class names?   3. Related to the previous question, is it correct to assume that this type of diagram should be high-level and this is something it shouldn't matter at this stage but rather be thought and decided at implementation time? Any comment will be appreciated.


Are "conditional" caching policies ever actually useful?

I'm designing an abstraction over ASP.Net's built in caching to make it not so horrible to use. One design decision I'm having to look at is if I should restrict people to using just one cache policy on each item. For example, say you're caching the HTML generated by your blog post or some such. Would you ever want to cache it sometimes for 30 minutes and sometimes for 2 hours? Note: this isn't cache invalidation. These are the policies available:   * Priority   * Absolute expiration   * Sliding expiration (where each access bumps the expiration by this much) Are there any use cases where someone would want to add an item to the cache with one set of policies and in another portion of the web application use a different set of policies when it gets added(but of course, if it already exists keep with the old policy)? Are there any real world uses to allowing this?


Why might I switch from ASP MVC to Node/Express?

So I've been wanting to try Node and Express. Not to mention Jade and Stylus. Webstorm has in my opinion an amazing user experience and I want to use it and these technologies. Here is where I get hung up though. ASP has some nice built in features that don't seem to exist in this other world. I will pick on authentication. Authentication can be a pretty complex in depth thing. Frankly it is nice to have something built in, tested, and robust for something so critical to some applications. Or if Authentication is too petty. How about compiled code? Why would I WANT to use JavaScript on the server side if I know c#. Isn't type safety a nice to have? What am I missing? these technologies are popular for a reason but I just don't see the draw? I would like to though.


Is refactoring for the purpose of unit testing a code smell?

Let me preface this question by saying that I get the need for unit testing. I painfully get it. You have to do it to ensure that future modifications don't adversely affect the application in ways you did not expect. It's also good practice to utilize a test driven methodology to ensure your current modifications work as expected while providing a solid testing base for adding edge cases (bugs) later. I also understand that testing is a requirement for any company that will, or plans to be, subject to an IT audit. And finally, I get that if your code is testable, it is probably written using solid design principles. The quandary that I have is that coding to an interface for the purpose of supporting unit testing alone, seems like a contrived complexity. Take the case where you have a database application that does not have the requirement to be database agnostic. You've already coded a DAL that communicates with that database and BL that uses that DAL for persistence. Integration tests are in place with the current architecture that utilize a development database for test data. To support 100% code coverage on unit tests you would now need to introduce interfaces for both the DAL and the BL, have concrete implementations of those interfaces, and use dependency or constructor injection to utilize those interfaces based on the context of the runtime. Does that not introduce a contrived complexity? A side question I guess is where is the line drawn between unit and integration testing in these cases? It's certainly feasible that the data model can change and you'd want integration testing in addition to unit testing because it's clear that unit testing will succeed where integration testing can fail in that case.


Visitor pattern

I was recently given the following task, and failed, the reason given that I misunderstood the question               Create a 'LibraryItem' interface.     Create 3 concrete implementations of LibraryItem: 'Book', 'CD', 'DVD'.     Apply the visitor pattern to your data model.     Write a MaximumBorrowTimeVisitor that computes the maximum time you can borrow a LibraryItem.     Create an arbitrary instance of a data model and apply the MaximumBorrowTimeVisitor.      I thought this was simple, and yet I failed the task. How would you solve this task?


Is it a good practice to have a remote branch for each developer?

Is it considered a good practice to have a remote branch for each individual developer in the project? We're using Git with the following branches:   * master   * release   * develop If each developer had their own branch, they could push code into their branches and others could merge these changes into their own branches.


Do any LOP languages exist?

I have read a few of the articles related to the **Language Oriented Programming** paradigm. Therefore, I concluded that LOP paradigm can let programmers be more productive because of it's extensibility. Are there any programming languages that are already implemented LOP or in development status?


Approach to coding algorithms to minimize rework

I find myself reworking my code quite a bit, especially when learning to write algorithms that involve keeping track of multiple attributes and labels. I feel that having the pseudo-code written up, having a small numerical example worked out, and a few test cases is usually a good approach. Yet, I find myself making mistakes and reworking code constantly. Is there a better approach or a structured methodology that I should follow? Greatly appreciate the advice.


Is it possible to write software that doesn't need to be continually modified?

I have written a lot of software in many different languages, and I've also "written" hardware for use with FPGAs using Verilog and VHDL. I tend to enjoy writing hardware more than software, and I think one of the primary reasons is that it is possible to write hardware that is "done" and never needs to be modified: you define the interfaces and the functionality, write a test bench, implement the hardware module, then test the heck out of it using a simulator. Then you can rely on that hardware module as a building block to create something bigger and better: if you need to add a feature to that module, you create a second module and add the functionality there. You never throw away the original module since it is working just fine and can still be useful. One of my main frustrations with software is that it is never "done". There is always another feature to add. Often when adding a feature it introduces a bug somewhere else that was working just fine before. This doesn't happen in hardware as long as the interfaces are not violated. To be clear, I'm not advocating building one version of something with a list of features and that's it forever: I'm in favor of iterations and multiple releases over time to add new features. I just don't want to poke the code on the left and find a bug on the right, and this seems to happen after adding a new feature. Is it possible to write software in a similar way in which hardware is "written"? Is there a good software development methodology that allows forward progress to always be made and allows new functionality to be added without needing to rewrite existing code and introduce new bugs?