Data migration - dangerous or essential?

The software development department of my company is facing with the problem that data migrations are considered as potentially dangerous, especially for my managers. The background is that our customers are using a large amount of data with **poor quality**. The reasons for this is only **partially related to our software** quality, but rather to the history of the data: Most of them have been **migrated from predecessor systems** , some bugs caused (mostly business) **inconsistencies** in the data records or **misentries** by accident on the customer's side (which our software allowed by error). The most important counter-arguments from my managers are that **faulty data may turn into even worse data** , the data troubles may **awake some managers at the customer** and some processes on the **customer's side may not work anymore** because their processes somewhat adapted to our system. Personally, I consider data migrations as an integral part of the software _development_ and that data migration can been seen to data what refactoring is to code. I think that data migration is an **essential for creating software that evolves**. Without it, we would have to create painful software which somewhat works around a bad data structure. _**I am asking you:_**   * What are your thoughts to data migration, especially for the real life cases and not only from a developer's perspecticve?   * Do you have any arguments against my managers opinions?   * How does your company deal with data migrations and the difficulties caused by them?   * Any other interesting thoughts which belongs to this topics?


Pattern for multiple datasources

I've already read this question on CodeReview. I was hoping for general advice. I'm writing a service which will go to numerous data sources. Each source requires getting copious amounts of data and changing it to a single format. What is the best pattern for a task like this? I currently have a "base" class which exposes a static `GetData` method, which the other classes inherit from and implement. This doesn't seem like the cleanest approach, so I was wondering what other approaches might suit my needs?


When should JavaScript generate HTML?

I try to generate as little HTML from JavaScript as possible. Instead, I prefer to manipulate existing markup whenever I can and only generate HTML when I need to dynamically insert an element that isn't a good candidate for using Ajax. This, I believe, makes it far easier to maintain the code and quickly make changes to it because the markup is easier to read and trace. My rule of thumb is: HTML is for document structure, CSS is for presentation, JavaScript is for behavior. However, I've seen a lot of JS code that generates mounds of HTML, including entire forms and content-heavy modal dialogs. In general, which method is considered best practice? In what circumstances should JavaScript be used to generate HTML and when should it not?


Is the Lisp "family" of languages any more closely related than the "C-like-syntax" family?

I was recently thinking about the large variety of lisp languages, specifically the fact that while they all have similar syntax, and could all in theory be implemented from the same small set of primitive functions, the way in which one typically uses each lisp can vary widely compared to all the others. I realized that one could plausibly make the same statement about the family of languages with "C-like" syntax. Yet, most "C-like" languages are commonly distinguished from each other, while it is common to refer to "lisp" in general, and not any specific variant of lisp. So, are C-like languages really more different from each other than lisp-like languages? Or do they just appear so because they have greater variability in syntax? Why are lisp-like languages more frequently lumped together into just "lisp"? No one would ever refer to C, C++, C#, Java as just "C".


How can I prevent a client from seeing my code written in an interpreted language?

I'm building a fairly complex interpreted program in Python. I've been working on most of this code for other purposes for a few months, and therefore don't want my client to be able to simply copy and try to sell it, as I think it's worth a fair amount. The problem is that I need the script to run on a server that my client is paying for, so is there any way I can secure a particular folder on the machine from root access, or make it so only one particular use can access the directory? The OS is Ubuntu.


In general: guard pages or heap checks?

I would like to know the advantages and disadvantages of using guard pages with bump-pointer allocation versus heap checks with bump-pointer allocation, including performance as a consideration. In a modern implementation, which would be the most appropriate?


Where does the reporting function fit into Enterprise Software development Best Practices

At my company, I develop and maintain all the operational reporting used by management to run the business. There is no reporting position on the application development team. I've taken it upon myself to step in and attend design review meetings to give input to the development team on how changes will impact reporting, consult on how modify designs to avoid impacting existing reports and what I will need in new development to be able to report on the data. It's been my experience that reporting is a key functional position on an enterprise application development team. I'm hoping to find some documentation that supports that concept as an industry standard or Best Practice. Can anyone help me there?


Why does HTML TextArea have its own HTML tag?

<input id='input1' type='text'></input>     <input id='input2' type='button'></input>     <input id='input3' type='checkbox'><input>     <textarea id='myTextArea'></textarea>      In HTML markup, most places where the user can interact with the page are denoted with the `<input>` tag. Why is it that textarea has its own tag, `<textarea>` as opposed so, say, `<input type='textarea'>`


Efficient development process for Golang (or any backend) and JavaScript?

I am developing a web application. The frontend is a mix between JavaScript and server-side generated html. The backend is written in Golang. Might not be very important, but if somebody made a similar experience with that language, it could be of help. As of now, everything was written in vim, and "debugged" in the browser (mostly Chrome). As the project gets larger I run into difficulties using my vim-chrome development stack. The backend development is not so hard, because Golang has a nice testing suite, which doesn't need much boilerplate to run. However, the mix between data-driven structs in the Golang templates, the Html and the JavaScript logic are getting somewhat complex:   * I find myself recompiling templates almost all the time when doing frontend development.   * I switch all the time between browser, vim (cygwin), web developer tools of the browser, and reloading pages, making sure caches are cleaned. So, my question is, how could I make myself more efficient? How should I change my development-testing cycle to make the work more pleasant, especially the switching between server (development) and client (debugging). (I am not looking for ONE SPECIFIC TOOL. I know this results in stupid answers. I am looking for development approaches, which happen to be accompanied by tools. So, offtopic, but might be interesting: Which tool combination has worked for you, if you ever encountered such a problem, and how did you use those tools?)


Why there are no compound assignment operators for logical operators (such as ||, && etc)?

According to ECMA-262, part 11.13, following is the exhaustive list of compound assignment operators: `*= /= %= += -= <<= >>= >>>= &= ^= |=`. According to the part 11.11, `var c = a || b` will put `a` value into `c` if `ToBoolean(a)` is true and will put `b` value into `c` otherwise. As such, the _logical OR_ is often used as the coalesce operator, e.g.               function (options) {         options = options || {};     }      Frequently enough, coalesce is used to specify the default value for the variable, as was shown above: `a = a || b`. It seems that compound assignment operator `||=` would be really useful, allowing to write the code above in a shorter and cleaner fashion: `a ||= b`. However, it is not there (although `*=`, `+=` and other compound assignment operators are). The question is, why?


Publishing an internal web app on the internet to a much larger group of users than before

My company has developed a web application based on GWT (Google Web Toolkit) and Ext GWT in the browser, JBoss application server and Oracle in the backend. The app allows users of different departments of the same company, working in different locations, to collaborate in order to employ a fairly complex approval process for really expensive technical equipment. Let's call this app app 1. The app is dialog-based, using Ext GWT's Desktop component to provide an MDI app within a browser window. It's been used productively for more than a year now. Another app, app 2, also has been developed which offers a specific subset of the functionality of App 1. By subset I mean that \- some dialogs are not provided (like those for administration of master data or system settings) \- some dialogs are reused but some input or display fields are missing \- some data are filtered (users will only see a subset of the information that is available to users of app 1) \- some dialogs are completely identical Currently, app 2 is there but nobody uses it, because it has not been officially published to anyone and nobody has an account to log in. The goal for 2012 is to open app 2 to a host of new users. These will be working at different companies in different locations all over Germany and potentially neighboring countries (Austria, Switzerland, France, ...) as well. It is not possible to get all new users together and give them a training of several days in order to learn how to use the app and the process. The documentation that exists so far is a user manual, a PDF file of more than 100 pages, to be found through a "?" menu. Both apps have been developed by my company for another company. None of these two have very much experience with providing and supporting a public web application for the rest of the world. So, what can we do in order to provide people with information and assistance on how to use this app? Here are the measures that I've come up with so far:   * Provide a start page (just static HTML) before the login screen that describes (shortly!) what this app is and why users would want to log in and use it. Also, how to obtain a login and where to find support   * Create a guided tour of short videos (created with Camtasia Studio) of at most 3 minutes each. Those will guide through the most important use cases step by step. I'm thinking of something like this https://sourcing.thyssenkrupp.info/lvportal/external/guidedtour/tk_uk_files/uk_html.html which was created a couple years ago in a very similar situation   * A start screen, which will pop up immediately after login. It will show a list of command links with a short explanatory text for the most frequent use cases. Also, it will provide a direct link to the guided tour and the user manual   * A task-oriented list of item counts for the user (like on every line something like "Items on which you have to do X", "Items on which you have to do Y" etc). This list will be either integrated into the background of the desktop-in-a-browser-window or put into a docked area to the left of the desktop itself   * I'm also considering an FAQ page. But of course there haven't been any questions asked yet so we don't know what to put there. So the idea is to have ab easily updatable page of static HTML content. Or maybe a miniature CMS integrated into the app itself. Any comments on those measures and any further suggestions are welcome.


How would I implement a "self-destruct" feature into the free trial version of my software?

There is the ongoing argument of free trial versus a freemium model (that is, a free-for-life version of their software with restricted and/or stripped down features) for allowing potential customers and users to test run their product. Upon my research, I can conclude that the free trial is the way to go on both for the benefit of the user experience of the individual using the software and for the benefit of the vendor in both aspect of sales and maximizing usage. There are many factors for a free trial software that can greatly maximize user usage like the length of the free trial. One keyword that reoccurs on my research for "freemium" is "frustrating". Many individuals chose to uninstall the software instead of having to use a piece of software where some features were unavailable to them. At the same time, these users never had the chance to use the "paid" features. Unbeknownst to them, and hidden by the very own vendors who are selling the software, they don't know and cannot know what benefits the Pro features will bring. Without first having to use them, a user will not know they have the feeling of "needing" something. Which brings me onto my next point of a free trial model. Some opinions of a free trial user is "I cannot imagine using this software without the Pro features." This goes back to the point of "the user not knowing they need something until they first understanding the feeling of have." Those that have had 14 days to use a the "full" version features said they cannot imagine not having or using the features provided there. So when fourteen days were over, they were more likely to dish out money than someone who's never experienced the full features. The length of the free trial is also an important factor is creating a lasting impression on users. In an experiment conducted by Visual Website Optimizer, they noticed that for a 14 day free trial versus a 30 day free trial, while the number of sign ups and installs were the same, the usage for the 14 day trial increased 102%. This, of course, in turn increased their revenue as well. Another very important point to mention is that "offering a useful and fully functional free version of the product" is VERY IMPORTANT. Fully functional free trials are effective in getting media coverage, and this publicity for new software and/or software vendors are fairly crucial. One other relevant aspect is the importance for users to give feedback. Consider, in the fully functional time-limited free trial, the ability for users to give feedback. One other feature important for our software is the need for telemetric data, that is, quantitative and comprehensive data on how a user uses our software. Some of usage statistics may fall into a legal grey area, as laws are different depending on the location in the United States, and the world. One way to combat this legal issue is to have an opt-in feature for gathering anonymous usage statistics. An opt-in feature would mean giving the user an option to turn off statistics gathering and at the same time, the user must be very well aware of what the gathering of anonymous usage information does. It is important to make it CLEAR to the user what data will be collected, what "we" will be doing with it, and make it easy to turn off any time, including allowing them to change their mind for turning it on or off. For more detailed statistics, like tracking individual activities of users, it could lead to legal issues. The Eclipse IDE logs detailed usage statistics, but it does it by the full consent of the user. We may have to potentially prepare a consent form with our legal team. The Eclipse Usage Information Collection collects this information: 1\. Plug- ins that are started by the system. 2\. Commands accessed via the keyboard shortcuts and actions invoked via menus or toolbars. 3\. When the "view" of the editor is given focus. 4\. System information like the version of the software being used, the operating system being used. 5\. Description of internal errors. Kill Switch A kill switch for our software can be managed logging the initial data, encrypting it with a salt, and whenever it's an invalid date, that is, the user tried to change it, it would disable the software. Another option is to have internet authentication on install, log that date to a central web database, and check the date every time the application is opened. On disabling the software, we can delete vital DLLs. The option of having to pay to generate a report cannot be considered. * * * I am interested in implementing a free trial version to my existing software. I plan on having the trial last 14 days. Upon the 14th day, my software would prompt the user to either pay for the paid version, or have the consequence of not being able to use it. The free trial version is entirely unlocked, meaning all paid features are there. However, my dilemma is about the "best" way to implement what to do for an end-of-trial solution. Do I delete vital DLLs? Have a user authentication system upon installation or use? Encrypt the initial time and date of use with a salt, and if it's an invalid date (AKA they try to change their initial date), disable the software? I am interested in knowing what are some effective measures of disabling software.


What's a RESTful url for a linked item?

This is going to be a web service that returns a JSON object. Currently, I'm using C# technology and simply using ASP.Net MVC to create the calls. This is not a web page, so SEO is not a concern. I've come across a number of instances where I want to get the "next" or "previous" item in a list. For example, I've got a service that returns a featured photo. http://myservice.com/photos/123 which returns a JSON               {"name": "At_The_Concert", "id": "123", "src": "http://myservice.com/photostore/123.jpg"}      The client (Ajax, Mobile device, etc.) of this service wants to know what the “next” item is going to be. I’m struggling about what the url should be.   * http://myservice.com/photos/123/next   * http://myservice.com/photos/next/123   * http://myservice.com/nextphotos/123 or maybe the id property should just be a parameter http://myservice.com/photos/next?photoId=123 Or maybe this is entirely wrong and it should be like http://myservice.com/photos/?method=getNextPhoto&photoId=123 though with .Net's routing, it might be easier to write it as http://myservice.com/photos/method/getNextPhoto?photoId=123 I’m relatively new to web services and REST. I get the basic CRUD for REST, but I don’t know what is the best practice for creating more custom urls, in this case the “next” photo. Is there an accepted RESTful practice?


Leaving "Else" comments

Let's say I have a not-so-intuitive `if` statement in my code, but only if you're new to the codebase:               def set_markets(markets=None):         """         Will accept 'all' as markets to set all markets on.         For individual markets, pass in a list of ints.         """         if markets:             if type(markets) == list:                 markets = ','.join(map(str, markets))             self._set_markets(markets)      For those of you wondering: The existing system I'm interacting with (a database) expects a list of integers from the front end interface. This code does it from the backend, so a list of ints was chosen since it best represents what a user might feed in otherwise. The `markets` stuff is handed down from another class, so even though it appears like it's taking place over 5 lines, it's more like ~50 lines. My question is, would you consider this more readable? Why or why not?               def set_markets(markets=None):         """         Will accept 'all' as markets to set all markets on.         For individual markets, pass in a list of ints.         """         if markets:             if type(markets) == list:                 markets = ','.join(map(str, markets))           # else:               # markets are set to "all"             self._set_markets(markets)      EDIT: This code looks worse than it is because I left off a detail: if `None` is fed in for `markets` (the default parameter), then it will not modify the markets settings the database. Here's what I have now:                   if markets is not None:             if isinstance(markets, list):                 markets = ','.join(map(str, markets))             else:                 markets = 'all'             self._set_new_header_markets(markets)


Optimizing code generation for expressions in a compiler

I don't know if this question has a simple answer or not, but I just have to ask. I'm reading this tutorial (I don't know if this is a well-known series, but it's name is 'Let's build a compiler!' by Jack Crenshaw). It's a nice series where you gradually learn how to construct a compiler (it is a learn-by-doing thing, really). In the second chapter already, I felt the need to optimize some things. In the series, some concessions are made, in order to keep things simple: there is no difference between lexical scanner (although I believe it is introduced later in the series) and the code generation: they are done in one go. Also, the author heavily relies on the stack to create the code to handle expressions. (Also, the output is assembly code, I don't know if this is normal for compilers, so I just thought I'd mention it...) For example, parsing the expression 5 + (7 * 3 - 21 / 3) (and storing the result in eax) results roughly in the following code (I use x86 asm, as opposed to the series, so this is the assembly code my compiler gave):                   push 5   ; These lines is generated by a simple number parser         push 7   ; This parser pushes its result to the stack         push 3   ; (like most other parsing functions)              pop eax  ; Code for multiplication         pop ebx         mul ebx         push eax              push 21  ; Result of parsing these numbers         push 3              pop ebx  ;  Division code         pop eax         div ebx         push eax              pop ebx  ; Subtraction code         pop eax         sub eax, ebx         push eax              pop eax  ; Addition code         pop ebx         add eax, ebx         push eax      As you can see, the code for handling the addition, subtraction, multiplication, etc. can stay the same each time the operation is used. This is very convenient, but of course, the assembly code generated is very slow and esoteric. When writing by hand, one would rather write something like:                   mov eax, 21         div 3         mov ebx, eax         mov eax, 7         mul 3         sub eax, ebx         add 5      My question is if there is any way to optimize the compiler output. Of course there is, but is there any specific way to make my code more like the second, ie: not using the stack so intensively, but instead relying on registers to pass values. I myself have been thinking about parsing the whole expression and representing it internally as a tree-like structure (I supposethis is the kind of thing a lexical parser does) before generating the code, but I'm not entirely sure how to proceed. On the other hand, there is peephole optimization and the possibility to optimize the assembler code after it has been generated, but I have no idea how effective this will be. Generating better code in the first place seems logical and more feasible to me. I know there are many techniques available to optimize my code (for example, constant folding, which would reduce the whole expression to 19. I have deliberately not used this kind of optimization to bring my point across better), I am hoping for a single technique that is well-suited for this kind of stuff.


Greenfield vs. brownfield revenue? (attempting to get an idea of measure of effort expended on the two)

The big question I have in my mind: how many developers are brownfield ("enterprise") compared to greenfield (all new code, from the ground up). I'm constantly reading breathless articles about the latest technology, only to find out that It Just Won't Work On Our Enterprise Software codebase. People aren't ready for automated testing (because the logic is in the click- handlers and/or database). People aren't ready for ORM tools because we have horrendous amount of logic in stored procs and triggers. People aren't ready for WPF because our existing stuff is all WinForms. We can't get the latest version of Reactive Extensions because existing code used RX 1.0 and there are breaking changes that will require more testing effort than is justified by the return. Etc., etc., etc. Very few articles seem to be oriented toward the brownfield developer, for whatever reason (can't sell ads for articles that start off with "you probably can't use this, but..."?). So, I'm truly wondering: is the software development industry just chock full of greenfield developers, developing new projects for clients which are then released and enjoy a short existence until complete replacement for whatever reason? Or are there hordes of brownfield programmers silently laboring away in the ADO.NET T/SQL VB.NET software mines, looking wistfully up at the sunshine of Entity Framework 5.0 and Haskell, et cetera? How do we even measure that? Salaries (wages??) paid to software engineers* in the two categories? How do we measure THAT? Maybe... revenue generated from selling said software? (There's an assumption that the crappy old software sold by XYZ Corp. actually has maintainers). **My question: Does anybody have any numbers that speaks to how much of the industry is green field vs. brown field?**


Is there a proven concept to website reverse certificate authentication?

We're looking at exposing some of our internal application data externally via a website. The actual details of the website aren't that interesting, it'll be built using ASP.NET/IIS etc, that might be relevant. With this, I'm essentially I'm looking for a mechanism to authenticate users viewing my website. This sounds trivial, a username/password is typically fine, but I want more. Now I've read plenty about SSL/x.509 to realise that the CA determines that we're alright, and that the user can trust us. But I want to trust the user, I want the _user_ to be rejected if _they_ don't have the correct credentials. I've seen a system for online banking whereby the bank issues a certificate which gets installed on the users' computer (it was actually smartcard based). If the website can't discover/utilise the key-pair then you are immediately rejected! This is brutal, but necessary. Is there a mechanism where I can do the following:   1. Generate a certificate for a user   2. Issue the certificate for them to install, it can be installed on > 1 machine   3. If their certificate is not accessible, they are denied all access   4. A standard username/password scheme is then used after that   5. SSL employed using their certificate once they're "in" This really must already exist, please point me in the right direction! Thanks for your help :)


Using MS-PL licensed library for internal company use

I want to use a MS-PL licensed library in a proprietary software, but it'll run inside my company, with no external distribution. Does the license allows this kind of usage or it constitutes a violation of the license?


Suggestion for setting web application parameters

I'm creating a web application on GWT. I'm using MVP pattern with activities and places. I have a xml config file containing some parameters to be used by the application. Content of this xml file is sent to the client using HttpRequest; I'm using a singleton class to hold the information from the xml file. Right now, the application is getting the data when the user starts the application in the home page, that is working well. Now, since I'm using activities and places, a user can bookmark a page and starts the application in any other page (Place). And here comes the problem: Since I'm using some of the information from the xml file to set some ui widgets, I have to check if the xml config file was read and the application already has the parameters (I do this by checking the singleton class). But the xml file is read by using an HttpRequest, so I got errors 'cause the application needs some parameters to initialize some ui widgets, but these parameters aren't ready on time. I was thinking on using an synchronous request to fix the problem, but it seems complicated and not recommendable to do that. So, I'd like to hear some other suggestions. Thanks.


Better control on code updates

I will briefly explain my situation. I have a website in PHP, this website is powered by a custom framework + some "plug-in" made ad hoc for it. I am the only developer of this. Until now I just test locally any changes than I upload the php files via FTP. I don't feel confortable anymore with this. The code base has grown quite a lot and I need some sort of system that helps to keep track of changes (line by line) and can restore to an old version easly if something goes wrong. Are there any good solution for this? Note: I never used something like version control or subversion because I think they are too much for this situation (I am the only developer and I just need basic feature) Note2: Something with a nice web interface would be perfect, I can pay for a good service too As now I found:   * http://beanstalkapp.com/   * http://github.com/   * http://www.codespaces.com/   * http://codesion.com/   * https://bitbucket.org/


Why design pattern is not named as implementation pattern?

I find that most of the design patterns are concerned with implementation of a model like mvc, or how to change the implementation with less cost. These are all happened in the implementation phase of a software. So why not call them implementation patterns?


exact answer for “what is j2ee?” - job interview

I'd like to ask if someone of you knows the exact meaning of JEE. That's because a collegue of mine was asked this question in a job interview, and was "unable to answer properly"... to speak with his interwiewer's words. And when he told me what he said to his interviewer I got really surprised, since it was more or less what I would have answered myself - in a concise form, the first paragraph of this article. > J2EE (Java 2 Platform, Enterprise Edition) is a Java platform designed for > the mainframe-scale computing typical of large enterprises. Sun Microsystems > (together with industry partners such as IBM) designed J2EE to simplify > application development in a thin client tiered environment. J2EE simplifies > application development and decreases the need for programming and > programmer training by creating standardized, reusable modular components > and by enabling the tier to handle many aspects of programming > automatically. That seems not to be enough, since the interviewer asked for "more precise and less general definition". Is there really a more precise definition for JEE? Or did my colleague just find the fussiest-interviewer-ever? :)


How can I unit test a class which requires a web service call?

I'm trying to test a class which calls some Hadoop web services. The code is pretty much of the form:               method() {         ...use Jersey client to create WebResource...         ...make request...         ...do something with response...     }      e.g. there is a create directory method, a create folder method etc. Given that the code is dealing with an external web service that I don't have control over, how can I unit test this? I could try and mock the web service client/responses but that breaks the guideline I've seen a lot recently: "Don't mock objects you don't own". I could set up a dummy web service implementation - would that still constitute a "unit test" or would it then be an integration test? Is it just not possible to unit test at this low a level - how would a TDD practitioner go about this?


Question about a simple design problem

At work I stumbled uppon a method. It made a query, and returned a String based on the result of the query, such as de ID of a customer. If the query didn't return a single customer, it'd return a null. Otherwise, it'd return a String with the ID's of them. It looked like this:               String error = getOwners();     if (error != null) {         throw new Exception("Can't delete, the flat is owned by: " + error);     }     ...      Ignoring the fact that getCustomers() returns a null when it should instead return an empty String, two things are happening here. It checks if the flat is owned by someone, and then returns them.   I think a more readable logic would be to do this:               if (isOwned) {         throw new Exception("Can't delete, the flat is owned by: " + getOwners());     }     ...      The problem is that the first way does with one query what I do with two queries to the database.   What would be a good solution involving good design and efficiency for this?


Do I need a database to implement AJAX functionality for my app?

I am new to the construction and design of a web app so I'd like some advice please (Django is my framework). I'm trying to code up a "how-to" website instructing users the step-by-step process for doing a certain task. I'd like the navigation of the website to be something like this... http://technet.microsoft.com/en-us/library/aa991542.aspx ...in which there is a tree-like navigation on the left-pane that lists each step (e.g. Step 1, Step 2, etc...) that expands and loads the instructions for each step into the right-pane. I don't want to reload the page each time so that leads me into AJAX. At this point, I'm not sure how to implement this. Do I store the HTML/CSS into a database to be pulled when the user clicks on certain links? Or do I write the HTML/CSS into my template files with `display: hidden` to be changed to `display: block` when corresponding links are clicked?


How to deal with the notion of time in UI/Integration tests

There are some well-known techniques for dealing with the notion of time in unit tests. These allow you to write unittests that always work with a specific time so the outcome of the test is predictable and can be verified. However, these techniques do not work with integration tests/UI test as the test and the application itself are separated (very much so in web applications where your application under test could be deployed on a separate server). For example, let's assume we are developing an appointment system that needs to implement a 'suggest the first available appointment date'-button. If the button is clicked, it needs to suggest the first available timeslot for the next business day. This means that if the button is clicked on any given day of the week except friday it should suggest a slot in the next day, BUT on friday and saturday it should suggest a slot on monday. How would one go about testing this requirement? _(I know it is possible to work around the issue for this specific example but bear with me - there are always situations where the test cannot supply the data to work from. I didn't want to supply an overly complicated example.)_


Cannot explain to the customer that he is taking the project wrong way

Being a junior developer in need of some money for new hardware, I have stumbled upon many of the freelancing websites, and really soon, I have gotten my first customer. Complete Project Management, CRM and simple accounting website for small business. As we have been discussing the terms, I have proposed GAE/Python/Bootstrap/NDB as that is something I am really familiar with, as I have been working on GAE projects for the past two years at my internship place. We discuss the pay, terms, non-disclosure and I offer my approach to the project (followed the path of what I learned closely). I propose working on the backend first in three phases:   * Company/User System + Project management    * CRM   * Analytic/Simple Accounting (intuit integration as he later added) I followed up with a 2 week period of the UI developing and testing. At first I have asked him, what are the functions you would like me to develop in all the three phases. His reply was that he doesn't have the time to prepare the document I asked him for, which I found ridiculous, and asked me to prepare one and he will edit it. Of course he never did edit. Okay, first sign of the client that doesn't have a clear picture of what he wants. He bought a template and asked when do we start testing. So I deployed the app with just PM and Company/User login after two weeks, only to be told he cannot test on anything that is not that template. I made a replica of the theme, literally, as we cannot use the stuff that the actual theme does have (fancy inbox, calendar etc) I told to myself whatever. The first approach I took was to create a base.html and base-nav.html and extend them in other templates, in order for the code and other stuff to be tested easily. I did made this via bootstrap. He repeated he cannot test on that. Now I am struggling with an html page that is 4 thousand line long I have to trim to create a base.html I will extend in other templates, with all the ridiculous amounts of static files that are completely unorganized in the template files and with a boss that wants to test. He doesn't even know what he wants to test. I have sent screenshots, deployed the app, chatted daily, but it just isn't enough to convince him we should be focusing on the backend instead of the frontend first. It's like building a car - first he wants to built the outside parts and limit the engine, instead of first building the engine then adjusting the outside to it. Do you have any tips on how to approach this and resolve it? template - http://www.keenthemes.com/preview/index.php?theme=metronic_admin


Generic repository unit testing best practice?

How can I unit test my generic repository? Unit testing code:               [TestClass]     public class UnitTestLanguage     {         private IUnityContainer _unityContainer;         private IUnitOfWork _uow;         private IGenericRepository<Language> _languageRepository;              [TestInitialize]         public void TestInitialize()         {             _unityContainer = new UnityContainer();             _uow = _unityContainer.Resolve<UnitOfWork>();             _languageRepository = _uow.GetRepository<Language>();         }              [TestCleanup]         public void TestCleanup()         {             _uow = null;             _unityContainer = null;             _languageRepository = null;         }                   [TestMethod]         public void TestMethodInsertLanguage()         {             var newLanguage = new Language { Name = "test_language" };             _languageRepository.Insert(newLanguage);             var insertedRowCount = _uow.SaveChanges();                  var insertedLanguage = _languageRepository.Find(newLanguage.Id);             _languageRepository.Delete(newLanguage);             var deletedRowCount = _uow.SaveChanges();                  Assert.AreEqual(insertedLanguage.Name, newLanguage.Name);             Assert.AreEqual(1, insertedRowCount);             Assert.AreEqual(1, deletedRowCount);         }     }      I use something like above. But I dont know this is the correct way to test repository. I cant find useful tutorial/article. How should be unit testing with generic repository CRUD operations?


Should a Parent with Children have a DefaultChild, or should a Child have a Default property?

Which of the following two models makes more sense? I'm leaning towards the first one because there can only be one default child. The examples are in C# but I think it can apply to other languages too. Here `DefaultChild` holds one of the items in `Children`.               class Parent     {         int ID { get; set; }              Child DefaultChild { get; set; }              IEnumerable<Child> Children { get; set; }     }          class Child     {         int ID { get; set; }     }      Here one of the items in `Children` has `Default` set to `true` while the others have it set to `false`.               class Parent     {         int ID { get; set; }              IEnumerable<Child> Children { get; set; }     }          class Child     {         int ID { get; set; }              bool Default { get; set; }     }      * * * A concrete situation: a `User` in our system has one or more `Customer`s attached. When logging in, if said `User` has a default `Customer`, they are immediately working under this `Customer`. If they don't, they have to select a `Customer` to work under. While logged in, they can switch between `Customer`s.


C# basic window content convention

I'm learning C# using visual studio express 2012, and I cannot find a source online that explains window content convention. What I mean by this is, what's the appropriate way to change the context / pass variables from the main window to different contexts? I've been able to change the content of my window by creating and editing new UserControl classes. As for parameter passing, I've experimented with having a static mainwindow with public fields and passing mainwindow field values through action functions (with little success). Is the appropriate way to handle changing the main window's context creating multiple usercontrol classes? If this is the case, should I be creating a tree with the main window as the root and the usercontrol classes as child elements? Most of the questions I find when searching for an answer revolve around forms or new windows, which lead me to question whether usercontrol is the correct item for changing context. If I'm missing a tutorial or simple explanation I apologize in advance :D


web spider for facebook

I just subscribed to a facebook page which post links to different open source projects or code archives. I'll like to save those links and descriptions to a local db. How can I do that? I heard something about the concept of web spiders and I know some php and java but I don't know how can I solve the problem from above. Thank you!


What's wrong with this approach to CSS?

I have a static Jekyll website. The website is constructed _once_ , on my computer, and then sent to the server in the form of plain HTML, image, and CSS files, to be served by a regular HTTP server. This construction process involves a template engine that has to glue various components together. For example, this is the template for my posts and pages (the only other template I have is for the main page, which shares quite a lot with this one):               <!DOCTYPE html>     <html>         <head>             {% include head.html %}             <link rel="stylesheet" href="/css/main.css">             {% if page.title == "Tautological Cascade" %}                 <title>Tautological Cascade</title>             {% else %}                 <title>Tautological Cascade: {{ page.title }}</title>             {% endif %}         </head>              <body>             <div class="site" >                 {% include header.html %}                 {{ content }}                 {% include footer.html %}             </div>         </body>     </html>      The most important part to notice here is the `body` section. It basically sandwiches a processed markdown file between two HTML files. Currently, I only have one, main CSS file, which is used by ALL pages. I find this approach a bit unpractical. Everything is defined in there, and it's getting messy. Couple that with my general ignorance of anything but the basic CSS, and you get something close to a nightmare. My idea is this: inline CSS for all of these parts that I glue together. So header.html would have its CSS in its file, footer.html would have its CSS, and the file that describes the content int its own. **Is this the correct solution to my problem? Is there something wrong with this approach?**


Is it bad practice to check object types with an identifying member variable?

**Preamble:** I am making a simple board game in C++, in which AI characters move around squares on the board. There are different types of squares, each inherited from an abstract class, each with different effects on the AI character. For example, some are shops where the character can buy stuff, others are workplaces where characters get money, etc. Likewise, there are different AI characters (also inherited from an abstract class), which make different kind of decisions. Some work more than others, some eat more than others, etc. The problem is that the AI character needs to know the square type in order to make a decision about what to do. At the moment checking the type using a type-name string as a member variable is the easiest solution, but it feels horribly inelegant and not very helpful when it comes to adding new types of squares and AI characters. **Question:** Is it bad practice to check the type of an object by asking it for an identifier which is placed into its class for this purpose? Is it bad practice to use other methods of run time type identification such as dynamic_cast and typeinfo for purposes of controlling the flow of execution? **Example:** Below the Square class (accessed through currentSquare() has a member function getType() which returns a string with the name of the type:               //Normal AI character     void decide() {         if(currentSquare()->getType()=="HOME") {             watchTV();             sleep();         }          if(currentSquare()->getType()=="WORKPLACE") {             work();         }      }          //Party animal AI     void decide() {         if(currentSquare()->getType()=="HOME") {             moveTo(getGameBoard()->closestBar());         }          if(currentSquare()->getType()=="WORKPLACE") {             sleep();         }      }


How much information about an error should be shown to the user?

Applications can always throw errors. If such an error occurs, the user should be notified, because what he asked the application to do has not succeeded. However, how much information should the user be given? I think most of us agree on not showing a stack trace (Should a stack trace be in the error message presented to the user?), but I can't find a question about the rest of the error contents or what to show to the user. For example, a language supporting exceptions (.net, java) has the exception type to share, where the exception occured, and a somewhat clarifying message to go along with the exception. Should this also be hidden from the user? Or should we show this anyway? Or should we show a generic message? or should we show one of a number of messages based on what the underlying exception is?


Advanced subversion techniques, what am I missing?

I started using SVN about 9 months ago and it's been a game changer to say the least. Although, I feel I'm still a bit lost. I feel like there is a lot more I need to take advantage of to really step up my application development. **For example** I would like to be able to quarantine any volatile/major changes into some kind of 'sub-repository' or something. I'm finding that major changes are impeding minor bug fixes that are quite urgent. How can I push one simple update without pushing incomplete or broken code?


Design Pattern For UI Control and Provider to Call Control's Events

I have a UI control that uses a provider class to implement the actual logic of a complex task. So the control delegates to the provider to do some work. But the provider needs to work with the control too; it needs to fire some events on the control. I was looking for a good design pattern of how the two could work together, but wasn't sure of any. I didn't want the provider to directly invoke events on the control. I thought about methods on the control that it could call, but I don't know that I quite like that either. Any ideas, thoughts? What is a good design pattern that the provider can use to fire a notification through the control? Each event may also need to pass custom parameters too.


How to tackle the outside party developement

Currently I'm working on a social networking project whose design is developed by the another company we are dealing with. We informed them that we need a task to be done on high priority to finish the project ASAP. We told them that what we need in the task and the party said, "What you do code or design?"? Is it their concern that I do design or code? When we have given them task, how can he ask a question that what I do? So I ask my boss what to do, and he said to tell him that "We need HTML and CSS". He the did the task. What exactly is this guy asking? I don't want to get into this kind of situation again. I want to handle these situations myself without talking to my boss. What am I missing here?


Make the lines hide (logically speaking) in applets

I am developing an application where I draw large number of lines (color is given as black) and update them where I need to remove them from screen. I thought of making their color to match with the background so that I can make them hide. It seems to be simple and works but in the practical sense I have 10000 points and almost more than 20000 lines to be drawn and as most the line overlap or cross each other it is so disgusting the view. So I need some kind of function to actually remove those selected lines between two known points from screen. Even I have a problem with the background color I can match the exact background default color of the applets. Can anyone suggest me solution or the color?


Helping a new programmer become more self-proficient and not ask me so much?

I'm currently working on a project with a new programmer. How do I help him speed up his work? He often asks me questions, and I pair programmed with him in backbone.js (a part of the project). Now I want him to handle the project himself so I can concentrate on other things to speed up the process. He doesn't want to Google things or ask on a forum if a problem comes up. He just comes to me. What should he do? What should I do? When I force him, then he does things quickly. How can I motivate him to do more work on his own?


Interacting With Data Using Multiple Databases/Servers

All of the projects that I've had to deal with so far have only required a single database on a single server. I'm interested in learning more about how projects that need to scale move to multiple databases and/or servers to help manage the load. I'm aware of High Scalability, but I'm particularly interested in some code examples or additional resources where I could read more on the subject. For instance:   * How are joins constructed between two tables on multiple databases? (A code example here would be helpful).   * Are there any special strategies for tracking which tables are in which database?   * Does the application code need to know that one or more databases are spread across multiple servers? If not, at what level are the requests filtered?   * When is it time to move beyond a 1 database/1 server setup? How common is it to need to do this?


Does it make sense to standardize including a created date and last updated date field on all DB tables?

My boss is currently attempting to apply some development standards to our team, so we had a meeting yesterday to discuss the standards which was mostly going well until she brought up:   * All DB tables will have a CreatedDate and LastUpdatedDate column, updated by triggers. At this point our team suffered an opinion schism; one half of us think that doing this on all tables is a large amount of work with little benefit (we work on fixed-budget projects so any cost comes from our company's profits); the second half believe it will help with support of the projects. I am firmly in the former camp. While I appreciate that some outside cases would cause the extra columns to improve supportability, in my opinion the amount of work that would be required to add the columns in the first place, as well as maintenance, would cause us to spend less time on more important things like Unit- or Load-Testing. Also, I'm fairly sure that these extra columns would make it more awkward to use an ORM - bearing in mind that we mainly use C# and Oracle, which isn't very ORM-happy to start with. So, my question is twofold:   * Am I in the right camp? I don't claim to have world-renowned database skills, so this might be a trivially easy addition with no adverse side-affects.   * How would you deal with a situation where a meeting about standards devolves into a slagging match? How can I really sell that this standard is not going to help us in the long term?


Need to figure out Timesheet via Email

So we are thinking that we might want to make timesheet submission easier by having our timesheet system send out a person's timesheet via email to the employee. The employee then should fill out the timesheet and send it back via email for it to be processed. Anybody know of some write up on how other's have done this? I've googled but without luck. Thanks for any thoughts/input.


How do functional languages handle random numbers?

What I mean about that is that in _nearly_ every tutorial I've read about functional languages, is that one of the great things about functions, is that if you call a function with the same parameters twice, you'll **always** end up with the same result. How on earth do you then make a function that takes a seed as a parameter, and then returns a random number based on that seed? I mean this would seem to go against one of the things that are so good about functions, right? Or am I completely missing something here?


Modelling Login and Authentication on an iOS mobile client

I'm about to start working on a V2 of a mobile application and I'd like to adopt a more object-centric approach. Primarily because I think it makes for more maintainable code, but a secondary benefit is easier testability. V1 of the app is pretty controller-centric. The Login ViewController has its login fields and it hits the backend via AFNetworking, reports errors if necessary, and receives a token which gets stored away securely for later use. There's only ever a single user. When the user logs out, all local data is deleted, so essentially the current user is 'global' and can either be nil (need a login) or not (doesn't). The situation is complicated of course by the idea of token expiry. Essentially any network request (either explicit GETs or asynchronous, delayed POSTs) can fail because the token expired and we want the user to re- authenticate. The V1 model of a login screen at startup if there's no current user doesn't easily extend to this model, and I feel,I'm missing an object somehow I'd route everything through. An Authenticator that provides a token, or throws up the login screen if it doesn't have one. Then we could do something like - when any request fails, we delete the current token and retry the request. The request asks the authenticator for the token, and the authenticator asks the user. Or something. How this could be better modelled? I feel like the code needs to be centralised, but that's hard as requests are used throughout the apps. Its almost like a filter layer is needed to handle auth errors centrally, but other errors / successes wherever they're needed (in a success/fail block).


Where do I put the changelog to display the recent changes to the user?

I want to create a changelog for my application to display the set of recent changes to the user. But I'm not sure where I put it. Do I create a text file and write in it? Where do I put this text file then?   Or do I use an action in the menubar and display the changelog in a new window when clicking on the action?


Best way to handle nulls in Java?

I have some code that is failing because of NullPointerException. A method is being called on the object where the object does not exist. However, this led me to think about the best way to fix this. Do I always code defensively for nulls so that I future proof code for null pointer exceptions, or should I fix the cause of the null so that it won't occur downstream. What are your thoughts?


CS subjects that an undergraduate must know

In college, I was never interested in theory. I never read it. No matter how much I tried, I was unable to read stuff and not know what was actually happening practically. Like for example, in my course on automata theory, my professor told me everything possibly related to the mathematical aspect of it, but not even once did he mention where it would be used practically. This is just an example. I managed to pass my college and interned with a company also, where I did a project and thankfully they didn't bother about my grades, as they were above average. Now, I am interested in knowing what subjects should a CS student must absolutely and positively be aware of? Subjects that can have relevance in the industry. This is because I have some free time on my hands and it would help me better to have a good understanding of them. What are your suggestions? Like for one, algorithms is one subject.


What is the best marketplace for freelance programmers?

I need a really talented, hardworking programmer who knows Cocoa and Objective C for my Iphone App. I'm looking for a partner and not just a programmer. It's a pretty big project that takes a talented programmer. What would you say is the best marketplace for someone like this. I've checked out digitalpoint and sitepoint but they are really for smaller projects.


How to have an improved relationship with recruiters?

I personally, always have problems with recruiter's and their constant spam.. I usually get tons of emails for jobs, not related to what I do. Or they have no idea what I do. Or they say they have a job in my field, but make me go thru hours of paperwork, only to find out they had no real job lead. Or my resume contained a keyword, that they searched for, but that keyword is like 1-10% of what I do, not my main job skill set. My point being is that I want to have a more polite, more accurate, less waste of each other's time. So I want to come up with a form letter, I can create in gmail to automatically send to all recruiter's, to help inform, educate and train them to deal better with me. That way, they know exactly what to send to me, so as to not waste my time. We don't play email/phone tag, just to find out they have no idea what I do, or how to find a job lead that matches that. I want this to be an improvement in my relationship and experience with recruiters, because honestly most of them waste my time. They call me at work, not considering I can't take phone call's at work, and they already had my email address. Mostly they annoy me, but I am tired of having to be rude to get my point across. I want them to immediately make sure they know what I can and have done, (Have you read my resume?) and have actual leads ready to be hired/interviewed soon or now. Any suggestions to how to improve the communication, to avoid wasting each other's time. I certainly hate having to come across as rude or improper, but when they just waste so much of my time, I don't know what else to do. So thank you for your time. Just to be clear, I want your help to write a form letter, that I can send to every recruiter that email's me, how to best work with me, and other people in IT/Web careers.


Is there a different usage rationale for abstract classes/interfaces in C++ and Java

According to Herb Sutter one should prefer abstract interfaces (all pure virtual functions) to abstract classes in C++ to decouple the implementation as far as possible. While I personally find this rule very useful, I have recently joined a team with many Java programmers and in the Java code this guideline does not seem to exist. Functions and their implementations are very frequently located in abstract classes. So did I get Herb Sutter all wrong even for C++ or is there a general difference in the usage of abstract functions in C++ compared to Java. Are abstract classes with implementation code more sensible in Java than in C++ and if yes why ?


Why can you have statefulness inside a static class in java?

I was playing around with Java today and I read about static inner classes. Why can you have 'statefulness' inside of a static inner class. For instance:               class outerClass {              static class Test {              private String a;                   String getA() { return a; }                   void setA( String newA) {a = newA; }               }     }      Am I misunderstanding something? It seems like you should not be able to keep mutable state inside of a class that is labled at static. Moreover it seems like you should not be able to instantiate something that is a static class, it should be a static singleton. Perhaps someone could correct me if I am making an incorrect assumption or enlighten me to why the Java authors decided to make this possible. EDIT: I feel as if I am confusing the keyword `final` and `static` in java, as `final` variables do not have state. It still seems _very_ strange to be able to instantiate a static class, though.


Is it normal to want some appreciation and acknowledgement?

I work for a Multi-national product development organization. I work directly for the person who established the Indian wing of the organization. I work incredibly hard and try to do the best possible work I can. But after 6 months of working here I am finding it hard to stay motivated to do my best because no matter how hard I try I do not get any acknowledgement that I did something right or wrong. Often times what I find that I need to do to get things done are not in the conventional wisdom of how software is made. The problem is bothering me so much that I am considering moving to a different company. I don't know if expecting an occasional "good job" is wrong. But it feels like a little sincere appreciation will help make things better for me. Is it just wrong to need it? Have you had a similar experience?


Is there any well known project to VBify C and make C as RAD language?

I have two questions: `Question #1`: Is there any well known project to **VBify** C? **VBify** here means **to make it as easy as in VB.NET** and to make C well supported in IDE just like VB.NET, i.e. with following features: word completion, function's argument description and everything just as with VB.NET development using Visual Studio. `Question #2`: Is there any well known effort to make C as **RAD (Rapid Application Development)** language?


Is there any scholarly research on the detrimental effects of a noisy workplace on productivity?

I work in an open office with typical office noise (people talking and walking by). It is simply too noisy and restless for me to work in. I've been trying and trying to get some change, to no avail. I'm at a point of starting to look for a new job, but thought I'd give it one more shot, and try to argue my case with research. I remember reading about research on how noise and disruptions affect knowledge work and software development in particular. Maybe I'm bad at searching, but I just can't find research papers that deals specifically with noise and work that requires high concentration. PS: While I appreciate tips on how to cancel the noise (music, white noise, etc.), please limit your answer to links to research papers. Thanks.


What should and what shouldn't be in a header file?

What things should absolutely never be included in a header file? If for example I'm working with a documented industry standard format that has a lot of constants, is it a good practice to define them in a header file (if I'm writing a parser for that format)? What functions should go into the header file?   What functions shouldn't?


How to create and publish a useful Java library

I've recently worked on a Java class that generates permutations per list of objects. In any case, I would like to have this library offered to the public, so I have several questions:   * Most libraries I see have this complicated package naming, specifically including `com`/`org`. Is there a convention for these or is a `permutations` package enough?   * Is there a specific format to publish these? Should I include separate WARs for source code / javadoc?   * I have the files on a GitHub repository. I guess I can serve the files there, but how do I get people to find my repo?


Steps to maintain a good bug database

Maintaining bug database is an important for every project. I am used to store the followings at bug database   * Issue date time   * Who is assigned to   * Whether it has been solved or not   * If solved then, solved date time Is those enough to maintain a good bug database?


what is the purpose of arrows?

I am learning functionnal programming with Haskell, and I try to grab concepts by first understanding why do I need them. I would like to know the goal of arrows in functional programming languages. What problem do they solve? I checked http://en.wikibooks.org/wiki/Haskell/Understanding_arrows and http://www.cse.chalmers.se/~rjmh/afp-arrows.pdf. All I understand is that they are used to describe graphs for computations, and that they allow easier point free style coding. The article assume that point free style is generally easier to understand and to write. This seems quite subjective to me. In another article (http://en.wikibooks.org/wiki/Haskell/StephensArrowTutorial#Hangman:_Main_program), a hangman game is implemented, but I cannot see how arrows makes this implementation natural. I could find a lot of papers describing the concept, but nothing about the motivation. What I am missing?


What is exactly the meaning of "portability"?

I know very well that java is a portable language..and it is the byte-code that makes it portable.. However I've studied also that C is a portable language. **"The programs written in C are portable i.e. programs written for one type of computer or operating system can be run on another type of computer or operating system."** Then what is the difference between C portability and Java's portability? can we say that C is also a portable language like java? I know that java portability may be in terms of different application such as mac, PC, mobile phone..and C can't be used in such cases..But my question is still as how portability is different in both language? Please clear my confusion. Thanks in advance..


Chat room for Ruby on Rails app -- should I do it with EventMachine or Node.js?

I have a chat room for a Rails app is implemented the old-fashioned way, using Ajax Polling. This is not scaling, and it is cluttering my log, so I want to reimplement using either EventMachine + HTML5 websocket/degrade to flash, or Node.js. Given that the rest of the app is in Rails, what are the the pros and cons of each of these two alternatives?


Finding an A* heuristic for a directed graph

In a previous question, I asked about finding a route (or path if you will) in a city. That is all dandy. The solution I chose was with the A* algorithm, which really seems to suit my needs. What I find puzzling is heuristic. How do I find one in an environment without constant distance between 2 nodes? Meaning, not every 2 nodes have the same distance between them. What I have is nodes (junctures), streets with weight (which may also be one- way), a start/finish node (since the start and end is always in the same place) and a goal node. In an ordinary case, I would just use the same way I got to goal to go back, but since one of the streets could have been a one- way, that may not be possible. ### The main question How do I find a heuristic in a directed graph?


How do you train freshers?

Training freshers has become my responsibility. I work in a good small company and they want me to train freshers (MCA/BCA students). But I am not an expert in training field. So can anyone please help me in this? Few hints/tips and something that is new/different to train them. What care should be taken while communicating them? How to clear their mind covered with college environment? Please help me.


Why is #include <iostream.h> bad?

I was reading another thread where a guy asked about C++ books for beginners, and one of the programmers answering wrote this: > Some warnings: avoid all books that present an "hello world" stating with >   >   >     #include <iostream.h> >   I opened my C++ book and sure enough it included the iostream header like the example above. Why is that bad? What other pointers should I keep in mind when learning C++? Background: I am proficient with C and I'll start to learn C++ this next semester.


Falsey values vs null, undefned, or empty string

I've worked with jQuery over the years. However, recently, I've found myself getting deeper into the JavaScript language. Recently, I've heard about "truthy" and falsey values. However, I don't fully understand them. Currently, I have some code that looks like this:               var fields = options.fields || ['id', 'query'];      I need to identify if fields is null, undefined, or has a length of 0. I know the long way is to do:               if ((fields === null) || (fields === undefined) || (fields.length === 0)) {      ...                         }      My question is, is the following the same:               if (!fields)  {      ...     }      Thank you!


Session in RESTful web services, how it works?

In a web services, how does the server know which request belongs to which session? I know that for a web application, the web server inspects the cookie (or the sessonId query parameter in case cookies are disabled) so it knows which session the request is associated with. But for a request that comes from a rest client, how do the server know?


Where does the word "argument" (in the programming sense) come from?   i.e. Why are actual parameters called "arguments"? The meanings don't seem related, and I haven't found any explanation of it anywhere. * * * **Note** on the terminology:   * "Formal" parameters (also known simply as "parameters") are the "placeholder" names (say, `x`) -- the _declared_ parameters of a function.    * "Actual" parameters (also known as "arguments") are the _actual values_ which are _passed_ to a function (say, `5`), hence I used this term above to prevent any confusion.


Moving from Employee to Business Owner smoothly

I currently work for a company, a big company. I have a contract that states that I need to ask for permission to have another job. Very standard I suppose. I'd like to start trying out some ideas for start ups. Some of them work without moving money (write a program, release it as shareware or something like that and see if people is interested), that's easy. But some ideas need to move money. One is, in some way, like Amazon's Turk Machine, where money should be involved since day 1. Without having to request permission from my current employer and having to set up a company, how can I give that idea a try?


Is there a version control system that can show changes to a specific method or function?

Sometimes it would be nice to be able to say something like:               (git|svn|hg|etc) diff Foo.c:main     (git|svn|hg|etc) log log Foo.c:main      to see the changes made to a specific function within a source file since the last commit, or the complete history of changes. My question is two-fold:   1. Does something exist that does this?   2. Would such a tool be practical? It would have to do some simple parsing of the code at each revision in order to compare different versions of the function; would the overhead be too much for it to be efficient?


In MVP, should presenters instantiate and control other presenters?

I've implemented an application using MVP with GWT, which is working out very nicely for views that have a single purpose. Now, it has evolved into views that are achieving multiple purposes in a single window. So now I have a view of views with each view having its own presenter. I used this example as my model for building out the application, take a look. The "view of views" also has its own presenter, which instantiates (or receives) the presenters for each of the other views it needs to fulfill its purpose. I reveal event interfaces through those presenters for the "view of views" presenter to hook into and listen and react to what's going on inside those other presenters & views. My questions are:   * Am I still following MVP principles or have I violated the separation of concerns somewhere by having presenters create/receive and control other presenters? aka Should I be doing this?   * What are some other design patterns for creating interfaces that are also composed of other complex interfaces? ## Update In response to Robert Harvey's question, there is difficulty with passing objects from a presenter of a view to the presenter of the "view of views" when an event is triggered. For instance, a button will flag a ClickEvent and the handler attached to this will need to pick up the data object related to the ClickEvent through another method revealed by the view's presenter. So this works, but do feel it will cause more problems later on as this kind of object handling grows in complexity.


Is there a license for selling a software with the sources so buyer can make modifications without claiming ownership of the code or distributing it?

I would like to sell a software that has some open source competitors. Therefore I would like to include the source code with the binaries so that the company buying it can modify it as it wishes. The only catch is that the source code will NOT belong to the company, in other words, I would like to maintain the copyright and ownership over the code so I can sell to other companies, etc. Is there a license name for this kind of model? The buyer can see the code, modify it for its needs, but it cannot take ownership over the code, in other words, it is licensed for a particular use/need and **he cannot give or show the code to anyone else**. Buyers are more likely to be companies in that model, in other words, they will be able to take control of the product by modifying the source code, but they will not be able to take ownership of the original code or do anything with it besides the initial purpose they bought it for. It is still closed source. **Only the companies that buy the product are entitled to see and modify the code but never to distribute it.**


Will interns and entry level positions care more about algorithms or projects/experience

I am 3 months into learning java, read head first java and made 4 things on my github + many small things. I also started learning android this month, but now am tossing and turning not knowing my next step. I applied to a few jobs and no call backs but have been getting noticed at least. My background is business and I have experience in QA. I have taught myself a lot but never really saw a need to learn algorithms or big o notation, I noticed that most people talking about this go to university and are applying to google or a big fortune 500 company. I have read so many success stories of people teaching themselves programming in 1 year with no background and they never talked about algorithms and still got jobs, but yeah most of them were web developers or android. I also hear that they mainly ask algorithm questions to students because they know students might not have much of a portfolio, so if I have a good portfolio would that negate the need to focus on algorithms? I don't know what kind of career I want so I am applying to anything java/android but no web related jobs as I am not interested. I know html/css/rdmbs/sql. TBH, I just really want to spend the next month or 2 learning more android and than apply for jobs after I put some apps on the market. I also want to finish making java projects to learn core java. The problem is time, I am unemployed and every month goes by looks bad to an employer. I don't want to spend 2 months learning android than 2 months playing with java, if after all that I still have to spend a few months learning algorithms. I feel if its THAT necessary, should I drop everything and focus on interview algorithms and such? I am hesitant to learn something I won't use much JUST for an interview, at least at my current intern level. I studied javascript and jquery before but I never used them, and its as if I never studied them when I think about it. I am aiming for small companies or startups who want an intern to grow with and train. Are these algorithm questions mainly asked for people aiming at the big four? thanks for any tips, I have currently a few pdfs on algorithms and MIT free course to look at...not sure where to start...


Is my understanding of abstract datatypes correct?

After reading lots of pages on various sites, I came to the conclusion that abstract datatype helps to separate the use of datastructure from its implementation. We can easily map the data into a datastructure by using an already available abstraction. And this abstraction is called ADT. Please tell me if I have understood this correctly. Also if you can give a small example, it will be very helpful. If you prefer to give any code in your example, C or Python would be helpful for me. **Addition:** They are a very special implementation of data abstraction. What separates them from other instances of abstractions is that ADTs are theoretical constructs. Theoretical constructs that help map or represent data in a desired data structure. They have attributes or operations associated with them. These operations may be applied on the data that has been mapped into the ADT. How the data is actually stored inside the ADT or how the operations work are kept hidden. EDIT: I had previously said, "ADT is like the blueprint of a datastructure". A few of the answers have explained why it's not. I didn't have a clear comprehension of what a 'blueprint' is and that was the reason for using the term. So, I've now removed it from my original text.


Multiple classes with the same name, but different namespaces?

I've run into some code (C# if it matters) that has classes which have the same name, but differ in their namespaces. They all tend to represent the same logical thing, but often are different "views" of the same object. The different namespaces are at times part of the same solution, and even the same dll. I have my thoughts, but couldn't find anything definitive about this practice to be considered a clever use of the tools available or a pattern to avoid. This question on smurf naming touches on this, but from the other direction. Disambiguating the names would likely require an arbitrary and pervasive prefix, which that question wanted to eliminate. What are the guidelines around this practice?


How does your team approach technical code QA?

For the first time, our team is taking a rigorous approach to technical code QA. We identify work to QA by picking out top level classes and QA'ing it and everything it calls or uses below it (and what they call/use etc.). I reckon our QA code coverage to be reasonably close to 100% and its an eye opener for me in terms of improvements both in code and design as well as catching bugs early. I'll definetly be promoting this in the future, but wondered how other teams approach techincal code QA. Do you have a rigorous approach? Do you aim to QA everything? Does one or two people tend to do it or is it spread evenly about the team? What do you look for when QA'ing? Any thoughts appreciated!


API always returns JSONObject or JSONArray Best practices

I'm making an API that will return data in JSON. I also wanted on client side to make an utility class to call this API. Something like :               JSONObject sendGetRequest(Url url);     JSONObject sendPostRequest(Url url, HashMap postData);      However sometimes the API send back array of object `[{id:1},{id:2}]` I now got four choices ():   * Make the method test for `JSONArray` or `JSONObject` and send back an `Object` that I will have to cast in the caller   * Make a method that returns `JSONObject` and one for `JSONArray` (like `sendGetRequestAndReturnAsJSONArray`)   * Make the server always send `Arrays` even for one element   * Make the server always send `Objects` wrapping my Array I going for the two last methods since I think it would be a good thing to force the API to send consistent type of data. But what would be the best practice (if one exist). Always send arrays? or always send objects?


Why does Linq to Entity Sum return null when the result set is empty?

There are quite a few questions on Stack Overflow about the Linq to Entity / Linq to SQL Sum extension method, about how it returns null when the result set is empty: 1, 2, 3, 4, 5, 6, 7, and many more, as well as a blog post discussing the issue here. I feel it is an inconsistency in the Linq implementation. I am assuming at this point that it is not a bug, but is more or less working as designed. I understand that there are workarounds (for example, casting the field to a nullable type, so you can coalesce with `??`), and I also understand that for the underlying SQL, a NULL result is expected for an empty result set. But because the result of the Sum extension for non-nullable types is also non-nullable, **why does the Linq to SQL / Linq to Entity Sum behave this way?**


Decoupling software components via naming convention

I'm currently evaluating alternatives to refactor a drivermanagement. In my multitier architecture I have Baseclass   * `DAL.Device` //my entity Interfaces   * `BL.IDriver` //handles the dataprocessing between application and device   * `BL.IDriverCreator` //creates an `IDriver` from a `Device`   * `BL.IDriverFactory` //handles the driver creation requests Every specialization of `Device` has a corresponding `IDriver` implementation and a corresponding `IDriverCreator` implementation. At the moment the mapping is fix via a type check within the business layer / `DriverFactory`. That means every new driver needs a) changing code within the `DriverFactory` and b) referencing the new `IDriver` implementation / assembly. On a customers point of view that means, every new driver, used or not, needs a complex revalidation of their hardware environment, because it's a critical process. My first inspiration was to use a caliburn micro like nameconvention see Caliburn.Micro: Xaml Made Easy   * `BL.RestDriver`   * `BL.RestDriverCreator`   * `DAL.RestDevice` After receiving the `RestDevice`within the `IDriverFactory` I can load all driver dlls via reflection and do a namesplitting/comparing (extracting the xx from xxDriverCreator and xxDevice) Another idea would be a custom attribute (which also leads to comparing strings). My question: is that a good approach above layer borders? If not, what would be a good approach?


Prevent indent when formatting CSS

In Visual Studio 2013 when I format my CSS code (`Ctrl`+`K`+`F`) it will sometimes indent my CSS properties into a hierarchy. For example: .a { color:red; } .a .b {color:blue; } Becomes:               .a {       color:red;     }             .a .b {          color:blue;        }      When I would prefer:               .a {       color:red;     }          .a .b {       color:blue;     }      Is there a way of modifying Visual Studio to prevent this indentation?


How to manage security of these self hosted web apis, to ensure that the request coming for accessing data is authenticated?

Let's pretend I am going to work on an enterprise application. Say I have 11 modules in the application and I would have to develop **Dashboards** for every role in the organization for whom I are going to develop application. We Decided to use **Asp.Net Web Api** and return json data from our apis. We are going to include 11 Self hosted web apis projects in our application (one **self hosted web api** ) for every module. All 11 modules are connected to one **Sql server 2012 Database.** Then once api is ready we would have to create Business Dashboards (Based upon roles in Organization). So Now my web api client is Asp.Net Mvc application.Asp.Net mvc will consume those web apis. Here is the part for whom all explanation is done. How should I manage Security of all 11 self hosted web apis? How should I only authenticated request is coming? If I authenticate user by login and password and then redirect user to appropriate Dashboard designed for the role that user have and load data by consuming web apis. How should I ensure that the request coming for accessing data is authenticated?


Models structure in PHP/MVC

I have some classes that are composed with ORM generated Models. example1: For example the Report.php (Model) is using a Document.php Model generated with ORM. Based on the document object a report is created. I would like to know some name suggestions for the Report.php folder path. It clearly belongs to the /Model folder but in what subfolder? example2: The CustomTagFilter.php will remove some html tags from a html string. I wish to find a clear path name for this kind of Models. Any suggestions ?               /Models/[SUGGESTION]


Architecting related products for different markets: MEF?

Hopefully, this question is not too open-ended... I have been tasked with taking a 3 year old application (.NET 4.0, WPF, WCF, EF 4, SQL 2008) that was designed for a very specific market X and "re- purposing" it for a another very specific market Y. To further complicate things, the company has also mentioned a third market Z, but that may be a year+ down the road. But it’s definitely coming. The deadline for getting the application Y ready for market is aggressive. It might be negotiable, but just assume it’s a matter of 2-3 months. I have been working at the company for a while, and I was very intimately involved with the initial creation of application X, and I am still involved with the maintenance. The new “application” Y is interesting because there is some “overlap” between the features required for X and Y. For example, let A, B, C, D, and E be features and let ‘ (prime) denote an enhancement to a feature. All of the following scenarios are valid:               ---X---|---Y---  …  ---Z--- (down the road)        A   |   A        B   |   B’        C’  |   C            |   D        E   |      Some features can be merged from X to Y as-is (A). Some features from X must be enhanced before they can be merged into Y (B). Some features in X will not be in Y at all (E), and Y will contain features that are not in X (D). You get the idea. Here are my questions: (1) In the eyes of upper management, they ultimately see 3 different applications - one for each market: X, Y, Z. Moreover, they see 3 different copies of the same feature A that will need to go into each application. As discussed, there may be some enhancements that will make it to select products, but at the core, they are nearly identical. Sometimes I'm guilty for finding excuses to use the latest programming trends, BUT I think there's a strong business case here for utilizing the Managed Extensibility Framework (MEF). Why have 3 different physical applications (and hence 3 code bases) when it could really be one “next generation” application with plug-able features through something like MEF? There are several benefits that something like MEF could bring to the table. Does an extensibility solution like MEF seem valid in a case like this? (2) Given the limited time to get application Y to market... (a) Should I go with a conservative approach and simply give management what they’re asking for, i.e. make a deep copy of X and modify it for Y? Perhaps there will be time after Y goes to market to develop a more ideal and extensible solution? My past experience with this company has seen demos become fully-fledged products within no time – if you get my drift ;) It could very well be more difficult to modify X code to make it work for Y rather than it would be to create Y from scratch and import X features. (b) Leaving X alone for now, should I create Y with MEF in mind. Features from X can easily be imported into Y. If this is done properly, Z should be easy to implement. It will probably be a risky undertaking to go back and address X to fit into this framework since it's so widely used, but it could be done on the side with no specific deadline. I have to pitch this to upper management. Any advice or thoughts?


Do any OO languages support a mechanism to guarantee an overriden method will call the base?

I think this might be a useful language feature and was wondering if any languages already support it. The idea is if you have:               class C       virtual F          statement1          statement2      and               class D inherits C       override F          statement1          statement2          C.F()      There would be a keyword applied to C.F() such that removing the last line of code above would cause a compiler error because it's saying "This method can be overridden but the implementation here needs to run no matter what".


Finishing an iteration early

I'd like some input on this on those working with agile methodologies... A current project is finding that development on our planned user stories is finishing some time before the end of the iteration, and that the testing effort and business acceptance is what's actually dragging us out longer towards the end. This means that the devs in question have spare time, and they're essentially going out to the iteration+1 backlog and starting work on cards there before our current iteration cards are 'done'. As iteration manager, I want to put a stop to this - I want a more team-orientated approach where the group takes ownership of getting all the cards done, as opposed to "Well, dev's done so what do I dev next?" The problem I face is convincing the team of this. On one hand, I understand why the devs don't want to test the code they've written (there are unit tests they write of course, but the manual testing to be done could be influenced by their bias). The team sees working ahead as making our next iterations easier, because a lot of the work is done before we start. I see this as screwing with the whole system of planning/actuals - but it's difficult to convince the team as to why this matters. What advice can you guys and girls give? How do we stop devs reaching ahead? What should they be doing instead? How much of a problem is this in the scheme of things, if things are still getting done?


Resources on securing domain models?

I'm have good resources on both security, domain modelling, and architecture patterns. I've noticed a distinct lack of any suggestion of how and where to integrate security into the systems I build. I imagine the thing that applies the most is Access control, as Authentications and many other security forms would seem to be obviously a layer above the model and is pretty easy to separate and find a place for. Access Control to actions seems more of a grey area. Are there any good resources on this? I prefer well written books, but other resources are also welcome.


How to use TFS as a query tracking system?

We already use tfs for managing defects in code etc, etc. We additionally need a way to "understand the domain & requirements of the products". Normally, without tfs we exchange emails with the consultants and have the questions/queries answered. If it is a feature implementation we sometimes "find" conflicts in the implementation itself. And when that happens the userstory is modified and the enhancement/bug as per that is raised in TFS. Sometimes it is critical we come back to decisions we made or questions we wanted answers to. Hence we need to be able to track how that "requirement idea" or that "query in concern" evolved. Hence how is it that we can use TFS to track all of this? Do we raise an "issue" item for this? Or do we raise a "bug" item? The main things we'd ideally look in a query tracking system are as follows:   1. Area: Can be a module, submodule, domain. Sometimes this may be "General" - to address domain related stuff, or, event more granular to address modules, sub-modules. Take the case for the latter, if we were tracking this in excel sheets, we'd just write `module1,submodule2`; i.e. in a comma separated fashion. The things I would like here is to be able search for all queries relating to `submodule2` sometime in the future.    2. Responses: This is a record of conversations between the consultant and any other stakeholder. For a simple case, it would just be paragraphs. Each para would start with a name and date enclosed in brackets and the response following that...each para would be like a thread - much like a forum thread   3. Action taken: We'd want to know how the query was closed, what was the input given, what were the changes that took place because of that, etc etc.  These are fields I think I would need in such a system apart from some obvious ones like status, address to, resovled by, etc. I am open for any other fields which are sort of important. To summarise my question: how can we manage "queries" in the system? Where should we ideally store data pertaining to those three fields I have mentioned above (for e.g. is it wise to store responses in the history tag assuming we are opening a bug for the query)?


What reasons are there for not using a third party version control service?

I've recently noticed a bit of a trend for my projects as of late. I use to run my own SVN server on my VPS, but recently the nail went in the coffin for that when I got my last project migrated from my server to a Mercurial repo on Bitbucket. What are some of the ramifications to this? (disregarding the change in version control systems) It seems like there has been a huge explosion in version control hosting, and companies like Bitbucket even offer private repos for free, and Github and other such services are extremely cheap now. Also, by using them you get the benefit of their infrastructure's speed and stability. What reasons are there these days to host your own version control? The only real reason I can think of is if your source code is super top secret.


Setting source IP with posix sockets

Is it possible for an application to request a socket (tcp) and have it set the source address without using raw sockets? (the addresses would be bound to the interfaces. [no spoofing]). This would be a tcp client connection, not bind()ing to a specified address.


Microsoft's coding standards for ASP.NET controls

I cannot find any naming standards/conventions in MSDN for naming ASP.NET controls. One of the following standards tends to be used by programmers:   * `lblAddress`   * `AddressLabel`   * `Address` According to MSDN's Name of Type Members, should we be treating ASP.NET controls as fields, hence using Pascal Case (e.g. `AddressLabel`)?


Are there any reasons not to accept a software deliverable as a virtual machine?

This is a question about logistics, not a technical question. My company has outsourced some embedded software work. Specifically, we have payed a contractor to develop an embedded system for us since we do not have adequate in-house knowledge to do it ourselves (we only have desktop application developers). So, the contractors have finished the software and they have asked if they may deliver it to us in a virtual machine. The VM is a Windows 8 machine containing the pre-configured CodeWarrior IDE with the source code as a CodeWarrior project. The idea is that this will allow us to make code changes within the VM that is already configured for further development of this project. Are there any drawbacks to doing this as opposed to having them walk us through how to configure our own development machines to make code changes to the project? The only problem I can foresee is the VM running slowly and it taking a long time to rebuild the project when we make code changes. But on the other hand, I like the idea of getting a pre-configured embedded system development environment so I don't have to add yet another IDE on my desktop application dev machine. I can't really think of a good reason why not to accept a VM deliverable, but I just wanted to run it by this community in case there's something I'm missing.


Lambda Calculus Free Variable

Here's something from Slonneger's "Syntax and Semantics of Programming Languages": > A variable may occur both bound and free in the same lambda expression: for > example, in λx.yλy.yx the first occurrence of y is free and the other two > are bound. I assume the free variable is the y right after the λx. and the bound y's are the λy.y which I can sort of intuitively grasp. So ((λx.yλy.yx)a)b) would reduce to (yλy.ya)b) then to bba ? Can someone explain how this came to be? In the end it's the expression b twice. Can someone perhaps provide more examples of bound and free variables?


Why have a wrapper constructor when storing a function in a data type?

I can never do too many Haskell tutorials. There is always something to refine and learn. So, I am working through chapter 10 of Real World Haskell, and everything makes sense. _but_ Why do               newtype Parse a = Parse { runParse :: ParseState -> Either String (a, ParseState) }          identity :: a -> Parse a     identity a = Parse (\s -> Right (a, s))          getState :: Parse ParseState     getState = Parse (\s -> Right (s, s))          putState :: Parse ()     putState = Parse (\s -> Right ((), s))      Why not simply do               type Parse a = ParseState -> Either String (a, ParseState)          identity :: a -> Parse a     identity a = \s -> Right (a, s)          getState :: Parse ParseState     getState = \s -> Right (s, s)          putState :: Parse ()     putState = \s -> Right ((), s)      In other words, what is the purpose of the wrap and unwrap pattern in here (which I see used in a lot of different places in Haskell)? We get the same `Parse Whatever` data type, but without the extra indirection.


Analogy of a class being a cookie cutter and objects being cookies

I came across the analogy of the _class being a cookie cutter and the cookies being objects_ while reading Code Complete. I fail to see why this analogy was drawn.How is it related to the concept of objects being run time instances of their classes?


Refactoring: Isn't it just a fancy word for clean up your code?

Before Martin Fowler's book "Refactoring: Improving the Design of Existing Code" came out, we used to call major changes to code "rearchitecture" and minor changes "cleanup". IMO, refactoring techniques are all common sense / obvious things we've been doing forever. Do you think refactoring was ever anything new? Perhaps just a way to trick management into allocating time for code cleanup?


Why does IIS default to Recycling the Application Pool every 1740 minutes?

Why does IIS default to recycle the app pool after a given time? Is there some specific reason other than perhaps most web apps are not managing the memory prudently? Given that you are managing your application's memory properly, is is safe to go ahead and turn this off? What are some potential down sides, up benefits to turning off recycling or keeping it on?