Didactic approaches to teach versioning with Git

I have already taught versioning with Git, but I think it could be more enjoyable for the guys I teach if I use another approach to teach them. The guys I mentioned before were used to working with SVN and I tried to teach Git based on SVN. Not such a good idea. It seems that some guys/teams which use SVN need a re-education on version control when they're learning Git or another DCVCS. In another attempt, I tried to show a scenario where a development team try to work without a (D)VCS and then I showed how their lives could be easier if they used a (D)VCS. I had the impression that part of the audience left the presentation without a clue what I was talking about. I've taught other classes on other subjects without problems, so I think this is not a issue with me as a teacher, but with my method. I know Git and versioning as well I know the other subjects I've presented to the other classes. So, basically, how to teach Git/DCVCS? Start with some diffs/patches and manual versioning and then teach how it can be more productive with Git? Start with Git object model? Or try to start with some pretty commands and try to save some time? To be clear: I'm looking for approaches on how to teach DCVCS (focusing on Git) effectively, based on real experiences.


Where can I get the Petshop application implemented in WPF and ASP.NET (.NET 4)?

I need the famous Petshop application implemented in WPF and ASP.NET (.NET 4). An older version can be found here. Where can I obtain it?


finding the time complexity of the following program

I need to find the time complexity in terms of Big Oh notation for the following program which computes the factorial of a given number: The program goes like this:               public int fact(int n){            if (n <=1)         return 1;       else       return n * fact (n-1);     }      I know that the above program uses recursion but how to derive the time complexity for the above program? Please explain.


How can robots beat CAPTCHAs?

I have a website e-mail form. I use a custom CAPTCHA to prevent spam from robots. Despite this, I still get spam. Why? How do robots beat the CAPTCHA? Do they use some kind of advanced OCR or just get the solution from where it is stored? How can I prevent this? Should I change to another type of CAPTCHA? * * * I am sure the e-mails are coming from the form, because it is sent from my email-sender that serves the form messages. Also the letter style is the same.      For the record, I am using PHP + MySQL, but I'm not searching for a solution to this problem. I was interested in the general situation how the robots beat these technologies. I just told this situation as an example, so you can understand better what I'm asking about.


Usage of mix licensies in commercial use

I'm developing a CMS, inside it I use many various plugins/addons wich licenses mostly like MIT, GNU, GPL (such as jQuery, nivoSlider, DataTables and so on..). After reading those licenses I believe I can use them inside my CMS and charge users for my CMS. In my project I have a specific folder where I store all these plugins with their license and all notices. Is this the correct way? Or should I somewhere on my site notice the all plugins Im using with the path where they can be found in my project folder? What about if I would use my CMS as SaaS? The end users would not have the access to source files so I would not exactly be distributing it. Is it posible? And lastly, can I protect my own source files with the license? Wouldnt it collide with the other ones? I would like to protect it as much as I can at least in a legal way as I cannot really protect it as all PHP files are easy accessible. Thank you for any help. Also note that I have read a lot about license, but these are things I would like to confirm or to see if I misunderstood something.


Will JVisualVM degrade application performance?

I have doubts in JVisual VM profiler tool related to performance. I have requirement to implement a JVM Monitoring tool for my enterpise java application. I have gone through some profiling tools in market but all them are having some kind of agent file which we need include in server startup. I have a fear that these client agent will degrade my application performance will more. So I have decided to JVisual VM because this profiler tool comes with JDK itself but before implementing JVisualVM, does anybody faces any issues with JVisualVM profiler tool? As well as, is this safe if I implement in application?


How to avoid a singleton in this example?

I have a class Image and another one ImageStore. The Image it's just a value object containing the package name and the image name. The ImageStore does all the actual work: calculates the real path of the image (based on the package and image name) and loads it from the server. Now I have a quite big (and deep) hierarchy of nodes (this is a render engine for a game) so for example now I am in a group and I want to insert a new Image. I do:               var image = new Image("packageName", "imageName");      At this moment the Image doesn't have any size yet, as I don't want to hard code the image size (in this case this can be a tile, which is not always 64*32 for example) in my game view.   * when the Image is added to the Group _(I suppose the group is already attached to the Renderer)_ then the Group will be invalidated   * the Renderer will request a new frame render.    * it will parse the hierarchy tree of node and when it finds the Image I've added before    * it will ask the ImageStore _(or TileImageStore, this one not only stores the width and height but also the bottom center point of the tile. This only when the bottom center of the tile doesn't match the bottom center point of the real image.)_ for the ImageData;   * the ImageStore now loads the package, which also has the info about the width and height;   * it will apply the new width and height to the image and will set a flag as loaded. I would like to have somehow the ImageStore detached from the render. To be able to use only the Image and ImageStore without the need of the renderer. **Edit:** I want to do this because I would like to know the size of a image even when the image is not rendered. In order to get the image it has to ask the ImageStore for the size, anchor and imageData. The packages are like this:               package = {image01: {base64: "very very long string", width: 10, height: 20, anchorX: 1, anchorY: 10}}      Only after the ImageStore loads this big file is able to know the image width/height;


Computer science jobs that don't let you develop software outside of that job?

I'm 15, and I was talking to my friends about what we wanted our future careers to be. I told them that I would like to have a job in the computer science industry (more specifically software development), and in my free time develop indie games that I could sell on the Android store to pull in a bit more cash. They told me that the contract for lots of jobs will say something like: "As long as you are working for us, you cannot develop anything outside of what you are developing for us", or, even worse, "You can no longer develop anything by yourself for the REST OF YOUR LIFE!!!". I'd never heard anything like this before and it has me a little concerned. So my question would be, do lots of careers in the computer science industry make you have to accept this kind of stuff? About how many jobs would make you sign this contract? And perhaps a little more specific info. on what this contract really means? EDIT: Right now I live in Ontario, Canada. Let's assume this is also where I will be living when I become an adult. I do not in fact live in an igloo ;)


Using akka actors with service spring beans

Do you think that using akka actors in front of transactional service beans, is a good idea ? Actors are waked up by a facade used by a client application, and actor use a message to handle right service call. Is it a good practice ? This article (http://honeysoft.wordpress.com/2012/08/05/akka-actor-dependency- injection-using-spring/) is talking about using spring beans with akka actors. But I could not see the gain to use actors in front of (singleton) spring beans.


Developing a mobile interface for Website

I have a website developed in ASP.NET MVC. Now, I am looking forward to getting up a mobile interface for it. My knowledge in this regard isn't that great, so I will explain what is needed to be done. It's much like on the lines of StackOverflow or Programmers and following are the few points that need to be addressed.   1. Much like Stack Overflow, if a site is visited from mobile, auto-detection should happen and the mobile version should be displayed.    2. Do I need to setup some sub-domain like `m.mysite.com` and should I have the mobile site installed for this domain (SE sites don't do this now but Facebook does that)   3. Lastly, How to design the website that is easily readable on all sized of screens for mobile.


How to convince my coworkers that doing things right will save them time

I recently started at a new company, with a handful of programmers. Its a medium sized company, with around 70 employees, but IT only has 9-10, and there are 3 "programmers" beside myself. However, these guys have very limited experience and are doing a lot of stuff really terribly. For example, one of our projects is a PHP website. The majority of the code is stored in a 20,000 line PHP controller, with ~6000 lines of JavaScript embedded in the PHP. I keep making small suggestions here and there but nobody has been listening, everyone says they are too busy to implement my suggestions. The thing is, they shouldn't be that busy, and wouldn't be if things were done right. They spend most of their time fixing things that keep breaking. If each project was built correctly, I could do it all myself. What approach should I take to convince these guys or the manager that things need to change, and that changing things will save a bunch of time? Should I skip trying to convince my coworkers and go straight to the manager, with a business-y proposal on how the company will save a bunch of money if they start doing things correct?


What is the difference between routed events and attached events?

I am just going through the WPF concepts I came across these routed events, dependency properties and attached events. What are the concepts behind them and why are they called instead of .NET ordinary methods?


Should the search engine return a dictionary or strongly typed objects?

I'm building a search engine using Lucene.NET / Solr.NET, and I'm wondering should search hits be returned as a dictionary or strongly typed object.               public class SearchResult     {         public string SearchTerm { get; set; }         public List<Dictionary<string, object>> SearchHits { get; set; }         ...     }          // where search hit looks like this     Dictionary<string, object> searchHit = new Dictionary<string, object>     {         { "Name", "John Doe" },         { "Address", "Some street" },     };      vs               public class SearchResult     {         public string SearchTerm { get; set; }         public List<Foo> SearchHits { get; set; }         ...     }          // where search hit looks like this     var searchHit = new SearchHit     {         Name = "John Doe",         Address = "Some address"     };      I will be indexing different types of objects (People, Web pages, Files, etc.). Each object has a different set of properties (people have name and address, while web pages have URLs and titles), and search hits don't have the same set of properties as original objects (`WebPage` class has the `MainContent` property, but after indexing, the search hit that represents this object will have the `PreviewText` property (the first 300 characters of `MainContent` property with stripped HTML tags). I don't want to duplicate the code all over the place and have: `IPeopleSearchService`, `IWebPagesSearchService`, `IFilesSearchService`, etc. and corresponding search results: `PeopleSearchResult`, `FileSearchResult`, etc.               interface IFooService     {         FooSearchResult Search(string text);         void Index(Foo foo);         ...     }          interface IBarService     {         BarSearchResult Search(string text);         void Index(Bar bar);         ...     }     ...      I would like to have a more generic solution, but I don't like over- complexity. It should be readable and easily understandable by junior developer.               interface ISearchService<TEntity, TSearchHit>     {         SearchResult<TSearchHit> Search(string text);         void Index(TEntity entity);     }      How would you design such a system? Any help would be greatly appreciated!


Understanding C++ for windows desktop application

I've been programming C++ for almost a year, and I've written complex programs however there are a couple of programming features of C++ which I didn't cover up (Classes & pointers), however I felt ready to develop a desktop application. I didn't get any books nor did I find any REAL documentation. I said to myself "Practicing is the most important thing in programming. I'll do that". Obviously I didn't learn much. After 4 months of programming in Visual studio C++/CLI I barely understand what I'm doing. I know how to do very basic operations, converting data types, but I am clueless on how the program works, how I add anything except events or how I change my GUI in code and not in the GUI builder. What should I do? Practice didn't really help, I only know some very easy things since I started working with Visual Studio, but the rest of the concepts leave me clueless. Should I hit the books, or should I just keep practicing?


Price Updates via database logic

How do the big price comparison services allow to send emails directly if the price of a product meets your targeted price. They will email you automatically. Is it a cron job that scans a table, or is it something compounded into the database?


Confused on how to properly employ a Repository Pattern with Service/Business Layer on top

I'm building a ASP.NET Web Api 2 solution for learning purposes, and I've hit a snag. I was wondering if anyone could tell me what exactly it is that I'm missing. My Web Api solution has 4 Layers:   * Data, which contains the Data Models ( POCOs ), Fluent API Mappings, EF Context, Migrations and Seeding   * Repository, which implements CRUD for all Data Models and returns the business Models   * Domain / Service / Business which supplies the IRepository interface, and should hold services which implement the application's business logic. Also contains the Business Models.   * Web, the Web Api controllers and DI / IoC to tie everything together. References are as follows: Data < Repository > Domain Web references all 3 layers for DI. The idea behind the separate domain layer is that it is completely oblivious to anything that happens in the Data or Repository layer. It simply outlines its requirements by providing the IRepository for the Repository layer, and the Business Models that it wants to get as a result. It's up to the Repository layer to meet the Domain Layer's requests. **Here is my connundrum** :   * Since Domain has no ties to Data, it does not know anything about the structure of the Data model. This means that the repository layer needs to convert everything to the Business Model before returning it. - I suppose I could return it as a generic object, and then map the generic object to the business model inside the Domain Layer. Would that be more appropriate?   * Again, since Domain does not know anything about the Data Model, I can't pass any expressions to apply on the data set to my Repository. This means that for every property I want to WHERE, I'd have to create a POCO specific Repository with matching IBussinessModelRepository which outlines it's requirements, and then implement that requirement. This quickly gets tedius though, as it calls for a bunch of "GetByProp1", "GetByProp2" - monkey code central.   * What if I want to create a composite business model that requires a complex query to hydrate? Is my only option to create yet another IBusinessRepository with a matching Repository and then write the complex query in the repository layer? If that is the case, then it feels like the service layer is mostly just another step that passes along non-crud requests to specific repositories.   * ~~Is it proper for web api controllers to send requests directly to the repository? It would seem pretty silly to route all CRUD requests through the service layer, which just passes the request to the repository layer anyway.~~ No, it's not as the service layer should be the entry point for all operations. ( With Web just acting as a consumer of the services offered. )   * I currently don't use a Unit of Work because there is a lot of mixed opinions when it comes to UoW + EF. I'm not yet experienced enough to be on either side of the fence. Would a UoW be helpful in this scenario? I feel like I am missing a vital part in what makes this pattern / layer approach tick. I know that I could easilly proceed by cheating ( i.e. give service access to data specific stuff like the context ), but I'm more interested in learning how to do it the proper way. The research I have done so far yielded results that vary wildly:   * From the Repository using AutoMapper to change the type to the business model without actually executing the query, allowing the service layer to pass Business Model Expressions which can then be applied and then running the query, returning the mapped result -- sounds great, except that approach does not seem to work for me due to AutoMapper not being able to deal with my Models having recursive nav properties.   * To the service layer just interfacing directly with the POCOs. ( And thus having direct access to the DAL ) What am I missing? Edit to explain more about my code: **My Generic Repository on Github** contains CRUD methods like this one:               public abstract class RepositoryBase<TData, TDomain, TId> : IRepository<TDomain, TId> where TDomain : EntityBase<TId>, new() where TData : class, IDataEntity<TId>, new()     {         private readonly ShortStuffContext _context;              public RepositoryBase(ShortStuffContext context)         {             _context = context;         }              public IEnumerable<TDomain> GetAll()         {             return _context.Set<TData>().BuildQuery<TData, TDomain>();         }     }      BuildQuery is a LINQ Extension which either grabs all entities, or can take a expression to fetch a single entity and then uses ValueInjecter to map the Data Model to the Domain Model. The repository methods are requested by the Domain Layer via Interface:               public interface IRepository<TDomain, TId> where TDomain : EntityBase<TId>     {         IEnumerable<TDomain> GetAll();     }      The RepositoryBase is extended by Repositories for the individual POCOs, which currently sit empty, only providing TData, TDomain and TId to the Repository Base:               public class UserRepository : RepositoryBase<Data.Entities.User, User, decimal>     {         public UserRepository(ShortStuffContext context)             : base(context)         {         }     }      Which can be requested by the Domain Layer via Constructor Injection `IRepository<User, decimal> UserRepository` through a ninject `InRequestScope` binding.


The line between ByRef Parameters and Module Variables

This question was brought up during a Standards discussion, which should revolve around SOLID Principles for Object Oriented Development. In your experiences, have you seen benefits or drawbacks in either code readability or performance based on whether variables are passed ByRef vs Module-Level Variable? Obviously: If a method calls a submethod, which will not only use but also modify a parameter, it should be passed as a reference pointer (aka: ByRef). Based on this logic, some in my discussion are very strict to never use module-level variables. In response, I say we have a toolbox and should know when to use what tool. For example, a sub declares a variable. That sub calls a function, which calls a sub, which calls a function, which calls a sub, etc etc, and eventually that variable is changed 10 methods down the line. I'd say make that variable a module level, whereas some say pass it ByRef through your tree of methods. So where is the line when examining SOLID OOP Principles? Do you go with an extreme?:   Never use ByRef, or Never use Module-level Variables. Or do you set a routine depth?:   1-method, always ByRef; 2 deep, consider it; 3-depth, Module-level Variable. Or maybe a Branching Principle?:   If, in your list of methods, the variable is really only updated in one place then passed ByRef all the way back up to the original... ByRef them all. But if the variable is changed during multiple stages in multiple branches of the tree of methods, make it a module level. If the latter is the case, should that also mean 20 methods down the line, ByRef all the way back up to the original is still fine? Or maybe a hybrid of these possible rules. What's your take on it?


How is Devise's secret_key used?

I've been using Devise for a while now and have wondered how the secret key is used. I looked through the source for references to `secret_key`, but it wasn't clear to me exactly what we do with it. It seems to me that it might be related to session security?


Source of this quote about code reusage?

does someone know where this quote comes from? I don't know it literally, but I know what is is about. Something like: > Writing code more than once is a waste of energy and creativity. I think that it was in some article about the definition of hacking or so, but I can't find it.


Must-have tools and practices for an agile start-up

I've been working in the software industry for a few years now. I've seen Waterfall in practice, and I've seen several projects attempt Agile with varying degrees of success... which got me thinking. What are the bare-minimum requirements for an Agile startup to be successful? I'm thinking in terms of tools, practices, team roles (e.g., source control, automated testing, BA role). I'd like to be able to draft a list of tools/practices/etc that are absolutely essential for the long term sustained success of a startup wanting to do Agile. I ask because I'd like to start my own software company eventually. Most of my experience is in SCRUM so I'm naturally biased towards it and I've already developed an opinion of what the minimum requirements for a SCRUM team to function are. But, being only human, and being only one sample, I wouldn't be surprised if my opinion was flawed or incomplete. I'd appreciate any and all insight and experience. Thanks


Should I fork in case the upstream deletes

I'm creating an open source PHP project that reuses other open source code instead of reinventing the wheel. I'm using composer to pull these projects into my vendor folder. What happens if these vendors delete their repository & all traces of their code from the internet? Now composer can't download the project. Should I fork every project I'm depending on, and depend on the fork? Seems like a pain, but the only 'safe' way to ensure the vendor can't delete things my project needs to run.


Where to put interface in .Net

I have VB.Net project, with a class with a couple of abstract (mustoverride) properties, that I am thinking about moving into an interface. My question, is structurally how do I do this? Currently all of the classes that would be implementing this are derived from this base class, so it might make sense to put it in the same file. Or I could create a separate interface file and put it in the same directory as the base class. Another option, would be to create a separate directory for interfaces (of which the project currently has zero) and put the file the. After writing this up, I'm strongly inclined towards the second option. I've looked around, but haven't found any guidance on this. What would be the best option and why?


Is 'using' appropriate in a context where there is nothing to dispose?

In C#, `using` statement is used to dispose in a deterministic manner the resources without waiting for garbage collector. For example, it may be used to:   * Dispose SQL commands or connections,   * Close streams, freeing the underlying source like a file,   * Free GDI+ elements,   * etc. I noticed that `using` is used more and more in cases where there is nothing to dispose, but where it's just more convenient for the caller to write a `using` block rather than two separate commands. Examples:   * MiniProfiler, written by Stack Overflow team, uses `using` to denote blocks to profile:              using (profiler.Step("Name goes here"))     {         this.DoSomethingUseful(i - 1);     }      One alternative approach would be to have two blocks:              var p = profiler.Start("Name goes here");     this.DoSomethingUseful(i - 1);     profiler.Stop(p);      Another approach would be to use actions:              profiler.Step("Name goes here", () => this.DoSomethingUseful(i - 1));        * ASP.NET MVC also picked `using` for forms:              <% using (Html.BeginForm())        { %>            <label for="firstName">Name:</label>            <%= Html.TextBox("name")%>            <input type="submit" value="Save" />         <% } %>      **Is such usage appropriate?** How to justify it, given that there are several drawbacks:   * Beginners would be lost, since such usage doesn't correspond to the one which is explained in books and language specification,   * The code should be expressive. Here, the expressiveness suffers, since the appropriate usage of `using` is to show that behind, there is a resource, like a stream, a network connection or a database which should be released without waiting the garbage collector.


Do threads use virtual memory or real memory?

I was trying to optimize my Linux server to handle 10,000 threads per process while it does just 382 right now. As per this article the following formula is used to find out total possible threads:               number of threads = total virtual memory / (stack size*1024*1024)      This means threads store all their data in virtual memory. And to the best of my knowledge, virtual memory is swap space in a Linux machine which is stored on harddisk than RAM or cache. So my question is does our threads uses harddisk to store for processing/store its data. If yes, then doesnt this effect performance? Can we enhance the performance by putting in them on RAM or cache? How? If no, how exactly do threads works? **Update:** According to **useless's answer**, virtual memory is a system comprising roughly:   * physical memory (RAM)   * any swapfiles you have attached   * hardware support for translating virtual to physical addresses and issuing page faults when a virtual address isn't available in physical memory   * (kernel) software support for: managing the lookup tables used by that hardware handling those page faults by pulling pages in from swap on demand Thus, Everything that is on virtual memory is collectively on RAM(Real Memory) and Hard Disk(Swap Files). And as **James explain in his answer** decision on Ram vs HDD is taken by Kernel using algorithims such as LRU.


Client-side javascript: How to include third party frameworks?

When developing web apps you often build your app on top of some frameworks like Twitter's bootstrap. These frameworks come with `less/sass/stylus`, `javascript`, images and sometimes webfonts. I'm wondering how to embed these frameworks in my app. Most of my apps are build using some grunt tasks that compile my `coffeescript` and `stylus` to `javascript` respectively `css`. Because I'm not shipping third party code (e.g. frameworks) with my app I add them as a dependency. This allows me to install e.g. frameworks using a package manager like `npm` or `volo`. Handling small javascript libraries (which consist only of _one_ file, no assets) is easy. I install them in a vendor dir and update my require.js conf. But if the library has images or `less/sass/stylus/css` files attached I'm always struggling how to handle them:   * Paths to assets in the `css` files or `javascript` files of these libraries are often hardcoded (relative)   * `less/sass/stylus` has to be compiled (which I can do with a grunt task)   * Copy all third party assets into my folder structure?   * Should I include third party assets (`stylesheets`, `javascript`) in my own files and minimize them together?   * If I use `stylus` and the framework uses `sass` I have to install a lot of further dependencies I think I'm not the only one who has these problems so I'm looking for solutions, best practices or some general tips.


Shouldn't Location be a Value Object?

Eric Evan's DDD book, Cargo Shipping Example, pg. 168: > Location > > Two places with the same name are not the same. Latitude and longitude could > provide a unique key, but probably not a very practical one, since those > measurements are not of interest to most purposes of this system and they > would be fairly complicated. More likely, the Location will be part of a > geographical model of some kind that will relate places according to > shipping lanes and other domain-specific concerns. So an arbitrary, > internal, automatically generated identifier will suffice. Reason why author made `Location` an entity is because two different places could have the same name. But since it appears that `Location` is _immutable_ and thus won't change over time, wouldn't it be better if it was instead a Value Object? Thus: a) Why couldn't we ( instead of automatically generated identifier ) introduce an additional attribute describing an actual charasteristic of a location, which would help distinguish between the two places with the same name? Then we could make `Location` a VO. b) Even if we don't introduce an additional attribute describing an actual characteristic of a location, but instead we use an automatically generated identifier, couldn't we still consider `Location` as a VO, since the fact still remains that it is _immutable_ and that application would work the same even if it tracked several instances representing the same `Location`? c) From the quote it seems that author would designate `Location` as an _entity_ even if instead of automatically generated identifier we'd use _latitude_ and _longitude_ to help distinguish between different locations. Why? Thanks


Assigning strings to pointer in C Language

I am a new learner of C language, my question is about pointers. As far i learned and searched pointers can only store addresses of other variables, but cannot store the actual values(like integers or characters). But in the code below the char pointer c actually storing a string. It executes without errors and give the output as 'name'.               #include <stdio.h>     main()     {     char *c;     c="name";     puts(c);     }      can anyone explain how a pointer is storing a string without any memory or if memory is created where it is created and how much size it can be created. I tried using it with the integer type pointer               #include <stdio.h>     main()     {     int *c;     c=10;     printf("%d",c);     }      but it gave an error               cc     test.c   -o test     test.c: In function ‘main’:     test.c:5:3: warning: assignment makes pointer from integer without a cast   [enabled by default]     c=10;     ^     test.c:6:2: warning: format ‘%d’ expects argument of type ‘int’, but argument 2 has type ‘int *’ [-Wformat=]     printf("%d",c);     ^      Pointers stores the address of variable then why is integer pointer different from character pointer. If there is something i am missing about of pointers plz explain. Thanks in advance.


Why does this method return 2 values if I only ask for one and there is no sort of conditional statement anywhere?

I'm writing this very simple program from this one PDF called Think AP Java, and I can't seem to wrap my head around this: When I write               public static double method_1(double x)     {         double result =( x*(Math.exp(-x)  )    ) + (Math.sqrt(1-Math.exp(-x) )    );              System.out.println(result);              return result;       }      I get the output of: 1.1629395387920924 But when I write:               public static double multAdd(double a, double b, double c)     {              double result = (a*b) +c;              System.out.println(result);         return result;     }      and               public static double method_2(double x)     {              double result_1 =  (multAdd(1.0,  (Math.exp(-x)), 0.0)) ;         double result_2 = (Math.sqrt(1.0-Math.exp(-x)));              double final_result =  result_1 + result_2;         System.out.println(final_result);              return final_result;     }      The output for method_2 is: 0.36787944117144233 AND 1.1629395387920924, printed directly over one another. What can explain the cause of this? Any help will be greatly appreciated, as I'm only just a beginner.


Redirection methods for webpages

(This is question involving user experience, but I am primarily interested in the best practice technical solution to this common problem.) * * * There are several places in my website where users are redirected: login screens, pay walls, etc. Sometimes these can be stacked. For example, login, then pay, then land on a particular page. (But I can't just hardcode them...sometimes they would login, pay, and the go to another page.) And the flow for users is dynamic, e.g. perhaps during the login flow the user may start an OAuth flow. * * * I can keep a "stack" of redirects. I could chain the redirects in the URL:               http://my.website.com/login?return_url=%2Fpay%3Freturn_url%3D%252FfinalUrl      or I could keep track of them in a cookie (e.g. serialized JSON array). * * * Is one of these two ways that is better of keeping track of redirects, or is one of these ways commonly used?


Why are there so many CSS properties which are essentially the same?

This answer really made me wonder. I've written CSS before and (usually) I don't really bother to support browsers other than recent firefox and chrome, but in researching I've noticed that, for the exact same CSS property, there are usually at least three different forms which behave identically, and can have the same values, but which all simply have different prefixes for the specific library that implements them. Here, for example:               -webkit-touch-callout: none;     -webkit-user-select: none;     -khtml-user-select: none;     -moz-user-select: none;     -ms-user-select: none;     user-select: none;      With the sole exception of the first one, these only differ by prefix. Why don't maintainers simply change the lexer rule which matches the string "-moz- user-select" to also match "user-select"? Sure, there's the possibility that the author of the original CSS wanted different behavior for Firefox v. other browsers, so "user-select" won't be the same as "-moz-user-select", but the risk of that weird corner case is far outweighed by the advantage, and there are other, arguably better ways to accomplish the browser-specific goal. If this is already occurring, why do people still use all of these? If they stopped:   * there would be fewer bits clogging the metaphorical pipes of the internet (network latency would go way down, plus individual pages would load faster), and   * people using ancient browsers would be given the impetus they need to update (which they should do for security reasons, anyway) ## TL;DR What would the disadvantage be of everyone using the same naming convention? Why haven't things normalized by now?


How much better is Apache Solr than its non-Java competition? Is it so much better than other solutions, e.g. this one (Sphinx with PHP API) or Zend_Search_Lucene that it would be worth suggesting that a client move to a different hosting provider than the one they are working with now? The current host does not support Java. If there are other decent solutions for indexed database search which are more palatable to typical web hosts, I'd like to hear about them. It is A Big Deal for them to change hosting providers, so I would like to know if the move would be justified.


JavaScript Compression and Caching of Assets

I'm working on an idea that i can't seem to find a good answer though hours and hours of searching, I'm planning a small Canvas/WebGL Application this application will be using WebSockets to talk to a game server for syncing data to and from so think of it as a MMO type service so im planning to have a queuing system to load assets E.G I make a request to get model1 and it's texture so that will quee               Mthd | Data                   | q | p | s     GET  | /asset/model_1/model   | 0 | 0 | 0     GET  | /asset/model_1/texture | 0 | 0 | 0     GET  | /asset/model_1/model   | 1 | 1 | 0     GET  | /asset/model_1/texture | 1 | 1 | 0     ...     GET  | /asset/model_1/model   | 5 | 5 | 0     GET  | /asset/model_1/texture | 5 | 5 | 0      **Key**               q = quality modifier      p = priority lower is better     s = status `0 not started, 1 downloading, 2 complete`      so my client is processing that download que however while this is going on another player has come into my view so i need that players model and texture so i add them to the que and end up like so               Mthd | Data                   | q | p | s     GET  | /asset/model_1/model   | 0 | 0 | 2     GET  | /asset/model_1/texture | 0 | 0 | 2     GET  | /asset/model_2/model   | 0 | 0 | 0     GET  | /asset/model_2/texture | 0 | 0 | 0     GET  | /asset/model_1/model   | 1 | 1 | 1     GET  | /asset/model_1/texture | 1 | 1 | 0     GET  | /asset/model_2/model   | 1 | 1 | 0     GET  | /asset/model_2/texture | 1 | 1 | 0     ...     GET  | /asset/model_1/model   | 5 | 5 | 0     GET  | /asset/model_1/texture | 5 | 5 | 0     GET  | /asset/model_2/model   | 5 | 5 | 0     GET  | /asset/model_2/texture | 5 | 5 | 0      Now i'm wanting to cache these file into the browser cache so i'm tied between using the database and compressing using something like LWZ, or putting the assets online and using appCache and loading them. So My Questions. If i load an asset though the browser normally (http request) will the browser will keep that image in memory once it's no longer being rendered. If i use Javascript to hold the base64 string should i then remove the string from the javascript variable (delete) i know it would free up the memory holding the string but would it free it all the memory used or would the browser still keep a copy of the image generated from base64 in memory. Is it possible to write content loading through WebSockets into the appCache E.G the base64 string from the WebSocket Server. Has any one found a better string compression system for Javascript other than LWZ i'm planning on compressing using a application at the server side so the only limit on compression is javascript supporting it.


Android, OpenGL and extending GLSurfaceView?

This question is part-technical, part-meta, part-subjective and very specific: I'm an indie game dev working on android, and for the past 6 months I've struggled and finally succeeded in making my own 3D game app for android. So I thought I'd hop on SO and help out others struggling with android and openGL- ES However, the vast majority of questions relate to extending `GLSurfaceView`. I made my whole app without extending `GLSurfaceView` (and it runs fine). I can't see any reason at all to extend `GLSurfaceView` for the majority of questions I come across. Worse, the android documentation implies that you ought to, but gives no detailed explaination of why or what the pros/cons are vs not extending and doing everything through implementing your own `GLSurfaceView.Renderer` as I did Still, the sheer volume of questions where the problem is purely to do with extending `GLSurfaceView` is making me wonder whether actually there is some really good reason for doing it that way vs the way I've been doing it (and suggesting in my answers to others to do). So, is there something I'm missing? Should I stop answering questions in the meantime? Android openGL documentation


Delphi to Java change - career advice

I'm a Delphi developer with aprox 5 years of experience. But now, Delphi seems to be dead, and the job opportunities are smaller. So, I want to begin learn Java, because I like it, and the job market is bigger(and competition also...). Until now I've searched for opinions about the best Java books and I've founded several books(Thinking in Java by Bruce Eckel,"Java 6 The Complete Reference " , complete JAVA for SCJP, etc - you can provide more examples if you want). Now, what I'm asking you: when you start to learn a new programming language (in this case Java) which are the steps you're following? How do manage the learning curve? (how you allocate time for different chapters and technologies) Thank you in advance


How to interview a natural scientist for a dev position?

# Original Question I already did some interviews for my company, mostly computer scientists for dev positions but also some testers and project managers. Now I have to fill a vacancy in our research group within the R&D department (side note: “research” means that we try to solve problems in our professional domain/market niche using software in research projects together with universities, other companies, research centres and end user organisations. It’s not computer science research; we’re not going to solve the P=NP problem). Now we invited a guy holding an MSc in chemistry (with a lot of physics in his CV, too), who never had any computer science lesson. I already talked with him about half an hour at a local university’s career days and there’s no doubt the guy is smart. Also his marks are excellent and he graduated with distinction. For his BSc he needed to teach himself programming in Mathematica and told me believably that he liked programming a lot. Also he solved some physical chemistry problem that I probably don’t understand using his own software, implemented in Mathematica, for his MSc thesis. It includes a GUI and a notable size of 8,000 LoC. He seems to be very attracted by what we’re doing in our research group and to be honest it’s quite difficult for an SME like us to get good people. I also am very interested in hiring him since he could assist me in writing project proposals, reports, doing presentations and so on. He would probably fit to our team, too. The only question left is: **How can I check if he will get the programming skills he needs** to do software implementation in our projects since this will be a significant part of the job? Of course I will ask him what it is, that is fascinating him about programming. I’ll also ask how he proceeded to write his natural science software and how he structured it. I’ll ask about how he managed to obtain the skills and information about software development he needed. But is there something more I could ask? Something more concrete perhaps? Should I ask him to explain his Mathematica solution? To be clear: I’m not looking for knowledge in a particular language or technology stack. We’re a .NET shop in product development but I want to have a free choice for our research projects. So I’m interested in the meta- competence being able to learn whatever is actually needed. I hope this question is answerable and not open-ended since I really like to know if there is a default way to check for the ability to _get_ further programming skills on the job. If something is not clear to you please give me some comments and let me improve my question. # Update to reflect the answers given until 2011-12-01 ## What answer I accepted and why Thank you all for your answers, most of them are quite helpful, so I upvoted a lot! Although Tom Squires' answer got the most votes, I'm going to accept the answer given by Prince Goulash. Of course Tom is objectively correct, but Prince's answer is just more helpful for me and I double-checked the FAQ that _this_ is the criterion to accept an answer. ## What I am going to ask him during the interview   * I'll let him explain some simple assignments like the example in The Camel Has Two Humps mentioned by Chris Burt-Brown   * I'll ask him to explain some more advanced control flows maybe in a graphical notation.   * I'll check his understanding of recursion using a math example.   * I'll let him explain an algorithm of his choice in natural language.   * I'll let him explain his Mathematica solution, in particular I'll ask for his procedure model, usage of tools, structuring of code and software in general as well as different abstraction layers.   * To check his motivation I will ask for his software development fascination.   * I'll ask him if he is aware of what he will need to learn about enterprise software development. Especially I want to turn the discussion into the direction of working in teams, pair programming, TDD since I expect him not to know a lot about this after working on his MSc alone. Sounds like it's going to be a long interview ;) # Update after the interview 2011-12-09 Again thank you all for your good answers. He passed the interview with flying colours. I never was more satisfied with an applicant. His Mathematica solution seems to be structured quite well. He was able to explain where he used higher-order functions, although he didn't know that these are referred like this. He answered my math-based recursion questions as well as simple assignments and control flow things from The Camel Has Two Humps. When he was explaining some algorithms I learned a lot about non-linear fitting ;) Also he honestly said that of course he can't guarantee that he will be able to learn things about professional software development that he doesn't know so far. But he believably statet that he was always good in learning new concepts -- even by himself -- and is really interested in software development. He also asked for the technology stack of the project, he would be applied to first, to have a look at it at home. He was curious about pair programming and team work, too. Now I hope that the employment contract will be concluded.


Backward compatibility with event-sourcing

How do you stay backward compatible with event-sourcing? Let say you release a version that has one kind of event, let call it X. You know how to handle that event in all the systems that extracts the events from the event source. In a later release you make a change to event X or delete it, how do you stay backward compatible with that? To have a fully functional system you need to be able to handle the old event as the same time as you need to handle the updated version. Or if you delete that event type, then you will be stuck with code that is only there to handle legacy events which in my head can be a little bit messy in the long run.


Where can I get a definition of how the code is laid out in VB.NET 2010?

I am just starting out learning Visual Basic 2010. I have books and videos. The books all seem to be written for people who have some programming experience, even the books that say they are for beginners. The videos were great until they started talking about variables. I got the basics of them but they started into complicated variables and I don’t see the need for them right away. Where can I go to see code for fairly intricate applications written out, with an over lay of definitions of which part of the code is a method as opposed to a class and so on? Also, I am working at a company that does not use SQL. So I need to use Access 2007 for all of my tables. Is there much of a difference to the coding?


How do you end up with event-sourcing if you use a xDD approach?

When working in a TDD or BDD manner your unit tests are supposed to drive your design. But how do you end up with event-sourcing using a xDD techniques? As I see it event sourcing is something you need to adopt early on to take full advantage of it. Lets say that you start without event-sourcing and do a release. Later on when you are releasing version 2.0 you realize that it would be great to use event- sourcing, but at that point you alread have missed all the events from version 1.0 so it makes it much harder to implement. Or do you take some kind of backup of your db from before event-sourcing and use that as base line and then add event-sourcing on top of that?


Finish feature reverted commits from develop

I am using git as a version control system, and using git-flow as the branching model. I started a feature branch some weeks ago in order to maintain the system in a clean state while developping that feature. The main development continued on the `develop` branch, and changes from develop were merged periodically into the feature, to keep it up to date as much as possible. However came the time where the feature was finished, and I used git-flow's `finish feature` to merge the feature back into develop. The merge was successfully done, but then I found out that some of the commits I made in develop were reverted by the merge commit! Nowhere in `develop` or in the feature branch were these changes reverted, I can't see any commit that overwrote them. I just can't find anything. The only theory I have for the moment is that git is failing on me, but that would be extremely unlikely. Maybe I did some kind of wrong manipulation that made this situation come true? I can trace back in the history when the commit was made. I can see that the changes from that commit were reverted by the merge commit. Nowhere in the branch I see a commit that reverts those changes. Yet they were reverted. How is this even possible?


Has anyone used OpenCalais succesfully in a project?

In a previous question here on programmers, the OpenCalais system has been referenced as a solution. Has anyone used OpenCalais? Can you identify pros and cons of the system ?


Pretty simple question. Should package structure closely resemble class hierarchy? If so, how closely? Why or why not? For instance, let's say you've got class A and class B, plus class AFactory and class BFactory. You put class A and class B in the package com.something.elements, and you put AFactory and BFactory in com.something.elements.factories. AFactory and BFactory would be further down the hierarchy package-wise, but they'd be further up class-wise. Is this sort of thing a good idea or a bad idea?


Why is the complexity of fetching a value from an array be O(1)?

How come the complexity of fetching a value from an array by it's index is O(1)? I thought the algorithm has to go through all the indexes, find the correct index, and then know what value to return. So that means the complexity is O(n/2) on average. Why is it actually O(1)?


What Functional features are worth a little OOP confusion for the benefits they bring?

After learning functional programming in Haskell and F#, the OOP paradigm seems ass-backwards with classes, interfaces, objects. Which aspects of FP can I bring to work that my co-workers can understand? Are any FP styles worth talking to my boss about retraining my team so that we can use them? Possible aspects of FP:   * Immutability   * Partial Application and Currying   * First Class Functions (function pointers / Functional Objects / Strategy Pattern)   * Lazy Evaluation (and Monads)   * Pure Functions (no side effects)   * Expressions (vs. Statements - each line of code produces a value instead of, or in addition to causing side effects)   * Recursion   * Pattern Matching Is it a free-for-all where we can do whatever the programming language supports to the limit that language supports it? Or is there a better guideline?


Should I Leave off the Currency Symbol?

I'm upgrading a desktop application that currently displays the currency symbol anytime money values are displayed or printed. A friend of my from the UK told me "Whenever British people see software with the American Dollar Sign ($) it automatically turns them off." Given the fact that we (developers) only have one shot at making a favorable first impression, wouldn't it make more sense to simply format all money values without a currency symbol?


Best Practices for Redesigning a Database

I'm aware of some general best practices when designing a database for an application, but what about redesigning? I'm on a team tasked with re-designing an internal business application, though despite me saying "internal," I'm unfortunately many, many layers of people away from contact with the actual users of the system. The current program is in Oracle Forms, scattered across a bunch of non- normalized tables, sometimes with multiple near-duplicate tables holding slight variants on each others' data. The constraints are often in the form of poorly-enforced stored procedures. Even the types don't seem to be stored right. I've encountered all sorts of bad data that Oracle seems to ignore but gave fits (and rightly so) to SQL Server's Import/Export Wizard. (For example, two digit integers do not constitute a complete datetime!) The original program probably goes back twenty years, and all of the original developers have retired so long ago that even the older people here have no idea who they were. As a result, there also aren't really any clean requirements to go off of--we're just supposed to duplicate the existing application's functionality and keep its existing data. The end result of the rewrite is going to be a web-based version running on ASP.NET with MS SQL Server for the back end. My other two developer teammates are much, much older than me, both with business/MIS backgrounds whereas mine is CS. The senior member's experience has been almost exclusively Oracle forms and the other member has mostly done business applications work in Visual Basic. Although my database background has been limited to designing new databases for projects in MySQL or SQLite, mostly for my undergrad classes, I seem to be the only one with experience actually designing databases at all. I've already written a little program in C# that reads in all the existing data to a neutral format, ready to be re-cast and placed into a new database. I plan to write the load-in code after the destination database is designed, so that data can be properly split across the new normalized tables, added in the correct order to follow new constraints, etc. The same program could then be run again later to copy the production data to the real newly deployed finished redesign. This leaves the actual redesign of the database as the main thing to figure out. **So the heart of my question:** what are some best practices for doing a redesign from the database level up of an existing application?


Designing a web app that will be used from distant geographic locations

I have designed/built a number of small web apps. Most have been used by clients who operate in a specific geographic area, mostly within the same state/province. For these I would follow best practices but normally didn't worry too much about issues caused by distance from the server. I have a potential client whose locations are spread out in several countries around the world. What specific considerations should I make in designing an app that will be used in locations that are not near each other? Some of the more obvious ones I've thought about:   * i18n/localized strings   * Static content delivery via CDN   * Reducing instances where the client needs to communicate with the server   * Communicating with the server in the background while the client is doing other things I feel that list should be longer, but I don't have the breadth of experience to be sure. I am mostly concerned about the marginal issues presented by serving a geographically-distributed userbase that would not otherwise be high-ranking concerns for clients in closer proximity.


How do I share my jQuery plugin with the world?

I made a plugin for jQuery, which I think is quite useful. It combines an animated colours plugin with an easings plugin, and adds a completely new feature of being able to refer to colours numerically (more useful in hex notation, so 0xff00cc for example) and therefore manipulate them mathematically more easily. I created a repository on github, and it sits there, nobody looks at it. Mostly, I would like people to look at it, use it, and improve it, so I can use the improvements and so on. I think this idea of numerically manipulating colors could be interesting. It makes it easy to change the hue without changing the saturation for example. Combined with animated colors, I think something interesting could be done, but I don't know what exactly. How do I let people know it (or any other project) is there..? I was going to post it on http://plugins.jquery.com which is currently down. Are there any other outlets for this kind of code?


MVC: View-Controller Interaction

I have a Java application that I am implementing following the MVC pattern. I want to have a window (view) that contains a form which allows the user to add several text fields. There will also be a button that will allow the user to add more text-fields to the form. I have several questions about this. Will the code for adding new text-fields be considered part of the controller or the view?   1. If controller, then this controller will not do anything to the model, it will just modify my view, so is this a violation of MVC?   2. If view, then will it be a violation of MVC as the changes in view were not directed from the model?


Is it possible to compile Java into machine code? (Not bytecode)

Can you have Java compiled straight into machine code? I want to do this so I have control over what platforms it's used on, and don't know C,C++ etc.


Determining the right amount of documentation

Where I currently work the general approach is - **avoid documentation as much as possible** **Only document if a different team will need it** just for clarification, I don't mean code-documentation - this we do, I mean all the documentation surrounding the design process - if it's UML or DB Schemas, class diagrams and word documents with specifications and the likes. I will list my Boss' reason to not document:   1. it's time consuming - focus on implementing   2. if design change - then the documentation should change, double trouble   3. in the end you just get hundreds of pages nobody wants to read, and nobody really edits so by time it will get out of date   4. Its a pain - nobody really wants to do it Now I realize we do work faster, but I also remember the time getting here and diving straight to some old code, not understanding anything. Actually, I still don't get most of this old code, and sometimes when I get in I see many patches from different developers trying to make small tweaks. I really think lack of documenting promotes these kind of patches and lack of system understanding in a broad sense. my question is: **How can we balance documentation so that we will promote continuous knowledge among the team and still be fast and efficient?**


Modern Java implementation of Blackboard Pattern?

Is there room for a practical modern application in Java of the Blackboard Pattern detailed in **"The Pragmatic Programmer"**? Is there any particular library that attempts to assist in the implementation of this concept? What is the general consensus on this pattern in the present software community (especially Java)? Though the idea is intriguing, I have a feeling that this portion of the book may be outdated. In case you are not familiar with this concept: http://flylib.com/books/en/1.315.1.55/1/


What's the most polite way to handle library dependencies when hosting code online?

Let's say you've written nifty JavaScript library that requires jQuery, and you want to host this project on github. Do you include the jQuery source with your project? Do you direct users to a download link for jQuery?


How should I manage short-term user preferences, to simplify data cleanup?

When rolling out a new feature, sometimes it makes sense to notify the end user what it is, and give them an opportunity to provide feedback whether the software should get them to 'try something new' or 'put it off'. ![Gmail new feature, "Try it now", "Not now"](http://i.stack.imgur.com/6jWVc.png) In a cloud software, how should user preference data such as this be managed? A small piece of information would have to be stored to save the preference, but eventually, it becomes irrelevant. (The old way is phased out.) The simple thing to do is just leave that data there. After all, it doesn't take much space. Eventually, as more features and changes come and go, and more messages are added, dismissed, and removed; there would be many items in the data storage that is no longer used, and there would be cost in the form of programmer hours in preserving or separating that data. Are there coding and software maintenance patterns that would make sense to get rid of old data structures along with removal of old features? Is there a common solution to this data cleanup?


Distinction between API and frontend-backend

I'm trying to write a "standard" business web site. By "standard", I mean this site runs the usual HTML5, CSS and Javascript for the front-end, a back-end (to process stuff), and runs MySQL for the database. It's a basic CRUD site: the front-end just makes pretty whatever the database has in store; the backend writes to the database whatever the user enters and does some processing. Just like most sites out there. In creating my Github repositories to begin coding, I've realized I don't understand the distinction between the _front-end back-end,_ and the _API_. Another way of phrasing my question is: **where does the API come into this picture?** I'm going to list some more details and then questions I have - hopefully this gives you guys a better idea of what my actual question is, because I'm so confused that I don't know the specific question to ask. Some more details:   * I'd like to try the Model-View-Controller pattern. I don't know if this changes the question/answer.   * The API will be RESTful   * I'd like my back-end to use my own API instead of allowing the back-end to cheat and call special queries. I think this style is more consistent. My questions:   * Does the front-end call the back-end which calls the API? Or does the front-end just call the API instead of calling the back-end?   * Does the back-end just execute an API and the API returns control to the back-end (where the back-end acts as the ultimate controller, delegating tasks)? Long and detailed answers explaining the role of the API alongside the front- end back-end are encouraged. If the answer depends on the model of programming (models other than the Model-View-Controller pattern), please describe these other ways of thinking of the API. Thanks. I'm very confused.


XML/HTML: Do we need the element name in closing tags?

Compared to other serialization languages, one of the main criticisms directed at XML is its verbosity; JSON's more terse and readable for most cases, but not all. But it seems to me that we could cut a lot of the excess from XML simply by stripping away the names from the closing tags. With proper indentation readability shouldn't be an issue (it should be an improvement, if you ask me), and since they're not structurally required any decent XML editor/viewer could easily be made to strip/hide or add them. **As such, the two formats should be completely equivalent and interchangeable.** Compare the following (source taken from http://www.w3schools.com/xml/simple.xml):               <breakfast_menu>         <food>             <name>Belgian Waffles</name>             <price>$5.95</price>             <description>                         Two of our famous Belgian Waffles with plenty of real maple syrup             </description>             <calories>650</calories>         </food>         <food>             <name>Strawberry Belgian Waffles</name>             <price>$7.95</price>             <description>                         Light Belgian waffles covered with strawberries and whipped cream             </description>             <calories>900</calories>         </food>         <food>             <name>Berry-Berry Belgian Waffles</name>             <price>$8.95</price>             <description>                         Light Belgian waffles covered with an assortment of fresh berries and whipped cream             </description>             <calories>900</calories>         </food>         <food>             <name>French Toast</name>             <price>$4.50</price>             <description>                         Thick slices made from our homemade sourdough bread             </description>             <calories>600</calories>         </food>         <food>             <name>Homestyle Breakfast</name>             <price>$6.95</price>             <description>                         Two eggs, bacon or sausage, toast, and our ever-popular hash browns             </description>             <calories>950</calories>         </food>     </breakfast_menu>      and               <breakfast_menu>         <food>             <name>Belgian Waffles</>             <price>$5.95</>             <description>                             Two of our famous Belgian Waffles with plenty of real maple syrup             </>             <calories>650</>         </>         <food>             <name>Strawberry Belgian Waffles</>             <price>$7.95</>             <description>                             Light Belgian waffles covered with strawberries and whipped cream             </>             <calories>900</>         </>         <food>             <name>Berry-Berry Belgian Waffles</>             <price>$8.95</>             <description>                             Light Belgian waffles covered with an assortment of fresh berries and whipped cream             </>             <calories>900</>         </>         <food>             <name>French Toast</>             <price>$4.50</>             <description>                             Thick slices made from our homemade sourdough bread             </>             <calories>600</>         </>         <food>             <name>Homestyle Breakfast</>             <price>$6.95</>             <description>                             Two eggs, bacon or sausage, toast, and our ever-popular hash browns             </>             <calories>950</>         </>     </>


How can I port msvc++ code with non-dependent names in templates to Linux?

I can deal with porting platform dependent functions. I have a problem that the compilers I tried on Linux (clang and g++) do not accept the following code, while the msvc++ compiler does:               template <class T>     class Base {     protected:         T Value;     };          template <class T>     class Derived : public Base<T> {     public:         void setValue(const T& inValue){             Value = inValue;         }     };          int main(int argc, char const *argv[])     {         Derived<int> tmp;         tmp.setValue(0);         return 0;     }      g++ error:               main.cpp: In member function ‘void Derived<T>::setValue(const T&)’:     main.cpp:11:3: error: ‘Value’ was not declared in this scope      I believe this due to the use of a non-dependent name (`Value`) in the second class. More information. The problem is that I have a very large code base, in which this type of code is used very often. I understand that it is wrong when looking at the standard. However it is very convenient not having to write `this->` or `Base<T>::` in front of every use of `Value`. Even writing `using Base<T>::Value;` at the start of the derived class is problematic when you use ~20 members of the base class. So my question is: are there compilers for Linux that allow this kind of code (with or without extra compiler switches)? Or are there **small** modifications that will allow this code to compile on Linux?


Patterns for a tree of persistent data with multiple storage options?

I have a real-world problem which I'll try to abstract into an illustrative example. So imagine I have data objects in a tree, where parent objects can access children, and children can access parents:               // Interfaces     interface IParent<TChild> { List<TChild> Children; }     interface IChild<TParent> { TParent Parent; }          // Classes     class Top : IParent<Middle> {}     class Middle : IParent<Bottom>, IChild<Top> {}     class Bottom : IChild<Middle> {}          // Usage     var top = new Top();     var middles = top.Children; // List<Middle>     foreach (var middle in middles) {         var bottoms = middle.Children; // List<Bottom>         foreach (var bottom in bottoms) {             var middle = bottom.Parent; // Access the parent             var top = middle.Parent; // Access the grandparent         }     }      All three data objects have properties that are persisted in two data stores (e.g. a database and a web service), and they need to reflect and synchronise with the stores. Some objects only request from the web service, some only write to it. **Data Mapper** My favourite pattern for data access is Data Mapper, because it completely separates the data objects themselves from the communication with the data store:               class TopMapper {         public Top FetchById(int id) {             var top = new Top(DataStore.TopDataById(id));             top.Children = MiddleMapper.FetchForTop(Top);             return Top;         }     }          class MiddleMapper {         public Middle FetchById(int id) {              var middle = new Middle(DataStore.MiddleDataById(id));              middle.Parent = TopMapper.FetchForMiddle(middle);              middle.Children = BottomMapper.FetchForMiddle(bottom);              return middle;         }     }      This way I can have one mapper per data store, and build the object from the mapper I want, and then save it back using the mapper I want. There is a circular reference here, but I guess that's not a problem because most languages can just store memory references to the objects, so there won't actually be infinite data. The problem with this is that every time I want to construct a new `Top`, `Middle` or `Bottom`, it needs to build the entire object tree within that object's `Parent` or `Children` property, with all the data store requests and memory usage that that entails. And in real life my tree is much bigger than the one represented here, so that's a problem. **Requests in the object** In this the objects request their `Parent`s and `Children` themselves:               class Middle {         private List<Bottom> _children = null; // cache         public List<Bottom> Children {             get {                 _children = _children ?? BottomMapper.FetchForMiddle(this);                 return _children;             }             set {                 BottomMapper.UpdateForMiddle(this, value);                 _children = value;             }         }     }      I think this is an example of the repository pattern. Is that correct? This solution seems neat - the data only gets requested from the data store when you need it, and thereafter it's stored in the object if you want to request it again, avoiding a further request. However, I have two different data sources. There's a database, but there's also a web service, and I need to be able to create an object from the web service and save it back to the database and then request it again from the database and update the web service. This also makes me uneasy because the data objects themselves are no longer ignorant of the data source. We've introduced a new dependency, not to mention a circular dependency, making it harder to test. And the objects now mask their communication with the database. **Other solutions** Are there any other solutions which could take care of the multiple stores problem but also mean that I don't need to build / request all the data every time?


Store data for multiple User Type

I am developing an app where four types of user share same module. So is it a good idea to create:   1. one table and user_type and user_id (something like that)   2. table prefixes basically 4 diff tables of same columns   3. your own suggestion (keeping in mind its a CakePHP App so joins and contain will be there)


Tools to produce & manage specifications/requirements (not ticket trackers)

I'm interested if there are any websites or software out there to aid in initial project design, and then management of the project's design over time as features are implmented, bugs are found, etc... My design will include requirements (functional & non-functional), use cases, and basic database schema design. Most sought-after feature:   * Being able to define requirements and track their changes over time (i.e. how is version 1.5 different than 1.0?) Nice-to-haves:   * Being able to collaborate with other project managers and the team when putting together the specifications What I'm _not_ looking for:   * Ticket trackers (JIRA, fogbugz, etc...)   * Software version control systems   * Wikis (unless they are built with requirements management in mind) Thanks.


PHP Frameworks That Don't Use a Front Controller?

Just like the title says, are there any PHP web application frameworks that don't use a front controller? > The Front Controller Pattern is a software design pattern listed in several > pattern catalogs. The pattern relates to the design of web applications. It > "provides a centralized entry point for handling requests." > > The front controller may be implemented as a Java object, or as a script in > a script language like PHP, ASP, CFML or JSP that is called on every request > of a web session. This script, for example an index.php, would handle all > tasks that are common to the application or the framework, such as session > handling, caching, and input filtering. Based on the specific request it > would then instantiate further objects and call methods to handle the > particular task(s) required. > > The alternative to a front controller would be individual scripts like > login.php and order.php that would each then satisfy the type of request. > Each script would have to duplicate code or objects that are common to all > tasks. But each script might also have more flexibility to implement the > particular task required.


Syntax-highlighting color scheme studies

Most programmers have their own personal preferences for syntax-highlighting color schemes, but I've been wondering, has anyone ever done an actual scientific study on what the best color scheme would be? I imagine such a study would look at things like the readability of the code, whether the programmer's eyes are drawn to the most important parts, etc. Perhaps this was already done for something like the default Visual Studio theme, but I'd like to know if there are any publicly available studies out there, and what they found.


Are you allowed to manage your own time and if so, do you sometimes abuse this?

The title is a bit vague so let me elaborate: I develop both hardware and software, and I'm in a position where I get a list of 'large' tasks/projects to do but not on a regular basis. Sometimes there's 10 new things to do in one month, other times months pass by without any real deadlines. This gets combined with 'small' tasks/projects/bugs that are extremely urgent. Basically no one but me is in a good position to decide how much time I spend on what, and when I do that: the basic philosophy is 'you do whatever you want, whenever you want, just make sure the things that are urgent or have a deadline are done in time'. Firstly I'd like to hear from others if they are working in a similar environment? The reason I'm asking is that I do not know many other programmers in person, and the ones I do talk to are more in a typical '9 to 5' job and their time is rather managed by, erm, managers. Secondly, for those that are in a such a situation, did you ever find yourself spending huge amounts of time on something that was not really necessary, hereby kind of abusing your freedom? I'll give some examples: about a year ago I spent at least a month on writing a build server application, only to abandon it last month in favour of Hudson. Which again took several days to setup. Sometimes I find myself losing huge amounts of time refactoring a core library for the xth time although it's not really needed. Once I spent weeks studying the ins and outs of digital filters, while the actual task was making a basic bandpass filter that anyone could probably do in a day or so. Then I changed my mind and went with an analog implementation after all. Please share similar stories.


Most flexible UI Framework for Windows endpoint?

I am tasked with designing and implementing a flexible UI solution for deployment across a series of "kiosk"-ed Windows endpoints. There is some debate about what is the considered to be the best technology solution for the actual UI itself. The requirements are:   * Must be hardware accelerated   * Must play WMV video (for licensing reasons)   * Must be skinnable/themeable.   * Must support off-screen rendering.


How to deal with bad versioned software as SCM

I have been asked to be the SCM (Software Configuration Manager) in my company. I've read online documentation to learn what SCM is, what SCM does, etc. Currently, the company works with a version control system (Bazaar), so the software is versioned correctly, but there are old programs that are not well versioned (some of them not versioned at all), some of them are in CVS, the old version control system used at first, but they are not updated. I'm asking for your help, based on experience more than theoretical information, to know how to deal with this, how to be a good SCM even with all these issues.


What programming jobs would be best for a mathematician?

I'm a math professor that is losing his job, and I'm trying to gain programming skills, since academic jobs are scarce these days. Are there particular types of programming jobs that I should try to work towards, in order to leverage my math Ph.D? What particular skills should I try to obtain for those jobs? **Update, 6 months later:** For those that are curious, I went the certification route, and it worked for me. I learned Java, then studied for the SCJP test, then obtained a job that is technically an internship, but is full time and pays comparably to being a math professor at a private school with tough finances. I recommend certifications for anyone without a CS degree or IT experience, it is the fastest and cheapest way to get _something_ objective on your resume.


What do you wish language designers paid attention to?

The purpose of this question is not to assemble a laundry list of programming language features that you can't live without, or wish was in your main language of choice. The purpose of this question is to bring to light corners of languge design most language designers might not think about. So, instead of thinking about language feature X, think a little more philisophically. One of my biases, and perhaps it might be controversial, is that the softer side of engineering--the whys and what fors--are many times more important than the more concrete side. For example, Ruby was designed with a stated goal of improving developer happiness. While your opinions may be mixed on whether it delivered or not, the fact that was a goal means that some of the choices in language design were influenced by that philosophy. **Please do not post:**   * Syntax flame wars. Let's face it, we have our preferences, and syntax is important as it pertains to language design. I just want to avoid epic battles of the nature of emacs vs. VI (which a great number of people these days know nothing about).   * "Any language that doesn't have feature X doesn't deserve to exist" type comments. There is at least one reason for all programming languages to exist--good or bad. **Please _do_ post:**   * Philisophical ideas that language designers seem to miss.   * Technical concepts that seem to be poorly implemented more often than not. Please do provide an example of the pain it causes and if you have any ideas of how you would prefer it to function.   * Things you wish were in the platform's common library but seldom are. One the same token, things that usually are in a common library that you wish were not.   * Conceptual features such as built in test/assertion/contract/error handling support that you wish all programming languages would implement properly--and define properly. My hope is that this will be a fun and stimulating topic. **Edit:** Clarified what I mean by Syntax Flame Wars. I'm not trying to avoid all discussion of syntax, particularly because syntax is a fundamental part of program language design.


OOP in C: which of these two approaches is closer to a cannonical solution?

Here are the two approaches to writing OOP (as in "we have objects and we can instantiate any number of them, each having it's own private data"). The language is C and the platform is embedded bare-metal. Simply, which is better. Is any of the two approaches sensible at all? Or, is there a third, canonical, way to do this in C? ## Approach I: Module.c               struct inputs{};     struct outputs{};     struct scratchpad{};     struct module{         struct inputs i;         struct outputs o;         struct scratchpad private;     }      main.c               main(){         struct module obj;         module_init(obj);         module_do_fancy_stuff(obj);     }      ## Approach II: Module.c               #define OBJ_COUNT 5     struct inputs{};     struct outputs{};     struct scratchpad{};     struct module{         struct inputs i;         struct outputs o;         struct scratchpad private;     }          static struct module obj[OBJ_COUNT];      main.c               #define COOL_MODULE 3     #BORING_MODULE 4     main(){         module_init();         module_do_fancy_stuff(COOL_MODULE);     }


Why doesn't VB.NET allow unnamed, one-line objects to be used?

Why isn't this allowed in VB.NET:               New SqlCommand("some string", someSqlConnection).ExecuteNonQuery()      Why would the language have been designed to require that this be used instead:               Dim com As New SqlCommand("some string", someSqlConnection)     com.ExecuteNonQuery()      It doesn't seem to me like it would have taken much time at all to implement. Am I wrong? Is there some theoretical advantage this would give a language? **EDIT** Please read: I thought this language feature was not supported in VB.NET. I had forgotten that I had used it in the past, and so when lines like the first one above would break, I did not expect there would be a work-around like in the accepted answer. ...Although, looking back at it again, there seems to be trouble doing this when it's off by itself on a line of code, and not used as a function argument or something. I bet that's probably part of why I originally posted this. I wonder why this in particular wouldn't be allowed, but I'm asking a question on SO to see if there's a similar work-around for that... This is _not_ a question about how to use unnamed objects on a single line; this was a question about why a language designer would intentionally choose to forgo such a feature in a language like this. Was there a lingual advantage to not allowing this feature, or would it just take unexpectedly long to implement? There was a misunderstanding, but that does not change the conceptual nature of the original question, and it does not change the fact that it was searching for a logical reason to omit such a feature. The bottom line is this: This is a site about "conceptual questions about software development". This almost immediately implies trace amounts of opinion, subjectiveness, etc - as specifically noted in the very same flag this question was put under. The rule is to not push it too far, and my question did not. Please remove the flag. Thank you.


Optimal organizational structure for IT?

There are many approaches to how to structure a company's IT shop to better fit the needs of the core business. In my scenario, developing web and mobile access is central to the the needs of the organization of which I am thinking. It is structured such that development is done by one group of worker bees, another for maintenance, another still for testing, etc. etc. It seems this structure tends to lend itself to adversarial relationships because each area has its own measure of what success is: Development --> Time To Market   Maintenance --> Stability of the environment   Testing --> Making sure they don't get spanked if something goes wrong. There are many other organizational groups (for lack of a better term) for analysts, project managers, designers, etc. In a perfect world, these groups would create checks and balances against one another, but in the end priority invariably gets placed on TTM, sometimes to the detriment of the other players. This creates a lot of tension whenever releases come because an attitude of 'throwing code over the wall' prevails as the MO. What other organizational structures have you observed in industry that better lend themselves to a greater sense of cohesiveness amongst the players?


Most effective way to increase programmer salary besides just doing your job?

If you have the time and resources, what would be the most effective way to increase your salary as a full-time _programmer_ , outside of just doing your job? By "salary" here, I mean salary (adjusted for location cost-of-living) coming from a _single_ programming job.


Help finding good documentation for C/C++?

I have programmed in Java, PHP, C# and a little bit in C in an OS course I have taken recently in college. For all of these languages, I've found decent documentation except C. I couldn't find a good source for it. Any thoughts ?


How does a non-technical manager add value to team of self-motivated software developers?

I am seeing a lot of programmers turning away from management and administration roles. They want to build stuff. And as a result, a lot of these positions are filled by non-technical people. I fail to see how they add value. Is scheduling meetings, booking offsites and other administrative work enough to justify their role? **Edit:** Thanks for the wonderful answers. I do know that administration details are important, but that is why we have a dedicated HR team, recruiting teams and other teams dedicated to support developers. This is different from a non-technical manager being in a important position.


Help in deciding on approach/language for Web App

I have a personal project - a web application I wanted to develop - but I'm confused on which route to take. I know a little programming, and have dabbled in Pascal, C, HTML, CSS and Actionscript (for Flash). And I don't mind learning a new language (PHP, Python, mySQL, etc). I am not under any time constraint. **About the App:** The best I can describe it is as a kind of expert system (but not AI) that needs to find the best workflow for a process, given a set of initial and final parameters. E.g. a 'capsule' of data must pass through many 'tools' or 'environments' to reach a desired output - something like a very complicated car wash. Let's say there are many tools that can be used at various stages in the process. I have estimated there are at least 500 tools as of now, and it is bound to grow in the future as newer tools are introduced. Existing tools will also have version updates. Each tool, on average, has at least 100 properties that define the tool. Some of them have as high as 1000 unique properties. Some of these tools are linked to each other - e.g if one tool is selected, there are only n tools that can correspond to it for the next step in the process. I also have the problem of 'matching' the tools for analysis. E.g. Tool A might have only three fixed rpms - 100, 200 and 500, but Tool B might have rpms from 20 to 2000. I'm not sure how I can construct a database without spelling out each number, as in the example above. The total number of tools needed for the process can be defined at the beginning, however, it will change as the application becomes more complex in the future. I plan to address every contingency in the process. The idea is - if the user inputs the initial parameters and the desired outcome (another set of parameters), the app must find the 'best' path - sort of like a decision tree. The best path can be the fastest, cheapest, etc. I would like the user to choose what is best for him/her. Unfortunately, parameters might change, relationships might change (but not regularly) - the 'rules' I will be using might be revised for better accuracy in prediction. I also need to track each user's path and solutions' for future reference (but no personal details except username and email address for logging in). Maybe when the app is up and running, I'd like to make it more democratic, with users contributing to refining the logic/rules involved. If possible, I would also like the app to output a graphical flowchart at the end showing the workflow with all tools grouped in an easy to understand layout. **My questions:**   1. Will the app be better served with a relational DB like mySQL or an Object database?   2. Can I make this work with PHP+AJAX+CSS+mySQL? Is there a better alternative? I would prefer free programs - I intend this app to be free, but I might want to make it commercial later on. I need this program to run on any device that can connect to the internet, including tablets and mobiles, etc.   3. Do I need a framework? CodeIgniter/Symfony vs Django/ZOPE? Which is the best way for me to begin, considering I might have to scale it up in the future - with more data, more users simultaneously logged in, and more algorithms? I don't want to change solutions later on - if I have to invest time and effort I'd rather do it the right way from the beginning. I would appreciate any help in getting started. Thank you in advance.


What does it mean to "promote" a file?

I hear this term around the office, and know it's relevant to software development lifecycle. What does "promote" mean? Context: e.g. to promote a file.


Where to show copyright messages?

In my Android application, I am using a couple of open source libraries. The only requirement these libraries have is that I must show their respective copyright notices in my application. I am trying to understand where would one typically display third-party copyrights. I could probably create a menu item "About" and display an about dialog box that has all the copyrights listed. However, I would appreciate your feedback on what the standard practice is.


Why most people change from being a contractor to full time at my companies, but not the other way around?

I have seen most people changed from being a contractor to being a full time employee, but not the other way around. And that happened in startups that had maybe 20% chance of IPO or being acquired, and another that had maybe a 50% chance. As far as I know, the rate (even for a 3 year experience graphics designer, or a programmer), can be $75 to $80 an hour. While a programmer with 15 years of experience may get $120,000 per year. So, the programmer with 15 years of programming experience earns $10,000 per month. At the same time, the programmer with 3 year of experience or the graphics designer will get $14,000 per month ($80 x 22 days x 8 hours). I know I have to buy my own insurance, but I can't imagine buying those for $4,000 each month... maybe $200, $300 at most. I probably need to pay Social Security (FICA) both way (myself and as self-employed = $210 x 2), but still, each month there will be extra $3,000 of income. So is the above calculation correct? But most often, I do see contractors wanting or becoming full time, but not full time employees becoming a contractor. Does somebody know what the reason is?


Flexible / Dynamic object creation or Alternative to list of lists

I have a xlsx file, that has some tabs with different data. I want to be able to save each row of a tab in a list. The first thing that comes to mind is a list of lists, but I was wondering if there is another way. I'd like to save that information in a object, with all its benefits, but can't think of a way to generate/create such diverse objects on the fly. The data in the xlsx is diverse and ideally the program is agnostic of any content. So instead of e.g. create a list for each row, than put that list in another list for each tab and each tab in another list, I'd like to store the information that each row represents in a single object and just have a list of different objects. The question can be summarized as : **What is an alternative to list of lists ?** A small graphic to visualize the problem :               +--------------------------------------------------------------------+     |LIST                                                                |     |                                                                    |     |    +------------------+ +------------------+ +-----------------+   |     |    | Class1           | | Class2           | | Class3          |   |     |    |------------------| |------------------| |-----------------|   |     |    | var1             | | var1             | | var5            |   |     |    | var2             | | var2             | | var6            |   |     |... | var3             | |                  | | var7            |...|     |    |                  | |                  | |                 |   |     |    |                  | |                  | |                 |   |     |    |                  | |                  | |                 |   |     |    |                  | |                  | |                 |   |     |    +------------------+ +------------------+ +-----------------+   |     |                                                                    |     +--------------------------------------------------------------------+


Handling one code base for multiple clients, with their own custom code

I am working on a CMS, in which we have multiple clients that use it, so the code is stored on their servers. Each client has the default code (user manager, pages manager etc), but every client also has it's own set of code (themes, scripts, custom modules). I am trying to figure out a way to maintain an up-to-date code base for all the clients without having to make every single change to the core to every single client. We are using GitHub for version control, so I was think of having all the clients as different branches, but how can I keep the core up to date with the master? Am I think about this all wrong? What are my options?


Plugin naming based on GPL v2

I'm programming a plugin for a software under GPL v2. I'm using an unique name for my plugin, but I'm considering to rename it. I would like to take another plugin's name which has been abandoned and isn't currently being developed. Am I allowed to take up that name without asking for permission from the author beforehand?


Is excessive indirection and/or redundant encapsulation a recognized concept?

I'm curious if there's a series of tendencies or anti-patterns when programming whereby a developer will always locally re-wrap external dependencies when consuming them. A slightly less vague example might be say when consuming an implementation of an interface or abstract, and mapping every touch-point locally before interacting with them. Like an overcomplicated take on composition. Given my example, would the interface not be reliable enough and any change to it never be surmountable any any level of indirection? Is this a good or a bad practice? Can it ever go too far? Does it have a proper name?


How much Ruby should I learn before moving to Rails?

Just a quick question.. I can never get a definitive answer when googling this, either. Some people say you can learn Rails without knowing any Ruby, but at some point you'll run into a brick wall and wish you knew Ruby and will have to go back to learn it..and some say to learn the "basics" of Ruby before learning Rails and it will make your life that much easier.. My current knowledge is low. I'm not a beginner, but I'm not pro, either. I went through the Learn Python The Hard Way online book in about a month, but I stopped once I got to the OOP side of Python (I know booleans, elif/if/else/statements, for loops, while loops, functions) I agree with learning the "basics" of Ruby before learning Rails, but what exactly are the "basics" of Ruby? Would I need to learn the whole OOP side of Ruby before I went on to Rails? Or would I just need to learn the Ruby syntax up to where I learned Python (booleans, elif/if/else/statements, for loops, while loops, functions) before I went on to Rails? Thanks!


Should state machine with synonym states be shown explicitly?

I am new to state machine modeling and while trying to model a system, I have a question. An example will explain it better: Considering a system that does calling (probably a customized cell phone device) with possible states: **idle->calling->signal-dropping->handle->call ended** **idle->calling->OS problem->handle->call ended** **idle->calling->battery drained->handle->call ended** **idle->calling->some other problem->handle->call ended** Above example is in form state1->transition1->state2->transition2->state3 Question is: Is there any significance of these intermediate states? Should they be shown/ modeled explicitly in UML or even programming? **Note:** It would be helpful if anyone can mention (some existing if applicable) technical term used to describe this scenario


What are the advantages of myBatis over Hibernate?

I've done some research on my own and understand the basic concept. But some insights can only be gained through actual experience. What are the advantages of myBatis that would make it worth learning a new framework?   In what case would you avoid using it?


Why is it called a memory leak?

I am a hobbyist programmer, bit of a stickler for terminology, currently learning C and recently came across the concept of _Memory Leak_. Now, I do understand what it means. Dynamic memory allocated to a program is not returned by the program. But where does the term ' _leak_ ' come from? Is it coming from the fact that other programs cannot access the dynamic memory, since one is already hogging it, and thus total memory available from the OS to the heap is reduced and therefore " _leaked_ " to the one hogging it? Basically, are we see the memory leak from the OS's perspective? And therefore saying that it is leaked to the program?