Is it useful to unit test methods where the only logic is guards?

Say I have a method like this:               public void OrderNewWidget(Widget widget)     {        if ((widget.PartNumber > 0) && (widget.PartAvailable))        {             WigdetOrderingService.OrderNewWidgetAsync(widget.PartNumber);        }     }      I have several such methods in my code (the front half to an async Web Service call). I am debating if it is useful to get them covered with unit tests. Yes there is logic here, but it is only guard logic. (Meaning I make sure I have the stuff I need before I allow the web service call to happen.) Part of me says "sure you can unit test them, but it is not worth the time" (I am on a project that is already behind schedule). But the other side of me says, if you don't unit test them, and someone changes the Guards, then there could be problems. But the first part of me says back, if someone changes the guards, then you are just making more work for them (because now they have to change the guards and the unit tests for the guards). For example, if my service assumes responsibility to check for Widget availability then I may not want that guard any more. If it is under unit test, I have to change two places now. I see pros and cons in both ways. So I thought I would ask what others have done.


Licensing: source code vs. production code in JavaScript

For commercial and licensing purposes, what is the correct wording for differentiating JavaScript source code (written by the programmer and including comments) from the minified version used in production?


When is it inappropriate to make objects immutable?

I have a class which represents an entity object in our system (for sake of argument, a Customer object)               public class Customer()     {       private int id;       private String name;       ... // 30+ fields            public Customer()       {         // empty constructor!       }            // getters and setters     }      I'm trying to refactor this so that the fields are extracted into their own objects where they are more sensibly grouped, and at the same time creating parameterised constructors - with the intent I could then lose the setter methods and make my objects immutable (since this is apparently a Good Thing(TM)). However, this doesn't make any sense - sometimes I need to update a customer's information! It's clearly not immutable. Should I just not make this class immutable - and can I apply the same argument to all my entity classes?


Is using "out" or "ref" parameters in Java methods to return extra values bad?

I happened to create a mutable class like this:               class Mutable<T> {         private T value;         public Mutable() { this.value = null; }         public Mutable(T value) { this.value = value; }         T get() { return this.value; }         void set(T value) { this.value = value; }     }      And then it's often used in a method like this:               boolean operation(String input, Mutable<Set<String>> dataOut) throws ... {         boolean result;         try {              String data = doSomething(input);              result = validate(data);              if (result && dataOut != null) {                  List<String> values = Arrays.asList(data.split(", "));                  Collections.sort(values);                  dataOut.set(new LinkedHashSet<String>(values));              }         } catch(SpecificIgnorableException ex) {              result = false;              logger.debug(ex);         }         return result;     }      ...which is just an example, could be any use case, where one would use `ref` or `out` parameters in C#, or non-const reference parameters in C++, or pointers to output parameters in C. First, same could be done by using an array (with one element) instead of above custom type. Does it make sense to have this custom type which clearly states _mutable_ , instead of using an implicitly mutable array? Second, is this pattern bad and code smell in Java? Let's limit to cases where using `out` parameter would make sense in C#. Should every instance of this kind of Java code be replaced? With what?


Getting humiliated by your senior programmer

As a junior, what would you think and do if you getting humiliated by your lead programmer if you can't handle his expectations ?


What would you do? Long overdue on basically everything and now customer won't talk to you

I took over a rather complicated project as the sole developer/project manager and tester sometime last year. In November last year there was a deadline for some new functionality to be delivered. The system I took over which was supposedly ready to be used was far from being ready. Sitting with one of the our customers users he came up with new features and requirements which was required. Even though the features they asked for was implemented he argued it was nothing like what they specified in the requirements. So I had to get back to the drawing board and do extensive changes to the system. Promise after promise, this is my own fault, I missed subsequent deadline due to different reasons: over-optimistic planning on my behalf, sick kids and various other personal issues. And there have been failings on the customer side too: only testing when I watch over their shoulder and so on. Yesterday we agreed that we go live if their users approve the application. Of course some issues showed up and now today, when I tried to call our customer he hung up and hasn't replied to any of my emails. This is really wearing me out, the hours and time spent on this far exceeds normal working hours and has taken its toll on my family as well Obviously there are things in this situation that are specific to this project, but I don't think the overall pattern (multiple small problems, leading to project breakdown) is uncommon. What would you do in a similar scenario?


A single access point for several applications

I've been asked to create a web page from which users can access several other applications created using oracle forms and jsf, this will include also sso. I cant think of an easy way to do it, what I was thinking about was that the user should register and enter all his usernames/passwords for each application, after which he will deal only with the username/password he created for this page. What I wanted to ask was if this is a good idea or is there a better way to deal with this?


Version-control friendly, append-only file format: "binary" or "text"?

I'm designing an append-only ("journaled") file format, and I'd like it to be friendly towards being stored in VCS (git/Mercurial/...). On one hand, I'd like if after each change, only delta (difference) from previous file state was added into the repository (i.e. some trailing bytes), not the whole contents of the file again. So, for this, I'm considering making the format "pseudo-text", that is no NUL (0x00) byte in the contents (or maybe even some stricter subset of UTF-8), to make it easily diff-able by git/Mercurial. On the other hand, the "pseudo-text" file format would not be predisposed to merging, it would totally cripple the contents. So to avoid that possibility, I'm inclined to make it "binary", even if only by putting a NUL byte at offset 0 in file. But then, merging even for "text" but structured file formats is not always really possible, even for "typical" cases like sourcecode, so maybe no need to worry here? I'm quite certain there will be totally conflicts all over the place if anyone tries to merge such files, so that could be enough of a warning sign. Did you have experiences with similar choice in the past? Which choice should I make, and why?


How are multiple values returned in Java?

Sometimes you want to return multiple values from a function. **How is this _normally_ done in Java?** One option is to use an array, like this Python snippet that returns a list or tuple:               value, success = read_unreliably()     if success:         print value      Another option would be to return a hash/dict, like this JavaScript example:               var result = readUnreliably()     if (result.success) {         alert(value);     }      One more would be to create a custom object just for this purpose, like this Java example:               ReadUnreliablyResult result = readUnreliably()     if (result.getSuccess()) {         System.out.println(result.getValue());     }      Of course you can also just use some global variables to store what you need instead of passing things around, but let's just say that's not an option.


Does anyone have suggestions for design or open source libraries specifically for a single page AJAX application?

I'm working on a major new version of a browser based application and I'm looking for comments/suggestions about the architecture/design. It's a single page application using AJAX and client side templating to get new "pages". I'm already using the Sammy Javascript library to handle bookmarking and forward/back buttons. I'm using JQuery, parts of JQueryUI, SlickGrid, and a little Dojo (mostly dojox/rpc/jsonrpc and it's dependencies) so far. I'm communicating with the server using JSON RPC calls through a very thin web server layer that just forward the JSON strings to the business server, which has an API accessible in various ways, but the browser uses JSON RPC only. Session state tracking happens in the business layer as part of the implementation of that API, though of course the RPC mechanism must give enough information to identify which session is calling it. All that was context; the question I have is: does anybody know of any resources supporting this kind of design? In particular I would be looking for open source Javascript libraries besides Sammy that support single page web applications. Sammy expects you to use client side templating, and has some support for that plus several plugins for particular templating libraries, but doesn't support similar functionality for using AJAX to apply CSS style sheets (and remove or deactivate others) when you change screens and would have changed pages in a more traditional web application. I'd also love to hear from anyone who has tried something similar. Were you okay with one stylesheet for the whole application? Did you have issues with memory leak issues from staying on one page for so long? Also, any suggestions for a client side design? Does MVP sound reasonable, with a model implemented in Javascript, presenter classes to implement events in an abstract way that's easier to unit test, and the view to handle the actual DOM stuff? Some sort of application manager to track what pages are up, and that would clean up resources when a screen closes? I haven't seen a lot of comprehensive references or libraries for the single page design, so anything people can tell me or refer me to would be appreciated. Note that I have read Dev approaches to complex JavaScript UI's, which is a great question but not specific to single page complex Javascript UIs.


Is there any reason not to include issue numbers in debug logs?

I was going through the answers to this question: What information must never appear in logs? And noticed that nobody mentioned this particular attribute. It's something I find useful- whenever any logging is added to the system as a result of tracing a particular issue raised in the bug tracker, or adding a feature, **_I tend to include the ticket number of the related helpdesk element._** This means that when going through the log, any programmer can cross reference each log message with the associated ticket number. Now I understand that using proper VCS/helpdesk integration means most commits are attached to a ticket number anyway- but over time it makes it easy for us to diagnose problems on inspection whenever a log message comes up. However it still makes me a bit uneasy leaving this in the logs. The problem is, I can't think of a scenario where this could become a problem. I'm hoping SE can help me out. By the way- I'm talking about the "verbose" log level. This is never done in a logging level that will appear in production.


The GPL License Mixing

From the understanding that I am gradually gathering about the GPL it is not possible to mix licenses unless both have a special clause added to allow so. So how are the following possible? Let's use Joomla as the basis of this example:   * People develop plugin scripts that have to invoke library functionality from the Joomla core in order to function. This surely means that the plugin has to be GPL.   * Said people then decide to sell the plugin scripts which I gather is fine as they are essentially selling a distribution/support service. But once purchased the end-user has every right to resell or do with it whatever they like (provided it falls under GPL terms). Q1. So, how can people sell non-GPL licensed plugins for Joomla? Q2. How is it acceptable to add some sort of activation system that limits use of the GPL source? Is this not going against the very goal of GPL? Q3. How can a non-GPL licensed plugin for Joomla be restricted to non- commercial use? Here is a response that I recently received from a non-GPL Joomla plugin vendor. They offer two varieties, non-commercial and commercial (but neither are GPL). > GPL does not mean that all associated or used software needs to be GPL. It > regulates its use. We also would call "Joomla" not a product, it is open- > source software under the GPL license. > > Our extensions are open-source software under our own specific license > terms, > > In case you want to resell sites that use our extensions or the extension > itself, that is not covered with our license. In case you want to use it on > your own site, or sites which you create as designer for your customers, > that is covered in our license. I will not make reference to the plugin vendor at any point in this question because I do not want to make any false allegations. I am simply confused. In my experience of Joomla I have seen this situation over and over again and I have received similar responses. I am sure that I am simply misunderstanding a fundamental aspect of the GPL, but I really want to understand it. Added: Please note, my intent is not to sue or anything like that. I want to understand so that I can avoid the same from happening to a project that I will be releasing as open source later in the year. I just want to understand each angle.


Should I take care of race conditions which almost certainly has no chance of occuring?

Let's consider something like a GUI application where main thread is updating the UI almost instantaneously, and some other thread is polling data over the network or something that is guaranteed to take 5-10 seconds to finish the job. I've received many different answers for this, but some people say that if it is a race condition of a statistical impossibility, don't worry about it at all but others have said that if there's even a 0.00000000000000000000000000000000000000000000000000001% (I kid you not on the numbers, this is what I've heard) of some voodoo magic happening due to race condition, always obtain/release locks on the thread that needs it. What are your thoughts? Is it a good programming practice to handle race condition in such statistically-impossible situations? or would it be totally unnecessary or even counterproductive to add more lines of code to hinder readability?


What should I use for a package name if I don't have a domain?

> **Possible Duplicate:**   >  What is the point of Java’s package naming convention?   >  What package name to choose for a small, open-source Java project? I write Java (and derivative languages with package names) for personal use, but I don't have a personal domain name, so the standard packaging naming convention doesn't hold. Since the same convention is used in Maven group- id's, the problem is the same there. What should I use for the root of my package name?


What package name to choose for a small, open-source Java project?

I'd like to publish a small open-source library in Java. I wonder what package name should I choose? I'm not a company and I don't have a domain that I could use as the basis for naming the package according to the naming conventions. Still I'd like to somehow follow the naming conventions to prevent an accidental conflict and to keep things standard.


instantiate or initialize when using a new class?

my question is rather a matter of English language. For proper commenting my code I want to know when you do for example the following code, what comment you can write for it?               public class TestClass     {         public double volt {get; set;}         public double curr {get; set:}     }       Somewhere else in the same namespace               public class AnotherTest     {         TestClass test;              public AnotherTest(TestClass test)         {            this.test = new TestClass(); //how to comment this?         }     }


How to document self explanatory setter functions?

Often boolean setters are pretty self-explanatory, like `setLogErrors($bool)`. I do see some benefit of providing some additional information in the documentation, in this instance maybe where these errors are logged. But how much documentation is too much, especially when it comes to documenting the value that is passed to the setter? Documentation tools like phpDocumentor would like that variable to be documented as well, but from the context it is pretty clear that it takes a boolean. Often I personally find it better when the code speaks for itself, especially in situations like this. What is the best practice in situations like this? **Should the argument be documented** or not, how about **the setter, should it be documented**? Wouldn't the code readability improve if there was less documentation in this circumstance? I am not part of a large developing team and I don't read a lot of code written by others. I was hoping to gain some insight into **what standards are set in larger organizations and what is the easiest for people to read when the code is not their own**. I hope this questions is not too opinion based.


SCRUM from scratch, with no base framework established?

We are a small group of 5 people that is about to start a new project. This is the first project where we will go all-in on scrum. We are struggling a bit with how we are going to establish a base for the project (frameworks and the like). Such tasks are not something the user will benifit from directly, so we are having a hard time figuring out how we write user stories for it. So in general, how do you use scrum, when you are starting a project from scratch, with no frameworks and no base library in place?


When to create a new MVC Controller for a model

**The Project:** I have several cases where I'm not sure whether or not I should be using a 'Separation of Concerns' approach or a simplistic one. They're all similar to the setup below. e.g. An `Estimate` contains multiple `Notes` EstimateController.Details -> Displays the details of an Estimate (Name, Description, Etc.) and below that it displays a tabular view of Notes (separated by type). **My Thoughts:** On one hand, it would be a separation of concerns and creating a new controller sounds like the proper way to do things, making use of partial views if necessary. On the other hand, it seems a bit like overkill to have a controller for all the cases like this. (i.e. Estimates contain: Notes, Specification Numbers, Drawing Numbers, and Addendums. This is similar to multiple other models in the business model as well). **Question:**   * How trivial is to trivial to justify creating a separate controller for an sub-model? I've found many places saying that you should have a separate controller for each view model but out of the ones I've seen none of them mention **why** or mention **how trivial of a model is too trivial**?


ISBN Code - What is the purpose of Publisher Code in an ISBN?

I want to understand the logic of how the Publisher Code range provided by ISBN Authority gets mapped to an ISBN. From the below links, http://xml.coverpages.org/costello-isbn-xsd.txt http://www.booklore.co.uk/Articles/Nigel/ISBNAtricle.htm                            Country     Publisher ID  If number ranges   Insert hyphen  Block Size                                              are between:     after the:                    ----------------------------------------------------------------------                       0           00.......19         00-19        3rd digit      1,000,000                    0           200......699        20-69        4th digit      100,000                    0           7000.....8499       70-84        5th digit      10,000                    0           85000....89999      85-89        6th digit      1,000                    0           900000...949999     90-94        7th digit      100                    0           9500000..9999999    95-99        8th digit      10                    1           55000....86979      5500-8697    6th digit      1,000                    1           869800...998999     8698-9989    7th digit      100                    1           9990000..9999999    9990-9999    8th digit      10       From the above table, what I understand is:   1. Any ISBN if broken for English Speaking areas should have a Publisher Code that falls in the above ranges specified.   2. Sample ISBN Number 978-0-00-000000-2, following forms the division, 978 as Prefix, 0 as English Speaking area, 00 as Publisher Code, Title digit - 6 digits (starts from 000000 to ending at 999999) and last the check digit calculated based on the number formed before. Questions:   1. Is my above assumptions and understanding correct ? Let me know if you need more information, please provide me the explanation for the table displayed above.


Where is the way for an experienced financial IT developer

I am a Java developer with more than 10 years work experiences. I have been working on investment banking industry since 2002 and I plan to continue my career in this industry. But recently I am a little confused about the direction to take in my career. I want to be expert in some aspects, but don't know how to develop myself. Could experts in this industry please help to shed light on this? Thanks in advance. Most of my experience is focused on trading system development including fixed-income and cash equity.


If we close browser window without getting logout, what will happen when we provide same URL in the browser?

A few days ago, I appeared in an interview in a software company for .net developer. There I was asked the following question: > If we close browser window without getting logout, what will happen when we > provide same URL in the browser? My answer was that user will be able to view the home page with login details instead of being prompted to provide username and password as session of the user has not ended. Login information will actually be retrieved from cookies. But it depends upon the logic we have implemented for Login. But the interviewer didn't seem be satisfied with my answer and didn't accept my answer. I am wondering what might be answer of this question. So, I need your kind guidance regarding correct answers. So please explain what I was supposed to reply.


How to mark an empty conditional block in Java

In C++ when I wanted to mark that if is empty by design I added `NULL;` as statement:               if (cond1) {         ...     } else if (cond2) {         NULL;     } else {         ...     }      However in Java it seems to be impossible to have `null;` as statement. What is the correct way of marking empty by design if in Java (is it just comment)?


I feel something uncomfortable with Haskell record syntax

Most of Haskell syntax has beauty of purity. But the record syntax looks ugly. It's uncomfortable. It feels some kind of mixture with C. It requires comma and braces. Haskell has tab,line based separation. So it looks too verbose than originally it requires. Why is it designed in that way?


Any good reason to open files in text mode?

(Almost-)POSIX-compliant operating systems and Windows are known to distinguish between 'binary mode' and 'text mode' file I/O. While the former mode doesn't transform any data between the actual file or stream and the application, the latter 'translates' the contents to some standard format in a platform-specific manner: line endings are transparently translated to `'\n'` in C, and some platforms (CP/M, DOS and Windows) cut off a file when a byte with value `0x1A` is found. These transformations seem a little useless to me. People share files between computers with different operating systems. Text mode would cause some data to be handled differently across some platforms, so when this matters, one would probably use binary mode instead. As an example: while Windows uses the sequence `CR LF` to end a line in text mode, UNIX text mode will not treat `CR` as part of the line ending sequence. Applications would have to filter that noise themselves. Older Mac versions only use `CR` in text mode as line endings, so neither UNIX nor Windows would understand its files. If this matters, a portable application would probably implement the parsing by itself instead of using text mode. Implementing newline interpretation in the parser might also remove some overhead of using text mode, as buffers would need to be rewritten (and possibly resized) before returning to the application, while this may be less efficient than when it would happen in the application instead. So, my question is: is there any good reason to still rely on the host OS to translate line endings and file truncation?


What reasons might a programmer have for wanting hyperthreading turned off?

My company just bought new computers to replace old 2GB Windows XP machines. Someone on my team noticed that they came with hyperthreading disabled, and told everyone to reboot and turn it on. Is there a benefit to programming on a machine with hyperthreading disabled?


What is meant by Distributed Systems Coding interview questions

I was told that I will be asked coding questions in my interview and that the context will be related to Distributed Systems (I took ONE Distributed Systems course and I don't even remember much from it!). I've seen a lot of data structure/algorithms coding questions but for Distributed Systems, all I can think of is questions about different concepts. What could they possibly ask me to code for them? I've tried looking up examples to practise or at least get an idea what kinds of things to expect but I haven't found any because they all just seem to focus on concepts, not design. Any ideas?


Visual Web Developer 2010 Express, automated testing, and SVN

We have an HTML designer who is not a developer but needs to modify .aspx files from our ASP.NET 2.0 projects from time to time in order to get CSS to work properly with them. Currently, this involves giving her the .aspx page by itself, which she opens and edits via Visual Studio 2008 (her computer used to be a developer's). I'm considering getting her set up with Visual Web Developer 2010 Express and Subversion access so she can be more independent, but I wanted to make sure VS Express will work properly with what we do. So:   * Does VWD 2010 Express support automated tests?   * If no to the above, what happens when it opens a solution file that includes a test project, modifies it, and saves it?   * Are there any potential snags with setting up AnkhSVN with VWD 2010 Express?


Is Rebol a functional programming language?

I ran into Rebol and I was wondering about it. I ran into the following script from here:                use [feed questions answers][         feed: load-xml/dom http://stackoverflow.com/feeds/tag/rebol         questions: map-each entry feed/get-by-tag <entry> [             find/match entry/get <id> "http://stackoverflow.com/q/"         ]              answers: make block! length? questions              foreach question questions [             question: load-xml/dom join http://stackoverflow.com/feeds/question/ question             foreach entry next question/get-by-tag <entry> [append answers entry/tree]         ]              insert clear feed/find-element <entry> answers         feed/flatten      ]      All the collection manipulation operations like `map-each` remind me of JavaScript and C# both of which have functional abilities. Is Rebol a functional language? Does it support functional programming? Would it classify as a pure functional language (PFL)?


How to explain to non-programmer to build my Visual Studio source code in "Release" mode?

I'm writing documentation for some software that I wrote. Specifically, I'm writing a guide to installing the software. I'm delivering the source-code to my client, so I expect that they will want to be able to build from source. I explain to open the solution in Visual Studio 2010 and to right-click on the project and select "Publish". There doesn't seem to be a clear and straight-forward way to explain that they must build it in "Release" mode or what the simplest way to explain how to do that is. What's the best way to explain this? **Edit:** In response to the comments asking me to be more specific, on my setup of Visual Studio 2010, there is a drop-down list next to the green icon that starts the debugger. It doesn't have any label next to it. That's how I'm familiar with changing the setting myself, but I don't want to write in my documentation, "Click on the drop-down list next to the green button and select "Release". There's got to be a better way. I am particularly concerned that if I get in wrong, it could result in someone changing the setting at the project level instead of the solution level.


Visual Studio build everytime JS and CSS changes?

I am relatively new to Visual Studio Development and I was wondering - it seems that everytime I make changes to my JS or CSS in my project - I have to "build" the project again. Is there any way to simply refresh the browser as opposed to building everytime ? My understanding is that all the files are copied to some temporary directory but I was hoping that I can quickly debug/write JS and CSS within the solution and just refresh the browser to see the changes ?


Moving from solo developer to a team

For the last 5 years I have developed as a lone developer. The business gives me the requirements, timescales etc and I do the rest. I choose which technology best fits the requirements, I decide on the architecture, I do all of the coding, releasing, testing and supporting. I have been looking at moving as I feel I am missing out on agile experience, team interaction and exposure to some practices. I was at an interview today and I was asked how I would feel having less control over the code I write as they have architects and project managers. I hadn't really thought about it to be honest and now I am wondering. I know what I stand to gain by moving, interaction with other developers, exposure to agile/scrum and also exposure to new technologies. My question here is, what do I stand to lose? I know I will no longer choose what technology I am using but just how little control will I be restricted to? How can I prevent myself from becoming someone elses code monkey who just has to write whatever they are told? I haven't experienced a set up with architects, BAs, projects managers etc so I am unsure what to expect. The teams are around 2-3 developers with an architect and/or lead developer.


Design in one team, coding in another

I will be involved in a project where all the software design is made by a local team and these designs are sent to an offshore team for coding. This is the first time I face a project with this characteristics and for me it feels kind of odd: The managers expects us to make very detailed design documents so there's no space for error for the offshore team; from my perspective they are making us coding in paper while we can do it in an IDE. So, my question is is this approach good, or proven right? What are the main considerations our software process has to have to have success in our project?


Is there a name for web applications that do most of the navigation on the client side?

Does the web industry have any standard or common name that refers _specifically_ to web applications that don't use the conventional window- HTTP-navigation model, instead relying on mostly or wholly on DOM manipulation? These applications usually have the following attributes:   * load an application frame from the server once (or infrequently)   * use a combination of Ajax requests, DOM modifications and history manipulation (via web fragment or `pushState`) to change state after that (while preserving reloadability)   * do not typically trigger new conventional location bar navigation events (window- or frame-level HTTP requests)   * most likely, present UIs that are highly interactive with a combination of dialog boxes, overlay layers, infinite scrolling, etc. Examples:   * Facebook   * Twitter   * Gmail   * USAToday Popular counterexamples, still relying mostly on traditional models   * YouTube (some navigation is done this way, but not enough)   * cnn.com I'm interested in names for this type of web application specifically. It feels like something I must have heard already, but I can't think of anything specifically. These seem too broad:   * Web application (could mean anything)   * AJAX application (could mean anything)


Grouping numbers to minimize group-means

I need to find a way or an algorithm that groups members of a given data set (of positive integers) so that the difference between group means is minimized (not maximized, as usual). There are two constraints:   1. The number of groups should not exceed log(N) base 2. N is the input array size. Let us assume that N = 16, always.   2. The size of the group should be at least log(N) base 2. In the below example, the size of the group should be at least 4. By searching on the WEB, I have found the following greedy algorithm. Please also see below example.   1. sort the numbers in the descending order   2. take the first K elements and put them into different groups. Here, K is the number of groups.   3. for the next (N - K) elements, put them in the group with the lowest sum. repeat this until completion of all the numbers. Can we get a better algorithm in terms of time complexity? Guidance toward a better solution to this problem is appreciated. Example:               for input array = (11, 11, 14, 16, 17, 18, 18, 19, 20, 21, 22, 25, 25, 26, 28, 31)          The solution:  (where sd: standard deviation, cv: coefficient of variation)              group           mean    sd  cv     (31, 20, 17, 11)    19.8    8.4 0.4      (28, 21, 18, 11)    19.5    7.1 0.4     (26, 21, 19, 14)    20.0    5.0 0.3     (25, 22, 18, 16)    20.3    4.0 0.2


Hosting image oriented ASP.NET MVC site; how to keep things fast?

I have a site that heavily relies on high res images being uploaded and viewed constantly. Currently it's hosted internally which keeps everything fast. I now want to move the site externally, but I am not quite sure how to keep the image viewing fast. What is important to know, is that the connection from the internal location to the external site is slow. With messaging (RabbitMQ) I can make the sending part work quite nicely. The viewing part is the thing I can't figure out. What I would like is that when viewing an image, first a local version is requested, if it's not present it will request it from the external server. Thoughts?


General recursion to tail-recursion

Is it theoretically possible to transform every kind of general-recursion into tail-recursion? Are they equivalent for example from a lambda-calculus point of view? That's a debate between me and an acquaintance. My view is that it's not possible everytime. For example if you have a function which calls itself recursively twice or three times, then you can't make all the recursive calls into tail-calls, right? Or is there always a way to reduce the number of recursive calls to one single recursive call?


How can I estimate projects when I need to include a learning curve for new technology?

Sometimes, there are research and development projects where nothing is known in advance about the technology, concepts, and client. However, the manager still needs time estimates. What can I do to produce useful estimates?


Are there any public statistics on the implementation time of software tasks?

I'd like to get better at estimating how long it will take me to complete tasks. When estimating things I know little about, I think it's best to start with base rate information and adjust it based on things I _do_ know, rather than to go on 'gut feeling' which is what I normally do, and is generally optimistic. What I lack is that base rate information. Are there any statistics available which give typical ideal man-hour costs (or some other metric) based on some property/properties of the task in question? For some context, I work as a programmer in the video games industry, and I'm talking about chunks of work that typically take somewhere between 2-16 hours, though occasionally drag on far longer than that... ;) I realise this is a big ask, but I have to start somewhere! Things I've already tried:   * google - my search terms appear to be too general - lots of irrelevant results.   * This question \- asks for overall estimate, in a different domain. Unsatisfactory answers.


Is this Hybrid of Interface / Composition kosher?

I'm working on a project in which I'm considering using a hybrid of interfaces and composition as a single _thing_. What I mean by this is having a contain*ee* class be used as a front for functionality implemented in a contain*er* class, where the container exposes the containee as a public property. Example (pseudocode):               class Visibility(lambda doShow, lambda doHide, lambda isVisible)         public method Show() {...}         public method Hide() {...}         public property IsVisible         public event Shown         public event Hidden          class SomeClassWithVisibility         private member visibility = new Visibility(doShow, doHide, isVisible)         public property Visibility with get() = visibility         private method doShow() {...}         private method doHide() {...}         private method isVisible() {...}      There are three reasons I'm considering this:   1. The language in which I'm working (F#) has some annoyances w.r.t. implementing interfaces the way I need to (unless I'm missing something) and this will help avoid a lot of boilerplate code.   2. The containee classes could really be considered properties of the container class(es); i.e. there seems to be a fairly strong has-a relationship.   3. The containee classes will likely implement code which would have been pretty much the same when implemented in all the container classes, so why not do it once in one place? In the above example, this would include managing and emitting the Shown/Hidden events. Does anyone see any isseus with this Composiface/Intersition method, or know of a better way? **EDIT 2012.07.26** \- It seems a little background information is warranted: Where I work, we have a bunch of application front-ends that have limited access to system resources -- they need access to these resources to fully function. To remedy this we have a back-end application that can access the needed resources, with which the front-ends can communicate. (There is an API written for the front-ends for accessing back-end functionality as though it were part of the front-end.) The back-end program is out of date and its functionality is incomplete. It has made the transition from company to company a couple of times and we can't even compile it anymore. So I'm trying to rewrite it in my spare time. I'm trying to update things to make a nice(r) interface/API for the front-ends (while allowing for backwards compatibility with older front-ends), hopefully something full of OOPy goodness. The thing is, I don't want to write the front-end API after I've written pretty much the same code in F# for implementing the back-end; so, what I'm planning on doing is applying attributes to classes/methods/properties that I would like to have code for in the API then generate this code from the F# assembly using reflection. The method outlined in this question is a possible alternative I'm considering instead of implementing straight interfaces on the classes in F# because they're kind of a bear: In order to access something of an interface that has been implemented in a class, you have to explicitly cast an instance of that class to the interface type. This would make things painful when getting calls from the front-ends. If you don't want to have to do this, you have to call out all of the interface's methods/properties _again_ in the class, outside of the interface implementation (which is separate from regular class members), and call the implementation's members. This is basically repeating the same code, which is what I'm trying to avoid!


Declare variable as interface

When should or shouldn't a variable be declared as a custom Interface type? When walking through some code, I required to know what was happening here:               Public Class MyMainProject         ....         Public Sub DoMyWork()             Dim objIMyInterface As IMyInterface             ....             objIMyInterface = GetReturnObject()         End Sub         ....     End Class      According to what I saw, `objIMyInterface` is only being used for one thing. I didn't know how many classes `implement` it, but there's no casting of similar types in this code. `objIMyInterface` is used just like a regular type, not anonymous in the least. Second of all, my research helped a little... `GetReturnObject` happens to return an instance of `IMyInterface`. The return object of `GetReturnObject`, of course, has a call to another method.               Public Function GetReturnObject() As IMyInterface         Dim retObject As IMyInterface         ...                 retObject = AnotherMethod()         ...         Return retObject     End Function      So I try to step into `AnotherMethod`, but it's in a project with no symbols. So after some research, I find the source and go through it. After repeating this process a few times, I eventually get to something like this:               Public Function FinalMethod() As IMyInterface         Dim FinalObject As MyClassType         ...                 FinalObject = GetMyClassType()         ...         Return FinalObject      End Function      Yay! `GetMyClassType` returns `MyClassType`! I go to that Class and of course:               Public Class MyClassType         Implements IMyInterface         ...     End Class      What I end up finding out is that `IMyInterface` is used by nothing else but this class. No biggie, it's all good code by the looks of it. But then I go back to my original project I notice this:               Public Class MyMainProject         ....         Public Sub DoMyWork()             Dim objIMyInterface As IMyInterface             ....             objIMyInterface = GetReturnObject()         End Sub         ....         Public Sub OtherWork()             Dim objMyType As MyClassType             ....         End Sub         ....     End Class      The guy who created this is long gone, but I'd like to know what your thoughts are on which method should be used. Should I declare both as `IMyInterface`? Or both as `MyClassType`? The code works fine either way.


Version control implementation advice on legacy websites?

Assuming no experience with version control systems, just local to live web development. I've been dropped in on a few legacy website projects, and want an easier and more robust way to be able to quickly push and revert changes en masse. I'm currently the only developer on these projects, but more may be added in the future and I think it would be beneficial to set up a system that others can use.


Implied precision of floating-point functions

While reviewing another programmer's implementation of a function to calculate the normal distribution CDF, I made a suggestion to either replace the entire implementation with Python's built-in functions or use SciPy, a common scientific library. Another programmer pointed out that neither `math.erfc()` nor `scipy.stats.norm.cdf()` provides any precision guarantees in their documentation. Therefore, I should be more cautious about replacing an approximation algorithm (which was taken from a respected source, and which had documented error bounds). To be honest, the thought to doubt the accuracy and precision of a built-in or library function had never crossed my mind. After all, I've been calling functions like `sin()` and `sqrt()` for years without much thought — why should `math.erf()` or `scipy.stats.norm.cdf()` be any different? But now, I'm concerned. My questions are:   1. In general, if the documentation makes no special mention, is it implied that these kinds of functions are completely accurate to the last decimal place, within the precision offered by IEEE double-precision floating-point?   2. Is that true for Python's `math.erf()` or SciPy's `scipy.stats.norm.cdf()` in particular? How can you tell?   3. This man page for `sin()` says… > These functions may lose accuracy when their argument is near a multiple of > pi or is far from 0.0. Why should such caveats exist, when the sine function is periodic and symmetrical? There seems to be a burden placed on the caller to canonicalize the input to obtain optimal accuracy. On the other hand, Mozilla's documentation for `Math.sin()` says nothing about accuracy or precision. Does that mean that it is fully accurate, or is it "common knowledge" that `Math.sin()` would only be accurate in certain circumstances in JavaScript, like everywhere else?


Which design patterns would I use for this algorithm?

I need to create a string using the following algorithm:   1. Generate a GUID as a byte array.   2. Convert that GUID to a string.   3. From this string, get the UTF-8 encoding as a byte array.   4. From this byte array, hash those bytes to another byte array.   5. From this byte array, get the base64 encoding as a string.   6. Append a string constant to this string. What design pattern(s) would I use? I am thinking builder and/or chain-of- responsibility, although I am not sure I would handle the changing between string and byte array types. **UPDATE:** I am programming in an object-oriented language (C++, Java, C#). The encoding of UTF-8 may change in the requirements, as well as the hashing algorithm in step 4. I am asking about design patterns to adapt for a change in requirements.


Technical documentation of Android app

You are joining the development team of an existing Android app and are handed a technical document about it. What information would you like it to have?


Which C# practices should be avoided in C++?

I'm currently teaching myself C++. I'm very proficient at C#, and was wondering which common practices in C# can lead to difficulties in C++, and what a C++ programmer should do instead.


What exactly is the Garbage Collector in Java?

I think I generally know what the Garbage Collector in Java does, but It's praised a lot, so I thought maybe I'm missing something about it's functionality. What I know is, that the GC takes care of erasing from the memory objects that have no reference to them, and thus are unreachable by the programmer. For example, if inside a loop I'm constantly creating a `new Object()`, the previous ones will eventually get deleted by the GC (correct me if I'm wrong). This is very useful for me as a Java programmer, and spares me a lot of headache that I assume C++ programmers have to deal with - manually deleting objects from the memory (again, correct me if I'm wrong). This feature is awesome, but is there anything more to the Garbage Collector? Am I missing something?


How do you name your private variables in C#?

What is the best practice, most commonly accepted naming conventions for private variables in C#?   1. `private int myInteger;`   2. `private int MyInteger;`   3. `private int mMyInteger;`   4. `private int _myInteger;`   5. `private int _MyInteger;`   6. Mysterious other option Which do you use and why? (My company is fairly new to C# and I would like to pick the most "industry accepted" method to try and get into our coding standard.)


In a web application backed by a database, how often should I validate data?

> **Possible Duplicate:**   >  Data input validation - Where? How much? Given that I have a web application with a user facing form that will store information in a database (that will be used by other applications as well), it seems to me to be worthwhile to validate 3 times: On the web client side via javascript to save postbacks to the server when the user enters bad data or forgets a field On the server side because we can't trust the web client to have validated the data and saves calls to the database when the data is invalid On the database side because this is the only way to ensure that the data stored in the database is valid. On the one hand, this seems excessive and violates the DRY principle. On the other hand, the performance would be noticeably different if I had to submit the request, send it to the database and return an error generated by the database for bad or missing user information. What is a reasonable amount of validation?


How much data validation is too much?

> **Possible Duplicate:**   >  Data input validation - Where? How much? I'm a new PHP developer and am into Powershell quite a bit but this question is language agnostic. I've been questioning my code quite a bit lately thinking about how many nets I should setup to catch exceptions, verify results, etc. I realize that I could go crazy trying to verify each and every line of code but at the same time I want the code as resilient as possible. I'm not talking about user input but verifying output from methods. Is there some standard or rule of thumb to go by when deciding when and where to do data validation?


Does JAXP natively parse HTML?

So, I whip up a quick test case in Java 7 to grab a couple of elements from random URIs, and see if the built-in parsing stuff will do what I need. Here's the basic setup (with exception handling etc omitted):               DocumentBuilderFactory dbfac = DocumentBuilderFactory.newInstance();     DocumentBuilder dbuild = dbfac.newDocumentBuilder();     Document doc = dbuild.parse("uri-goes-here");      With no error handler installed, the parse method throws exceptions on fatal parse errors. When getting the standard Apache 2.2 directory index page from a local server: a SAXParseException with the message _White spaces are required between publicId and systemId._ The doctype looks ok to me, whitespace and all. When getting a page off a Drupal 7 generated site, it never finishes. The parse method seems to hang. No exceptions thrown, never returns. When getting http://www.oracle.com, a SAXParseException with the message _The element type "meta" must be terminated by the matching end-tag " </meta>"._ * * * So it would appear that the default setup I've used here doesn't handle HTML, only strictly written XML. My question is: can JAXP be used out-of-the-box from openJDK 7 to parse HTML from the wild (without insane gesticulations), or am I better off looking for an HTML 5 parser? PS this is for something I may not open-source, so licensing is also an issue :(


Forgetting to merge changes from trunk to branch

Recently, I forgot to merge changes from trunk to our maintenance branch. This caused us to rebuild - twice - and put QA on hold for two days while we fixed the mess. Normally, when committing to both branches, I commit a single changeset to trunk, and immediately merge it over to the maintenance branch.   However, this time there were 12 changesets spanning many code review changes, and I failed to merge all of the changes over. I had only merged one change over, which completely threw me off - I thought I remembered it was a rollup commit of all of the other changesets, but it wasn't. After some development discussion, we decided that the best approach would be to make 1-to-1 trunk and maintenance branch commits, so you could visually verify that all of the code was there. Is there a way to enforce changeset commits for a given fix-for version?   We use JIRA, Fisheye, and Crucible, and our Fisheye workflow won't let you resolve an issue unless the code reviews are complete. I'd like something similar that enforced parallel checkins on trunk and maintenance branches, based on the fix-for version specified in the issue. Or is there a better solution to this whole mess besides "don't do that"?


What's the normal way machine-learning algorithms are integrated into normal programs?

I'm currently taking a machine learning course for fun, and the course heavily focuses on Matlab/Octave to write the code. One thing mentioned in the course is that, while Matlab/Octave are great for prototyping, they're very rarely used for production algorithms. Instead, those algorithms are typically rewritten in C++/Python/etc., using appropriate libraries, before reaching customers. Fair enough; I get that. But here's my question: is that done for cultural reasons, for technical reasons, or because there is really no language that provides Matlab/Octave-like fluidity, but in a compiled form that can be linked from C/C++/`$MainstreamLanguage`? The game industry uses Lua for game logic because it's easy to embed, and vastly superior for expressing things like AI. Likewise, there are Prolog variants for rules-heavy applications, Scheme variants for compilers, and so on. If there's a matrix equivalent language, what is it? If there isn't, why is this field different?


Why does Scala require functions to have explicit return type?

I recently began learning to program in Scala, and it's been fun so far. I really like the ability to declare functions within another function which just seems to intuitive thing to do. One pet peeve I have about Scala is the fact that _Scala requires explicit return type in its functions_. And I feel like this hinders on expressiveness of the language. Also it's just difficult to program with that requirement. Maybe it's because I come from Javascript and Ruby comfort zone. But for a language like Scala which will have tons of connected functions in an application, I cannot conceive how I brainstorm in my head exactly what type the particular function I am writing should return with recursions after recursions. This requirement of explicit return type declaration on functions, do not bother me for languages like Java and C++. Recursions in Java and C++, when they did happen, often were dealt with 2 to 3 functions max. Never several functions chained up together like Scala. So I guess I'm wondering if there is a good reason why Scala should have the requirement of functions having explicit return type?


Why don't all companies buy developers the best hardware?

I must be missing something. The cost of employing a programmer in my area is $50 to $100 an hour. A top end machine is only $3,000, so the cost of buying a truly great computer every three years comes to $0.50/hour. ($3000/(150 wks * 40 hours)) Do you **need** a _top-end_ machine? No, the $3000 here is to represent the _most that could possibly be spent_ not the amount that I would expect. That's roughly the cost of a top-end iMac or MacBook (17 inch). So suppose you can save $2000 every three years by buying cheaper computers, and your average developer is making $60. (These are the most charitable numbers that I can offer the bean-counters. If you only save $1000, or $750, it only strengthens my case.) If those cheaper computers only cost you 10 minutes of productivity a day. (Not at all a stretch, I'm sure that my machine costs me more than that.) then over 3 years the 125 lost hours would add up to a loss of $7500. A loss of 1 minute a day ($750) would give a net gain of $1250, which would hardly offset the cost of poor morale. Is this a case of "penny-wise and pound-foolish" or have I oversimplified the question? Why isn't there universal agreement (even in the 'enterprise') that software developers should have great hardware? **Edit:** I should clarify that I'm not talking about a desire for screaming fast performance that would make my friends envious, and/or a SSD. I'm talking about machines with too little RAM to handle their regular workload, which leads to freezing, rebooting, and (no exaggeration) approximately 20 minutes to boot and open the typical applications on a normal Monday. (I don't shut down except for weekends.) I'm actually slated to get a new machine soon, and it will improve things somewhat. (I'll be going from 2GB to 3GB RAM, here in 2011.) But since the new machine is mediocre by current standards, it is reasonable to expect that it will also be unacceptable before its retirement date. **Wait! before you answer or comment:**   1. $3000 doesn't matter. If the machine you want costs less than that, that's all the more reason that it should have been purchased.   2. I'm not asking for more frequent upgrades. Just better hardware on the same schedule. So there is no hidden cost of installation, etc.   3. Please don't discuss the difference between bleeding edge hardware and very good hardware. I'm lobbying for very good hardware, as in a machine that is, at worst, one of the best machines made three years ago.   4. $50 - $100 / hour is an estimate of _employment cost_ \- not salary. If you work as a contractor it would be the billing rate the contracting agency uses which includes their expenses and profit, the employers Social Sec. contribution, employers health care contribution etc. Please don't comment on this number unless you know it to be unrealistic.   5. Make sure you are providing new content. Read all answers before providing another one.


How much should I pay to Microsoft when I am selling a desktop software built on VB.NET?

I am using Microsoft's free tool Visual Basic 2010 Express (downloaded from here ) to develop a desktop application with database features using Microsoft access as the database. Connectivity is being done by OleDbConnection. The software is now complete. I am planning to sell it for money. The software is going to cost 400$ to end customers. How much and where should I pay money to Microsoft?


Implementing non-fixed length array support in a compiler

I'm thinking of building a language for PIC microcontrollers. I want to be able to use non-fixed size arrays, like this:   1. Declare the variable as `int[]`   2. Wait for input from serial connection   3. Make the variable _`input`_ long I think such a feature would be useful, but don't know how I should go about implementing this in a compiler which compiles to assembly. I want the arrays to be stored on consecutive register addresses, of course. Since I'm working with PICs, this has to be very memory efficient. When someone writes `int[]`, I don't think it's a good idea to reserve memory space for the variable yet, is it? Then the array would have a fixed maximum size. For example, when the array gets reserved memory address 5-100, and other variables get 4 and 101, the array has fixed borders and can't grow any bigger than 96 registers. Also, when I'd reserve memory from the start, let's say _x_ bytes, and I in the end only need _y_ bytes, I'm wasting _x_ \- _y_ bytes. I don't want that. That means the only option I see is initializing the array and reserving space in the microcontroller, on the fly. This will take up some memory and execution time, of course. I thought of a system like this:   * Initialize an array `int[` _`x`_`] = {int, int}` which holds pointers to the start and end of arrays that are not initialized from the beginning - _`x`_ would be the maximum amount of arrays (this is a concession, but is better than a maximum length for all arrays)   * Store a variable _c_ = 0 to indicate the number of arrays used   * Store the borders of the initialized (reserved) memory in a variable somewhere   * When an array gets a length:     * Put pointers to the start (the current border) and end (the current border + the length) in the array from the first point at index _c_     * Increment _c_ I think this would work (wouldn't it?), but there a few cons, mainly concerning memory: I need to store the array, _c_ and the current memory borders as overhead. Would there be a better way to implement non-fixed size arrays in a language for PIC microcontrollers? My requirements are:   * Low memory overhead   * The array length does _not_ have to be changed on the fly   * With the system I thought up, one cannot store values in arrays that haven't been initialized yet. If there would be a system that can store values in an array of undefined length, that would be an advantage   * Faster systems (at runtime, compile time doesn't matter) are preferable


how do you call the “number of seconds since epoch” format

I wanted to gives a good name for a variable date_in_(number of seconds since epoch format) I googled it and couldnt find anywhere the term to use. Any ideas?


Is it a good idea to appoint one of the scrum team member or scrum master as Product Owner?

Lately we had a project, in which client was busy touring. As usual scrum team was formed, management decided to appoint our analyst as Product owner since Client won’t be able to participate actively. Analyst was the one who worked closely with client for requirement analysis and specification drafting. Client doesn’t have the time to review first two releases. Everything went smoothly until, client saw third release; he wasn’t satisfied with some functionalities, and those was introduced by make shift Product Owner (our analyst). We were told to wait till design team finished mock-up of all pages and client checked each one and approved to continue working. Scrum team is there, but no sprints – we finished work almost like classic waterfall method. Is it a good idea to appoint scrum team member or master as product owner? Do we need to follow scrum in the absence of client/product owner participation?


Changing story-point estimates after closing the story

In a running multi-year multi-team project there is a set of stories that have been fully estimated and closed, having fulfilled the definition of done. Time has progressed and possibilities in Jira Agile have advanced, making it more useful to group user stories using an Epic to describe the total goal of the set of stories. There are new stories groomed and estimated that belong to these same epics, however the comparison between the old story points and the new story points cannot be made to fit: the new story points are worth less per story point. Is it acceptable to re-estimate the completed stories, increasing the number of story points that were completed a year ago? What sort of problems may arise from this if the changes are handled as scope changes?


API design: concrete vs. abstract approach - best practices?

When discussing APIs between systems (on the business level) there are often two different point of views in our team: some people prefer a more - lets say - ~~generic~~ abstract approach, other a straight forward "concrete" approach. Example: the design of a simple "person search" API. the concrete version would be                searchPerson(String name, boolean soundEx,                   String firstName, boolean soundEx,                   String dateOfBirth)      People in favour of the concrete version say:   * the API is self-documenting   * it is easy to understand   * it is easy to validate (compiler or as a webservice: schema validation)   * KISS The other group of people in our team would say "That is just a list of search criteria"               searchPerson(List<SearchCriteria> criteria)      with               SearchCritera {       String parameter,       String value,       Map<String, String> options     }      with possibly making "parameter" of some enumeration type. Proponents say:   * without changing the (declaration of) the API the implementation can change, e.g. adding more criteria or more options. Even without synchronizing such a change at deployment time.   * documentation is necessary even with the concrete variant   * schema validation is overrated, often you have to validate further, schema cannot handle all cases   * we already have a similiar API with another system - reuse The counter-argument is   * lots of documentation about valid parameters and valid parameter combinations   * more communication effort because it's more difficult to understand for other teams Are there any best practices? Literature?


How to use BDD to unit test a compiler?

My team is writing a compiler for a domain-specific language (DSL) which will be integrated into an IDE. Right now, we are focused on the analysis phase of the compiler. We are _not_ using any existing parser-generators (such as ANTLR) because we need real-time performance and highly detailed error/warning/message information. We have   1. classes, each of which represents a node in the concrete syntax tree for the language, as well as   2. classes which act as annotations for each node (i.e., for errors and additional information), as well as   3. internal classes which build and manipulate the concrete syntax tree (i.e., lexer, parser, cache for strings, syntax visitors). We are trying to decide on an overall strategy for organizing our tests. Our company is pushing behavior-driven development (BDD) and domain-driven design (DDD). Although we are building a DSL for our company’s domain, the domain of the compiler is a programming language. We are still in the process of building the compiler and have some tests already. We are aiming to have 100% statement coverage. We currently have tests in which we input source code to the syntax tree builder, and then run a verification on each property of every node of the resultant syntax tree to make sure that the expected information (line number, relevant error(s), child/parent tokens, width of token, type of token, etc.). Now, since each node is its own class, and certain annotations and errors attached to a node are separate classes, this test ends up referencing many classes. We currently have tests for certain classes such as the lexer in which we can isolate the input (a string) and the output (a list of tokens) from other classes (e.g., the classes for the nodes of the syntax tree). These tests are more granular. Now, the tests in the paragraph immediately above can be put in correspondence with the class under test (e.g., lexer, string cache). However, the tests from the second paragraph above really test the whole analysis phase of the compiler; that is, each test can have well over 300 assertions for the syntax tree, given the input source code. The tests are for the behavior of the analysis phase. Is this an appropriate testing strategy? If not, what should we be doing differently? What organization strategy should we use for our tests?


Javascript: initiating file download and routing file off via POST

Every so often (seems about once a year) I get a chance to play with JS.   While not proficient, I'm comfortable enough to get the job done if I have some good references. At this point, I feel like I'm just _not_ coming up with the right search terms to find anything useful. **GOAL:**   I'm looking for examples, tips, advice and/or links to any documentation/articles/instructions that my help. **BACK STORY:**   We have a vendor on whose site we search part numbers.   The results page has basic spec's and stat's, and there is a download link for a pricing sheet.   We have developed a tool to parse through the sheet and automatically enter the pricing into our system. The current workflow is to download the file and save it locally, and then upload the file to our form. **TASK:**   What I intend to do is make a bookmarklet to cut out a few steps.   I'd like to have the JS initiate the DL (?straight into a temp location?), and then POST the file right off to the current form-processing `action` url.   Done. **SUMMARY:**   Of course, snippets and examples are always _**awesome**_!!   Beyond that, any-and-every bit of sharing will be appreciated


How to write JavaScript while keeping HTML/CSS out of it

What is / are some recommended ways to write JavaScript as to control behavior of showing HTML on screen, while keeping well-maintainable code? Basically, I started to look for ways to keep HTML/CSS out of JS (assuming it's the recommended practice), but I might as well check into the latest ways of writing JavaScript well. See below for more details. **My specific problem** I have JS files that look something like this:               var selection = eval("(" + document.getElementById("result").innerHTML + ")");          if (selection[index].selected) {         result += '
';         result += '
';         result += 'Data	';         result += '
';              var flag = "All";              if (selection[index].flag == 'P')             flag = "Premium";              result += '
';         result += 'Flag	';         result += '' + flag + '	';         result += '
';         result += '
';     }          document.getElementById('final').innerHTML = result;      In fact, entire JS codebase I work with is plagued by this. You can see here HTML, CSS JS, and JSON (`selection` var gets its content from JSON prepared by PHP earlier). I want to make this better. **My experience level** I am new to writing good JS or to having experience with JS patterns, tools, tips, techniques, and so on. I am looking for help with those. **My specific issue:** I have a series of tables and data to be shown to the user. It is a "series", so user can select which "element" of the series is currently active on the screen. An "element" is essentially an HTML partial (with JS and CSS and HTML), and is described below: "element": a block of HTML that serves as static data (tables, titles, and divs), and a long JSON string that encodes some previously prepared data. JSON string is assigned to a JS variable and that JSON data/JS variable stores records numbered `1` through `n`, where each `i` holds various data to be injected into the block of HTML, forming "HTML partial". I have navigational buttons on the screen, allowing user to step through the "series", where the HTML is the same, but the data inside it changes. I am looking for a good way to write this "step through HTML blocks" functionality using what is considered to be good maintainable JS code. Namely, I am looking for the following characteristics:   * separation of concern   * cleaner code - I need tools or techniques to allow me to avoid mixing HTML with JS with CSS (as in seen my example), unless where necessary or convenient. (what I have now is not convenient)   * I prefer techniques rather than tools, but open to considering/evaluating well-established tools. By "techniques", I mean pure JS, HTML, CSS, PHP approaches. By "tools", I currently know and trust jQuery, and for other tools prefer to have some track record to them. **Note on HTML visibility/hiding** I should also perhaps note that in my case HTML is static, aka it does not change structurally, as I step through the elements. However, based on the JSON/selection variable, some blocks of HTML are show/hidden (as is shown in my example). Once they are shown/hidden at page render time, they stay shown/hidden throughout stepping through selection.


Can I close the source of my application if I used code under the Mozilla Public License in it?

I need to use a group of Java classes licensed under the Mozilla Public License. I want to close the source code of my application. Is it possible without charging a fee for the MPL classes?


Why does the use of interface-based programming appear to be limited to behaviour?

I have been doing a little thinking about inheritance vs. realization vs. composition. I am not about to post the whole detail here. So I was wondering, when we are not talking about creating interfaces to facilitate unit testing: Why does interface-based programming seem to focus upon the grouping of common behaviour, e.g., IPettable (for an animal), IEditable (for a user control), ISubmitable (for a form), etc. Why does the use of interface-based programming appear to be limited to behaviour and not essences. We could pragmatically use an interface, not so much realize behaviour but, to realize commonsense physical similarities which could have nothing to do with behaviour? It is not that there is some limiting feature within interface-based programming that we do not think to do this. This means that there is a tendency to use an interface in a fraction of its possible ways; so how come?


Getting experience overseas

I'm English and been living in central Europe for most of my adult life. More recently, I've been having high hopes in a degree in Informations Systems Management and a few months Java training to get into a job as software developper. However, it seems the lack of relevant job experience and age (just turned 36) could form a serious obstacle and cause all of this effort to go to waste. A contact got into a job in London with little formal training so I'm wondering if I should contemplate getting experience overseas. The alternative would do my best to get a position here and perhaps continue with a Master's degree (education is dirt cheap). However, if things don't work out on the job front I fear that I may be sabotaging my chances of getting a good career off the ground. What do you think? Have you been down this road or know someone who has? Would a profile like mine stand a better chance in some countries you know?


Contract-to-hire - determining rate?

I'm in discussion with a company for a full-time web development position. Since the position would require telecommuting or a relocation of my family, we've agreed on doing 2-4 weeks of contract work as a sort of evaluation period. Now they're asking what I would like my contract rate to be. I know generally what I'd like my salary to be, should this progress to the full time job, but I have no idea how that translates to the contract work. Taxes are different (I'm in the U.S.) and there are no benefits since I'm not yet an employee. Should I aim about on par with the salary I'm eventually hoping for, or do I need to adjust upwards to make up for taxes, etc.? (Or would I be expected to adjust down, since this is a sort of extended interview process?)


Is there an encyclopedia of algorithms?

Is there an encyclopedia of algorithms similar in style to the Handbook of Mathematics? It seems useful to have large numbers of them available in one place. I know the Art of Computer Programming is considered a good source but it does not seem encyclopedic so much as instructive. > ### Moderator Note > > We're looking for long answers that provide some explanation and context. > Don't just list a book: please explain _why_ you're recommending a book or > resource. Answers that don't explain anything will be deleted. See Good > Subjective, Bad Subjective for more information.


Should one create underlying architecture to increase flexibility - in advance or when needed?

In this question I asked: Is the cost of designing more levels of abstraction to allow loose coupling worth the benefits, or not? People said that it's often worth the cost, but one should sense whether his/her application will actually be using this underlying design later on, or if it's just going to be a waste of time. My new question is: Should one create the infrastructure to allow flexibility and maintainability **in advance** \- thus making the development 'cleaner' and more 'organized', as things are developed on existing infrastructure and abstraction levels? With this approach, you desing the underlying infrastructure while not having much knowledge on how things will actually be implemented later. Thus, you might be coding things that might not be used later, and waste your time. But, the development will be cleaner and more organized. Or should one create infrastructure to increase flexibility and make things more loosely coupled, **during** the implementation of something - thus wasting less time on things that might not actually be used later? This approach prevents you from coding things that won't be used, but forces you to design underlying abstraction levels and designs **for existing code** , thus modifying existing code, instead of coding the underlying designs **before** coding the code that uses these designs. **Example for approach 1:** "Okay, now we start making this relatively large part of the application. This part will generally have to do with reacting to a couple of GUIs. Let's make an underlying level of abstraction for this part of the program, to later use when we implement it." **Example for approach 2:** "Okay, I'm in the middle of designing this part of the program. While working on it, I see this part better be loosely coupled. Let's make another level of abstraction to allow it, and modify this code to use that level of abstraction". Which approach makes more sense, or is more common?


Model-View-Presenter implementation thoughts

I'm trying to get a good grasp of how to implement good decoupling between a UI and the model, but I'm having trouble figuring out exactly where to divide the lines. I've been looking at Model-View-Presenter, but I'm not sure exactly how to go about implementing it. For example, my View has multiple dialogs..   * Should there be a View class with instances of each of the dialogs? Then in that case, how should the dialogs interact with the Presenter? ie. if an individual dialog needs to request data from the Model via the Presenter, how should the dialog get a reference to the Presenter? Via a reference to the View given to it during construction?    * I was thinking maybe the view should be a static class? Then the dialogs GetView and get the Presenter from there...    * I'd been thinking about setting it up the Presenter with ownership of the View and Model (as opposed to the View having the Presenter and Presenter having Model) and the Presenter registering callbacks for events in the View, but that makes it seem a lot more coupled (or language depended, at least.) I'm trying to:   1. make this as decoupled as possible    2. ideally make it possible to couple the Presenter/Model with Views of other languages (I've not done a ton of inter-language stuff, but I know it's possible, particularly the more `void(void)` I can stick to, at least a C# app with a C++ library...    3. keep the code clean and simple  So.. any suggestions how the interactions should be handled?


When to use packages or Repositories in Laravel?

I'm a Laravel (PHP) developer, and new with DI, Packages (workbench) and Repositories (Pattern). I want to know about the best concept/methodology for a more flexible design; ie. the project can grow and become something very modular. For example, after watching some Jeffrey Way videos in Laracasts I decide use that pattern:   * app/   * app/config   * app/controllers   * app/database   * app/views   * app/patrickmaciel (psr-4 in composer.json)   * app/patrickmaciel/user (repositories, eloquent model, validation, etc)   * app/patrickmaciel/group    * app/patrickmaciel/post    * app/patrickmaciel/billing   * app/patrickmaciel/helpers   * app/patrickmaciel/filters But after watch more videos, and reading more about flexibility, I see developers using **packages** instead of this psr-4 alternative (composer.json):               "require": {         "patrickmaciel/group",         "patrickmaciel/user",         "patrickmaciel/post",         "patrickmaciel/billing",         "patrickmaciel/helpers",         "patrickmaciel/filters"     }      So, **what is better for more flexibility**?


which open source licence to use with my project?

I am working on a software project in my college. And I want to make it open source. But I want that people to only contribute to the project. I don't want that they should also release a project using my source with some modifications. So what will be the best Licence to use with my project ?


Teaching a QA person to program

I have a friend who has been doing QA for about a year and wants to further their career. I have always leaned to C using gcc and makefiles as you have to do everything yourself. I have also read the best ways to teach a beginner to program, but in this case should I start with the technology his company uses, namely .NET? Is there any drawback to learning a object-oriented high-level language first, or should I stick with C?


Pooling (Singleton) Objects Against Connection Pools

Given the following scenario   * A canned enterprise application that maintains its own connection pool   * A homegrown client application to the enterprise app. This app is built using Spring framework, with the DAO pattern While I may have a simplistic view of this, I think the following line of thinking is sound:   * Having a fixed pool of DAO objects, holding on to connection objects from the pool. Clearly, the pool should be capable of scaling up (or down depending on need) and the connection objects must outnumber the DAOs by a healthy margin. **Good**   * Instantiating brand new DAOs for every request to access the enterprise app; each DAO will attempt to grab a connection from the pool and release it when it's done. **Bad** Since these are service objects, there will be no (mutable) state held by the objects (reduced risk of concurrency issues) I also think that with #1, there should be little to no resource contention, while in #2, there'll almost always be a DAO waiting to be serviced. Is my thinking correct and what could go wrong?


How should I approach storing single boolean results for a whole table?

I previously asked this question on stack overflow. But have not received any responses that might help me. So I thought I would try here. http://stackoverflow.com/questions/24883527/best-way-for-me-to-approach- storing-single-boolean-results-for-overall-table Essentially I am creating a Java application that reads and writes form a database. In the course of the design it creates new tables with new information as well as linking the information from those tables. Anyway, the question is, the client has requested that the JTable that I use to display the Table names from the database now include 3 columns each with a checkbox. What would the best action be for me to store the data from these checkboxes? Some of the methods I have considered are   1. Store the information within the table in new columns (this will involve changing the code for modifying and writing of these tables, which is possible)   2. Create a new table and store the other table names and the values in columns within (have it on load check the current names against the meta data and add/remove where needed)   3. Create a properties file and pull the information from that, where it matches the names from the MetaData (ie. TableName=yes,no) The option that strikes me as the easiest/fastest to do/run would be to go with option 3, and make a properties file. NOTE: Within the application I already have methods for reading and writing from a properties file, as well as to create a new table within the database, and to write/read from the rows of each table.


Domain-specific Interfaces

Are there any real benefits of using interfaces over abstract classes in a domain model? Does anyone have any experience using interfaces in a domain model in a real project? From a technical perspective, DDD defines stereotypes like _aggregate_ , _value_ , _repository_ , etc. Repositories then, for example, can be defined as interfaces like `ICustomerRepository` which are then implemented by the infrastructure. Now that's a valid use case for an interface, since there can be multiple implementations of the repository (mocks, fakes etc.). However that is an entirely technical reason for using it: here the interface is only used to separate domain-specific repository from its technical implementation. But what about purely domain-specific interfaces? Has anyone ever encountered a situation in which both the interface and its realization were non- technical? In particular, what reasons could speak for choosing an interface over an abstract class when implementing a domain-specific type? Maybe when multiple inheritance is involved it would be required, but how probable is it and could it be considered a good design then?


Proper way to measure the scalability of web Application

Let's say that I have a web Application where i'm going to have 300 users and each one have to see data on real time, imagine that each client make an ajax call to the server to see in real time what's happens with the changes of the data, this calls are made each 300 ms per user. I know that i can run a simulation to see if the hardware of my server supports this example. But what happen's if the number of users start to grow up. Is there a way that i can measure the hardware needed to handle this growing behavior, a software, a formula, algorithm or maybe recommend me if i need to implement an distributed application with multiplies servers and balance the loads.


Is SVN out of style?

It's been only several years since I migrated from Visual Source Safe to SVN. And SVN for me is still kinda "WOW! I can do so many things! SVN is so cool!" But many people around me keep saying "SVN? Really? Meh..." And there's so many of them that I'm worried. Should I move my team to Git / Mercurial or some other fancy thing? I know I sound ridiculous and the obvious answer would be "stay with what works for YOU". SVN does work for me... But every time I create a new project in my repository I keep asking myself - may be this was the time to move? So... Is SVN really that bad? Do I miss a huge opportunity by sticking with it?


Do I need to learn Design Patterns if I'm preparing to be Android Developer?

Please advise if it is required to learn design patterns if I'm studying for Android development?


Why would a programmer want to separate implementation from interface?

The bridge design pattern separates implementation from the interface of a program. Why is this advantageous?


Should a developer accept a workload estimation done by a Excel macro?

In a new project, a friend had to write tests where the time required to write them was calculated by an Excel macro written by his non-developer manager. In such circumstances, should a developer accept the responsibility to write and run the tests in the calculated time? Are the results of these test trustworthy? For information, my friend refused to be responsible for estimations he didn't made, ask succeed to work on another project, and have been replaced by an inexperienced out-of-the-school yes-guy.


Python's Django or Delphi's IntraWeb?

Well, forgive me if it is an off-topic question. I have no knowledge about web programming, so I apologize in advance, if it is a stupid question. I will start to build a web based application. To be more specific, I will make a webpage which will have components like buttons, textboxes and etc. It will use a database to store information. My question is, which one is better to learn for that purpose? Python's Django or Delphi's IntraWeb? I know both Delphi and Python(although I know Delphi better).


How can I break my vendor lock-in situation?

I'm developing software for about 10 years. I began on QBasic and now I'm developing .NET using C# language. I'm always trying to follow the best design patterns and principals like SOLID. In short I'm very happy with my work while as a tiny ISV I'm free to choose between technologies. Of course we almost develop mid-size web applications for start-ups. Although I'm moving to MS open stack more and more (Ex. MVC, EF, etc.) and I've also tried Mono, _I feel tied to MS_. I seriously want to break this vendor lock-in situation. I want to be able to develop Windows and Web application using a strongly-type open and free (at least more free) language using the best software practices which is more vendor independent. I think I have no choice except Java. Then;   * What is the best way to start breaking this situation?   * Should I migrate to the Java platform? (I know it cost me a lot)   * Then how can I start?    * C# is an amazing language. Some of its features do not exist in Java (LINQ, real generics, async/await, etc.)! How can I get to that?


When should pointers be checked for NULL in C?

**Summary** : Should a function in C always check to make sure it is not dereferencing a `NULL` pointer? If not when is it appropriate to skip these checks? **Details** : I've been reading some books about programming interviews and I'm wondering what the appropriate degree of input validation for function arguments in C is? Obviously any function that takes input from a user needs to perform validation, including checking for a `NULL` pointer before dereferencing it. But what about in the case of a function within the same file that you don't expect to expose through your API? For example the following appears in the source code of git:               static unsigned short graph_get_current_column_color(const struct git_graph *graph)     {         if (!want_color(graph->revs->diffopt.use_color))             return column_colors_max;         return graph->default_column_color;     }      If `*graph` is `NULL` then a null pointer will be dereferenced, probably crashing the program, but possibly resulting in some other unpredictable behavior. On the other hand the function is `static` and so maybe the programmer already validated the input. I don't know, I just selected it at random because it was a short example in an application program written in C. I've seen many other places where pointers are used without checking for NULL. My question is general not specific to this code segment. I saw a similar question asked within the context of exception handing. However, for a unsafe language such as C or C++ there is no automatic error propagation of unhandled exceptions. On the other hand I have seen lots of code in open source projects (such as the example above) that does not do any checks of pointers before using them. I'm wondering if anyone has thoughts on guidelines for when to put checks in a function vs. assuming that the function was called with correct arguments. I'm interested in this question in general for writing production code. But I'm also interested within the context of programming interviews. For instance many algorithm textbooks (such as CLR) tend to present the algorithms in pseudocode without any error checking. However, while this is good for understanding the core of an algorithm it's obviously not a good programming practice. So I would not want to tell an interviewer that I was skipping error checking to simplify my code examples (as a textbook might). But I also would not want to appear to produce inefficient code with excessive error checking. For instance the `graph_get_current_column_color` could have been modified to check `*graph` for null but its not clear what it would do if `*graph` was null, other than it should not dereference it.


Deciding between obj->func() and func(obj)

I was thinking about this when I was starting to set up some code for a new project: are there any rules of thumb for when a method should be part of an object, and when it should be a stand alone function that takes an object as a parameter? EDIT: as pointed out in a comment, this can depend on language. I was working in C++ when it came to mind, though I'm this is an issue across a number of languages (and would still love to see answers that pertain to them).


What are the advantages of mainframes?

The downsides of Mainframes is well trodden ground; expensive, legacy, dwindling community, etc. I'm not particularly interested in the downsides, but I am curious if there are any benefits to mainframe hardware/software over the current Intel/AMD & Linux/Windows environment. I've been told that MFs are particularly good (and better than current servers) at heavy I/O loads. Is this still true?


When being a technical genius is not enough to be a successful developer?

There has been a lot of discussion around the excellent question "Will high reputation in Stack Overflow help to get a good job?". I immediately agreed with **JoshK** that basically said "No" (I'll will explain why), but **Joel** chimed in with lot of convincing facts which made me upvote him as well. My question is **what other skills (other than being a technical genius) do you require from a developer?** To get the job, or to _keep_ it. I believe being a genius is far from being enough. I have met many technical geniuses in various companies I have worked for that impressed me a lot, but sadly in lot of cases, they were simply fired after a few months or put in ivory towers (mainly because of internal mutiny from other developers). I've seen many in personal distress as a result of this which I understand. That's why I'm a big fan of non-technical questions for technical positions. I like to know how the candidate will interact with others (including non- technical employees), how much consideration he will have for the business, if he will work for the desired outcome, and so on. I would like to know what you require from your developers and **WHY** it's important _(after all, you hire someone to write code, don't you? Why would you want him to be assertive?)_. **Ideally, I'd like you to come up with an example question you would ask during interviews** in support of your answer.


boolean or Boolean?

I was doing edit reviews on Stack Overflow and found out that people keeps correcting the word "boolean", replacing it with "Boolean" when it appears in text (but not in source code, of course). And then I found out that the spelling checker in my browser agrees with them. Is there any rationale behind this? It seems grammatically incorrect. I think the word boolean is used in two different ways, either among programmers as a simple noun, "return a boolean", or as part of a mathematical term, "boolean logic", "boolean algebra". None of these cases seem to motivate a capital letter. You don't write "return a Float", "Fuzzy logic" or "Linear algebra" (unless of course it is at the beginning of a sentence). I suppose that the capital letter in "Boolean" somehow refers to the name George Boole. But then that doesn't make sense either. I found this link which gives some excellent examples of similar cases, where some term is named after a person, but no capital letter is used. Any consensus? What is correct? What should we use?


Legitimate use of the Windows "Documents" folder in programs

Anyone who likes their Documents folder to contain only things they place there knows that the standard Documents folder is completely unsuitable for this task. Every program seems to want to put its settings, data, or something equally irrelevant into the _Documents_ folder, despite the fact that there are folders specifically for this job1. So that this doesn't sound empty, take my personal "Documents" folder as an example. I don't _ever_ use it, in that I never, under any circumstances, save anything into this folder myself. And yet, it contains 46 folders and 3 files at the top level, for a total of 800 files in 500 folders. That's 190 MB of "documents" I didn't create. Obviously any actual documents would immediately get lost in this mess. **My question is** : can anything be done to improve the situation sufficiently to make "Documents" useful again, say over the next 5 years? Can programmers be somehow educated en-masse not to use it as a dumping ground? Could the OS start reporting some "fake" location hidden under AppData through the existing APIs, while only allowing Explorer and the various Open/Save dialogs to know where the "real" Documents folder resides? Or are any attempts completely futile or even unnecessary? * * * 1For the record, here's a quick summary of the various standard directories that should be used instead of "Documents":   * `RoamingAppData` for _user-specific_ data and settings. This is **the** directory to use for user-specific non-temporary data. Anything placed here will be available on _any machine_ that a given user logs on to in networks where this is configured. Do not place large files here though, because they slow down login/logout in such environments.   * `LocalAppData` for _user-and-machine-specific_ data and settings. This data differs for every user and every machine. This is also where very large user-specific data should be placed.   * `ProgramData` for _machine-specific_ data and settings. These are the same regardless of which user is logged on, and will not roam to other machines in a network.   * `GetTempPath` for all files that may be wiped without loss of data when not in use. This is also **the** place for things like **caches** , because like temporary data, a cache does not need to be backed up. Place your huge cache here and you'll save your user some backup trouble. "Documents" itself should only _ever_ be used if the user specified it manually by entering a path or selecting it in a Save dialog. That is the only time it is _ever_ appropriate to save stuff in "Documents".


Best way of accessing data on different pages

I'm looking for a way to load data into properties/variables etc and have this information accessible to all the pages of my app. I want the information to be loaded via a background thread to keep UI thread free. Some of the pages will have various properties of their controls binding to these global properties. Here is what I tried.   * Created a static class. All pages could access the data but can't bind.   * Changed the static class to a Singleton and used DependencyProperty's. All pages could access data and binding worked fine but cross-threading issues when accessing via background threads. I have read in various places on this subject but haven't really come up with the best method yet for my situation.