Recently I've been working on projects that heavily use threading. I think that I'm OK at designing them; use stateless design as much as possible, lock access to all resources that more than one thread needs, etc. My experience in functional programming has helped that immensely. However, when reading other people's thread code, I get confused. I am debugging a deadlock right now, and since the coding style and design are different from my personal style, I am having a difficult time seeing potential deadlock conditions. What do you look for when debugging deadlocks?


title: Group messaging of computers over internet

text: I want to be able to send messages between computers on the internet network but with minimal functionality requirement are- 1)computers can join/leave the group (I expect the group size to be a maximum of 5-10) 2)any message generated by any computer will be sent to every other node (this is the main requirement and I have short messages which need to be sent in shortest possible time: suggest network layer protocol to be used here), message wont be resent or ack (except leave)..but I still want to maintain high reliability, can I maintain it without receiving acks? one problem would be to communicate on the internet I will need some sort of NAT support? how can this be managed without a stun server? Should I use a p2p library? as I think most of the features they offer wont be needed by me could anyone suggest some here? I'm working in C++.


title: Quit my job (for a new job). Old job wants me to be available for contracting. Steps to take?

text: The company I am leaving has asked that I make myself available to answer questions and/or debug programs occasionally should the need arise. I'm not opposed to this. After searching google for some kind of standard contract for this sort of thing, I didn't see any. Is there a standard contract for this sort of thing that you use? Are there any other steps I should take to ensure this kind of arrangement works smoothly?


title: Best way to delimit variable elements of a path in code documentation?

text: Often some element of a path is variable, but the path as a whole needs to be documented in some manner for later programmers. Especially when using *nix systems, almost any character is a valid symbol for the path. Given that, I would like to delimit the variable portions of my path to prevent misunderstanding, but in a way that also survives best across different display environments (especially the browser). Methods I have seen include (example path in users home directory):   * /home/<username>/foo - needs special escape for web browser context   * /home/your_username/foo - unfortunately the variable element tends to be overlooked   * /home/{username}/foo   * /home/:username/foo Which have you seen most often or had the most success with and why? If a double delimiter method (which seems to be the most common/successful), what lead your choice of delimiters?


title: Biggest mistake you've ever made

text: Similar to the question I read on Server Fault, what is the biggest mistake you've ever made in an IT related position. Some examples from friends: > I needed to do some work on a production site so I decided to copy over the > live database to the beta site. Pretty standard, but when I went to the beta > site it was still pulling out-of-date info. OOPS! I had copied the beta > database over to the live site! Thank god for backups. And for me, I created a form for an event that was to be held during a specific time range. Participants would fill out the form for a chance to win, and we would send the event organizers a CSV from the database. I went into the database, and found ONLY 1 ENTRY, MINE. Upon investigating, it appears as though I forgot an auto increment key, and because of the server setup there was no way to recover the lost data. I am aware this question is similar to ones on Stack Overflow but the ones I found seemed to receive generic answers instead of actual stories :) What is the biggest coding error/mistake ever…


title: Why normalization improves numerical precision?

text: I was reading the following article: Polynomial interpolation of GPS satellite coordinates, Milan Horemuz and Johan Vium Andersson 2006 and it states the following: "The estimation procedure of the ai coefficients is done with the Matlab function polyfit, which estimates the coefficients in a least squares sense. **To improve the numerical precision, the dataset p is normalized** by centering it at a zero mean; by subtracting its mean value p; and scaling it to a unit standard deviation by dividing each observation with the standard deviation σp as follows..." My question is how does the value normalization improves the numerical precision of computational operations?


title: Should the methods of a class call its own getters and setters?

text: Where I work I see lots of classes that do things like this:               public class ClassThatCallsItsOwnGettersAndSetters {              private String field;              public String getField() {             return field;         }              public void setField(String field) {             this.field = field;         }              public void methodWithLogic() {             setField("value");             //do stuff             String localField = getField();             //do stuff with "localField"         }     }      If I wrote this from scratch, I would have written the `methodWithLogic()` like this instead:               public class ClassThatUsesItsOwnFields {              private String field;              public String getField() {             return field;         }              public void setField(String field) {             this.field = field;         }              public void methodWithLogic() {             field = "value";             //do stuff                         //do stuff with "field"         }     }      I feel that when the class calls its own getters and setters, it makes the code harder to read. To me it almost _implies_ that complex logic is happening in that method call even though in our case it almost never is. When I'm debugging some unfamiliar code, who's to say that the bug isn't some side effect in that method? In other words, it makes me take lots of side trips on the journey of understanding the code. Are there benefits to the first method? Is the first method actually better?


title: What to do with private fields with getters and setters in Java

text: When are Getters and Setters Justified is an excellent question which focuses on using getters and setters as part of the external interface. What I am struggling with is ... by having getters and setters there is now multiple ways to update the state of the object since private fields can updated directly bypassing the setter or can be updated by the setter. Take the example below ... _size is the private field and it has two methods `getSize()` and `setSize(int size)`. If incrementing _size is coded up like the `increment` method, all is good. On the other hand, using `increment2` can put Order into an illegal state. Is there a way to prevent developers from accidentally bypassing the getter / setter and use the private fields directly!? If not, what convention should be used to ensure that the object is never put into an invalid state?               public class Order {              private int _size = 0;              public int getSize() {             return _size;         }              public void setSize(int size) {              if (_size < 0)                  throw IllegalArgumentException("...")                  _size = size;          }              public void increment(int increment) {             setSize(getSize() + increment);         }              public void increment2(int increment) {             _size = _size + increment;         }                     }


title: How faster is an 'if' construct compared to an immediate 'if' statement (IIF) and when should I use it?

text: How does the traditional `if` statement compare with that of the _immediate if statement_ (IIF, the one usually written as `condition ? value_if_true : value_if_false`) in terms of speed of execution? Also, in what scenarios should we be ideally using the IIF?


title: Best way to store revision information for quick access to view or revert changes

text: What I am looking for is the most optimal solution for storing content revisions in an MSSQL database. We have an application that allows users to make changes to small HTML content blocks similar to a wiki, but we need to have tight audit control over the changes. At any point in time, the manager might want to look at previously submitted contents or revert the entire HTML block back to the previous state. I had it setup in the past where we had a primary table that stored the HTML information (along with various other meta tags) and then an audit table that kept a copy of the entire data row everytime a change was made. What I am wondering is if this is the best way to go, or should I just keep 1 table with all the current records and the changes in it and just have a flag that lets me know which one is the current one?


title: Are "Clean Code" practices really that clean and useful?

text: I am currently doing an internship in a large corporation and they are undergoing many changes in software delivery structure (moving to Agile). In the past couple of months I have noticed this religious attachment to `Clean Code` practices and the book being like a bible for the developers. Now, one of the most important features of the clean code is self-explanatory code which is based on understandable naming and rigorous re-factoring. This is followed by `no commenting` rule. I understand that this clean code is a long term investment which will ease following code maintenance and improvement, but... is this really worth all this fuss? Would anyone share their experience on Clean Code and any opinion whether I am just too conservative or it is just a temporary trend.


title: In freelance software development, what kind of penalties should firms have when they miss deadlines?

text: I was talking with a co-developer. He has a client that wanted to make sure that he delivers on time. The client wants repercussions for missed deadlines. While I do not do freelance work, I couldn't give an answer. So, my question is: What repercussions do you (freelancers) agree upon with your client if you miss deadlines on your deliverables (aside from being fired)?


title: How many types of programming languages are there?

text: Basically, I want to learn lots of programming languages to become a great programmer. I know only a handful to depth and **I was hoping someone could elaborate on how many _classes_ or _types_ of programming languages there are**. Like how you would lump them together if you had to learn them in groups. Coming from a Java background, I'm familiar with static typing, but I know that in addition to dynamic typing there has to be such variety in available languages that I would love to see a categorical breakdown if possible.


title: Just how bad is it not to Dispose() SqlConnections?

text: Personally, I break out in hives if I don't put ADO objects that implement IDisposable in using statements. But at my current contract, I've found that their homegrown enterprise framework "data access provider" code does not 1) implement IDisposable and 2) call Dispose() on anything it uses, at any point, ever. Users have been complaining a great deal about performance issues in the Winforms applications that heavily use this framework for data access, and though there are a LOT of other problems in the code that could be hitting performance, this one just screams at me and is more low-hanging-fruit than the others. So, beyond saying something like "Dispose is there for a reason, use it," what can I tell these people to convince them that this is really, really bad?


title: When to stop reviewing code?

text: I am working in a team of 4 members. we have started reviewing code 2 months ago. we are using Gerrit as code review tool. while reviewing code initially we have found lot's of problem in the code i.e. no proper code comments. method are too big. no null pointer checking. no proper exception handling etc. but now a days it looks code has improved. so when i am reviewing code i am not getting that much problem in the code. so my question is should we continue code review even there is not that much flaws in the code? or will we stop?


title: How should someone used to FP thinking read imperative code?

text: I graduated from university about five months ago, and have been working in a local startup for past four months. While at university, I studied Haskell, F# etc on my own. We were taught Java at the university, but I was exposed to functional programming very soon, and have spent far more time with it than I did with imperative programming. As a result, my brain is wired for a functional thinking. The company I have joined uses Python, and the code is heavily imperative. I am having a very hard time reading imperative code. I cannot keep a track of mutations. When an for-if-else-for-... nesting goes more than four levels deep, I completely lose the track of what's happening in the code. To add to it, Python is a dynamic language, so there are no types in the code. It's been weeks since I have been trying to understand a part of our codebase (which is supposedly 'moderately complex'), but I haven't made any appreciable progress so far in understanding it. Please offer me some practical techniques on how I should go about understanding that code. Thanks in advance! **Edit:**   Maybe I should also mention that there aren't really many comments in the code, and the names are also not very intuitive.


I am in a situation where I have a Web Application (WAR) that is accessing a REST service provided by another application. The REST service uses Basic HTTP Authentication. So that means the application calling the REST service needs to store user credentials somehow. To further complicate things, this is an enterprise, so there are different 'regions' the application moves through which will have different credentials for the same service (think local development, development region, integration region, user test region, production, etc...) My first instinct is that the credentials should be stored by the JEE container and the application should ask the container for the credentials (probably via JNDI?). I'm beginning to read about Java Authentication and Authorization Service (JAAS) but I'm not sure if that is the appropriate solution to this problem. How should a JEE application store credentials for logging in to an external system? * * * A few more details about my WAR. It is a Spring-Integration project that has no front-end. The container I am working with is Websphere. I am using JEE 5 and Spring 4.0.1. To this point I have not needed to consider spring-security... does this situation mean I should re-evaluate that decision?


title: MVC: my controller seems useless half of the time. Is this a problem?

text: Often when I design a program with MVC, the controller is useless half of the time. What I mean is this: something happens on the view (e.g. a button click). The view then notifies the controller. The controller then directly delegates to the model and does nothing else because it has nothing to do. For example: User presses button 'Color Blue' > view tells controller `controller.colorBlue()` > controller tells model `model.colorBlue()` > model colors something blue. In this example, the controller seems useless. It adds nothing. The view might as well have talked straight to the model. The other half of the time, however, the controller _does_ do some kind of mediation between the view and model. My question is this: how common is this in MVC structures? **Is it reasonable that half the time my controller seems unnecessary? Or is this a problem?** Is this common? How should I approach this? If my question isn't clear enough, please say so.


title: Shouldn't Android's TextView.getText() return String instead of possibly mutable CharSequence?

text: I've just spent hours debugging some code because I forgot (actually never considered it) that `TextView.getText()` returns `CharSequence` that may be in fact a mutable class... Shouldn't it return (immutable) `String` instead? I mean I can't imagine a situation when you want to share a state with a text field, at least not by default. Isn't that something that can be objectively called a design mistake in a library?


title: How do we isolate dependencies for a .Net app deploy in a way which is safe for a strongly-named assemblies?

text: To design in such that it is easy to deploy dependencies with your app, and so that development environments are easy to set up, it is advantageous to isolate an app's dependencies from it's environment. That means the app can get its dependencies from a package manager, and it will not be affected by it's deployment environment (such as the GAC). This principle comes from the Dependencies section of the very interesting "Twelve-Factor App" standards. In .Net, I guess this would mean explicitly specifying to use dependencies from the bin folder of an app? I am concerned that this might cause problems for shared, strongly-named assemblies. In this Microsoft article, Ferrandez says locking conflicts can occur if apps do not share strongly-named assemblies via the GAC, since the assembly is loaded into a shared domain. The 12-factor app describes the pieces needed to satisfy this principle as a _dependency declaration manifest_ and a _dependency isolation tool_. Does anyone have an established setup for isolating dependencies which is working for you, and is safe for strongly-named assemblies? Are we in the .Net world stuck with separating all our apps into VM's to achieve isolation? * * * > Personal context: I maintain a SAAS app where each server instance runs a > few services/apps which engage in some inter-process communication. They > have some strongly-named dependencies in common. Having the dependencies in > the GAC makes deployment complex, setting up dev environments a pain, and > restricts freedom to choose deployment environments. Even without the strong > naming or shared dependency issue, I am interested to know how people do > dependency declaration and/or isolation. Thanks!


title: Is agile more than just small waterfalls?

text: I've mostly used the waterfall methodology on my projects, but now I'm expanding my horizons into agile methodologies. From what I've read so far, and maybe I've read the wrong things, agile means small waterfalls. Instead of a big waterfall spread over one or two years, you have small waterfalls that last weeks or maybe a few months at most. Is my understanding correct or is there more to it than that? What are the agile philosophies?


title: Understanding the Open Game License

text: I'm thinking about using the basic mechanics behind the D20 system royalty- free, however, I'm unsure if the OGL allows that. Any thoughts appreciated. And if I can't use the D20 system royalty-free, then any suggestions on other well tested systems appreciated as well.


title: Do you use project management on your personal projects?

text: I got some projects at home, and I want to get them done already.   I was wondering, is it common to use project management for this?   Even though it would only be for me, do you use some kind of project management   for personal projects?


title: How are operating systems compiled and booted the very first time?

text: I'm interested in how operating systems work. I've been reading some articles about Linux and seem to understand how it all generally comes together, but I feel like there's a chicken and egg dilemma when it comes to constructing an operating system. Since Linux is written in C (and Assembly), which needs a compiler to be compiled, how does one actually compile an operating system for the first time? Do you first write a boot loader out of your existing OS? Or do you do something else? Do you have to dual-boot for the first time? Or you need two machines? What did Linus first end up with when he started his project? What did his very first result look like? What's the very first thing you need to design and write when you're programming an Operating System?


title: Is it a good idea to schedule regular time to clean up code?

text: I'm managing a small team of developers. Every so often we decide we're going to spend a day or two to clean up our code. Would it be a good idea to schedule regular time, say 1 week every 2 months, to just cleaning up our codebase?


title: Writing an API that is syntactically valid in multiple programming languages

text: I'm planning to write a single API that is syntactically valid in most major programming languages (to the greatest extent possible, so that only minimal amounts of code will need to be re-written when moving from one language to another). I think the simplest way to do this would be to write a group of functions that consisted entirely of function calls and variable assignments, since the syntax for function calls is almost exactly the same in all major programming languages. Of course, I'd need to write "wrapper" functions for if-statements and while- loops, since the syntax of each of these is different in each programming language. Here's a proof-of-concept for one "polyglot" function that should work in most programming languages:               //JavaScript syntax     function proofOfConcept(){         printSomething("This is just a proof of concept."); //the function printSomething will         //                      need to be implemented separately in each programming language.     }          //Java syntax     public static void proofOfConcept(){         printSomething("This is just a proof of concept."); //the function printSomething will         //                      need to be implemented separately in each programming language.     }          //Python syntax     def proofOfConcept():         printSomething("This is just a proof of concept."); //the function printSomething will         //                      need to be implemented separately in each programming language.          //C syntax     void proofOfConcept(){         printSomething("This is just a proof of concept."); //the function printSomething will         //                      need to be implemented separately in each programming language.     }      Would this be a useful design strategy, or is there a better way to do this? I think this would be a useful strategy for developing libraries in multiple programming languages, althogh it would require a small number of "language- specific" functions to be written for each target language.


title: Why would more CPU cores on virtual machine slow compile times?

text: [edit#2] If anyone from VMWare can hit me up with a copy of VMWare Fusion, I'd be more than happy to do the same as a VirtualBox vs VMWare comparison. Somehow I suspect the VMWare hypervisor will be better tuned for hyperthreading (see my answer too) I'm seeing something curious. As I increase the number of cores on my Windows 7 x64 virtual machine, the overall compile time **_increases_** instead of decreasing. Compiling is usually very well suited for parallel processing as in the middle part (post dependency mapping) you can simply call a compiler instance on each of your .c/.cpp/.cs/whatever file to build partial objects for the linker to take over. So I would have imagined that compiling would actually scale very well with # of cores. But what I'm seeing is:   * 8 cores: 1.89 sec   * 4 cores: 1.33 sec   * 2 cores: 1.24 sec   * 1 core: 1.15 sec Is this simply a design artifact due to a particular vendor's hypervisor implementation (type2:virtualbox in my case) or something more pervasive across more VMs to make hypervisor implementations more simpler? With so many factors, I seem to be able to make arguments both for and against this behavior - so if someone knows more about this than me, I'd be curious to read your answer. Thanks Sid [ _edit:addressing comments_ ] @MartinBeckett: Cold compiles were discarded. @MonsterTruck: Couldn't find an opensource project to compile directly. Would be great but can't screwup my dev env right now. @Mr Lister, @philosodad: Have 8 hw threads, using VirtualBox, so should be 1:1 mapping without emulation @Thorbjorn: I have 6.5GB for the VM and a smallish VS2012 project - it's quite unlikely that I'm swapping in/out trashing the page file. @All: If someone can point to an open source VS2010/VS2012 project, that might be a better community reference than my (proprietary) VS2012 project. Orchard and DNN seem to need environment tweaking to compile in VS2012. I really would like to see if someone with VMWare Fusion also sees this (for VMWare vs VirtualBox compartmentalization) **Test details:**   * Hardware: Macbook Pro Retina      * CPU : Core i7 @ 2.3Ghz (quad core, hyper threaded = 8 cores in windows task manager)     * Memory : 16 GB      * Disk : 256GB SSD   * Host OS: Mac OS X 10.8   * VM type: VirtualBox 4.1.18 (type 2 hypervisor)   * Guest OS: Windows 7 x64 SP1   * Compiler: VS2012 compiling a solution with 3 C# Azure projects      * Compile times measure by VS2012 plugin called 'VSCommands'     * All tests run 5 times, first 2 runs discarded, last 3 averaged


title: Does Java promote a separation between class definitions and implementations, as is  C++?

text: I have a homework assignment and I need to evaluate which approach is better according to GRASP "Protected Variation". I found a question on Stack Overflow about the separation of header and code files in C++. However, what I want to know why Java does not follow C++ in promoting the separation between class definitions and class implementations. Are there any advantages with the Java method, over the C++ method?


title: What was the earliest use of cryptographic tokens in URLs?

text: I was wondering: it now seems to be more and more common to see people/framework putting cryptographic tokens in the URLs their webapps are generating (to prevent quite effectively against quite some attacks). It is advised by OWASP etc. However I was wondering: what was the earliest known usage of this technique (specifically inside Web URLs)? I've found a message on Usenet dating from 2003 (for a Java webapp) describing the technique by someone who, obviously, independently discovered it (he's asking for know "prior art"):               Every single link in any of the jsp page transmitted to the client is      generated with a checksum that act as a signature for the URL      The description clearly shows it's a cryptographic checksum being used (and the way it works seems very close to the modern "tokens" OWASP advocates etc.). Interestingly enough the person describing it says that "it cannot hurt" but that it may not be that useful since that Java is relatively immune to buffer overflow. The author couldn't have imagined that this technique would has stopped most XSS and CSRF exploits dead in their track way before these techniques were even invented... So my question is simple: what are the oldest know usage of this technique you know of? **EDIT** Upon re-reading the old description, I think in that message from 2003 the technique is even more advanced than the "per-session tokens" that OWASP advocates in that every single parameters are checked against forgery (but I'm not sure)


title: Which version of Java should I use for learning?

text: I am a QA engineer interested in mobile development and automation.I have basic programming experience (intermediate level Python, C++ programmer) and as most companies choose Java for writing frameworks I need to pickup Java. I use Ubutnu 12.04 LTS and I will be using Head First Java as learning material. When I searched for JDK options I found Oracle Java 6 and 7 and Open JDK. I read somewhere in Ubuntu forums that Java 6 is not recommended on Ubuntu systems and I am a little bit confused about which version should I use, that would be compatible with the book and the OS.


title: All programming functions always return to the If or If/Else statement?

text: After learning, coding, and coding even more than ever now, I have noticed a trend in a lot of programming which I do. The trend is that the _majority_ of my functions are `if{}` or `if{} else{}` statements when it comes to performing the functions in my code. I narrowed out the option of it just being the project which I am working on. The project is building a PHP Framework or Application (whichever you want to call it). The vast majority of my code for the `autoloader.php`, `application.php`, and all of the _heavy-lifting_ files are performing their functions of making sure everything loads correctly and builds the environment. After working with very complex functions within my code to do this and that, they are all wrapped within an `if{}` or `if{} else{}` statement. Is this a common trend for the majority of programming? Or am I over reacting to something which I am seeing a lot of? Does the most complex functions in coding always go back to the basics of the legendary `if{}` or `if{} else{}` statement?


title: Decoupling when constructors have non-contractual parameters

text: By non-contractual parameters, I mean parameters that are not interfaces or service dependencies, something like `class Person(string name)`. I am writing a webpage scraping application, and so far I've written it in the wrong order (hence the creation of this question). I made a class to parse HTML documents (from string format) and give me all the urls and images in it. That class has the following description:               public class PageParser     {         private readonly string _html;              public PageParser(string html) {             _html = html;         }              public IEnumerable<string> GetImages() {             /* not important */         }              public IEnumerable<string> GetLinks() {             /* not important */         }        }      This code works great, unit-tested, 100% coverage, etc... The problem is now how do I write unit-tests for code that uses this class without worry about the constructor of this class. I only need this new class to work with the behavior of the `PageParser`. The pseudo code for this new functionality is as follows:               public Report CreateReport(string url)     {         var html = _webClient.DownloadString(url);               var parser = new PageParser(html);                var images = parser.GetImages();         var links = parser.GetLinks();              var relevantLinks = links.Where(l => l.Contains('something'));              return _reportBuilder.Create(images, relevantLinks);     }      The problem that I have is I don't want to have a bunch of unit-tests that have epically sized HTML documents for all my various test cases the `CreateReport` method can have. The options I have come up with are: **1) Leave everything as is** Leave the class structure as is, just live with having tests with large setup variables **2) Expose the page parser (+interface) from a Factory** Create an interface for `PageParser`, and create a factory with corresponding interface.               interface IPageParserFactory     {         IPageParser Create(string html);     }          class PageParserFactory : IPageParserFactory     {         IPageParser Create(string html)         {             return new PageParser(html);         }     }      Then the resulting pseudo code would look something as follows.               // ... download string          var pageParser = _pageParserFactory.Create(html);          // ... create report      **3) Move the parameter html to each method and create an interface** (so now the class has no construction dependencies)               interface IPageParser     {         IEnumerable<string> GetImages(string html);         IEnumerable<string> GetLinks(string html);     }      **4) Something else entirely** If there's another pattern that solves this problem I would like to know it.


title: Should I make package private my DAO interfaces?

text: I have several DAO classes that implement an interface. In the other hand, I have Service classes that use those DAO implementations. So far all the DAO interfaces are public and I was thinking if would it be better to make them package private and to put the service classes in the same package so they are the only ones being able to use them. The reason is because I wouldn't like that programmers could use DAO implementations in a Controller or a web service without using the service layer. A programmer could think for example that adding a new order is as simple as calling the addOrder dao method, ignoring that indeed there is a service method that does more than that. What do you guys think?


title: Algorithmic approach for text analysis of ingredients and instructions

text: # Background Looking to separate lists of ingredients from instructions. Users scan recipes from 3x5 cards, magazines, cookbooks, etc. OCR software converts scanned images into plain text--typically a single text paragraph without line breaks (see below for an example). # Problem Users must manually separate the list of ingredients from the instruction text. I would like to automate this step as much as possible (perfection not required; reducing manual effort by 80% is a win). # Assets System assets include:   * 350 culinary verbs (e.g., cook, boil, mash)   * 400 equipment nouns (e.g., bowl, thermos, toothpick)   * 8300 normalized ingredient nouns (i.e., no plurals, no duplicates)   * Natural Language Processor that parses ingredients into quantity, measure, noun, and adjectives. # Ideas   * Use a neural network and unsupervised training   * Use Bayesian statistics to separate the ingredients from instructions   * Use word clustering with text mining techniques? # Question What algorithm(s) would provide the greatest accuracy to identify the most likely boundary between ingredient and instruction text? # Input Example input text produced by the OCR:               Maple-Roasted Parsnips with Pecans and Cranberries Earthy parsnips roasted until tender with cranberries, pecans and spices would make a nice side dish for roast pork, Cornish hen, turkey or chicken, baked ham, or baked salmon fillets. Preparation time: 15 minutes, plus soaking time Cooking time: 40 minutes Makes: Six servings 1/3 cup dried cranberries 1 1/2 lbs parsnips 1/4 cup maple syrup 1/4 cup chicken or vegetable stock 2 Tbsp lemon juice 1 Tbsp melted butter 1/4 tsp ground cinnamon 1/8 tsp ground nutmeg I salt and freshly ground black pepper to taste 1/2 cup pecans halves 1 Tbsp chopped fresh parsley or mint LYLE STAFFORD, TlMES COLONIST Maple-Roasted Parsnips with Pecans and Cranberries make a nice side dish to complement pork, Cornish hen, baked ham or salmon fillets. Place the cranberries in a bowl. Cover with one cup of warm water and let stand at room temperature one hour. Drain cranberries and reserve. Preheat oven to 375 F. Peel parsnips and cut lengthwise in half. Slice the parsnips, widthwise, into 1/2-inch pieces. Place the parsnips in a 9x13-inch baking dish. Add the maple syrup, stock, lemon juice, butter, cinnamon, nutmeg, salt and pepper, and mix to combine. Roast the parsnips, uncovered, 20 minutes. Mix in the pecans and cranberries and roast 10 minutes more. Give the parsnips a stir and then roast another 10 minutes, until nicely glazed and tender. Spoon into a serving dish, sprinkle with parsley or mint, and serve. Curried Parsnip and Apple Soup with Almonds, Yogurt and Mint Mild, curry-spiced, Indian-style parsnip soup accented with sweet apple, fresh mint, rich almonds SUNDAY, FEBRUARY 3, 2013 B3 cooking with parsnips and tangy yogurt. Preparation time: 20 minutes Cooking time: 25 minutes Makes: Six servings 3 Tbsp vegetable oil 1 lb parsnips, peeled, halved lengthwise and sliced 1/2 medium onion, chopped 1 Tbsp coarsely chopped fresh ginger 2 Tbsp all-purpose flour 1 Tbsp mild curry powder 4 1/2 cups chicken or vegetable stock 1 Tbsp lime juice 1 large or 2 small red apples, peeled, cored and cubed I salt to taste I plain yogurt to taste 1/4 cup toasted, sliced almonds (see note) 2 Tbsp chopped fresh mint Place the oil in a medium to large pot set over medium heat. Add the parsnips, onion and ginger and cook until softened, about five minutes. Mix in the flour and curry powder and cook and stir two minutes more. While stirring, slowly pour in the stock. Mix in the lime juice and apples. Bring the soup to a gentle simmer. Simmer soup until the parsnips and apples are very tender, about 15 to 20 minutes. Purée the soup in a blender or food processor, or in the pot with an immersion blender. Return the soup to a simmer; season with salt. Ladle the soup into bowls. Top each bowl with a dollop of yogurt, and a sprinkling of almonds and mint, then serve. Note: To toast the almonds, , place in a non-stick skillet set over medium heat. Cook the almonds a few minutes, swirling the pan from time to time, until lightly toasted. Q) 1] 3 ~§ lp to . CS ‘ I V ® ?aii§‘;?’§‘7e-SF E E d fragrant, ‘DO ‘YOU ‘V C LIAC -°DI EASE‘? \\ , , : V'' N ‘\ ''» / 5 i \ \


title: Defining a random "safe" path for a game character

text: I am writing a game in Java and it can be likened to the recently popular game "Flappy Bird" in the sense that the character moves up and down and the users touch and must avoid the obstacles. The obstacles are going to be asteroids of varying sizes. I want to spawn these in at a random y co-odinate and with a random size, and then have them move across the screen. The character must then avoid these. It cant be completely random however as that may result in an non-traversable path. Thus I thought it would be best to define a random safe path first and then fill in the surrounding area with these obstacles. Is this the best approach to solving this problem, and if so is there correct and efficient way of doing this?


title: On implementing a dynamic proxy in PHP

text: I'm trying to implement dynamic proxies in PHP and I'm running into a problem of implementing interfaces. My current approach to building a dynamic proxy is by having a class which uses the __call magic method. The issue is that this class implements no interface and/or extends no other class. So if I have a method which accepts only objects of a certain type through PHP type hints, I cannot pass an object of my dynamic proxy type. One case I'm currently dealing with is a LazyLoader class, which checks the method being called to see if it should perform the loading procedure. My data source method for loading a user, instead of returning a User object, returns a LazyLoader object, which will load the user's friend list lazily. Many other data source methods will do similar things. The issue is that, there, I return a LazyLoader object and not a User object. So whenever I use a data source object to load a User object, I'll get back a LazyLoader object, which I can't pass to methods/functions which take a type hinted User parameter. Any way to dynamically make a LazyLoader object "be a" User? **Edit:** I could make several kinds of lazy loaders which extend the right class. For example, I could have a UserLazyLoader, a FinanceSheetLazyLoader and so forth. This is a possibility, but I'd like to see if I could solve this issue in a more generic way first.


title: Is hiring a junior developer as a technical trainer a good idea?

text: So my friend's boss brought in four junior candidates with some work experience, she is one of them. Her manager wants them to be experts on the subject matter of tomcat in a matter of two months in order to justify them as billable to other clients as a technical trainer. My biggest concern is this, they only have a year to no experience in development but no production support experience. Is it possible to turn these greenhorns into gurus in a short amount of time with the use of text and forums? Also they don't have a proper sandbox to play with, i.e. any servers. I am helping in my spare time but I don't feel she has enough time to become a SME. What can I do to help her become an expert or what can I say to her that the position may not be a good fit?


title: Looking for an information system for collaborating on files metadata

text: I am looking for an information system which has the following features:   * upload files and add custom properties depending on file type (e.g., author, composer, painter, singer);   * support for sructured properties (e.g., `painter` is not just a string, it is an object with own properties: firstName, lastName, dateOfBirth, placeOfBirth, etc.);   * describe third-party files (given their URLs);   * version control of descriptions;   * search for files and other objects by their properties;   * edit descriptions of files created by others (ability to edit depends on one's reputation, as on StackExchange);   * voting on files (influences reputation), flagging them. I was thinking about implementing it myself using Semantic Web technologies, but still can't believe that there is no very similar system. If there is no such a system, are there any components that I could reuse? If it does matter, I prefer Python, but most software in Semantic Web world is written in Java, so I resigned to the fact that I will have to write some code in Java.


title: Why did javascript libraries like knockoutjs, backbonejs, and angularjs only come out in 2010?

text: Being a relatively new web-developer I am surprised that these libraries didn't exist before. Is there a particular technical or historical reason that at around Sep 2010, a sudden development and interest in client-side javascript RIA applications and libraries? http://www.google.com/insights/search/#q=backbonejs%2Cangularjs%2Cknockoutjs%2Cjquery%20tmpl&cmpt=q


title: How to submit a part of project based when other parts are not completely implemented yet

text: I have been given an online task in which I am supposed to develop a service which is based on some other class/service which has not been implemented yet but I have a rough API for that and the results return by my class would be used by some other class/service I am not sure what would be the best way to return this. I mean shall I have some dummy/mock implementation for the service I am expecting or using in my class and also for the service that would use the result returned by my class or is it Ok to just develop my part and assume things based on the rough API spec. For example : I am in Team C and have to implement CService service. My class will call Team A's AService service (this is not implemented yet but I have a rough spec for this) and the results returned by my class would be used by Team B's service.


title: Using Statement lambda in exception handling

text: Following is a code snippet from MVP Win Forms application and this explanation would be helpful when answering the questions. My DAL doesn't handle exceptions and it will be propagated up to the calling method in the presenter classes where the exception will be handled. I'm using a single handler called `ExecutAction(Action action)` so I'm catching exceptions in one place rather than repeating code in every method. At the moment, I'm not logging errors. Just alert the user for an action and try to keep the system alive if possible. When showing messages to users, Presenters will use a static class called `MessagingService`. (`ShowErrorMessage()`). So that I can customize all massage boxes in one place.                       private void Search()             {                 ExecutAction(() =>                 {                     var info = _DataService.GetByACNo(_model.AccountNumber);                              if (info != null)                         {                             _Model = info ;                             this.SetViewPropertiesFromModel(_Model, _View);                         }                         else                         {                             MessageBox.Show ("Bank account not found");                         }                     });                 }                           private void ExecutAction(Action action)                 {                     try                     {                         action();                     }                          catch (NullReferenceException e) { MessagingService.ShowErrorMessage(e.Message); }                     catch (System.Data.SqlTypes.SqlTypeException e) { MessagingService.ShowErrorMessage(e.Message); }                     catch (System.Data.SqlClient.SqlException e) { MessagingService.ShowErrorMessage(e.Message); }                 }             }      Should I include general exception handler to this, to be able to handle any unforeseen exceptions? Also could you show me a better way to handle showing messages than using a static? Does use of lambda statements in every method call (`ExecutAction(() =>`) degrade code readability? When showing user messages how to show a custom message like "Check the server connection" etc. first and then if the user wants more information (like StackTrace / technical details) he /she could press a button like `More Info` which is in the MessageBox dialog?


title: putting methods in base class that doesnt make sense/belong there

text: I've been lately thinking over design principles and patterns and a question did strike me. Let us say, I want to design a racing game. I want to design the classes for a variety of cars.   * each car may have different feature   * the most common features can be put in the base class - 'Car' Now, I learned that you should always strive to work with abstractions. All the code that tries to manipulate the car will try to call the abstract methods on `Car` like `Car.Accelerate()`, `Car.TurnLeft()`, etc... But what about the specific features? Like some cars might have rocket thrusters or a parachute and you might want to use them (I know this sounds ridiculous, but my point here is 'There might be special features in derived classes that might not justify the actual type(or base type) of that specific class')? So, what about them? Would you rather raise few more abstract methods in base class making it less cohesive, or would you put some if blocks and type casts (to get the actual class object and use that method) making it more coupled?


title: Explaining technical things to non-technical people

text: I often have to explain technical things and technical decisions to my _extremely_ non technical manager and I'm pretty awful at it. What are good ways to essential dumb things down for the rest of the world who don't have a passion for programming? Example questions I've been asked:   * Why are you using Django instead of Java (Didn't accept that it was cheaper either)   * Asking me to rephrase things in non technical words, my sentence was "Certain HTML tags are not allowed". How can I possibly dumb that down?   * Other stuff that makes perfect sense to me, but is just _so_ basic I don't know how to explain it   * Why this, why that, why everything! Also, how do I tell my manager to look the basic stuff up on Google, like "What is Pylons?" I'm ready to rip my hair out, these questions are driving me insane!!


title: Resources for up-to-date Delphi programming

text: I'm a developer in a small department and have been using Delphi for the last 10 years. Whilst I've tried to keep up-to-date with movements there are a lot of changes that have occurred between Delphi 7 and (current for us) 2010. Stack Exchange and here have been great for answering the "how do you" questions, but what I'd like is a resource that shows great examples of larger scale programming. For example is there anywhere that hosts examples of well written, multi form applications? Something that can be looked at as a whole to illustrate why things should be done a certain way?


title: Is it okay to call functions when event occurs, or after that?

text: So I was not sure how to structure this title, feel free to edit it. My question is: When I have a Game Loop, I have 3 main blocks. Handle Events, Update game state, and draw. Let's say for example I check for keyboard/mouse events, and I want to move my character when buttons are pressed. Whenever `KEYDOWN` event occurs, should I immediately call `Player.move`? Or should I toggle `move_left/move_right bools`, and then call `Player.move` when I'm in the Update game state block. I was wondering this becouse, for example a function performs a long algorithm and I call it when an event occur's, calling the function will take some time, and meanwhile I might press more button's/events. I think I will lose some of those events becouse in that time the algirthm function was runing. Or, I can toggle a bool when the event occurs, and after checking for ALL events, I perform functions based on the bools. PS: Feel free to edit this post in a more constructive question.


title: Why aren't there automated translators from one programming language to another?

text: Most programming languages are Turing complete, which means that any task that can be solved in one language can be solved in another one, or even on Turing machine. Then why aren't there automatic translators that can convert programs from any given language to any other language? I've seen couple attempts for two languages, but they always work only on a limited subset of a language and can hardly be used for converting real projects. Is it possible, at least in theory, to write 100% correct translator between all languages? What are the challenges in practice? Are there any existing translators that work?


title: What is (was) an update channel?

text: I was checking out what version of Firefox I'm using and it was telling me that I'm on the 'release update channel'. So I googles "Update Channel" and I finds this seemingly antiquated MSDN article which has a confusing bit of ASP.NET pre-processed into the article to give you the sense that you both should not use this technology and should never have used this technology. > Microsoft Active Channel technology is obsolete as of Windows Internet > Explorer 7 and should not be used. Users want an easy and convenient way to > download and install new versions of software. Software Update Channels are > specialized channels that you can use to notify users of software updates > and also deliver and install the updates on their computers. Users who have > downloaded your software and subscribed to your Software Update Channel are > notified when new versions of your software become available. When notified > of an update, users can click a gleaming icon representing your channel, > which returns them to your download site so they can obtain the new version. > Users can also choose to have software updates delivered and installed on > their computers automatically. > > Active Channel technology is obsolete as of Internet Explorer 7 and should > not be used. This article introduces you to the terminology, benefits, and > implementation of Software Update Channels. After reading this article, you > will understand how easy it is for users to discover and interact with this > technology, and you will know how to create your own Software Update > Channels. Links to relevant overviews, references, and tutorials are > provided at the end of the article. So, I ask you. Is this still some sort of metaphor for getting software easily to your clients. If I store the info for my programs updates in a database, is there existing non-obsolete Microsofty technology that could take a generated XML file and tell people using my software that there are updates available and you should probably download them?


title: Should a primary key be immutable?

text: A recent question on stackoverflow provoked a discussion about the immutability of primary keys. I had thought that it was a kind of rule that primary keys should be immutable. If there is a chance that some day a primary key would be updated, I thought you should use a surrogate key. However it is not in the SQL standard and some RDBMS' "cascade update" feature allows a primary key to change. So my question is: is it still a bad practice to have a primary key that may change ? What are the cons, if any, of having a mutable primary key ?


title: When should I copy a pointer inside a function?

text: I'm trying to teach myself programming and I'd really appreciate some help with this issue. I've just read a tutorial on pointers but I have a problem with the example. The function copies one string to another. In the original function a copy is being made with ptr. What is the meaning of this? because as far as I can see it's unnecessary. Is there anything wrong with my revised function or am I missing something? //Tutorial example               char *my_strcpy(char *destination, const char *source){         char *ptr = destination;         while(*source != '\0'){             *ptr++ = *source++;         }         *ptr = '\0';         return destination;     }      My revision               void my_strcpy2(char *destination, const char *source){              while(*source != '\0'){             *destination++ = *source++;         }         *destination = '\0';     }      Thanks.


title: Is there a 'boilerplate' lightweight NDA I can use to cover sharing proprietary code with a third party?

text: I want to engage a freelancer to work on some software that was developed internally. We're agreed that it'll be difficult for them to quote/estimate the work without access to the existing source code, and I'm happy to give them access to that code but would like something on paper before I do so. There is nothing in the code that's hugely confidential or sensitive, but it would be negligent of me to share our code without getting them to acknowledge in writing the terms under which we're sharing it. Does anyone have, or know of, a one-side, "lightweight" NDA that they've used to cover sharing of code at the pitch/estimate phase of a job before? I'm in the UK, so ideally UK law but I'm happy adapting something. Yes, we have lawyers. Getting them to write something is hugely expensive. Getting them to read something is much cheaper.


title: What's the best way to design a data and php model for a multi-account system?

text: I'm doing some high-level sketching of a system that will require users to register, when they do they get an account and can invite others to that account. To be clear, an account would be similar to a private workspace, and the users will belong to that account and cannot exist outside of that account. The users will be identified by a unique username (likely their email) and this will give them access to the account on a one (account) to many (emails / users) basis. Each record generated in that account is visible only to those users who belong to that account. Is there a good pattern for modeling this type of system? Being extremely new to programming, I'm imagining a field in each table that references the account #, but this makes virtually every entity a one to many. Is there a better way?


title: How should I handle the publishing of an iPhone app under someone else's name?

text: I've agreed to build an iPhone app for a client that was referred to me. I'm a full-time software engineer by day, but this is only my 2nd iPhone app and I agreed to do it without upfront funding as it would give me a project to further learn the API as well as increase my portfolio of iPhone apps. The client suggested as payment, that we split the profits 50/50. Normally I would not think this was fair but in a situation like this, I was ok with it since my family's life does not depend on it. As we are nearing the end of development on the app, I asked the client if they would prefer their personal name be put on the project, or if they minded that it was my name (since I have the developer license). Naturally, they requested their name. I've not told them all that that entails because I would relinquish management of the app and profit divisions to them. My question to this community, and pardon if this is not the proper place, is **am I going about this the right way?** **Should I request a partnership be setup?** **Should I insist my developer name goes on it? What would you do?** Additionally, I'm going off of his word that this is a niche product with high demand (its in the medical field) so we will be able to charge a bit more for it.


title: Where is sympy library used?

text: I'd admire the functions of sympy library, what it does is really awesome. The integration functions are really few guys intellectual work. But where exactly we use them practically on computers? If not sympy, do we really need such libraries? If we need them, what languages would satisfy our needs?


title: In .net, why can't values of intrinsic data types (such as DateTime) be null?

text: First the history: I found out DateTime data types cannot be null (Yes they can be nullable using the ? nullable declaration). I was told this is because they are value types and placed on the stack (not on the heap). I can understand why the stack is quicker and why value types need to (mostly) be placed on the stack, what I do not know is.   1. Is it true the real limitation of why a value type cannot be null is because the stack cannot handle null values?   2. If yes - Why? If No what is the real limitation.  I understand in .net we often don't care about exact memory allocation, yet it is important in performance applications to take the stack and heap into consideration, so I'm trying to wrap my head around this. Thanks in advance for your expertise on a difficult question. EDIT: Another thing to add are nullable types hence placed on the heap or stack?


title: Implement a file system for ios devices

text: I've read that ios apps can communicate via unique urls. An online tutorial on tutsplus says > Communication between apps provides your application with an opportunity to > take advantage of other application’s functionality, send and receive data > between apps, and provide a rich user experience that “just works”. I have to admit that since I have no experience with objective c and cocoa I only scanned the article. But as far as I've understood the url based communication, your app can register a unique url that serves as a socket for communication. Is this not the perfect basis for a crude file system ? I know that all ios apps run in a sandbox and can only access their own data. I do recognose the merits of this design decision but still it seems cure and curse at the same time. This is not meant to be a discussion about apple's ecosystem and the concept of ios apps. **My question is simply:** Can url communication be used to create a file storage that works like a simple "desk" ? I would love an app that could store and host my files to allow a simpler workflow between different apps. Is this technically possible or did I misunderstand the url system ? Would apple allow an app like this in the app store ?


title: Teaching software concepts: formal definition is a necessary evil?

text: Recently I had to teach what my PM declared a "Best Practices Course" on programming. I decided to have them read a chapter per week of Uncle Bob's Clean Coder book while I followed a somewhat related syllabus during that week e.g. if a chapter of the book is about object orientation then I teach the S.O.L.I.D. principles; if a chapter covers testing then I teach BDD. Anyhow, when I asked for feedback I drew a lot of criticism because I always gave the "formal" definition of the concept e.g. > Let q(x) be a property provable about objects x of type T. Then q(y) should > be provable for objects y of type S where S is a subtype of T. And then tried to explained somewhat but a little less formally: > If we have a type B being a subtype of A, then we should be capable of doing > anything with B that we can do with A. And in the test I scored some answers like these: > if you give me the formal definition of the concept, you get a 0.7 points; > if you give me a non-formal definition of a concept you may get 0.7 points > based on the completeness. The rest of the point is by giving an example of > the concept. Thus everyone thought this was somewhat unfair as I somewhat pushed for memorizing definitions. Of course this was not my intention but I believe that completeness was a requisite as in previous tests they answers in form of wandering examples e.g.: > Having a lot of code in the function indicates that it is doing a lot of > things and also have a lot of concerns; making difficult to apply changes in > the code to have a better function very difficult. And this somewhat could have been better understood by citing the separation of concerns and single responsibility principles along with refactoring. Thus, I tend to believe that knowing the concepts formally and have a clear relation of the concept and the meaning is indicative of good communication skills and professionalism. Which is somewhat a goal of the course: that they communicate the ideas better by using established concepts. So, are formal concepts a necesary evil or I just screwed and should have managed the score differently?


title: What stage of development do activity network diagrams belong to?

text: Activity network diagrams are used to determine the forward and backward paths for a project, and consequently to determine the critical path or maximum time to development.      I'm already familiar with using work breakdown structures which break down functional requirements into necessary and sufficient deliverables, but I'm unsure of what stage of project planning activity network diagrams fit into.   for clarity my interpretation of the planning cycle.: https://docs.google.com/file/d/0B6m1-u6HxISZeGNCQ2JudXNyZ1U/edit?usp=sharing Please could someone help me clarify this matter?


title: In what language should I name my business classes?

text: I'm requesting best practice with this question. This is only an issue if the customer company is strictly national has a native language other than English, I think. If the customer has a lot of mainly very domain specific (say, German) expressions, mixed with some lesser domain specific namings. The language of our code comments, class/method/variable names is English. Would you translate all domain specific names?


title: Best practice for handling asynchronous inter communication?

text: Recently completed a project for handling credit card processing. One of the difficulties I faced was handling the delay / possible failure of notification messages. The most complex example was:   * an external system sending the request for payment   * my system turning that request into a request to the payment gateway   * sending the user to the gateway   * waiting for the user to perform payment   * the user returning back to my system but being held until the system receives notification of success/failure   * Sending the user back to the external system depending on failure Even more difficult was the fact that upon failure to send the notification the gateway attempts to send the notification every 15 minutes for a number of hours. I solved it using a database record of pending transactions and then detecting success and failure from the return plus a timed delay listener for the notification and transaction handling... Reasonably difficult! But this must have been solved a gazillion times before so what is the best practice? I can see my future is going to be writing the handling between all of these systems and managing the time delays and possible network failures so I want to be following the best practices. Book / article recommendations would be great. Thanks in advance!


title: How best to prevent having to revisit a change after check in

text: Normally what happens is that I work on something for a while and then when I am done I check it in(After the test/review process of course). Sometimes I have to go back and fix something that I got wrong the first time due to me not understanding the problem enough, lack of testing, etc.. What is an acceptable rate for this? Ideally you would hope that you never have to go back but sometimes you do. What rate does the average programmer have and what is the expert programmers rate? Do people track this? Lastly what kind of checks are best at preventing this? PS: I am not counting the cases where the requirements have changed and you have to go back in. I know that there is no real answer to this so let me change the actual question to: "What general checks could be implemented, before code is sent for review or checked in, that would help prevent the need to revisit the change later?"


title: Does being a general programmer naturally lead to failure?

text: In business they say that to succeed > "Pick one or two things and do them very well". This is the antithesis of the modern programmer. We are exposed to a constant stream of changes in business, technology, tools and everything else. There are a handful of guys lucky enough to concentrate on one core technology, say C#...then blog about it, be an expert at it. But all in all, knowing C# well (but no other technology) + 50 cents will buy you a Coke. So, are we all doomed to miserable customers and generally miserable careers? Or, is there some way to succeed despite the "law of business"?


title: Are Session implicit objects examples of Models in MVC?

text: I have read that the Model is responsible for maintaining state among HTTP requests, for example in this article: > The Model is responsible for maintaining state between HTTP requests. > > Basically any data whether on a database, in a file, stored in the Session, > or cached inside APC must be preserved between requests and thus forms part > of the state of the application at the time the last request was completed. > So always remember that the Model is not just the database. Even the data > you get from web services can be expressed as a Model! Yes, even Atom feeds! > Frameworks which rattle off introductions to the Model, almost never explain > this upfront which only exacerbates misunderstandings. When we use some implicit Session objects (say in PHP, JSP etc.,) does it mean that this Session is a Model object?


title: How do asserts and other error avoidance checks fit into TDD?

text: http://butunclebob.com/ArticleS.UncleBob.TheThreeRulesOfTdd > You are not allowed to write any production code unless it is to make a > failing unit test pass. So where do asserts fit into this? If you followed this rule you'd never write an assert without a unit test. But how would you test for the existence of an assert? The very nature of `assert` seems to make this idea impossible as the test would explode. And what about code meant to handle absurd conditions that are difficult or impossible to replicate? Some sort of FUBAR from a system call for example... You need to handle the error but the condition that causes the error is pretty rare and comes from the OS. How do you write a unit test to make that fail? Or say you're writing a template library and want to do some concept checks before going too deep into template vomit land? I don't know of any framework that supports compile time failure as a test PASS. I've tried to live by some of these TDD edicts, but at some point I've always run into walls I can't get around. These are some. I guess I should say that I'm talking about assert in the C/C++ sense in which a program, built without NDEBUG, will fault out if the assertion fails. Not some exception throwing mechanism that's _called_ assert. Didn't even realize someone would use that name for throwing exceptions.


title: Can neural network discover rng patterns

text: Can neural network find connections beetween numbers generated by random number generator without knowing about it's seed and predict this rng's next numbers with more sucess then randomly guessing? I really couldn't find any data about this. Thanks


title: Should there be a formal role (internal or external) assigned to dev environments to control wasteful complexity?

text: A few years ago, I worked for a small company that went so far into developing in-house frameworks that they dedicated their most senior developer, and their architect to developing a custom MVC framework and ORM from scratch. These two things were orthogonal to their core product. Unfortunately the support for this framework-driven approach came from the top, and it delayed delivery of revenue-generating software - and the frameworks produced were notably inferior to off-the-shelf alternatives, which compounded the delays. The company burned through cash quickly, and, eventually, everyone was laid off. A later employer made a similar mistake - they got a highly technically skilled developer - a perfectionist, with a strong grounding in enterprise design patterns to grossly over-engineer a consulting solution for one of their clients, knowingly taking a loss, in the hope that the solution could be adapted and extended for other customers. The project overran significantly. But no other potential customers bit. A gold-plated strategic blunder that cost a small fortune. In both cases there was a significant degree of overengineering. In both cases the company and project management were people with domain or analysis backgrounds, rather than a programming background. In both cases the software architects built overly-complex solutions to scratch their itches, and enhance their résumés, with some complicity from non-technical management. In both cases the architects had no stake in keeping costs down (apart from the risk of losing their jobs if the companies went bankrupt- which wasn't much of a risk, considering their high employability). My experience suggests that it isn't an uncommon trap for dev shops to fall into. Is there place in software projects for a formal internal or external technical adversarial role - a "Quantity Surveyor" - to use a building analogy- that can call out, or prevent wasteful over-engineering? Who is best suited to fill this role?


title: Is there a specific reason that dingbat fonts are supported or ever even created?

text: I have known about the weird dingbat fonts since the first time I tried to change the font on MS word and stumbled upon them. Since then I never questioned them, I just thought hey cool. Now I have some questions. What is the purpose behind creating dingbat fonts? Is there anyone/entity that actually uses/needs these types of fonts?


title: Static vs. non-static? (with non-OOP functions)

text: Although this question has come up before, mine _is_ different because it is not supposed to cover anything OOP but only **plain (ANSI) C**. Especially in open-source software, I usually encounter a plethora of functions (please don't call them methods since we're _not_ in OOP) with the `static` keyword preceding the data type. But what effect does this actually have with plain C? In my own projects, I've never had an occasion where the `static` keyword was actually needed. (Although a so-called expert programmer would probably have given me the advice, "This function should be declared static" and I would probably have replied in my own sarcastic way: "Uh-huh. Well, it works as-is, after all". :)). From reading the OSS code, I assumed it might just generate less overhead when compiling the project. However, CPU have advanced in performance so much that I've wondered many times why there is such an ongoing interest to declare functions static even though it might need some benchmark tool to measure the differences in execution speed.


title: Nested maps vs. combined keys

text: in the project I am currently working on we had three different types of prices depending on the age of the user (adult, child, etc...). So we had on the DB a table looking like this: > >     PRICES >     type     Amount >     A         20 >     B         15 >     C         .. >     D         .. >   At first we only had 4 different types of prices, so in the code, we had something like this:               Map<String, BigDecimal> prices = new HashMap<String, BigDecimal>();      Where the keys were the price type. Recently, they added a new business rule that adds 3 subtypes to every price type, so now we have something like this: > >     PRICES >     type   subtype  Amount >     A          1      20 >     A          2      15 >     A          3      .. >     B          1      .. >     B          2      .. >     ...        ..     .. >   **Which of the following two options do you think is better and why?** # Nested Maps               Map<String, Map<String, BigDecimal>> prices;      where the keys are the price type and subtype:               prices.get(type).get(subtype);      # Combined Keys The same map than originally:               Map<String, BigDecimal> prices;      And concatenate the keys to index the different prices:               prices.get(type+"_"+subtype);


title: Producer-consumer pattern with consumer restrictions

text: I have a processing problem that I am thinking is a classic producer-consumer problem with the two added wrinkles that there may be a variable number of producers and there is the restriction that no more than one item per producer may be consumed at any one time. I will generally have 50-100 producers and as many consumers as CPU cores on the server. I want to maximize the throughput of the consumers while ensuring that there are never more than one work item in process from any single producer. This is more complicated than the classic producer-consumer problem which I think assumes a single producer and no restriction on which work items may be in progress at any one time. I think the problem of multiple producers is relatively easily solved by enqueuing all work items on a single work queue protected by a critical section. I think the restriction on simultaneously processing work items from any single producer is harder because I cannot think of any solution that does not require each consumer to notify some kind of work dispatcher that a particular work item has been completed so as to lift the restriction on work items from that producer. In other words, if Consumer2 has just completed WorkItem42 from Producer53, there needs to be some kind of callback or notification from Consumer2 to a work dispatcher to allow the work dispatcher to release the next work item from Producer53 to the next available consumer (whether Consumer2 or otherwise). Am I overlooking something simple here? Is there a known pattern for this problem? I would appreciate any pointers.


title: Designing module interfaces

text: I'm studying software engineering and one thing I'm really trying to improve is my skill in software architecture. My question is quite broad, so I'll try to explain it with an example. Suppose you have a model layer and a service layer. The model manages various entities (such as users, products, orders, campains etc.). The services provide features, such as _evaluating the efficency of a campaign_ , and use several modules of the model layer to access the required data. _How_ and _when_ do you specify those dependencies? I see the following possibilities:   * Allow general access to all models. This is the approach taken in many MVC frameworks, where the controllers can access any model classes. **Pro:** You don't have to specify the dependencies, the developer writing the controller is very flexible.   **Contra:** If you want to test a service, you don't really know which model you have to mock because the service could use everything. These implicit dependencies can also make maintainance a pain.   * The services specify the required models explicitly. Dependency management systems like requirejs or CommonJS require work this way. **Pro:** No implicit dependencies simplifies maintanance   **Contra:** Mocking is impossible. When designing the module, you have to know exactly what the module will need. If you later notice that you need another interface, you have to change the architecture.   * Specify explicit interfaces that will be provided to the service. Anyone instancing the service will have to provide implementations of the interfaces. I think dependency injection works this way, although the injection is automated there. **Pro:** No implicit dependencies simplifies maintanance, Testing is simplified, because you know exactly what to mock.   **Contra:** When designing the module, you have to know exactly what the module will need. If you later notice that you need another interface, you have to change the architecture. In theory, dependency injection seems like the best way. But is it practical to specify each requirement? How fine-grained should it be? Per entity? Group them? Or one dependency per "thing you can do with an entity"? There are simply too many possibilities, and I'd like to get some real-world advice.


title: Reusing Mocks/Stubs as Test Specification

text: We use mock to ensure that a unit test only runs against the code that should be tested. This prevents that a bug in a module A causes tests of a dependent module B to fail. However, now we also have to test the interaction explicitly. It is not enough that A and B are green on their own, A has to work as B expects it, and B has to have the right expectations. Now, B's expectations are already formally defined: in the mocks and stubs. If I have a stub where A returns certain output for certain input, this means I expect it must be possible to have A in a state where it shows this behavior. So instead of writing long integration tests, I just have to set-up an A and test it against the stubs and mocks that are already there. Or, to turn it around, I can use an actual instance of A to test the correctness of my mocks. Does this work in practice? Are there best practices (e.g., where do these pseudo-integration tests belong to, should A's test suite already provide some likely-to-be-used mocks)? Is this even possible with the popular mocking frameworks?


title: When should you use a private/inner class?

text: To clarify, what I'm asking about is               public class A{         private/*or public*/ B b;     }      vs.               public class A{         private/*or public*/ class B{             ....         }     }      I can definitely think of some reasons to use one or the other, but what I would really like to see are convincing examples that show that the pros and cons are not just academic.


title: Why is Internet Explorer the only browser to be referred to by version when talking about compatibility?

text: Whenever I read something or hear someone talking about HTML5, CSS and JavaScript support, they always refer to Internet Explorer with the version number such as Internet Explorer 6, and Internet Explorer 9. But they only refer to Google Chrome, Firefox, Safari and others without version numbers. Shouldn't they also specify the version number in which certain web technologies are incompatible for other browsers instead of just Internet Explorer?


title: What makes the difference between "Hire" and an honest "almost" for final on-site interviews?

text: So, I have recently had on-site interviews with Google and Amazon and received polite rejection letters letting me know I was close, but not quite right for the skills they were looking for. I've made it to the final round for all the interviews I've done (except for some offers from small uninteresting positions that I interviewed with for practice), but so far having 5-8 interviews in a day gives me enough time to have my mistakes add up just enough to put me out of the running. I know I did well there at least on the coding questions and other general technical questions, apparently I'm bad at designing OOP things like card games or parking garages though (I dove too deep into one object and used up all my time, instead of being broader) and my coding answers although they work overall didn't quite had a few bugs/edge cases I missed (like a case where an input node could actually could be the answer rather than needing to be distinct). And I have no problem saying "I don't know", but maybe I'm rambling a bit and need to say it for questions I think I can answer, but can't give a crisp answer to... So, what are the things that push you over the top from being good, but not quite to "Hire"? Any advise on what you look for or something you know that gave you that little extra boost?


title: How to implement "email invitation" feature using Asp.Net Identity Framework 2.0 and OAuth?

text: My engineers are implementing authentication and authorization using Asp.Net Identity Framework 2.0. The requirements state that we need to support the following scenario:   1. Global admin user signs in.   2. Global admin user views an organization.   3. Global admin user invites organization user or admin to system.   4. Email is sent to invited user containing special link.   5. Invited user clicks on link, signs into their "Microsoft Account" (@hotmail.com) and is then signed into our website and associated to the organization and with the correct role assignment. In my opinion, we should be able to do all of this using out-of-the-box features of Asp.Net Identity Framework. For example: In step 3, we can call the CreateUser() method and it should provision a user account that has not yet been confirmed. We can use the ConfirmationToken it generates to email the user. Is this not the correct way to proceed? My engineers think that they need to implement custom user, role and organization tables and implement all custom authorization and roles for this because they believe that the user account within the identity framework can only be created when the user comes back from signing in (via OAuth) the first time.


title: Why does Java's String class not implement a more efficient indexOf()?

text: Following the below question on Stack Overflow http://stackoverflow.com/questions/5564610/fast-alernative-for- stringindexofstring-str I got to wondering why it is that java (6 at least) not use a more efficient implementation? Following is the code: java.lang.String#indexOf(String str)               1762    static int indexOf(char[] source, int sourceOffset, int sourceCount,     1763                       char[] target, int targetOffset, int targetCount,     1764                       int fromIndex) {     1765        if (fromIndex >= sourceCount) {     1766            return (targetCount == 0 ? sourceCount : -1);     1767        }     1768        if (fromIndex < 0) {     1769            fromIndex = 0;     1770        }     1771        if (targetCount == 0) {     1772            return fromIndex;     1773        }     1774     1775        char first  = target[targetOffset];     1776        int max = sourceOffset + (sourceCount - targetCount);     1777     1778        for (int i = sourceOffset + fromIndex; i <= max; i++) {     1779            /* Look for first character. */     1780            if (source[i] != first) {     1781                while (++i <= max && source[i] != first);     1782            }     1783     1784            /* Found first character, now look at the rest of v2 */     1785            if (i <= max) {     1786                int j = i + 1;     1787                int end = j + targetCount - 1;     1788                for (int k = targetOffset + 1; j < end && source[j] ==     1789                         target[k]; j++, k++);     1790     1791                if (j == end) {     1792                    /* Found whole string. */     1793                    return i - sourceOffset;     1794                }     1795            }     1796        }     1797        return -1;     1798    }


title: Some team members don't actively participate in Sprint planning

text: Some team members just wait until the stories they are most likely to work on will be discussed and only then they participate. Otherwise they just play with their phone and don't listen. In some way I understand this position. Why listen to a discussion about a feature you are unlikely to help develop in the Sprint or ever? What do you think we should do?


title: Asynchronous Designing and Programming

text: Me and a friend are looking to team up for some freelance web designing. We both are very strong PHP coders and website designers, but I am better at design and he is better at PHP. So, I'll be controlling the stuff the user sees, he'll be controlling the stuff the user does. In order to speed up development, I'm wondering if anyone has experience or recommendations for asynchronous web designing and coding. So far my best idea is to create a doctrine of which tags and classes every element should be wrapped in (if any), then have us developing via FTP. He would create the code that spits out snippets of HTML, and I would simply style those snippets and wrap it in the page. Does anyone know of a better way? So, any ideas?


title: svndumpfilter Multiple Versions

text: I have a few questions about the Subversion open source project. I know that there are multiple versions of svndumpfilter (2,3). What are the tradeoffs and benefits of each version? In other words, what problems does each version seek to address? There are known bugs in the original svndumpfilter that have not been resolved for years. Out of curiosity, why is this the case? Is it because svndumpfilter is of lower priority than the other working components of svn?


title: Is there something which can write the function for me given the pattern?

text: For example I have the following. The inputs are on the left. The outputs are on the right. The second term in the input which is the number 3 is the number of output numbers I want. It would be really useful if there was a program which given this pattern could just give me the code written to produce it. Is there such a thing?               0 3 -> 0 1 2     1 3 -> 3 1 2     2 3 -> 3 4 2     3 3 -> 3 4 5     4 3 -> 6 4 5     5 3 -> 6 7 5     ...


title: Third party libraries in an open-source C# project

text: I'm going to start an open source project from scratch, using git (via github) to manage the source. The project will be written in C# and will depend on at least two external libraries (more are likely to come). I wonder how I should reference the libraries, and the following ideas came to my mind:   * A folder within the project that contains all external libraries as dll   This would mean I have the dll files in my repo, which I think is bad, because it isn't source. Also, I don't know how Visual Studio (or other IDEs) store the path the libraries, if they use absolute paths, that would be impossible.   * Get the external libraries via nuget   This would be a clean and nice way to have the libraries organized, but what what if a library I need doesn't have a nuget-package? I can't just create one, can I?   * Storing the source of the external library as part of my repo   Sounds like a stupid idea, it would make updating the libraries a pain.   * Reference the repositories of the other projects via git somehow.   Sounds good, I could make my own fork of it to keep a state or just point to a commit. But is that even possible? Is that a good way? **tl;dr:** How should I handle external libraries in an open-source C# project?


title: Am I wrong in thinking that needing something like AutoMapper is an indication of poor design?

text: Automapper is an "object-object mapper" for .Net, which means copying objects from a class into another class that represents the same thing. Why is this ever useful? Is the duplication of classes ever useful/good design?


title: What is the/Is there a right way to tell management that our code sucks?

text: Our code is bad. It might not have always been considered bad, but it is bad and is only going downhill. I started fresh out of college less than a year ago, and many of the things in our code puzzle me beyond belief. At first I figured that as the new guy I should keep my mouth shut until I learned a little more about our code base, but I've seen plenty to know that it's bad. Some of the highlights:   * We still use frames (try getting something out of a querystring, almost impossible)   * VBScript   * Source Safe   * We 'use' .NET - by that I mean we have .net wrappers that call COM DLLs making it almost impossible to debug easily   * Everything is basically one giant function   * Code is not maintainable. Each page has multiple files that are created every time a new page is made. The main page basically does Response.Write() a bunch of times to render the HTML (runat="server"? no way). After that there can be a lot of logic on the client side (VBScript), and finally the page submits to itself (often time storing many things in hidden fields) where it then posts to a processing page which can do things such as save the data to the database.   * The specifications we get are laughable. Often times they call for things like "auto-populate field X with either field Y or field Z" with no indication of when to choose field Y or field Z. I'm sure some of this is a result of not being employed at a software company, but I feel as if people writing software should at least care about the quality of their code. I can't even imagine that if I were to bring something up that anything would be done soon, as there is a large deadline looming, but we are continuing to write bad code and use bad practices. What can I do? How do I even bring these issues up? 75% of my team agree with me and have brought up these issues in the past, yet nothing gets changed.


title: What are some useful resources for learning tuple calculus?

text: I've been trying to go over my tuple calculus over and over again. What's worse is that my professor and tutors are not much help during their hours. Does anyone know a good place to learn about tuple calculus? I'm having a hard time understanding how to "speak" the language in terms of what I want to get from a database.


title: Algorithm to use for shop floor layout?

text: I ran into a classroom problem yesterday (business oriented class, not computer science) and I found it interesting from an algorithmic perspective. The problem goes something like this:   _Assume there is a shop floor with N different rooms, and you have N different departments that need to go in those rooms. The departments and the rooms are all the same size, so any department could go in any room. There is a known travel distance from each room to each other room. There is also a known amount of trips necessary from one department to another (trips are counted the same regardless which room they originate from, so a trip from A to B is equivalent to a trip from B to A). Given those inputs, determine a layout of departments into rooms which minimizes travel time._ What is the best way to approach this problem algorithmically? Is there already a particular algorithm or class of algorithms designed to solve this type of problem? Does this type of problem have a name in computer science? I am not looking for you to _design_ an algorithm to solve this, although feel free to do so if you would like. I'm wondering if this is a problem space that has already been well defined and studied algorithmically and if so get some links to research further. I can see a lot of different data structures and algorithms that might apply to this and I'm curious which approach would be "best". And don't worry, you are not doing my homework for me. This is not a homework problem per se, as this is a business course and we were simply discussing the concepts and not trying to solve the problem algorithmically.


title: Fluent interface implementation and reflection. Case study

text: I hope I picked the right group for this question... I have this little framework I want to implement and I would like to have an opinion on it. In particular I am more concerned about the succinctness and style of the solution. My class sketch looks like this:               public interface Builder<T> {              T build();     }          public interface RootObject {                   public static abstract class MutableBuilder<T> implements Builder<T> {                  protected MutableBuilder() { }                  protected abstract void setA(A a);                  protected abstract void setB(B b);                  protected abstract void setC(C c);                  protected abstract void setD(D d);         }     }      The goal is to have a Builder which returns an instance of (hopefully) immutable objects. The whole implementation is left to the client code, but I still want to give the imprinting of the Effective Java's fluent interface. If it was just for this, I would not be that puzzled. The problem comes into lay when I add the requirements:   * the framework needs to reflectively search through a generic `RootObject` implementation in order to find if the `MutableBuilder` static inner class has been implemented.   * if found, the framework instantiates one or more `MutableBuilder` dynamically (that is the reason why I have an abstract class with a constructor and return it or them to the client code. The mere talking about reflection makes me wonder if I am doing the right thing. It looks a reasonable solution to me (of course).


title: Can I continue to sell a tool/library I wrote in the past now that I got a full-time job or company will not like it?

text: I was selling a library/framework/tool to companies. Licensing the binaries. Now I got a full-time-job. Haven't started yet, but will start soon. And I just got a request for quote from a company in the same industry as my new employer. Not direct competitors, but same industry. Is it ok for me to license my software to them? Or this will put me in trouble with my soon-to-be employer? I don't think asking the company is even appropriate at this time. They are giving me a job to work for them, not to ask if I can sell my software on the side. No idea what to do. Any recommendations?


title: DLL Hierarchy issues

text: I want to preface this by saying "I love my job and I want to stay here" But I've got a serious problem,   1. Circularly linked DLL's (DLL's linked back to the EXE)   2. Special builds with conditional defines to get rid of the links when the EXE doesn't exist for using the DLL's in special utilities.    3. Inability to reference our own DLL's as external functions because they throw errors when linked (have to use Windows LoadLibrary functions instead) So... My question is, referencing the executable seems like a bad idea, but a necessary evil to get session information (this is a client/server application with multiple users). Is the best way around referencing the executable in it's called DLL's is to initialize the DLL's called by the executable with all the information it could ever possibly need to do its job?


title: How do you find the first common element in two arrays

text: The way I did it was to loop through each at the same time and add the current value to a separate set for each of the lists. Also, check if the current element is already in the other list's set. I have no idea if this works though and if so, why? I know it finds a common element but does it find the first common element? I can't think of counter examples but I'm having trouble convincing myself it's definitely correct. Also, even if it is correct, is there a better way of finding the first common element?


title: Is Entity Framework only for Asp .NET / Asp. NET MVC?

text: I never coded on VS and I'm a junior programmer in C# and I would like to know if the entity framework is available only for ASP .NET applications ?


title: serving up future-proof kinfolk - extensible contract interfaces

text: Ok, **I have this human here, but what can it do** , how would you discover its special abilities? And when you find out what kind of expert you've got then how would you actually make use of its unique responsibilities? An example for this architectural pattern question: ### Base Interface with Characteristics Common to All               interface IHuman {         DateTime GetDoB();     }      ### Extended Interface 1               interface ICivilian : IHuman {         string GetEmail();         void SendEmail();     }      ### Extended Interface 2               interface IAccountant : IHuman {                 double CalculateProfits();     }      ### Extended Interface n+               interface IAnotherSpecializedHuman : IHuman {         void DoSomethingExpert();     }      ### Specialized API Discovery and Usage How would you design   * a highly pluggable and loosely-coupled system   * with which you can carry out all the common human operations (e.g. get age),   * but also carry out any specialized operations that are available,   * depending on which modules are incorporated      * e.g. you can send email, because ICivilian module is provided     * but you cannot calculate profits, because IAccountant plug-in is not provided   * and the question is **not so much aboutproviding different implementations but about providing different specialized APIs** (and APIs that have a common parent with shared functionality)


title: For a socket based application : how must I handle dynamic ip adress?

text: I plan to write an network application whose use steps is the following :   1. Connect to the server and choose a name (and enter your email "id")   2. The list of others "free" (not playing a game) players is shown to you : so you have to select one.   3. The server use the two players ip adress in order to connect them But I think I will be facing a great issue :   * how to handle dynamic ip adress carefully : can a dynamic ip adress change while the established connection is not yet finished ?   * if yes, how must I handle that, let's with Java 7 for example ? Regards


title: Hiding query strings logically?

text: I feel uncomfortable when using query string parameters as: `http://xyz.com/default.aspx?carId=1129&country=uk&uniqueId=98745DVF4563VVf1259` I would rather use something that should not make sense to anyone who is trying to make some sense from the URL: `?a=1129&b=uk&c=98745DVF4563VVf1259` (after all this query sting info is for my use only) Firstly is this a good thing to do? (I mean to hide logic of you query string) If it is, then is there a way, that internally developers can use `carId`, `country` and `uniqueId` in code, but externally the url uses `a`, `b` and `c` respectively? So if someone goes to   `?a=1129&b=uk&c=98745DVF4563VVf1259` when I do `Request.QueryString["carId"]` I should get 1129. Can this be done?