title: Java Web Frameworks (JSF vs Wicket) Third-party component suites in Wicket?

text: A presentation linked in an answer here demonstrated a comparison of several web development frameworks. It was a good comparison but caused me a little worry based on the technology stack that I have been pushing for awhile now at my current company. While it seemed like the author was biased towards RoR, he pointed out some major pain points about JSF, which I am using right now and personally have no significant problems with. It seems hip to hate JSF, and I would like to look into something different like Wicket. The problem is that rich third-party component libraries like Primefaces have me hooked by the extreme convenience of throwing prebuilt web components onto a page with simple XHTML compliant markup. Frameworks like Wicket are great because they merge the page with the View, and with Spring this is a powerful combination, but I can't help but wonder how long would it take me to implement the fully featured Primefaces Data Table component in a framework like Wicket? Clearly JSF is a component based framework like Tapestry, but does Wicket have an answer to rapid component-based web development like JSF+Primefaces? Further, I am aware of the major drawbacks of JSF, one of which being the level of effort and frustration it takes to develop a component, but with component suites in JSF becoming more stable and fully featured, is this a major issue for relatively simple web applications with loose open ended UI specifications? If it doesn't have to look exactly like the spec visually, why would custom components need to be developed? I know there is a lot of JSF hate out there... just mentioning it a developer conference causes people to break out into seizures from so much fail. The web is littered with JSF Sucks blogs, but I have done some pretty cool things with it. Any thoughts on this?


title: What is a good support knowledge base tool?

text: I have been searching for a tool to help my team organize its knowledge for resolving recurring support cases. Context: our team is developing and supporting an huge applications (lots of different screens and workflow processes. We already have a good tool for managing our documentation, but we are struggling with support cases.   Support action involve often quite a lot of manual steps to fix stuff and the knowledge for these actions is more 'oral transmission' than modern tools. We need an efficient way to store them in a knowledge base to be able to retrieve similar cases based on patterns (a stacktrace, an error message, a component name, a workflow step, ...) and ranked by similarity. Our wiki search is not very powerful when it come to this kind of search and the team members don't want to 'waste' time writing a report that will never be found... Do you know efficient knowledge base tool for this kind of use case ?


title: Starting off with web dev with php

text: I'm currently working with Java / C++. I'm interested in web development and am planning to shift my stream. I heard that PHP is a good platform to start off and also it does not require that much of knowledge in technologies like JSP / Servlets or frameworks like springs / struts / hibernate. I have basic ideas about HTML and Javascript as well. I have gone through previous posts in SO and found out the relevant resources as well:   * http://net.tutsplus.com/tutorials/php/the-best-way-to-learn-php/   * http://www.webhostingtalk.com/archive/index.php/t-1028265.html   * http://www.killerphp.com/   * http://phpforms.net/tutorial/tutorial.html   * http://www.php5-tutorial.com/ etc. Now, my question is: I heard of PHP frameworks like CodeIgniter, Zend Frameworkd and Yii.   1. Doesn't learning PHP & MySql implicitly makes us aware of these frameworks?   2. Am I making a good choice in stating with PHP?   3. Is it a good idea to shift streams?


title: Comparison of IDEs for C++ and C development on Linux: KDevelop, Eclipse, NetBeans, CodeBlocks and Anjuta

text: I'd like to note your experience of full scale IDEs on Linux. I personally work mostly with `vim`, however other programmers would like to see a real IDE. So I'd like to hear your personal opinion about different IDEs and comparison between them, in following context:   * C++ and maybe some C development (not Java, Python and other stuff)   * Server side programming (no need for GUI development)   * Working on Linux not "cross-platform" development. Opinion needed regard:   1. How stable is it? If IDE crashes I don't need it.   2. Comfortable to use.   3. Powerful for debugging.   4. Integration with various build systems   5. Scalability over huge projects (projects of hundreds thousands of lines of code) I used to work with KDevelop and it was very nice IDE and seems that KDevelop 4 is a huge progress. It seems also that many rather use Netbeans and Eclipse.


title: Protecting the uninitiated (developer) from generics

text: Is it acceptable to have a dummy generic parameter in the parameters list in order to save method consumers from the need to specify type arguments? For example -               public T Generate<T>(int paramForInstance) where T : MyClass {         return MyClass.SomeFactoryMethod<T>(paramForInstance);     }          //calling code needs to specify type     MyDerivedClass instance = Generate<MyDerivedClass>(5);          public T Generate<T>(int paramForInstance, T dummy) where T : MyClass {         return MyClass.SomeFactoryMethod<T>(paramForInstance);     }          //calling code needs to provide a "sample" to enable type inference     MyDerivedClass instance = null;     instance = Generate(5,instance);      The assumption here is that if ~~junior~~ other devs on the team don't need to think about generics, they're less likely to kick. ## A Little Background (feel free to skip this) A couple weeks ago, a management-developer type in my team freaked out when he saw code (my code) that looked like this:               //conversion methods, using generics     private static TResult? IfNotDangerous<TResult>       (SomeType firstThing, string name, Func<object, TResult?> conversion)        where TResult : struct     {         return IfNotDangerous(firstThing, name,                (any, dummy) => conversion(any), (TResult?)null);     }          private static TResult IfNotDangerous<TResult>       (SomeType firstThing, string name, Func<object, TResult, TResult> conversion,       TResult defaultValue)     {         if (firstThing == null) return defaultValue;         if (!firstThing.Contains(name)) return defaultValue;         if (firstThing[name] == DangerousValue) return defaultValue;         return conversion(firstThing[name], defaultValue);     }      The complaint he had was, "Why are you using a struct?! That's so resources- heavy! And what does 'where' mean? **Nobody** on the senior development end knows what that does - I've asked them all!" After overcoming my self-pity, I found a way around that didn't use generics for this particular method. Appeasement was achieved. But I'd like to avoid trouble in the future, if possible. **EDIT** I appreciate all the encouragement, but the question was not "should I look elsewhere for work?" - it was "is this a usable workaround?"


title: Are programmers inclined towards order or chaos?

text: We've all met both kinds of people, which generally can be categorized by the status of their desks: the ones who have a clean, non-cluttered desk; and the ones whose desk look short of having been struck by a bomb shell. But what kind are programmers? Is programming driven by:   1. either order _or_ chaos, but not both,   2. a combination of both,   3. or does it have no impact whatsoever?


title: In c/c++, are block-scope variables stacked only if the block is executed?

text: Suppose this:               void func()     {      ...      if( blah )      {       int x;      }      ...     }        Is the space for `x` reserved on the stack immediately when `func` is entered, or only if the block is actually executed?   Or is it the compiler's choice?   Do C and C++ behave the same about this?


title: What is a good method to do lightweight architecture evaluation?

text: I'm familiar with architecture evaluation methods such as the technical Architecture Tradeoff Analysis Method (ATAM) and more business-oriented Cost Benefit Analysis Method (CBAM). However, these methods are fairly large scale: they prescribe several brainstorming sessions, presentations, development of a host of scenarios describing tradeoffs, etc. While useful for projects of a certain size, they are too big for internal projects or desktop applications that are typically developed by a handful of developers (or less), that even though they are small, have some fairly steep quality constraints (performance, scalability, adaptability). A typical practice I have used in the past is to have one developer (or the architect if a team has one) to come up with a general architecture for the application and then discuss it on a whiteboard with the rest of the team, typically using some pseudo-UML notation that is easy to draw and understand. This typically leads to feedback and some iterations on the architecture. But it tends to be a little too informal causing all kinds of assumptions to be made that can later turn out to be wrong decisions. Methods like ATAM typically force all stakeholders to think deeply about the architecture, which leads to discussions until everyone at least agrees on what the architecture exactly _is_. Does anyone have experience with doing lightweight up-front architecture evaluation? If so, what are good practices?


Is it possible to develop a functional language based on PHP opcode? Similar to Scala/bytecode or F#/CIL Has somebody done this already?


title: "Columnar" programming language

text: There are column-oriented databases, like HBase or Teradata. My question is whether there are programming language implementations that store the objests/structures in a similar format when they are stored in a collection. (To improve cache locality, possibly reduce memory footprint in some cases.) (Searching did not reveal these kind of languages for me, but probably I tried the wrong keywords.) What I mean is the following (in Scala syntax):               case class Data(a: Int, b: Array[Byte])     var someData: Array[Data] = new Array(Data(2, new Array[Byte](2)), Data(3, new Array[Byte](3))     var someData(1).b(1) = 1.toByte      Could be represented as the following: Array for the `a` parts:               ---     |2|     ---     |3|     ---      Array for the `b` parts:               ---------------               -----     |byteArrayRef0|   ------>     |0|0|     ---------------               -----   -------     |byteArrayRef1|   ----------------->  |0|1|0|     ---------------                       -------      Object passing would require more stack space with this structure, for example to pass the only second element from `someData` it would require to pass the the array references (for the `a` and the `b` parts) and the index `1`. Probably this is its main drawback, but I guess there might be clever solutions, or this would not be a huge problem. (The arrays should be internal implementation details, not visible, unless the container for `someData` is immutable. Probably arrays are not ideal for this kind of data primitives, but an ArrayList implementation would be better.) **Edit:** This question is not about whether this is a good/bad idea or which implementation is better. This is only about existence -or probably also announced plans, articles if they exists. (I am quite busy currently, so cannot check the suggestions yet, but will check them during the weekend.) If my question is not clear, I'll try to reformulate it.


title: How to organize the dependencies of a project

text: I have a project built with Gradle, which contains libraries which can be used freely outside the main project, like this: ![Project structure](http://i.stack.imgur.com/KwjNy.png) The folders with a square at the bottom right are project modules. I want to opensource this project (I mainly use Git and GitHub for tasks like this), but I have no idea how to organize it. Should I create separate repositories for each library (and if so, how can I link them to the main repository?), or should I put it all in one repo (I guess that's bad practice)? The main criteria is that when `git clone repo_url` is run, it should recreate project structure one-to-one, so it can still be built with `./gradlew build`.


title: Why are source control systems still mostly backed with files?

text: It seems that more source control systems still use files as the means of storing the version data. Vault and TFS use Sql Server as their data store, which I would think would be better for data consistency as well as speed. So why is it that SVN, I believe GIT, CVS, etc still use the file system as essentially a database, (I ask this question as we had our SVN server just corrupt itself during a normal commit) instead of using actual database software (MSSQL, Oracle, Postgre, etc)? EDIT: I think another way of asking my question is "why do VCS developers roll their own structured data storage system instead of using an exisiting one?"


title: show or publish software applications

text: I am thinking of uploading on source forge some personal projects that may be useful to other people.   The main reason I decided to do that is I am planning to start pursuing job in another company (leave current one).   I thought this might help me, by showning to employers stuff I did.   Is this a good idea (for the reason I am aiming) or there are any pitfalls?   Also is source forge the best place for something like this? Thanks


title: Simple dependency handling for objects (perl)

text: I am a bit stuck with a design of a project, where many objects has to have access to the same piece of information. It could be some data, to construct a global-like object for themselves or the object itself (essentially a config object). Essentialy these object are in a tree: On a top is a 'Router' object, which has 'Interface's, which has 'Host's. Router creates interfaces and interface creates hosts. Also, the router object gets that config object as parameter in constructor. I would like to keep the code clean and easy to test, keeping the neccessary mocking at minimum and allowing easy test setups. Which methods is recommended for providing access to this config object accross the project?   1. use a singleton instance of the config object   2. use a superglobal config object   3. Each object (router, interface, host) should get the config object via the constructor -> in every new object calls there should be this config object. It would be like: Host->new({config => $self->config})   4. Each object should have a reference to the parent router. Interface and Host will have access to the Router (which will be passed to them in the constructor -> weak_ref to the main Router object), and they will access the router's config object   5. Interface will have a delegate method to retrieve the config object from the router and Host will have access to this config object through this method -> this implies, that everyone should be aware of it's parents (host should have a reference to the parent interface, interface should have a reference to the router etc.)   6. Or maybe have a singleton global object-storage, from which everyone could retreive what they want (config object, database handle etc)?   7. Or use some existing dependency injection system, which seems like an overkill (a lot)


title: Does this count as 'machine learning'?

text: I've been working for a while on an app (hobby project) that makes up melodies. Each melody is composed of several phrases (musical sentences, or 'sub-melodies'). Lately I had the idea to allow the user to press a button to 'like' a melody. What this will do is save the phrases composing the melody to a storage. These phrases will be integrated into future melodies. Does this count as machine learning?


title: Would a simple attribution satisfy the BSD license's requirements for reuse or do I need to copy the whole copyright notice?

text: Would something like `This program uses code written by Nathan2055` satisfy the requirements for the BSD license, or do I need to copy out the whole notice? I know it asks that the notice is kept intact, but if I'm only using one file of code it's a waste to have to copy the entire license into the main copyright file.


title: MongoDB: Replicate data in documents vs. “join”

text: Disclaimer: This is a question derived from this one. What do you think about the following example of use case?   1. I have a table containing orders.   2. These orders has a lot of related information needed by my current queries (think about the products; the buyer information; the region, country and state of the sale point; and so on)   3. In order to think with a de-normalized approach, I don't have to put identifiers of these related items in my main orders collection. Instead, I have to repeat all the information for each order (ie: I will repeat the buyer's name, surname, etc. for each of its orders). Assuming the previous premise, **I'm committing to maintain all the data related to an order without a lot of updates** (because if I modify the buyer's name, I'll have to iterate through all orders updating the ones made by the same buyer, and as MongoDB blocks at a document level on updates, I would be blocking the entire order at the update moment). This raises the following questions:   1. Do I have to replicate all the products' related data? (ie: category, maker and optional attributes like color, size…)   2. What if a new feature is requested and I've to make a lot of queries with the products "as the entry point of the query"? (ie: reports showing the products' sales performance grouping by region, country, or whatever)      1. Is it fair enough to apply the $unwind operation to my orders original collection? (What about the performance?)     2. I should have to do another collection with these queries in mind and replicate again all the products' information (and their orders)?     3. Wouldn't be better to store a product_id in the original orders collection in order to be more tolerable to requirements change? (What about emulating JOINs?)   3. The optimal approach would be a mixed solution with a RDBMS system like MySQL in order to retrieve the complete data?      * I mean: store products, users, and location identifiers in the orders collection and have queries in MySQL like `getAllUsersDataByIds` in which I would perform a `SELECT * FROM users WHERE user_id IN ( :identifiers_retrieved_from_the_mongodb_query )`


title: Is "Experience working on large projects" something that I should strive for?

text: This is in the context of job search. There are fancy words such as "Enterprise software" (as opposed to a school project). Then there is the experience of developing/architecting large software products - something that some employers desire. While large companies may pride themselves in being able to create the "nuclear power plant equivalent", I personally see little glory in that. Surely, individual things like the Google search engine, or MS Office, or .Net framework are impressive. But then there are things less glamorous. I have worked for a couple of giants, and do not see what the big deal is. Surely, 50 programmers (+ 10 analysts and 5 managers etc.) can build something big over 4 years, but 2 programmers in 1 year can build a lot more than 1% of the comparable thing. In fact, before I had my BS degree and worked for a lab in college, I put together some code that impressed me at the time ;), but I have not seen too many examples of great code since. Long-term I think I want to gravitate to a small company. So, I wonder if I have an excuse to be opinionated about large companies, or do I truly have something to learn from working on a large project (other than: business folks do not understand software, politics sucks, we are moving too slowly, we are stuck with bad karma, we are supporting too many branches and customizations which should be dead by now, it ought to take less than 2 days to get a dev machine set up, it ought to take less than 4 hours to complete a build, unit tests would be nice)? Have you worked on a large project and learned something invaluable, something that you would not learn in a smaller place? Please share good and bad stories.


title: Is there a difference in usage between halting and terminating?

text: The title says it all: Are halting and terminating synonyms in the context of computability theory?


title: Any valid reason to Nest Master Pages in ASP.Net rather than Inherit?

text: Currently in a debate at work and I cannot fathom why someone would intentionally avoid Inheritance with Master Pages. For reference here is the project setup: >   * BaseProject   > >     * MainMasterPage >       * SomeEvent >   * SiteProject   > >     * SiteMasterPage   > >       * nested MainMasterPage >   * OtherSiteProject   > >     * MainMasterPage (from BaseProject) > The debate came up because some code in BaseProject needs to know about "SomeEvent". With the setup above, the code in BaseProject needs to call `this.Master.Master`. That same code in BaseProject also applies to OtherSiteProject which is just accessed as `this.Master`. SiteMasterPage has no code differences, only HTML differences.   If SiteMasterPage Inherits MainMasterPage rather than Nests it, then all code is valid as `this.Master`. Can anyone think of a reason why to use a Nested Master Page here instead of an Inherited one?


title: What happens when an unexpected packet arrives at a computer?

text: I have been wondering this for a few days. I basically understand how networks and packets work. But what happends when an unexpected packet arrives? Like, when I didn't send a request for a website's index, but it sends the index to my machine anyways ? Does my browser pop up? Does it ignore it? Anyway to actually catch it?


title: Why do "Joke" programming languages exist?

text: First of all please be aware this post contains some abusive language but I hope it will not bother anyone. I apologize for the bad language but that's what the name is. As I've been doing documentation on existing programming languages attempting to make a complete list of them I stumbled across terrible programming languages, which were clearly not made for actual use and implementation due to their insane difficulty. Languages such as Brainfu*k and LOLCODE or Whitespace are fool languages because they have no real use. For example, a "Hello world" program written in BrainFu*k. Taken from Wikipedia:               The following program prints "Hello World!" and a newline to the screen:          +++++ +++++             initialize counter (cell #0) to 10     [                       use loop to set the next four cells to 70/100/30/10         > +++++ ++              add  7 to cell #1         > +++++ +++++           add 10 to cell #2          > +++                   add  3 to cell #3         > +                     add  1 to cell #4         <<<< -                  decrement counter (cell #0)     ]                        > ++ .                  print 'H'     > + .                   print 'e'     +++++ ++ .              print 'l'     .                       print 'l'     +++ .                   print 'o'     > ++ .                  print ' '     << +++++ +++++ +++++ .  print 'W'     > .                     print 'o'     +++ .                   print 'r'     ----- - .               print 'l'     ----- --- .             print 'd'     > + .                   print '!'     > .                     print '\n'      or another example taken from LOLCODE language:                HAI      CAN HAS STDIO?      PLZ OPEN FILE "LOLCATS.TXT"?          AWSUM THX              VISIBLE FILE          O NOES              INVISIBLE "ERROR!"      KTHXBYE      These languages are very difficult to learn/read/work with. My question is - Why do they exist? What is the purpose of them? Also, is there an official "name" for these type of languages?


title: Handling "related" work within a single agile work item

text: I'm on a project team of 4 devs, myself included. We've been having a long discussion on how to handle extra work that comes up in the course of a single work item. This extra work is usually things that are slightly related to the task, but not always necessary to accomplish the goal of the item (that may be an opinion). Examples include but are not limited to:   * refactoring of the code changed by the work item   * refactoring code neighboring the code changed by the item   * re-architecting the larger code area around the ticket. For example if an item has you changing a single function, you realize the entire class now could be redone to better accommodate this change.   * improving the UI on a form you just modified When this extra work is small we don't mind. The problem is when this extra work causes a substantial extension of the item beyond the original feature point estimation. Sometimes a 5 point item will actually take 13 points of time. In one case we had a 13 point item that in retrospect could have been 80 points or more. There are two options going around in our discussion for how to handle this.   1. We can accept the extra work in the same work item, and write it off as a mis-estimation. Arguments for this have included:     * We plan for "padding" at the end of the sprint to account for this sort of thing.     * Always leave the code in better shape than you found it. Don't check in half-assed work.     * If we leave refactoring for later, it's hard to schedule and may never get done.     * You are in the best mental "context" to handle this work now, since you're waist deep in the code already. Better to get it out of the way now and be more efficient than to lose that context when you come back later.   2. We draw a line for the current work item, and say that the extra work goes into a separate ticket. Arguments include:     * Having a separate ticket allows for a new estimation, so we aren't lying to ourselves about how many points things really are, or having to admit that all of our estimations are terrible.     * The sprint "padding" is meant for unexpected technical challenges that are direct barriers to completing the ticket requirements. It is not intended for side items that are just "nice-to-haves".     * If you want to schedule refactoring, just put it at the top of the backlog.     * There is no way for us to properly account for this stuff in an estimation, since it seems somewhat arbitrary when it comes up. A code reviewer might say "those UI controls (which you actually didn't modify in this work item) are a bit confusing, can you fix that too?" which is like an hour, but they might say "Well if this control now inherits from the same base class as the others, why don't you move all of this (hundreds of lines of) code into the base and rewire all this stuff, the cascading changes, etc.?" And that takes a week.     * It "contaminates the crime scene" by adding unrelated work into the ticket, making our original feature point estimates meaningless.     * In some cases, the extra work postpones a check-in, causing blocking between devs. Some of us are now saying that we should decide some cut off, like if the additional stuff is less than 2 FP, it goes in the same ticket, if it's more, make it a new ticket. Since we're only a few months into using Agile, what's the opinion of all the more seasoned Agile veterans around here on how to handle this?


title: Why (or why not) are existential types considered bad practice in functional programming?

text: What are some techniques I might use to consistently refactor code removing the reliance on existential types? Typically these are used to disqualify undesired constructions of your type as well as to allow consumption with a minimal of knowledge about the given type (or so is my understanding). Has anyone come up with a simple consistent way to remove reliance on these in code which still maintains some of the benefits? Or at least any ways of slipping in an abstraction that allows their removal without requiring significant code churn to cope with the alteration? You can read more about existential types here ("if you dare..").


title: Looking for parallel programming problem

text: I am trying to come up with a problem that is easily solvable in a parallel manner and that requires communication between threads for a test. I also am trying to avoid problems that require require random waits, which rules out dining philosophers and producer-consumer (bounded buffer), two of the classics. My goal is for the student to be able to write the program in less than 20-30 minutes in front of a computer not knowing of the problem beforehand. (This is to prevent preparation more than to come up with something novel.) I am trying to stress the communication aspect of the program, though the multi-threaded nature is also important. Does anyone have some ideas? **Edit** : I'm using Google Go for the language and testing comprehension of the goroutines/channels combo vs an actors library that I authored.


title: Where to keep global variables in Windows Forms App

text: I have here a Vb.Net employee management application. It has employees, managers, teams, trainings and so on. The way the application is set up now, data is read from the database in the startup form (frmMain) load event and kept in that forms public properties. After that all other forms (and there is many of them) reference those lists (list (of employee), list of (team)) usging those properties. For example               dim emp = frmMain.Employees.Find(Function(x) x.ID = 128) , or     dim team1 as new Team     frmMain.Teams.Add(team1)      I feel that this is a very bad way to solve this problem, but I'm stuck on deciding how this should be done. Some singleton class that would keep all those lists (there is lots of them) instantiated on application startup, or is there a better way to do this?


title: Moving from PHP to ASP.NET

text: I have been working for a long time with PHP, and tried to be as good as possible on it (good coding practices, knowing how every request is handled from the start to the end, etc.), but now, for job reasons I have to start learning ASP.NET and C#. I've read and tried to understand it's foundations, as ASP.NET is always working with a given Framework called .NET, but there are so many versions, and different approaches like MVC or WebForms, etc. I've made some tests, and I see that parts of the code get compiled, others not —don't know why—, and that a lot of shit is generated in the final HTML output. I have the feeling of **losing control** over my WebApp, so my question is: **Where can I start to understand how that works?** Any tutorial, book, etc is welcome (as up-to-date as possible). **Is it possible to keep having control of the code with that Microsoft software, so the final output is clean, lightweight and high performance JS and HTML code?** For the C# part, I think this it is the easiest one, I'm just looking for a good book to read... I guess version 5.0. **Am I right?**


title: What is the difference between state and field?

text: Is state another name for field or is it something different? For example:               private int telNumber;      can I say about telNumber that it is a state or it is a field?


title: Does the term "Learning Curve" include the knowing of the gotchas?

text: When you learn new technology you spend time understanding its concepts and tools. But when technology meets real life strange and not pleasant things happen. Reuqirements are often far from ideal and differ from 'classic' scenario. And soon I find myself bending the technology to my real needs. At this point I begin to know bugs of the system or that is is not so flexible as it seemed at the very begining. And this 'fighting' with technology consumes a great part of the time while developing. What is more depressing is that the bunch of such gotchas and workarounds are not concentrated at one place (book, site, etc.) And before you really confront it you cannot really ask the correct question because you do not even suspect the reason for the problem to occur (unknown-unknown). So my question consiststs of three: 1) Do you really manage (and how) to predict possible future problems? 2) How much time do you spend for finding the workaround/fix/solution before you leave it and switch to other problems. 3) What are the criteria for you to think about yourself as experienced in the tecnology. Do you take these gotchas into account?


title: How to mentor junior programmer who may not be a good fit for programming?

text: I'm in a bit of a precarious position. I'm working remotely for a client that has recently brought in a junior developer straight out of college into the project. He works physically at their office. I believe he studied computer science (although I can't recall 100% at the moment). He has been with the company a couple months now and was started, by the project manager, on testing and getting familiar with the app and for about the past month, has been assigned small bugs and features. The thing is, in that time, he has only committed code once and it was code that I basically walked him through and wrote out for him. (I thought it would be beneficial for him to see the working solution after he had spent days trying to get it to work). I have had a few calls with him and some pair programming sessions but he is spending days getting frustrated at simple JavaScript code that should really not be that difficult even for a junior developer. I am beginning to think that maybe programming is not a good path for him but want to make as much effort as I can to helping him find solutions on his own and help him improve. This is the first time I have been in a position of having to provide training and mentoring. Being remote probably makes this much more difficult as well. What can I do to help him improve and to get him going?


title: What is expected of an intern iOS SDK programmer from self-taught arena?

text: **edit** : I'm asking for samples an intern would want to show, please don't answer soft-skills that get this marked as a dupe, it is NOT. To be more specific, what sample apps and background, is minimum expectations for an intern? Yes, I pass the FAQ tests with this and it is related, let me narrow it down a bit though. So, when I went professional from hobbyist, I had to know C++ like english (a language), have the iOS manuals read, and at least be smart enough to learn libraries even if I haven't used them before. Besides algebra, the bar wasn't much higher than that. As an intern, I was not expected to architect, only to fix apps. Right now, I am tutoring someone. I am his only rubric, so I need help from others on this so he knows when he's "hirable", in the programming field. I realize a definite this/that is impossible, but a rough estimate on what your company expects of interns or learning people is all I need. For example, I would expect sample apps that 1) Consume a web service. 2) Transition between view controllers. 3) Show a simple game, cards or board, that show off basic state transitions and iOS workflows. We do not need to debate the philosophy of learning attitudes and other soft skills, just what sample apps we look for. Soft skills questions get closed, this is programming-specific. We can infer the rest based on the samples one would look for. Specifically iOS apps. If you have a design pattern addition to an app, feel free. Thank you for answering. This question is hard to word, I saw so many relevant ones get closed, but as far as I can tell I match the topics


title: Base classes as factories?

text: I was writing some code over the weekend and I found myself wanting to write a factory as a static method in a base class. My question is simply to know if this is a c# idomatic approach? My sense that it might not be comes from the fact that the base class has knowledge of the derived class. That said, I'm not sure of a simpler way to get the same result. A whole other factory class seems (to me at least) like unneeded complexity (?) Something like:               class Animal     {       public static Animal CreateAnimal(string name)       {          switch(name)          {             case "Shark":               return new SeaAnimal();               break;             case "Dog":               return new LandAnimal();               break;             default:               throw new Exception("unknown animal");          }       }     }     class LandAnimal : Animal     {     }          class SeaAnimal : Animal     {     }


title: Should I use the Date type in JAX-RS @PathParam?

text: This is what I'm thinking about doing on a JEE Glassfish server using Jersey.               @GET     @Path("/{name}/{date}")     public String getMessages(@PathParam("name") String name, @PathParam("date") Date date)      I like the idea of being able to tell people consuming this RESTful webservice that "The date here is anything that works with the Date class in Java". That's pretty simple from the standpoint that they can just look at the Date spec, and they'll already have a working model that they can test with. The problem that I'm worried about is that when I do this, JAX-RS is not very nice when Date() doesn't like what it gets in the constructor. Since Date() throws an error if it can't parse what it's given (like if you pass it the string "today" instead of a real date), the JEE server returns a 404 error. Is this a good practice? Is there a better way to do this that I'm not thinking of?


title: Highlight global variable in vim (or any other free editor)

text: In Source Insight, global variable show up in a different colour. Is there a way to accomplish this in vi (or any other free editor)?


title: Web api authentication techniques

text: We have a asp.net MVC web service framework for serving out xml/json for peoples Get requests but are struggling to figure out the best way (fast, easy, trivial for users coding with javascript or OO languages) to authenticate users. It's not that our data is sensitive or anything, we just want users to register so we can have their email address to notify them of changes and track usage. In our previous attempt we had the username in the URI and would just make sure that username existed and increment db tables with usage. This was super basic but we'd notice people using demo as a username etc so we need it to be a little more sophisticated. What authentication techniques are available? What do the major players use/do.


title: How to improve my email communication

text: Paraphrase of an email I sent to a colleague > I noticed a problem with System A. I have determined that it is not caused > by X. I suspect that it is being caused by Y. (since you are in charge of Y) > Can you please take a look at it? (The part in parentheses was not included in my email because this colleague knows full well he is in charge of Y... it should be understood that's why I was sending him the email) I run into the colleague half a day later, and say, "did you look at the problem with System A yet?" and he answers, "Oh, yeah, I got your email about System A being broken but I assumed it was probably caused by X, so I was waiting for you to check on that." Obviously my message did not get communicated. This is an all-too-common result of emails I send and is very discouraging... yet, I don't know how I could make my emails any clearer. They are always as brief, clear, and to the point as I can make them. Any suggestions? Maybe there is something inherent about the medium of email that is just not effective for these types of communications?


title: Laptop like keyboard, trackpad, and monitor combo that I can hook up to my desktop so I can program while reclining on my couch?

text: My desktop is fine, except that I like programming while reclining on a couch. My legs hurt after sitting too long in an office chair. Is there anything like a keyboard, trackpad, and monitor combo that I could hook up to my desktop (8 feet away from the couch), so I can work on the couch? I was thinking of buying a laptop for this purpose, but I'm looking to save money.


title: Is paper indispensable in a programmer's everyday work?

text: As a programmer who work in a company whose vision is to make **paperless office** possible, is there any way I can work effectively while using less paper? I can list at least several kinds of papers I use quite often:   * Paper notebook, on which I do most of the pre-coding design work and ideas   * Books   * Temporary printouts of source code, though not so often ( _in color, with a 6 point font at 600 DPI_ )   * Sticky note, to remind myself of things that should be taken care of within a few days On the other hand, I also use a wiki and an office text editor. Once a while I would use a diagramming software to make a few flowcharts. **Deeper questions:**   * Is there a relationship between paper use and productivity?    * How can programmers help save the trees?    * Is paperless software development fundamentally different from paperless office? Related questions:   * Do you ever write code with pen and paper, and should we do it more often?   * What physical tools do you find useful to work as a programmer?   * What things are essential on a programmer's desk?   * Stuff every programmer needs while working Additional info, if it helps:   * Everyone has dual monitors.   * We have decent project management and issue tracking software (both web-based). **Please be constructive.** In particular, please give your answer to your peer programmers who wish to be flexible and are willing to change working style in order to become more productive as well as meeting certain their own personal values. * * * _**Edited:_** I removed the company's view because it appears to be too flamebait. If you need to see my original words, go to the edit history. _**Deleted: Doxygen and whiteboard._**   Reason: disregarding my personal experience with these great tools, we never had to print out anything as a consequence of using/not using them. To see my original words, go to the edit history.


title: Is the agile approach too much of a convenient excuse for cowboys

text: I believe that an agile approach is best for projects where the requirements are fuzzy and a lot of interaction is required to help shape the end user's ideas. _However..._ In my professional work, I keep ending up at companies where an "agile" approach is used **as an excuse as to why no effort was put into an up front design;** when the requirements are well understood. I can't help but thinking that if the agile approach wasn't around, I'd be sitting here with a nice high-level specification and not having to revisit the same screen and functionality every second day when something else crops up or so and so hadn't thought of that. > Are the benefits of agile methodologies really enough to outweigh the excuse > for being lame it gives to cowboy technical leads? Update: Ironically I'm now a certified Scrum Master. One of the papers presented on the Scrum course observed that the best development process was one where there was a single expert or guru making the design decisions, however that has obvious weaknesses. Scrum shifts the responsibility for producing quality software to the "Team" which means a sub-standard team can get away with churning out spaghetti which I guess is no different to other Agile and non-Agile development processes.


title: When should you move the post-statement of a 'for' loop inside the actual loop?

text: With a `for` loop you can move the post-statement empty and move it to the bottom of the code in the loop:               for (int i = 0; i < 10; /* empty */ ) {         //...         ++i;     }      But in this case it doesn't gain you anything; more importantly it makes the code harder to read as you would expect the `++i` to reside at the top of the statement as the post-statement. So when is it valid to move the post-statement from its usual location to somewhere inside the loop? **EDIT:** The code which made me think about this question I got from _C++ Primer_ :               for (T* p = first_free; p != elements; /* empty */)        alloc.destroy(--p);      Here `first_free` is a pointer to the first free element in an array of objects to be destroyed in reverse order, and `elements` is a pointer to the first object in the array. Here it seems, to me, valid to move `--p` from a post-statement into the loop, because otherwise you would need to rewrite the code as such:               for (T* p = first_free - 1; p != elements; --p)        alloc.destroy(p);      Here the code would run into problems if the array doesn't actually contain any objects as you would skip over `elements` and thus cause a crash (or at least undefined behaviour). This means you would need an additional check before the loop whether the array actually contains any elements or not.


title: How to automatically generate build numbers for a Python GitHub project?

text: What's the best way to automatically generate or increment version numbers for a (python) project that's on GitHub? In the past I've always manually incremented the versions number manually via the `argparse` or `optparse` libraries.


title: Can I use GPL software in a commercial application

text: I have 3 questions about the GPL here:   1. If I use GPL software in my application, but don't modify or distribute it, do I have to release my application under the GPL?   2. What if I modify some software that my application uses. Then do I have to release my application under the GPL, or can I just supply the modified software under the GPLs terms.   3. And what if I use GPL software, but don't modify it, can I distribute it with my application? My case in point is, I have a PHP framework which I use the GeSHi library to highlight some output.   1. Because GeSHi is GPL, does my framework have to be GPL?    2. Can I modify GeSHi for particular use cases of my application if I supply the modifications back to the GeSHi maintainers?   3. Can I redistribute my framework with GeSHi?


title: Having trouble with exposing class properties across projects

text: I have several projects in my solution:   * **Logan.Web.DBContext** defines the DbContext for the database and builds the data model   * **Logan.Web.Objects** defines the classes that will represent the tables in the database   * **Logan.Web.Data** defines the data layer that the application will use   * **LoganMVC** is the actual MVC website Obviously I don't want the MVC website to know too much about the database so I have no links between it and the Objects/DBContext projects. Instead, the Data project acts as a "middle-man" between them and contains all the CRUD functionality. The problem I'm having with this structure is that, to show anything on the Views, the Models need to know the properties for the data as defined in the Objects classes. I'm not sure how to expose them without referencing the Objects project in the MVC project, but it is my understanding that this would not be good practice. Instead, I'd prefer, if at all possible, to expose them through the data layer, but I also can't figure out how to do that in any way that makes sense. I've posted all the code for most of these projects as such currently exists on pastebin: http://pastebin.com/eFahpGzE   * DBContext namespace starts on line 1   * DBObjects namespace starts on line 141   * Data namespace starts on line 185 What's the best way to expose the properties of the classes in Logan.Web.Objects so that they can be used in LoganMVC given the structure defined here?


title: When and Where should we use hoisting in Javascript

text: I'm new to Javascript. I'm learning the concept of hoisting in Javascript.   Based on the Javacsript tutorials in Mozilla website, I came across this word `hoisting`. According to those tutorials, **variables in JavaScript is that you can refer to a variable declared later, without getting an exception**. But, my question is on what circumstances is it suitable to use hoisting in a client-side Javascript or why should we use hoisting in Javascript. What are its advantages.


title: How do you regularly take advantage of VS2010's multi monitor support?

text: Although I like VS2010's multi monitor support, I seem to have too many accidental window drags, where I unsnap a window without intending to. This behavior has made me still live in the mental model of vs200X's non-snappable windows. 1) Do you have a particular layout that works for general purpose work? 2) How have you optimised for specific scenarios (SQL, Debugging, Workflow, WPF) 3) Are you aware of any hotkey or utility that will jump to a particular window layout? 4) Are you aware of any way I can reduce the times I accidentialy undock a window?


title: Why does Microsoft still ship VBA within Office products, instead of integrating .NET directly?

text: I know that it's possible to call .NET code from your VBA code, but why does VBA continue to exist? The only reason I can think about is legacy. I just had to sort a `Scripting.Dictionary` and the amount of code needed was frightening. The IDE looks like Visual Studio 2003. And there are many little details, that drive you insane (Like changing the line, and getting a warning because of some compilation error). Or, if you open more than one spreadsheet, it mixes into you "VBAProject" and this is really confusing. The whole module/classmodule/form division is actually not that bad, but I end up everytime with directly writing logic in forms, or having one huge module that handles everything. Why can't I press Alt+F11, and hack in C#?


title: Is there any evidence that syntax highlighting in IDEs & editors aid new learners?

text: We take for granted syntax highlighting in IDEs and text-editors, and it is the one thing I ask for in any editor. Is there any evidence that syntax highlighting actually is useful--i..e, do people program better (with fewer typos) when using it than without? In particular, I am trying to find some research that shows new programming students make fewer mistakes when using an editor with highlighting versus new students who use a plaintext editor without highlighting.


title: Should you avoid adding unecessary stack frames?

text: I have been working with laravel (PHP) recently, and there is an option when using their fluent ORM to define where clauses using closures. This gives us two, functionally equivalent, ways to specify a where clause that should only be added in certain cases: Example 1                   $query = App::make('Vendor_Orders')->             where(function($query) use ($admin) {                 if (!$admin) {                     $query->where('vendor_id', '=', $this->id);                 }             })->             get();      Example 2                   $query = App::make('Vendor_Orders');         if (!$admin) {             $query->where('vendor_id', '=', $this->id);         }         $query = $query->get();      As you can see, one of these is using a closure (and maintaining the "fluent- ness"), while the other avoids it. My instinct is to prefer the second, because using an anonymous function like that is adding an extra stack frame, which I would expect to make the program less efficient (possibly a holdover from my time working with C). On the other hand, my colleague (whose first language was PHP) prefers the first example, because it avoids the use of a second assignment operator, and he doesn't see anything wrong with piling up extra function calls. This started me wondering - how much effect does that extra stack frame really have, in a modern system? Does it make any practical difference if one uses a function call instead of an if statement? I'm not looking for subjective which-do-you-prefer answers, I'm asking for some sort of facts regarding the impact of unnecessary jumps - particularly to anonymous functions - in modern, interpreted languages (e.g. PHP, Java, etc.). Possibly also some notes on how this differs from old-school compiled languages.


title: How best to design Access Control Layer in n-tier architecture application

text: This is a typical architecture scenario for a 3-tier design: **UI-tier**   Has Graphical User Interface components **Middle-tier**   Has business logic including the following layers:   1. Data Access Layer (DAL)   2. Access Control **Data-tier**   Typically your database or physical data storage What is the best way to implement **Access Control** when performance is top of priority list?   * Should the DAL return ALL data and have the UI layer worry about Access Control?   * Should the DAL perform Access Control, i.e. decide with data to return, so that the UI does not worry about Access Control?  What are your thoughts on this, and what guides you when making such design decisions?


title: Why does the iterative version take longer?

text: I was looking over at http://programming.lispdream.com/blog/2011/06/recursion- vs-iteration/ and I saw that on his implementation of the recursive and iterative implementations of the factorial function, the iterative actually takes longer given n = 1,000. I can't figure out why (he doesn't explain, but says that it is an exercise for the reader). Sorry for my newness to all of this.


title: Use of c89 in GNU software

text: In GNU coding standard it is said that free software developer should use C89 because C99 is not widespread yet. > 1999 Standard C is not widespread yet, so please do not require its features > in programs. Reference here. Are they talking about developers knowledge of C99, or about compilers supporting it? Also, is this statement plausible as of today or is it somewhat "obsolete" or at least obsolescent.


title: Better style for member variables?

text: class awesomeClass {         std::list<A> myList;         //...         void fillList();     };          awesomeClass::awesomeClass() {         fillList();     }          void awesomeClass::fillList(){         //...         foreach(A a, otherList)             myList.push_back(a); //add to list     }      Compared to :               awesomeClass::awesomeClass() {         myList = fillList();     }          std::list<A>& awesomeClass::fillList() {         //...         std::list<A> ret;         foreach(A a, otherList)             ret.push_back(a); //add to list         return ret;     }      This is just a class with an `std::list` as a member variable and a function which fills this list. The first fills it inside the function and the second one returns a list and assigns it to the member list. Which of these is better style? The one which fills the list inside the function or the one which returns a list? Or is there an even better solution?


title: Developing android on android

text: Is there currently a way of developing android apps on an android phone? In other words, write, compile, install and run regular android java on the phone without using a pc? If not, what would make it possible, if at all? (would rooting be necessary? Or an android emulator compiled for android?)


title: What do goroutines, Ruby Fibers, etc. look like to the OS/Kernel?

text: In process concurrency and thread concurrency it's quite obvious how the kernel sees these as they map directly to real things that the kernel manages. When it comes to Golang goroutines and Ruby Fibers (these are similar things right?) I'm clueless as to how these are managed. Are they managed by the respective languages implementation/Virtual Machine(I know Go doesn't have a VM) or are they mapped to something that the kernel is better at handling?


title: Is it possible for a technically open source application (specifically javascript) to be released under a proprietary license?

text: A javascript application release won't technically be closed source - at best it can be obfuscated. Given that, my question has two parts: >   * Is it at all possible to release a technically open source application > under a proprietary license? >   * Are there any examples of applications which are technically open > source, have been kept under a proprietary license, and are being profitably > sold? >


title: How can I find all connections in a mesh network/graph?

text: Suppose I have a mesh of relationships, such as   * Friends who trust some friends and not others    * A IPv6 router that needs to locate peers across the Internet   * A PGP Web Of Trust that needs two people to locate each other's trust level I'm interested in determining not only the shortest path, but the cost of each (an arbitrary weight by be added), the nodes of each path, and other information typically used in this general purpose need. What approaches are there to accommodate this need? Ideally this will be something that I can run locally on a phone or computer and search a large graph in O(N) speed or better.


title: Difference between a heap and a priority queue

text: I always thought that heaps and priority queues were synonyms - an abstract data structure that supports the `insert`, `findMin` and `deleteMin` operations. Some literature seems to agree with me - Chris Okasaki's Purely Functional Data Structures (chapter 3), for instance. On the other hand, Wikipedia's heap page defines it as a tree-based data structure, and states that heaps are a concrete implementation of priority queues. I'm having a hard reconciling this with the fact that I can think of more than one heap implementation - leftist heaps, binomial heaps, splay heaps... Does the simple fact that a heap can be implemented with different data structures not mean, by definition, that it is an abstract data structure? And if that's the case, is there an actual difference with priority queues?


title: Efficiency of getters/setters with database performance

text: I'm currently in the process of refactoring a very old personal project of mine, which used procedural PHP-in-HTML code. I'm modernising it as a learning project, using OOP where beneficial. I understand the basics of OOP but I'm wondering if I understand correctly as it would seem my old way of doing this was faster in this case. On a user's profile page, all of their stats are listed. It's a game so there are lots of individual fields containing stats like wins, losses etc. Now I've made a User class and given every stat its own getter/setter. A typical pair looks like this:               function getEmoticon() {         if ($this->emoticon) {             return $this->emoticon;         }              $stmt = $this->conn->prepare('SELECT emoticon FROM profile WHERE id=:userid');         $stmt->execute(array('userid' => $this->userid));         $row = $stmt->fetch();              return $this->emoticon = $row['emoticon'];     }          function setEmoticon($emoticon) {         $stmt = $this->conn->prepare('UPDATE profile SET emoticon=:emoticon WHERE id= :id');         $stmt->execute(array('id' => $this->userid, 'emoticon' => $emoticon));         return $this->emoticon = $emoticon;     }      There used to be one single "GET * FROM profile" SQL query to get all the user's stats in a single query. Now though, I'm resorting to using the getter for every stat, resulting in a database query for every stat. On the profile page it means it has gone from 1 database query to dozens. Is this the right way to do things? It seems more inefficient but I'm not sure how else to do it, unless I have a User class method like getAllStats() or something.


title: Who should have full visibility of all (non-data) requirements information?

text: I work at a smallish mid-size company where requirements are sometimes nothing more than an email or brief meeting with a subject matter manager requiring some new feature. Should a programmer working on a feature reasonably expect to have access to such "request emails" and other requirements information? Is it more appropriate for a "program manager" (PGM) to rewrite all requirements before sharing with programmers? The company is not technology-centric and has between 50 and 250 employees. (fewer than 10 programmers in sum) Our project management "software" consists of a "TODO.txt" checked into source control in "/doc/". Note: This is nothing to do with "sensitive data access". Unless a particular subject matter manager's style of email correspondence is top secret. Given the suggested duplicate, perhaps this could be a turf war, as the PGM would like to specify HOW. Whereas WHY is absent and WHAT is muddled by the time it gets through to the programmer(s)... Basically. Should specification be transparent to programmers? Perhaps a history of requirements might exist. Shouldn't a programmer be able to see that history of reqs if/when they can tell something is **hinky** in the spec? This isn't a question about organizing requirements. It is a question about WHO should have full VISIBILITY of requirements. I'd propose it should be ALL STAKEHOLDERS. Please point out where I'm wrong here.


title: Why is there an alternative download page of python for China?

text: On http://python.org there are two download pages, http://python.org/download/ for international users and http://python.org/getit/ for Chinese users. When accessed from a country other than china, the second link redirects to the normal download page. Why is that so?


title: Python decorators and Lisp macros

text: When looking Python decorators someone made the statement, that they are as powerful as Lisp macros (particularly Clojure). Looking at the examples given in PEP 318 it looks to me as if they are just a fancy way of using plain old higher-order functions in Lisp:               def attrs(**kwds):         def decorate(f):             for k in kwds:                 setattr(f, k, kwds[k])             return f         return decorate          @attrs(versionadded="2.2",            author="Guido van Rossum")     def mymethod(f):         ...      I haven’t seen any code transforming in any of the examples, like described in Anatomy of a Clojure Macro. Plus, Python’s missing homoiconicity _could_ make code transformations impossible. So, how do these two compare and can you say they are about equal in what you can do? Evidence seems to point against it. **Edit:** Based on a comment, I’m looking for two things: comparison on “as powerful as” and on “as easy to do awesome things with”.


title: What are the advantages and disadvantages of storing the number of comments in an integer column vs. calculating it on the fly?

text: Let's take CodeReview page as an example. If you go here, you will see the list of the questions with their vote numbers and comment numbers Now, I am wondering if these numbers are calculated on the fly (e.g. count the total comments in db for this question), or is there an actual field in the `questions` table called `voteCount` and it's incremented by one whenever someone votes for this question? Just another question. Both VoteCount and CommentCount are just integers, what about the user information that is displayed for each question? Hope this is the correct place to ask this question.


title: Precaching HTML image resources

text: I wrote a web cam viewer where the javascript source basically sources the image according to an "active" class in a list. I was wondering what are good modern techniques to make images load faster in the background, so a user can get a better experience flicking through images. Obviously it doesn't make sense to download all images, I imagine it needs to be like when one scrolls through a Google map in principle, images are loaded on demand.


title: Should consistency be favoured over programming convention?

text: When designing a class should consistency in behaviour be favoured over common programming practice? To give a specific example: A common convention is this: If a class owns an object (e.g. it created it) it is responsible of cleaning it up once it's done. A specific example would be in .NET that if your class owns an `IDisposable` object it should dispose it at the end of its life. And if you don't own it then don't touch it. Now if we look at the `StreamWriter` class in .NET then we can find in the documentation that it closes the underlying stream when it is being closed/disposed. This is necessary in cases where the `StreamWriter` is instantiated by passing in a file name as writer creates the underlying file stream and therefore needs to close it. However one can also pass in an external stream which the writer also closes. This has annoyed me heaps of times (yes I know you can make a non-closing wrapper but that's not the point) but apparently Microsoft has made the decision that it's more consistent to always close the stream no matter where it came from. When I come accross such a pattern in one of my classes I usually create a `ownsFooBar` flag which gets set to false in cases where `FooBar` is injected via the constructor and to true otherwise. This way the responsibility of cleaning it up is passed to the caller when he passes the instance explicitly. Now I'm wondering if maybe consistency should be in favour over best practice (or maybe my best practice is not that good)? Any arguments for/against it? **Edit for clarification** With "consistency" I mean: The consistent behaviour of the class always taking ownership (and closing the stream) vs "best practice" to only take ownership of a object if you created it or explicitly transfered the ownership. As for an example where it is enoying: Assume you have two given classes (from some 3rd party library) which accept a stream to do something with it, like creating and processing some data:                public class DataProcessor      {          public Result ProcessData(Stream input)          {               using (var reader = new StreamReader(input))               {                   ...               }          }      }           public class DataSource      {          public void GetData(Stream output)          {               using (var writer = new StreamWriter(output))               {                    ....               }          }      }      Now I want to use it like this:                Result ProcessSomething(DataSource source)      {           var processor = new DataProcessor();           ...           var ms = new MemoryStream();           source.GetData(ms);           return processor.ProcessData(ms);      }      This will fail with an exception `Cannot access a closed stream` in the data processor. It's a bit constructed but should illustrate the point. There are various ways to fix it but nevertheless I feel that I work around something I should not have to.


title: Origin of the programming language term "boxing"?

text: What was the first programming environment (probably language) to use the words "boxing" and "unboxing" to indicate encapsulating a primitive type in some kind of wrapper to allow it to be used in more object-y contexts? (Or something like it.) (I recently noticed that "boxing" is a very critical concept in the J programming language, and so I suspect it may be from APL. A coworker of mine thinks it might be from LISP.)


title: Is it justified to use project-wide unique function and variable names to help future refactoring?

text: Refactoring tools (like ReSharper) often can't be sure whether to rename a given identifier when, for example refactoring a JavaScript function. I guess this is a consequence of JavaScript's dynamic nature. ReSharper solves this problem by offering to rename reasonable lexical matches too. The developer can opt out of renaming certain functions, if he finds that the lexical match is purely accidental. This means that the developer has to approve every instance that will be affected by the renaming. For example let's consider we have two Backbone classes which are used completely independently from each other in our application:               var Header = Backbone.View.extend({         close: function() {...}     })          var Dialog = Backbone.View.extend({         close: function() {...}     })      If you try to rename `Dialog`'s `close` method to for example `closeAndNotify`, then ReSharper will offer to rename all occurences of `Header`'s `close` method just because they are the same lexically prior to the renaming. To avoid this problem, please consider this:               var Header = Backbone.View.extend({         closeHeader: function() {...}     })          var Dialog = Backbone.View.extend({         closeDialog: function() {...}     })      Now you can rename closeDialog unambiguously - given that you have no other classes having a method with the same name. Is it worth it to name my functions this way to help future refactoring?


title: I failed FizzBuzz, would you hire me?

text: I'm a developer with a CS degree and have work experience doing development in a number of languages for almost 3 years. Today I had an interview, overall it went quite well, I prepared for most of the questions and felt ready for anything. At the end of the interview, they gave me ONE programming question...a problem like FizzBuzz (without the print the number part). I believe I made too many mistakes and thus have "failed" it. Is all hope lost for me? Here is my code:                 void FizzBuzz()       {         for(int i = 0; i <= 100; i++)         {           bool isThree = i % 3;           bool isFive = i % 5;               if (isThree)          {              print "Fizz\n";          }          else if(isFive)          {              print "Buzz\n";          }          else          {              print "FizzBuzz\n";          }       }      }      As you can see I messed up the bools which should have the syntax i % 3 == 0; If I'm remembering the question right I also put an else instead of an elseif with isThree && isFive. I was quite stressed, but that's no excuse for missing a simple problem. So the question is, how important is being able to produce working code on the spot relative to other factors, such as experience and personality? For instance, would the above code be a deal breaker?


title: Replaceable parameter syntax meaning

text: Replaceable parameter syntax for the console object in C#. I am taking the O'Reilly C# Course 1 and it is asking for a replaceable parameter syntax and it is not very clear on what that means. Currently I used this:               double trouble = 99999.0009;     double bubble = 11111.0001;     Console.WriteLine(trouble * bubble);      Am I missing the meaning of replaceable parameter syntax? Can someone provide an example for what I am looking for? Original question for the quiz: "Create two variables, both doubles, assign them numbers greater than 10,000, and include a decimal component. Output the result of multiplying the numbers together, but use replaceable parameter syntax of the Console object, and multiply the numbers within the call to the Console.WriteLine() method."


title: How do operating systems… run… without having an OS to run in?

text: I'm really curious right now. I'm a Python programmer, and this question just boggled me: You write an OS. How do you run it? It has to be run somehow, and that way is within another OS? How can an application run without being in an OS? How do you tell the computer to run, say, C, and execute these commands to the screen, if it doesn't have an OS to run in? Does it have to do with a UNIX kernel? If so, what is a Unix kernel, or a kernel in general? I'm sure OSes are more complicated than that, but how does it work?


title: Looking for session/event analytics analysis tool

text: I have data that is basically made up of a set of sessions filled with events. For example:               Session1 - [Event1] [Event2] [Event3]...[Event64]     Session2 - [Event1] [Event3] [Event4]...[Event64]      The data itself currently lies in a MySQL database in the following 2 tables:               sessions: id, time     events: sessionId, sequence, event      What I need to create are funnels in percentages that show the movement from one event to the next. I need a tool to analyze the sessions and output a combined "tree" of sorts, to show where most users went. Example:               START -> Event1 -- 50% --> Event 2                |                |                ----- 50 % --> Event 3 -- 20% --> Event 23                                  |                                  ------- 30% --> Event 24                                  |                                  ------- 50% --> Event 25      I can also assume for simplicity that no cycles are needed in the analysis. If for instance we come across these sessions:               [Event 1] [Event 2] [Event 3] [Event 2]     [Event 1] [Event 2] [Event 2]      Then the processed tree would be ordered like this:               [Event 1] -- 100% --> Event 2 -- 50% --> [Event 3] -- 100% --> [Event 2]                              |                              ------- 50% --> [Event 2]      I can also safely assume that all sessions start with [Event 1]. Now, I can always write some code to arrange data in a certain way but the analysis and visualization seems a bit complex. Also, the amount of sessions is rather large (a few millions). Is there any existing tool or framework that can help me analyze this?


title: Service to prove authorship with trusted timestamp

text: This question is related with copyrights. The copyright is granted by default to the author of some code, however this requires to prove that some person is the "first" author of some piece of code. Consider the following example:   * Andy writes some code in 2010 and stores it in a not secure enough place.   * Brian copies that code in 2011 and registers this code in some service to associate it with some timestamp, to prove he had it written in 2011.   * Andy decides he should be able to prove he is the author of the yet not published code and gets proceeds as Brian in 2012.   * Carol has to judge who is the original author of that code in 2013 and all the evidence is in favor of Brian. I think such a service is important and if I'm not mistaken there are some services like that which provide this for a price. At the same time nowadays there are quite a few git based services like Github, Bitbucket, Assembla, etc. that provide a version control system and store all the different versions made available for some code through time. They are free and offer really nice features. In some of them it is possible to define a repository as private and then switch it as public when the code is ready to be released. The problem with the git based services is that they trust and believe the client on the dates for the commits. This means that if Brian commits in 2011 some code and publishes (pushes) it then David could manipulate the date in his computer to pretend he committed that code in 2009, beating Brian and Andy (the real author of the code). So basically I would like to know if there is some kind of service like these that:   * handles timestamps in a trustworthy way   * allows publishing the code   * allows publishing the different versions and diffs   * allows private repositories that can be made public if shit happens   * is free So far, the most reasonable approach I found is sending something through mail. Even though the MIME headers can be manipulated the SMTP servers in the route should not be reasonably trustworthy and they set the timestamp for the time the mail goes through them. This is a whole mess when compared with bitbucket, for instance, you cannot read my e-mails (I truly hope). Bitbucket allows private repos, repos can be made public with all the previous versions and diffs, etc. The only problem: the timestamps an be manipulated and thus they are not trustworthy. So the question is: do you know about any service like this? PD: Emails should be as valid as regular mail or escrows, even though they may raise more eyebrows among lawyers. But even if a tarball in an email is something simple to produce and do, it's much more natural to simply use some CVS, which should be used anyway. They do even have the timestamps already and I guess that should work in centralized systems like subversion, where the timestamp is set by the server. So maybe services that allow subversion repositories (SourceForge, Assembla, Google Code, etc.) could be enough? Would they be enough? Do you know about other (possibly better) alternatives? Assembla seems to be the only one fulfilling all the requisites. Thank you.


title: How to ensure quality of code?

text: I have been learning programming in C# for about a year and a half now. How should I ensure that the code that I am writing and the habits are forming are good ones?   ie. I don't want to end up having written code which only I can understand. I know that we must use the naming conventions as per language. But are there any more concrete guidelines which I must keep in mind? Any rules which various companies enforce on their programmers while writing code? Any Documentation standards ? Any books/websites would also be helpful.


title: Repeat digit problem

text: There are numbers 1 to N present in a list, and an additional number that has been included by mistake. So, in total there are N+1 numbers. Assume that the largest integer that the language can handle is N. What is the fastest algorithm to find the repeat digit? Note: This is not a homework problem.


title: How should I connect to my php framework to use methods written in the framework, in a framework agnostic environment?

text: My company runs 2 websites, a public facing website for clients, and an employee intranet. The intranet is used as a backend for employees to edit and maintain various parts of the public website. Both are written in PHP. The intranet is years older, and was designed using an inhouse framework. We have recently created a new public website, and because of the opportunity to "start from scratch" with it, we designed it using a PHP framework (Kohana). We knew from the beginning that there would be implementation issues with getting the intranet to interact with the public site, and vice-versa. We are now at that point. There are a few different ways we have been able to make things work: For direct data manipulation, both use mysql, so the query builder in Kohana can manipulate the same data as the straight mysqli queries of the intranet. But beyond that, when the public site needs to use certain auditing methods written on the intranet framework, or when the intranet needs to send an automatic email written in Kohana, or use any number of other methods and functions, we have 1- Included one framework within the other, to have access to both. Problems with this are: a. Both rely on object buffering to prepare output, and are constantly starting and ending buffers at odd times. b. Conflicting class names being autoloaded c. autoloaders overwriting each other d. errors designed to be handled in one way are being handled improperly by the other framework's error handler. e. any number of other incompatibility issues We have gotten around these on a case by case basis, but it has been a nightmare 2- Using a remote API. We have written webservice methods on each server, and the other framework makes a cURL request of the other server. Problems with this are: a. The added work of protecting the API and authenticating requests b. the need to write service methods c. The overhead of having to make http requests instead of loading files locally 3- Using a local api. Similar to the above, except the framework is included on the same server, and the api methods are written in shell scripts which output data to be read by the calling script via `shell_exec`. This alleviates the need for authentication, but it seems like an ugly, hacky way of doing things We don't want to rewrite the intranet using a proper framework. It would take an incredible amount of time that we do not have. Is there a better way to do this, or at least a more "standard" or "conventional" way of dealing with this problem? Or are we stuck hacking away at it like we currently have been?


title: Fix bugs, or wait for the customer to find them?

text: Do other people fix bugs when they see them, or do they wait until there's crashes/data loss/people die before fixing it? ## Example 1                Customer customer = null;      ...      customer.Save();      The code is clearly wrong, and there's no way around it - it's calling a method on a null reference. It happens to not crash because `Save` happens to not access any instance data; so it's just like calling a static function. But any small change anywhere can suddenly cause broken code that doesn't crash: to start crashing. **But** , it's also not _inconceivable_ that correcting the code:               Customer customer = null;     ...     customer = new Customer();     try        ...        customer.Save();        ...     finally        customer.Free();     end;      might _introduce_ a crash; one not discovered through unit tests with complete coverage, and manual user testing. ## Example 2               float speed = 0.5 * ((G * mass1 * mass2) / R) * Pow(time, 2);      People knowing physics will recognize that it's supposed to be R2 in the denominator. The code is wrong, it's absolutely wrong. And overestimating the speed will cause the retro-rockets to fire too soon, killing all the occupants of the spacecraft. But it's also possible perhaps having it over-estimate the speed is masking another issue: the air-bags can't deploy while the shuttle is moving too fast. If we suddenly fix the code:               float speed = 0.5 * ((G * mass1 * mass2) / Pow(R, 2)) * Pow(time, 2);      Now the speed is accurate, and suddenly airbags are deploying when they shouldn't. ## Example 3 Here's an example that i had recently, checking if a string contains invalid characters:               if (StrPos(Address, "PO BOX") >= 0     {        //Do something     }      What if it turns out there's a bug in the `Do something` branch? Fixing the obviously incorrect code:               if (StrPos("PO BOX", Address) >= 0     {        //Do something     }      Fixes the code, but introduces a bug. * * * The way I see it there are two possibilities:   * fix the code, and get blamed for breaking it   * wait for the code to crash, and get blamed for having a bug What do _you_ politically do? * * * ## Example 4 - Today's real world bug I am constructing an object, but calling the wrong constructor:               Customer customer = new Customer();      Turns out that the "parameterless" constructor is actually an parameterized constructor from further back in the inheritance chain:               public Customer(SomeObjectThatNobodyShouldBeUsingDirectly thingy = null)     public Customer(InjectedDependancy depends)      Calling it is a mistake, since it bypasses all the subsequent constructors. I could change the object's lineage to not expose such a dangerous constructor, but now I have to change the code to:               Customer customer = new Customer(depends);      But I can't guarantee that this change won't break anything. Like my **Example 1** above, perhaps someone, somewhere, somehow, under some esoteric conditions, depends on the constructed `Customer` to be invalid and full of junk. Perhaps the `Customer` object, now that it is **properly** constructed will allow some code to run that previously never did, and now I can get a crash. i can't bet your wife's life on it. And I can test it from here to Tuesday, I can't swear on your daughter's life that I didn't introduce a regression. Do i:   * fix the code and get blamed for breaking it? or   * leave the bug, and get blamed when the customer finds it?


title: Decoupling UI code?

text: In my application I have several event handlers that perform some action in response to user interface events such as a button click or menu selection. The code in these event handlers looks like this for example:               void MyDialog::OnCommandLoadFile()     {         char strFilter[] = { "Text Files (*.txt)|*.txt|All Files (*.*)|*.*||" };              CFileDialog fileDlg(TRUE, ".txt", NULL, 0, strFilter);              if( fileDlg.DoModal() == IDOK )         {             const std::string path = fileDlg.GetPathName();                  std::vector<std::string> urls;             int maxNumberOfUrls = settings_->Get<int>(Settings::MaxNumberOfUrls);             UrlProvider *urlProvider = new FileUrlProvider(path);             urlProvider->GetUrls(urls, maxNumberOfUrls);                  webMonitoringService_->MonitorUrls(urls);                  DisplayMessage("URLs loaded.");         }          }      This is typical of my event handlers. I don't code monolithic event handlers but they do "glue" various pieces together. I usually have some business- logic/service classes which the UI has a reference to and in the event handlers I make calls to one or more of these to perform the desired task. What I'm wondering is is this still too coupled? If I wanted to turn this into a command line app I'd have to extract bits and pieces from the UI code. In the above example, there is a compound action going on so should I'm thinking it should look more like:               void MyDialog::OnCommandLoadFile()     {         char strFilter[] = { "Text Files (*.txt)|*.txt|All Files (*.*)|*.*||" };              CFileDialog fileDlg(TRUE, ".txt", NULL, 0, strFilter);              if( fileDlg.DoModal() == IDOK )         {             const std::string path = fileDlg.GetPathName();                  application->MonitorUrlsFromFile(path);                  DisplayMessage("URLs loaded.");         }          }      Is that right? In the above code what would "application" be? A controller? Is that the right abstraction for this? Whenever I need to perform some task in a UI handler, should it always be a one-liner (aside from getting data in or out of text boxes etc.) Anyone have a pointer to a tutorial that really covers this (in any programming language)? Furthermore, if in fact you should abstract compound actions, how to you propagate error messages from within the compound abstraction back out to the UI? An exception hierarchy? Single exception with error code? **UPDATE** I'm looking at the Command Pattern which looks promising. **UPDATE 2** In the end I decided on refactoring my code as described in the Humble Dialog Box paper in the accepted answer. My understanding is that this is a Model View Presenter (MVP) type pattern and more specifically a Passive View. The refactoring is going smoothly. There are some rough edges in my understanding of the full application of the pattern when it comes to things like displaying message boxes and file open dialogs or dealing with event timers but overall I'm happier with my code; the tight coupling was bothering me. I also found this "bundle": patterns & practices Web Client Developer Guidance: Model View Presenter (MVP) Bundle which has sample MVP code. It's a web project whereas my current implementation is desktop but I guess that's the beauty of MVP is that it partly doesn't matter. One thing I got from that was to dependency inject my service layer objects into the presenter rather than new'ing them inside my presenter class.


title: Are long functions acceptable if they have internal structure?

text: When dealing with complicated algorithms in languages with support for nested functions (such as Python and D) I often write huge functions (because the algorithm is complicated) but mitigate this by using nested functions to structure the complicated code. Are huge (100+ line) functions still considered evil even if they're well-structured internally via the use of nested functions? Edit: For those of you not familiar with Python or D, nested functions in these languages also allow access to the outer function scope. In D this access allows mutation of variables in the outer scope. In Python it only allows reading. In D you can explicitly disable access to the outer scope in a nested function by declaring it `static`.


title: Licensing code "not for reuse"

text: I have a client-side Javascript framework that is publicly available and BSD licensed. Each file says it is copyright me, the date, all rights reserved, and the BSD license text. I am making a project which uses - and adapts and makes code changes to - my BSD licensed framework. Although obviously browsers will download and execute this code, I don't want to BSD license my derived project. I don't object to people seeing my code, but I don't want them to cut-n-paste and make derivatives of my project. What boilerplate text do I put at the top of each file? I would like to include a link to my BSD-licensed framework too. How should I phrase that?


title: Is it bad form to stage a function's steps in intermediate variables (let bindings)?

text: I find I tend to need intermediate variables. In Clojure that's in the form of let bindings, like `cmp-result-1` and `cmp-result-2` in the following function.               (defn str-cmp         "Takes two strings and compares them. Returns the string if a match; and nil if not."         [str-1 str-2 start-pos substr-len]              (let [cmp-result-1 (subs str-1 start-pos substr-len)               cmp-result-2 (subs str-2 start-pos substr-len)]             (compare cmp-result-1 cmp-result-2)))       I could re-write this function without them, but to me, the function's purpose looks clearer. I tend to do this quite in a bit in my main, and that is primarily for debugging purposes, so I can pass a variable to print out intermediate output. Is this bad form, and, if so, why? Thanks.


title: How big a problem is Qt's cross-platform GUI?

text: I read something on this site saying that Qt's GUI being a big problem that stop programmers from using Qt. They say the problem is that the GUI don't look native, and they are inconsistent. I personally use Windows, and from what I can see (some tree view and table view), they look pretty good and very native-looking too. So I want to know what they are like on Mac, and what are the differences? and what differences there should be between ordinary Mac apps and ordinary Windows apps in terms of user experience?


title: Platform to Learn/Experiment with Web Programming

text: I am looking to teach myself some web programming, but I am not sure how I can experiment with an actual website. Are there sites that host platforms for these purposes?


title: Who decided on the terminology downcasting and upcasting?

text: As far as I know, the terminology comes from how the **inheritance hierarchy** is traditionally displayed, with the extending types at the bottom, and the parent types at the top. This is a bit pointless, unless you feel like calling the following _leftcasting_ and _rightcasting_. ![horizontal inheritance hierarchy](http://i.stack.imgur.com/6YUSl.png) I am _not looking for opinions_ why the terminology is as is, but they are more than welcome as comments. I am looking for references on **who first introduced up and downcasting, and why they decided on that name**.


title: Where can I find "SVN for Git Users" resources?

text: So I took a job where the firm uses SVN (but will be moving to Git sometime in the future). The problem is that I don't know SVN. I've tried numerous Google queries and all I can ever find are SVN->Git tutorials, "Why is Git better than SVN" blogs, and a particular "cheat sheet" that gives (some) comparable commands... Short of reading the O'Reilly book on SVN, what are the brief (but not _too_ brief) instructions to SVN for Git users?


title: Where to start when designing an application that allows plugins

text: I'm building an application, and I'm thinking long-term I would like to be able to allow plugin support. The application I'm creating is a Java based application. How could I allow plugins using a scripting language, or is it better to require plugins to use Java? Would I need to create some sort of plugin interface to allow the use of plugins? Any ideas of references of where to start?


title: Client and I don't know each other - any tips on ensuring client won't run off w/o paying?

text: I'm in college. I've taken to finding badly coded websites, e-mailing the owners and telling them I can fix it in exchange for Paypal money. I just completed one of these little fixes for a site, and having been previously burned, I'm a little hesitant to e-mail him his corrected code. Specifically I'm using @media queries in CSS to hide ads on certain, mobile sized screens and hiding mobile ads on desktop sized screens. How can I prove to my client that I have his completed work without just handing out my code? We both don't know anything about each other, we've probably sent a total of 6 emails to each other. I really need this 60$, lol


title: What type of applications Silverlight is designed for?

text: I have 3 years experience in ASP.NET with C# and now I am learning Silverlight with Beginning Silverlight 4 in C# book. As I have completed my first 4 chapters, I am getting the feeling that Silverlight is just about creating RIA which can also be done with Flash. What is a scope of Silverlight for a C# programmer?


title: Are frameworks used for "big" websites?

text: I'm kind of new to PHP. I can create basic sites with login/registration, etc., but I always struggle to build complex sites with lots of features, because eventually the code becomes messy and I just run into more and more little bugs, and then fixing those produces another, and so on. I realise that that's partially to do with me simply not writing clean code (I'm working on that!) but I would also probably benefit from using a framework. But is using ready-made frameworks "unprofessional"? Would a big site such a YouTube or Facebook use a framework like CakePHP or CodeIgniter?


title: Are SMART goals useful for programmers?

text: Several organisations I know use SMART goals for their programmers. SMART is an acronym for Specific, Measurable, Achievable, Relevant and Time-Bound. They are fairly common in large corporations. My own prior experience with SMART goals has not been all that positive. Have other programmers found them an effective way to measure performance? What are some examples of good SMART goals for programmers (if they exist).


title: What is your best whiteboarding technique when collaborating with your team?

text: I wanted to know what solutions you guys tend to do when sketch modeling on whiteboards. Since my reading on Creg Larman's very good book Applying UML and Patterns, I do my everyday business and software modeling with whiteboards. The problem is, I have a hard time being 'agile' and 'iterative' after the whiteboard has been erased and snapshotted. Sketching is the way to go for me but as soon as all my work is snapshotted in a digital picture, I don't find the required added value of having to either redraw it on the whiteboard, or use an UML tool. I wanted to know, for those of you who favor whiteboarding over UML tools, what are your techniques? (web/desktop based softwares, hardware, materials, etc.) you employ to achieve those criterion:   * Refine and iterate over past whiteboards that have been erased   * Collaborate remotely (not only room-to-room)   * Synchronize and simultaneously work on your sketches I have come to search for online web-based whiteboardings and I found the following which are pretty neat:   * Vyew   * Dabbleboard   * Twiddla However, my solution seems to go over with Smart Technologies, especially with their Notebook software which is very good for whiteboarding multiple designs. I was wondering also if some had some feedback for this application and their conferencing software as well (usage of their digital whiteboards and etc.)


title: How to use a switch statement with enum efficiently?

text: I would like to know how I can use a `switch` statement with `enum` values for the following scenarios: I am making a small program for a flight reservation system. The program is meant to enter certain details about the passenger. The program also restricts the user to choose destinations other than the following 3 destinations. Once destination is chosen, the flight number is supposed to be automatically assigned. The user will choose one of three destinations and program will assign an appropriate Flight No for the passenger. The Flight No will be assigned as below:                    Destination                    Flight No.           London                            201           Frankfurt                         233           Berlin                            241      So let's say I make an `enum` of destinations, then how can I use switch statement here? This isn't a homework. I am doing it just for the sake of exploring.


title: Clarity over Python and Jython

text: I'm a Java programmer, but I want to program in Jython. I've never coded in Python before, but have been looking through some tutorials and I'm fairly confident I can grasp it. My question is clarity over Jython. I understand with Jython you have the joys of writing Python code with the added bonus of accessing Java libraries. Does this mean, all aspects and coding practices of Python can be applied, such as creating animation, input out structures, or is there a whole new structure which needs to be learned to code Jython?


title: What is the Meaning of Return False in a Php Function

text: i wanted to know what is the meaning of return False in an function. go Through this function:               function reset_password($password,$user_id)     {         $sql="UPDATE user SET password='$password' WHERE user_id='$user_id'";              if(!mysql_query($sql,$this->mycon))         {             array_push($this->err_msg,"Error in Inserting - ".mysql_error($this->mycon));             return false;         }         else         {             //Reset Password code.         }        }      in this function i wanted to know what is the meaning of return false.