Reason for return statement in recursive function call

I just had a doubt in my mind. The following subroutine(to search an element, in a list, for example) has a return statement at the end:               list *search_list(list *l, item_type x) {       if (l == NULL) return(NULL);       if (l->item == x)         return(l);       else         return( search_list(l->next, x) );     }      I cannot get the significance of return statement at the end (i.e. return search_list(l->next, x) ). It would be really helpful if anyone could explain this concept, using stack model.


Deleting Old Nuget Package Folders after upgrading

Should you delete the old Nuget package files/folders under the packages directory after you upgrade a package? Maybe I'm just being overly picky, but seeing files/folder for older package versions it bothering me. Is there a good reason NOT to delete the package folders for previous package versions?


Inter-process and inter-thread data sharing

I know that operating systems facilitate inter-process and inter-thread data sharing. I want to know about the mechanisms used to facilitate such sharing. I read about "pipes". What are the other ways?


Sharing Large Database Backup Among Team

I work on a team of three - five developers that work on an ASP.net web application remotely. We currently run a full local database from a recent backup on all of our machines during development. The current backup, compressed, is about 18 GB. I'm looking to see if there's an easier way to keep all of our local copies relatively fresh without each of us individually downloading the 18 GB file over HTTP from our web server on a regular basis. I guess FTP is an option, but it won't speed the process up at all. I'm familiar with torrents and the thought keeps hitting me that something like that would be effective, but I'm unsure of the security or the process.


Three variants of circular references between objects: how to choose?

I'm designing an object dependency graph of my program and one ambiguity between design variants appears from time to time. Imagine two objects having a reference to each other. Obviously, at least one reference should be assigned after object's initialization (for example, through a subscription method) and another one optionally can be a direct dependency. Here's an object diagram ![enter image description here](http://i.stack.imgur.com/7w2Jl.png) I'm not sure I've used correct UML, so here's my description: 1) Both objects have subscription/binding methods. Usage:               A a = new A();         B b = new B();         a.Set(b);         b.Set(a);      2) `ObjectB` is a component of `ObjectA`:               A a = new A(new B());               // somewhere, possibly in a's method :         b.Set(a);      3) Third is actually an opposite of the second, no need to explain. In my situation I can use any of these and my program will work, but I want some theoretical reasons. Can they be found?


What is the "default" software license?

If I release some code and binaries, but I don't include any license at all with it, what are the legal terms that apply by default (in the US, where I am). I know that I automatically have copyright without doing anything, but what restrictions are there on it? If I upload my code to github and announce it as a free download / contribute at will, then are people allowed to modify and close source my work? I haven't said that they cannot, as a GPL would, but I don't feel that it would by default be acceptable to steal my work either. So what can and cannot people do with code that is freely available, but has absolutely no licensing terms attached? By the way, I know that it would be a good idea for me to pick a license and apply it to my code soon, but I'm still curious about this.


Common Javascript mistakes that severely affect performance?

At a recent UI/UX MeetUp that I attended, I gave some feedback on a website that used Javascript (jQuery) for its interaction and UI - it was fairly simple animations and manipulation, but the performance on a decent computer was horrific. It actually reminded me of a lot of sites/programs that I've seen with the same issue, where certain actions just absolutely destroy performance. It is mostly in (or at least more noticeable in) situations where Javascript is almost serving as a Flash replacement. This is in stark contrast to some of the webapps that I have used that have far more Javascript and functionality but run very smoothly (COGNOS by IBM is one I can think of off the top of my head). I'd love to know some of the common issues that aren't considered when developing JS that will kill the performance of the site.


Why do we write the action to be performed by a function in jQuery inside the parentheses?

Generally whenever we're programming in any Programming language, say C, we would pass the parameters we need to pass to a function using the parentheses next to the name of the function. Whereas in jQuery, other than the user defined `function()` we write the action we need the function to perform inside the parentheses, for example,               $('div').mouseenter(function(){        /* blah blah blah*/     });      Why?


Are there advantages to declaring stack variables constant in C++

It's not clear to me what benefits there are of declaring your stack variables as constant in C++, I was hoping somebody might explain the benefits and purpose for this technique. For example:               void func(const std::string& arg)     {        if(someCondition)        {           const std::string foo ("some string plus " + arg);           std::out << foo << std::endl;           someFunction(foo);           // dozens more lines of code...        }        // bla bla bla...     }      Thanks!


What would be the best way to manage a lot of jQuery code?

Sorry for the blunt question, I will try to explain further. I am going to have a website which uses jQuery, and I feel that at some point in time, there will be A LOT of jQuery code, meaning A LOT of functions, jQuery selectors, etc. Is there a way to limit the availability of jQuery code for specific pages? Perhaps using objects? I'm looking for the best approach here so I don't just run off into a storm and can't find my way out. Thanks.


Why do some sorting methods sort by 1, 10, 2, 3...?

I've noticed than many numerical sorting methods seem to sort by 1, 10, 2, 3... rather than the expected 1, 2, 3, 10... I'm having trouble coming up with a scenario where I would need the first method and, as a user, I get frustrated whenever I see it in practice. Are there legitimate use cases for the first style over the second? If so, what are they? If not, how did the first sort style ever come into being? What are the official names for each sort method?


Why does the Git community seem to ignore side-by-side diffs

I used to use Windows, SVN, Tortoise SVN, and Beyond Compare. It was a great combination for doing code reviews. Now I use OSX and Git. I've managed to kludge together a bash script along with Gitx and DiffMerge to come up with a barely acceptable solution. I've muddled along with this setup, and similar ones, for over a year. I've also tried using the Github diff viewer and the Gitx diff viewer, so it's not like I've not given them a chance. There are so many smart people doing great stuff with Git. Why not the side- by-side diff with the option of seeing the entire file? With people who have used both, I've never heard of anyone that likes the single +/- view better, at least for more than a quick check.


How to best annotate MVC custom action filters?

As I get deeper into the area of ASP.NET MVC 3, I feel like I'm finding a lot of very nice technical nuggets as well as new ways of doing things versus classic ASP.NET. One of those "nuggets" is custom action filters. You can simply decorate your controller classes or methods with attributes that, by convention, point to a "custom action filter" class that can perfom some operations given some point of execution (e.g. On Exception, On Method Execution, etc). They are VERY handy if you have some sort of operation that needs to be performed at a regular point in the execution of your code. The question is this: How does this best fit in with object oriented design? What do you think is the best way of annotating that on a UML diagram or when you are trying to draw them up on a white board and explaining the design? I'm very visual, so I like explaining my designs on the white board, but I'm at a loss of how to best convey custom action filters in an Object Oriented basis. They are not really an interface that needs to be implemented. They do take advantage of inheritance, but not in the context of where they are executed. They seem to fit best under the realm of "Aspect oriented" programming, where you have actions that take place under the covers for different scenarios (e.g. Logging, Exceptions). Any thoughts are appreciated.


How much freedom should a programmer have in choosing a language and framework?

I started working at a company that is primarily C# oriented. We have a few people who like Java and JRuby, but a majority of programmers here like C#. I was hired because I have a lot of experience building web applications and because I lean towards newer technologies like JRuby on Rails or nodejs. I have recently started on a project building a web application with a focus on getting a lot of stuff done in a short amount of time. The software lead has dictated that I use mvc4 instead of rails. That might be OK, except I don't know mvc4, I don't know C# and I am the only one responsible for creating the web application server and front-end UI. Wouldn't it make sense to use a framework that I already know extremely well (Rails) instead of using mvc4? The reasoning behind the decision was that the tech lead doesn't know Jruby/rails and there would be no way to reuse the code. Counter arguments:   * He won't be contributing to the code and is, frankly, not needed on   this project. So, it doesn't really matter if he knows JRuby/rails or not.   * We actually can reuse the code since we have a lot of java apps that JRuby can pull code from and vice-versa. In fact, he has dedicated some resources to convert a Java library to C#, instead of just running the Java library on the JRuby on Rails app. All because he doesn't like Java or JRuby I have built many web applications, but using something unfamiliar is causing some spin-up and I am unable to build an awesome application in as short of a time as I'm used to. This would be fine; learning new technologies is important in this field. The problem is, for this project we need to get a lot done fast. At what point should a developer be allowed to choose his tools? Is this dependent on the company? Does my company suck or is this considered normal? Do greener pastures exist? Am I looking at this the wrong way?


Overwhelmed by complex C#/ASP.NET project in Visual Studio 2008

I have been hired as a junior programmer to work on projects that extend existing functionality in a very large, complex solution. The code base consists of C#, ASP.NET, jQuery, javascript, html and xml. I have some knowledge of all these in addition to fair knowledge of object- oriented programming and its fundamental concepts of inheritance, abstraction, polymorphism and encapsulation. I can follow code up through its base classes, interfaces, abstract classes and understand a large part of the code that I read while doing this. However, this solution is so humongous and so many things get tied together whenever I navigate through the code that I feel absolutely overwhelmed. I often find myself unable to fully follow everything that is going on with objects being serialized, large amounts of C# and javascript operating on the same pages and methods being called from template files that consist mainly of markup. I love learning about code, but trying to deal with this really stresses me out. Additionally, I do know that a significant amount of unit testing has been done but I know nothing about unit testing or how to utilize it. Any advice anyone could offer me regarding dealing with a large code base while using Visual Studio 2008 would be greatly appreciated. Are there tools that I can use to help get a handle on what is going on? Perhaps there are things even in Visual Studio that I am not aware of. How can I follow the code to low level functionality in order to get a better grasp of what is going on at a high level?


How did separation of code and data become a practice?

**Please read the question carefully: it asks _how_ , not _why_.** I recently came across this answer, which suggests using a database to store immutable data: > It sounds like many of the magic numbers you describe - particularly if they > are part dependent - are really data, not code. [...] It may mean an SQL > type database, or it may simply mean a formatted text file. It would seem to me that if you have data that is part of what your program does, then the thing to do is to put it _in the program_. For example, if your program's function is to count vowels, what's wrong with having `vowels = "aeiou"` in it? After all, most languages have _data structures_ designed for precisely this use. Why would you bother to _separate data_ by putting it in a "formatted text file", as suggested above? Why not just make that text file formatted in your programming language of choice? Now is it a database? Or is it code? I'm sure some will think this is a dumb question, but I ask it in all seriousness. I feel like "separate code and data" is emerging culturally as some sort of self-evident truth, along with other obvious things like "don't give your variables misleading names" and "don't avoid using whitespace just because your language considers it insignificant". Take for example, this article: The Problem with Separating Data from Puppet Code. _The Problem_? What problem? If Puppet is a language for describing my infrastructure, why can't it also describe that the nameserver is 8.8.8.8? It seems to me that the problem isn't that code and data are mingled,1 but that Puppet lacks sufficiently rich data structures and ways to interface to other things. I find this shift disturbing. Object oriented programming said "we want arbitrarily rich data structures", and so endowed data structures with powers of code. You get encapsulation and abstraction as a result. Even SQL databases have stored procedures. When you sequester data into YAML or text files or dumb databases as if you are removing a tumor from the code, you lose all of that. Can anyone explain how this practice of separating data from code came to be, and where it's going? Can anyone cite publications by luminaries, or provide some relevant data that demonstrates "separate code from data" as an emerging commandment, and illustrates its origin? 1: if one can even make such distinctions. I'm looking at you, Lisp programmers.


Why did Shannon's outguessing machine beat Hagelbarger's?

I'm reading "Rock Breaks Scissors", which describes two "outguessing machines" built at Bell Labs that try to exploit human non-randomness in the game of matching pennies. There was an outguessing machine built by the famous Claude Shannon, and one built by Dave Hagelbarger. The machines worked like this (quoted from the book): > Suppose you win twice in a row with the same choice. What would you pick > next? You could stick with the choice that's been winning - or you could > switch, perhaps on the grounds that three times in a row wouldn't be > "random." > > Each time a particular situation occurred, [Shannon's] machine archived what > the player had decided. Every decision was encoded as a 1 or 0 and slotted > into one of the machine's 16 precious bits of memory. For each of the eight > given situations, Shannon's machine cataloged the last two decisions only. > That filled the machine's 16 bits. > > When the machine needed to predict, it looked at what the player had done > the last two times that the same situation had occurred. Whenever the > player's response had been identical both times, the machine predicted that > the player would do the same thing once again. Otherwise, it guessed > randomly from its [random number generator]. > > The main difference between Shannon's machine and Hagelbarger's was that > Shannon's was simpler. Hagelbarger's machine kept track of a percentage of > outcomes for each of the eight situations. The higher the percentage, the > more likely Hagelbarger's machine was to predict a repeat of the past. This > may sound more reasonable and nuanced than Shannon's all-or-nothing > approach, but in practice, Shannon's device was the better predictor. Shannon's machine beat humans at a higher rate than Hagelbarger's, and also beat Hagelbarger's machine when they played each other. I don't understand why Shannon's simpler approach was significantly better than Hagelbarger's percentage-based approach.


Is there a pattern to restrict which classes can update another class?

Say I have a class ImportantInfo with a public writable property Data. Many classes will read this property but only a few will ever set it. Basically, if you want to update Data you should really know what you're doing. Is there a pattern I could use to make this explicit other than by documenting it? For example, some way to enforce that only classes that implement IUpdateImportantData can do it (this is just an example)? I'm not talking about security here, but more of a "hey, are you sure you want to do that?" kind of thing. ## UPDATE I've been faced with similar situations before, that's why I tried to keep the question more generic but it seems that a more concrete example is definitely required. So here it goes: I have a Context class with a a property CurrentYear. Many classes use this Context object and, whenever CurrentYear changes, they need to react (reload themselves, for example). Now, there are some classes that can legitimately change CurrentYear. Of course, you don't want just everybody to change CurrentYear as that has an effect in many other classes. How would you go about that?


What's better approach when creating a user control: receive a full object or only the needed values?

I'm working with ASP.NET Web User Control (WUC) and I got to this question: I'm creating a WUC to show an object's data. This object is already loaded when I call that WUC. I'm wondering what would be better: give the WUC the full object or only the necessary attributes?


How do you keep SOA DRY?

In our organization, we've shifted to a more "service oriented architecture". To give an example, let's assume we need to retrieve a "Quote" object. This quote has a shipper, a consignee, phone numbers, contacts, email addresses, and other location information. In other words, a Quote object is made up of many other objects. So, it seems like it would make sense to make a "Quote Retrieval Service". In our situation, we've accomplished this by creating a .NET solution and writing the service. The service API looks something like this (in pseudo-code):               Function GetQuote(String ID) Returns Quote      So, so far so good. Now, when this service is consumed, to keep things "de- coupled", we are creating essentially a duplicate of the Quote object and mapping from the QuoteService version of the Quote into the consumer's version of the Quote. In many cases, these classes will have the exact same properties. So, if the Quote service is consumed by 5 other applications, we would have 6 definitions of what a "Quote" is. One for each consumer, and one for the service. This feels wrong. I thought code was supposed to be DRY, but it seems like our method of SOA is forcing us to create tons of duplicated class definitions. What are we doing wrong, or is the code duplication just a "necessary evil" of SOA?


Why are JOINS deprecated for a in-memory database?

Correct me if I'm misunderstanding. Refer to the following sentence: > Stack Overflow copied a key part of the Wikipedia database design. This > turned out to be a mistake which will need massive and painful database > refactoring to fix. **The refactorings will be to avoid excessive joins in a > lot of key queries.** This is the key lesson from giant multi-terabyte table > schemas (like Google’s BigTable) which are completely join-free. **This is > significant because Stack Overflow's database is almost completely in RAM > and the joins still exact too high a cost.** 1 Actually I'm trying to pass from the interest on single technology like Asp.net MVC to architectures design. Can you better clarify the quoted sentence? [1] http://highscalability.com/stack-overflow-architecture


Git work-flow for uncertain premise (pending decision)

I am not quite sure, how to name my problem. But I will start with how I usually used git. I am working as a single developer on one git repository. Usually I make feature-branches from master, and merge them back into master, when the feature is finished. When meanwhile another feature-branch was merged into master, I rebase the other branch on master, before merging. That worked very good, until recently. One dependency I have in my project, needs an update. But it was not yet decided how this update will be implemented. But I can simulate the new behavior quite simply. So I branched from master, and simulated that fix. So when the actual fix is available and merged into master, all changes above can be rebased back on master. But the decision on that fix is still pending, and my branches are stacking up:               * ee8d0ab (HEAD, featureTwo)      * e659932      * 27986c0 (featureOne)      * f0011e6      * d4187cf      * 552e35a      * 37d597f (simulatedFix)      * e0eb3d0 (origin/master, master)     * b06583c      * d295b3e       I feel, that this is not good. It feels like I am building up dept. Imagine how this would look at featureTen, or featureTwenty. What are the possible drawbacks of this method? And what is the best way, to handle this situation?


How is it called when you define constants that simply refer to a large namespace?

I am using JRuby. I have many classes implemented in Java, and I want to create objects off of them in my Ruby scripts. Suppose that I have a class `Sprite` in Java. In Ruby, to refer to it, I use the following:               Java::ComMyWebsiteMyProjectName::Sprite      Because Sprite is defined in the package `com.myWebsite.myProjectName`. Now then, to simplify things, I like to do this:               Sprite = Java::ComMyWebsiteMyProjectName::Sprite      Which sets the constant `Sprite` to the `Sprite` class defined in Java. Now my Ruby code can refer to it by just writing `Sprite`. I have a file full of that kind of declarations. Something like:               Sprite   = Java::ComMyWebsiteMyProjectName::Sprite     Texture  = Java::ComMyWebsiteMyProjectName::Texture     Bitmap   = Java::ComMyWebsiteMyProjectName::Bitmap     Math     = Java::ComMyWebsiteMyProjectName::Math     Geometry = Java::ComMyWebsiteMyProjectName::Geometry      Now, I am not exactly very familiar with programming concepts. I am having problems giving this file a name, because I don't even know if there is a name for this kind of thing. **Does this kind of "practice" have an actual name?**


How do you incorporate GTD into your daily programming tasks?

David Allen's "Getting Things Done" method seems to be a very useful way of organizing tasks and getting those tasks done. Has anyone here used GTD in their day-to-day programming tasks, and if so, what's the best way to go about it?


How can I track programming productivity on a daily basis?

How can I track that I'm developing software more or less productive than the previous days?


Is smarter software necessarily bigger?

This is kind of a vague question so I apologize in advance. When software is "smarter", I tend to interpret that as really just saying that it covers more edge cases. First of all, is this correct? Assuming it is, does this mean that the software is full of if/switch statements to make sure input is handled properly, therefore making it "smarter"? This thinking makes me feel like the code would end up bloated and messy. I'm running into a point where I'm wanting to handle these edge cases, but I don't want to bloat my code merely overlooking some best practice. What am I missing?


Is it possible to do decent spam filtering without scanning the contents of emails?

I don't have much knowledge of the subject but as I know, when servers receive an email they have two sources of data to classify it as SPAM or not. The contents of the message (subject + body) and the metadata that goes with it (from who / to who / server that sent the message, etc). I know you can do basic filtering by blacklisting emails list and other sorts of metadata. But is it possible to do decent spam filtering without checking the contents of a message? Defining 'check the contents' as using any function that relies on data found on the body/subject of the message to classify it as spam or not spam. **Edit** : The reason I ask for this because of the "scroogled" campaign where Microsoft accuses Google of scanning the contents of emails for advertising purposes, and I think that they do the same for spam prevention purposes. So I asked them and they said: > We have tools and system set up to filter spam emails to and from > Outlook.com email accounts. However, we are not allowed to disclose how > these spam filters work for security purposes. > > ME: So can you assure me that no content from my personal email is being > analysed and cross referenced with other data in any way? > > ...In response to your question, its a yes, we can assure you that.


Interview: how to ask development process/culture related questions

I just watched a presentation about simplicity by Rich Hickey at InfoQ where he goes over the constructs programmers use to produce artifacts and how those constructs make various trade-offs when it comes to achieving simple artifacts. I think that most programmers would agree with a lot of what he says but at the end of the day I don't know how many development shops are actively practicing development processes and using tools that allow them to make simple artifacts. As an interview candidate I would like to work at a software development shop where producing simple artifacts is a top priority. What are some questions I can ask to figure out if the place that is interviewing me is actually such a place.


Best Way to Access Hardware per COM Serial Port over USB Adapter

We are starting a total new Branch at our firm. I am usually developing database interfaces or internal server/client applications/tools for our company, but I never had to do something with hardware. **Szenario** My Boss want to sell a device, which has a touch-screen to set up the many, many features. However, the configuration of the device can be very time consuming. He wants to give a software free for a good customer and for a litte charge to "small" customers. The customer should only be able to use the software, if he registers at our system, so that he can't copy the software without a notice by us. **Requirements** The device has a build in USB cable. If you plug it in your computer it opens a new COM serial port. The software has the following requirements:   * Configurating different presents for the device   * Reading and writing the presets to the device   * Software will refuse to start, if the user has no registration at our server   * The user can store his presets at our server and share it with other customers   * One preset, copied over and over to multiple devices My boss has seen similar system (he said something about logitech harmony remote controls) and it is now on me, to create the architecture. Server Side: The server is not that kind of problem. We have enough different machines to suite any kind of favour (IIS, LAMPP, Apache/Tomcat etc.) I could take MSSQL or MySQL DBase to store the data, thats not the problem. Client Side: This is the tricky part for me. I never did something with hardware. My boss suggested I should use Silverlight. I claimed that I want to do it with a native application. But what is the best combination?   * Total Client-Side (C++, C# or Java are the languages I could write)   * Mixed Structure #1 Silverlight + Native "Driver" Application   * Mixed Structure #2 Java-Applet + Native "Driver" Application   * Browser Only - Silverlight or Java-Applet?   * Any other suggest The device is for a special customer group who's getting personal trained with any purchase so security risks like unsafe code or dangerous browser plugins are no negative selling argument. I did some research about COM Serial Port connection with Silverlight and P/Invoke but I don't want to start without a discussion what would be the best way.


How do I know I'm not violating a software patent?

I'm using a android like lock screen (The one with the nine dots that you have to connect to log in) in my application currently. I'm afraid of getting a mail from google because of some patents that I didn't know. Is the android lock screen patented or can I rebuild it and use it in my application?


What is a good stopword in full text indexing?

When you go to the Appendix D in Oracle Text Reference they provide lists of stopwords used by Oracle Text when indexing table contents. When I see the English list, nothing puzzles me. But the reason why the French list includes _moyennant_ (French for _in view of which_ ) for example is unclear. Oracle has probably thought it through more than once before including it. How would you constitute a list of appropriate stopwords if you were to design an indexer?


Can a layer consist of multiple projects / dlls?

I am working on the architecture for a new web application and I am pretty much a complete newbie when it comes to architecture. Working my way through .NET Application Architecture Guide, 2nd Edition and learning a lot. I have decided to go for the "standard" 3-layer architecture: Presentation layer, Business layer, Data layer. Will be using ASP.NET MVC and Entity Framework. Currently the business layer contains the logic and business entities (anemic models). I am planning to use the business entities as EF entities. That would, however, cause the data layer to have a depency on the business layer. This "problem" can be solved by moving the business entities into its own project and have the layers that have dependencies on the business entities reference that project.   1. Is that an ok / good way of doing things?   2. Will / can / should the business entities project be considered part of the business layer?   3. Can a layer consist of multiple projects, that is, the layer only acts as a "logical container"? In the above mentioned book they talk about how the business layer can consist of "Business Workflow", "Business Components", "Business Entities", and I assume that each of those are a separate project (maybe even multiple projects)?


What are all the components of a "Facebook App"?

I am a developer who has never personally partaken in social media (in any form) for reasons completely outside the scope of this question. I am "off the grid" (no Facebook, Twitter, etc accounts). I'm currently building a web app and would like the app to have a presence on Facebook, and possibly even "port" my app over as a Facebook app. My _understanding_ of Facebook Apps is that they're just normal web apps that get `<iframe>`d into a Facebook page. The app is actually hosted on your server (not FB's servers). But this got me thinking:   1. Don't Facebook Apps have "profile pages"? Is there anything developers can do to customize the behavior of their own profile pages?   2. Do apps have the ability to do things like MySpace themes used to do (i.e., customize and interact with User profile pages, Groups, etc.)?   3. Do Facebook Apps gain any sort of extra capabilities (inside of Facebook) that a normal web app would not have? It seems to me like if all a Facebook App is, is an iframed-web app, that it would still need to communicate with Facebook via its many APIs, just like a normal app would have to, right?   4. If it's not possible to write an app that can customize the UI or behavior of user profiles and other pages, then how do games like "Farmville" interact with User profiles so that you see updates to profiles like "John Smith reached level 2 of Farmville"? Basically, I'm asking any battle-worn Facebook app developers if my understanding of Facebook Apps is correct, or if I'm missing anything big here. It's my understanding that for security reasons (obviously) Facebook doesn't allow apps to customize anything outside of the iframe it lives in. So if I want my app to appear like it's "interacting" with its Facebook users, it looks like I just need to publish stuff to the users' news feeds to try and encourage people to use my app (please correct me if I'm wrong here!). Thanks in advance for any corrections, clarifications, advice or suggestions!


How do you keep enthusiam up when working on an overwhelming project?

When I'm working on a complex / large programming project and I get overwhelmed or lost, I often lose motivation and just don't have the energy to really dig into the problem once again to figure it out. After some time goes by, I may get back to it and have the renewed enthusiasm it takes to think about the problem from first principles again. This usually works, if I get back to the original problem. More often than not, I get side- tracked on other projects and the original program/problem lies dormant forever. I know this is a common reaction to complexity, or being overwhelmed by a problem and not knowing where to go to next. You run out of steam pretty quickly. But there are things I've come across that I can focus on for fun, and it often gets me stoked to get back into programming, the more complex the project the better! These things would sound incredibly dorky on any other site, but probably less so here. I'm talking about things like listening to a Stack Overflow podcast, reading an old Steve Yegge or Paul Graham article, watching an episode of Matt Chat where he's interviewing some programmer that worked on an old game for the Atari 800, or just watching a movie like Wargames (not many other movies come to mind though). The problem is, sometimes I run out of these ideas that renew my interest in computer science, so I'm asking for some of your ideas. Maybe limit it to one per answer so people can vote for particular answers/recommendations. Thanks for your input!


Amazon SOA: database as a Service

There is an interesting interview with Werner Vogels which is partly about how Amazon does Service Oriented Architecture: > For us service orientation means encapsulating the data with the business > logic that operates on the data, with the only access through a published > service interface. No direct database access is allowed from outside the > service, and there’s no data sharing among the services. I do not understand that. Why do they need to 'wrap' a database into some layer if it already can be consumed as a service by other service through database adaptors? Does Amazon do that just because they need to expose the database to third parties or because of anything else? Why "no direct database access is allowed"? What are the advantages of such an architectural decision?


Ajax application: using SOAP vs REST ?

I'm building an ajax heavy application (client-side strictly html/css/js) which will be getting all the data and using server business logic via webservices. I know REST seems to be the hot topic but I can't find any good arguments. The main argument seems to be its "light-weight". My impression so far is that wsdl/soap based services are more expressive and allow for more a more complex transfer of data. It appears that soap would be more useful in the application I'm building where the only code consuming the services will be the js downloaded in the client browser. REST on the other hand seems to have a smaller entry barrier and so can be more useful for services like twitter in allowing other developers to consume these services easily. Also, REST seems to Te better suited for simple data transfers. So in summary SOAP is useful for complex data transfer and REST is useful in simple data transfer. I'm currently under the impression that using SOAP would be best due to the complexity of the messages but perhaps there's other factors. What are your thoughts on the pros/cons of soap/rest for a heavy ajax web app? **EDIT:** While the wsdl is in xml, the data I'm transferring back and forth is actually in JSON. It just appears more natural to use wsdl/soap here due to the nature of the app. The verbs GET and POST may not be enough. I may want to say something like: processQueue, or executeTimer. This is why my conclusion has been wsdl/soap would be good for bridging a complex layer between two applications (client and server) whereas REST would be better (due to its simplicity) for allowing many developer-users to consume resources programmatically. So you could say the choice falls along two lines   * Will the app be verb-oriented (completing tasks: use soap) or noun-oriented (consuming resources: use REST)   * Will the api be consumed by few developers or many developers (REST is strong for many developers)?  Since such an ajax heavy app would potentially use many verbs and would only be used by the client developer it appears soap/wsdl would be the best fit.


What kind of screen has the best image quality for reading/programming?

I'm thinking about buying a new laptop, and while I bought my original one oblivious to the fact that there could be different quality screens out there, after seeing the screen on my sister's netbook I realized that I might have to be cautious with my next purchase. Granted, I did not confirm that the reason my sister's screen looks the way it does is due to the screen itself and not color scheme/graphics card, but I know very little about the different screen technologies and how they differ in image quality and therefore can't really tell if wondering about it even makes sense or not. So what I'm asking is: should I be worried about screen quality? And if so, what technologies should I be looking for? How do they differ and which are the best ones? What are the different elements that determine the quality of a screen and which stats should I go for in each element? For the record, I'm not interested in opinions about screen size, but picture quality for lots of reading/coding.


What is the benefit of using sharp architecture?

I'm working in a project that use nhibernate as orm. Is there any benefit for me to use sharp architecture? what is these benefits?


AddIn, AddOn, And Plugin

Even though at first glance the words AddIn, AddOn, And Plugin give the same meaning, there are some differences between them. Could anyone explain to me the subtle differences between _AddIn_ , _AddOn_ , And _Plugin_?


What is the correct UI interface to learn for creating Windows phone 8 apps?

I am a veteran Delphi 6 programmer transitioning to C# development. My first project is a open source library that will have a minimal user interface since it is meant to be used as a Component primarily on desktop PCs running Visual Studio. My next project is going to be a Windows 8 phone app and I intend for that platform to be my primary focus for future C# development, not the desktop. My concern is that I waste as little time as possible learning a presentation framework that will benefit or distract me from writing Windows 8 phone apps. The plethora of framework names I have already encountered include, WinForms, WPF (Windows Presentation Framework), Silverlight, Silverlight Mobile, Metro and there may be others. Given my goal outlined in the first paragraph above, which is the correct framework to study for developing Windows 8 phone apps? I read about the Portable Library Tools on this Stack Overflow thread: http://stackoverflow.com/questions/5522355/windows-phone-7-wpf-sharing-a- codebase But the reply by Simon Guindon seemed to indicate to me that it's not the best solution for writing a competitive Windows 8 phone app.


What amount of time do you spend doing each of the following

Recently I've been thinking I spend too much time on SO and general learning / keeping up with technology rather than actual coding. So my question is what ratio's of your time do you spend on the following:   * Actual coding   * Reading around the subject, improving knowledge, learning new things


Are there any good resources for refactoring existing C# code to use LINQ while keeping your tests passing?

I've been teaching myself a little LINQ and an exercise I thought would be useful was to take my existing Project Euler C# code, which I built using Test Driven Development and gradually convert it to LINQ. I realise that LINQ is not always the best solution for all of the Project Euler problems, but I don't want to get into that here. I'm wondering whether or not it's feasible to refactor "traditional" OO C# code to use LINQ and functional programming syntax whilst keeping all of your tests passing. I can't find a way to make the tiny steps I'm used to making using TDD when converting to LINQ and this is a roadblock for me. I seem to have to make large changes to come up with a single function that I then replace whole chunks of my code with. I realise I could write this from scratch in LINQ, but in the real world, I'd like to be able to replace parts of my existing C# code to take advantage of LINQ where appropriate. Has anyone been successful with this approach? What resources did you find useful for refactoring existing C# code to use LINQ whilst taking a Test Driven Development approach?


Robot arm sample problem in Skiena's "Algorithm Design Manual" seems to be invalid to me

I'm reading Skiena's _Algorithm Design Manual_ and there is a problem on page 5, "Robot Tour Optimisation", where he says this about the sample problem: "Suppose we are given a robot arm equipped with a tool, say a soldering iron. In manufacturing circuit boards, all the chips and other components must be fastened onto the substrate. More specifically, each chip has a set of contact points that must be soldered to the board. To program the robot arm for this job, we must first construct an ordering of the contact points so the robot visits the first contact point, second, etc..." "We must first construct an ordering" - that seems strange to me. Because, well, every chip has certain number of pins and they're numbered and their position is documented, look here: ![enter image description here](http://i.stack.imgur.com/Q0MWK.jpg) I mean that chip doesn't have a set of pins, it have an ordered list of pins, ok, it doesn't but it has very specific dimensions and specific order of pins on each side so their precise position (and order) can be easily calculated. Maybe unrelated, but probably IRL the board is moving on some sort of clamp in X, Y dimension and soldering iron only goes up and down. The simplest problem I can give as an example of Robot Optimisation tour is a pizza courier who rides a car and needs to visit all his clients (let's assume that traffic is near zero) and returns to the restaraunt with as little gasoline spent as possible. So he needs a tool (car navigator), that will solve this problem for him. And that navigation application needs to find the optimal route - so, it illustrates the problem. Am I right that original problem illustration with robot arm is wrong?


Why is it always "what language should I learn next" instead of "what project should I tackle next"?

Why do beginning programmers (like me) always ask about the next language they should learn instead of asking about the next project to tackle? Why did Eric Raymond, in the "Learn How To Program" section of his "How To Become A Hacker" essay, talk about the order in which you should learn languages (vs. the order in which you should tackle projects). Do beginning carpenters ask "I know how to use a hammer ... should I learn how to use a saw or a level next?" I ask because I'm finding that almost any meaningful project I'm interested in tackling (e.g. a web app, a set of poker analysis tools) requires that I learn **just enough** of a **multitude of languages** (Python, C, HTML, CSS, Javascript, SQL) and frameworks/libraries (wxPython, tkinter, Django) to implement them. Thanks, Mike


Is it bad style to redundantly check a condition?

I often get to positions in my code where I find myself checking a specific condition over and over again. I want to give you a small example: suppose there is a text file which contains lines starting with "a", lines starting with "b" and other lines and I actually only want to work with the first two sort of lines. My code would look something like this (using python, but read it as pseudocode):               # ...     clear_lines() # removes every other line than those starting with "a" or "b"     for line in lines:         if (line.startsWith("a")):             # do stuff         elif (line.startsWith("b")):             # magic         else:             # this else is redundant, I already made sure there is no else-case             # by using clear_lines()     # ...      You can imagine I won't only check this condition here, but maybe also in other functions and so on. Do you think of it as noise or does it add some value to my code?


Javascript tools for branch coverage

I'm looking for tools that will help me write test cases to cover all paths through a function in Javascript. Ideally, I'd like something that will spit out a list of combinations of parameter and property values that should be tested. However, if the tool simply told me which parameters and properties have an effect on the function, that would be very useful as well. Thanks! edit: I'm not certain that "branch coverage" is the correct term for what I'm describing. If "code exploration" is a better term (or anything else), please add a comment.


Is there a language offering LISP-like macros with a more complex syntax?

LISP's macros are extremely powerful constructs, and the inability to introspect and modify the program itself beyond the method signature level has always struck me as a limitation. Yet I favour "complex" syntax because it tends to be closer to natural language. **So far I have failed to find a language which combines a powerful macro mechanism such as LISP's with a naturally looking syntax** (1). Is anyone aware of such a language? Footnote:   1. I would consider python to have a naturally looking syntax as it allows constructs like this: `if 0 < a < 5 and b in list`. The avoidance of braces to structure blocks is irrelevant in this case, though.


How to deal with well-meaning open-source contributors?

If a programmer contacts you and asks to contribute to your project, how do you handle it?   * You don't know if this guy is any good. Perhaps he'll be more trouble than he's worth.   * He might be trying to attach his name to a successful project just for the kudos.   * He might be trying to take the project in a direction you don't really want, adding features you think aren't worth the extra complexity.   * Or, he might be a very useful contributor. You just don't know. How do you handle such requests from people you don't know (On GitHub, specifically, if that makes any difference)? What's the etiquette here?


How to sell logistical procedures that require less time to perform but more finesse?

I am working with a group where part of the responsibilities is managing a certain set of configuration files which, of course, have the same skeleton/structure across different environments but different values (like server, user, this setting, that setting etc.). Pretty classic scenario... The problem is that everyone just goes and modifies final, environment- specific files and basically repeats the work for every environment. Personally, I am offended to have to peform repeatable, mundane tasks in this day and age when we have technologies to automate it all. So I devised a very simple procedure of abstracting the files into templates, stubbing env-specific values with parameters and then wrote a simple Perl script that, given a template and an environment matrix with env-specific values for each param, produces the final file. So this is nothing special, cutting-edge or revolutionary -- I am pretty sure that 20 years ago efficient places did their CM like that. However, that requires that changes are made at the template level and then distributed across different environments using the script and not making changes in the final environment-specific files. This is where I am encountering resentment as they feel "comfortable" doing it their old, manual, repeated labor way. Personally, I don't have a problem with them working hard rather than smart but the problem is when I have to build on top of someone else's changes, I have to merge their changes into my template from a specific file, which takes time and is grueling. So my question is how to go about selling my method, which makes it so much faster in an environment that is resentful to change and where most things have to be done at the level of the least competent team member?


Why was support for Windows XP dropped in PHP 5.5?

In the release notes for PHP 5.5.0 it's announced that Windows XP and Windows 2003 are not supported anymore: > Drop Windows XP and 2003 support. (Pierre) Why is this? Many people in different companies develop applications under Windows XP. So, can anyone tell me what is the sense of dropping Windows XP and 2003 support?


Looking for enterprise web application design inspiration

I've checked many websites to be inspired about what the look and feel of a serious enterprise web-application should look like. But the whole I saw were designed for being used by single users and not serious corporate users. The designs I saw were mostly happy-colored, and looked like being developed by a small team of eager young passionate developers. But what I'm looking for, are showcases of serious web apps' designs (e.g. web apps developed by large corporations) that are developed for being used by a large number of corporate uses. Can you suggest me sources for this kind of inspiration?


Who is the father of CIL?

...formerly known as MSIL, simple question, it is widely known that Anders Hejlsberg is the father of C#, but is there a "father of CIL"?


to know how many visitors visit my website, i absolutely have to put some kind of tracking code within the page itself?

Is it true that to know how many visitors visit my website, some kind of tracking code had to placed within that page itself, and there is no other way around it? Even if we use something like Google Analytics indirectly they are also placing some kind of tracking script within our pages right? Or is it true that even there are no tracking script within my page, someone (some authority?) will have access to this info?


Is it bad practise to create instances from a SQL-query?

I'm researching ways to create a OO-model/repository-layer using PHP's PDO. My idea was to create model classes that represent a domain object and a repository class for each model that has the responsibility of:   * Saving to the database by taking a model as argument and mapping the objects properties to the VALUES of the SQL-query.   * Reading from the database by return an instance of a model in a similar fashion. I was inspired from a course in OOP in which we used .NET, EF and LINQ for the Labs. I asked a question on SA about how this could be achived on SA. I got flamed because is is supposedly bad practise. I don't see why this is the case.


Scrape Intranet site without a web server

I'm trying to rebuild a simple c# time tool that displays certain statistics about time worked for the web, however, I don't have access to a server so I can't use server code like PHP which I would do if I could and this task would be a doddle. The employee's work information is stored on an intranet site that the C# tool could access by scraping that site and grabbing what it needed. How can I do this (scrape the intranet site) without using server code and only client-side things like HTML, JavaScrit/jQuery? **Edit:** Forgot to mention the Windows machines don't have .net installed


How to read large XML files efficiently

I have a large XML file (about 75,000 lines) where I have to build a catalogue (houses) from. Building the lists works fine, but now I have a problem. The catalogue should have a detailed presentation page of one house. One house (`<item id="123">`) has about 800-1200 lines of data, based on the house type. **Which is the best way, as referring to making the script faster and saving lines of code, to read these data and present them?** Some houses, for example, have a sauna, and when these data are in the XML file, the presentation page should contain a section sauna. I tried before to read the whole XML content with a recursive function into arrays and with a lot of `foreache`s (maximum depth of children is three) with SimpleXML, but it was really ugly slow, and the recursion did not work at all, because my computer could not handle so much input. **Is there any other way to build this data except to query every variable with`if`?**


Useful Scripts for CM?

I'll be forming a remote team, and I want to be able to use scripts (or something) to make _sure_ that people's code is checked in every night. I currently use some BASH scripts that are kindof wonky and aren't customizable easily. Does anyone have any useful tools, tips, or resources for this?   Are there any pitfalls to doing this that I'm not seeing, or can I do it better another way? (cross-posted to super-user)


Do libraries and frameworks swing more on the GPL or MIT side?

I like the GPL license but the project I'm working on is a more general purpose one that will be used inside other programs. It doesn't run independently like a CMS or application would. So I'm looking around at other projects to see what they've done.   * JQuery has an interesting MIT/GPL license   * Zend framework has New BSD license   * Symfony framework has MIT license  As developers, is there an established preference that we expect from libraries. I rarely cared because I never build applications that were sold or distributed, which eliminated the possibility that I would be in conflict with the license of a library I'm using, but I want to know what others are thinking. Will you avoid using a library or a framework if it's GPL? I'm a bit torn. I'd like to use GPL and as the only license (unlike JQuery for example) but I also worry that this will scare developers away who want to use the library to build distributable code. The other thing is I'm seeing that many libraries are frameworks are released as MIT, but I find the MIT license, well, a bit too "loose" for my taste.


Do you read C or C++ compile errors after the first one?

I never understood why C and C++ compilers try to recover from errors and continue parsing. Almost always, the first error generates a stream of bogus errors that will disappear as soon as the first one is fixed. After several years of experience, I simply stopped looking at any error except the first one of every file. I rerun the compiler and then do that again until there is no more errors. Is it a common practice?


Browser security and payments

I've been finding a lot of blog posts claiming JS encryption is unsafe, here's a couple of detailed ones: http://www.matasano.com/articles/javascript-cryptography/ http://rdist.root.org/2010/11/29/final-post-on-javascript-crypto/ My question is, if browsers truly are inherently unsafe then, by extension, entering any PCI-related info in the browser is unsafe - regardless of JS encryption, HTTPS, or any other security measures? Which would imply that malicious parties should be taking major advantage of this fact, right? Could someone provide specific examples where browser vulnerabilities were leveraged to steal **massive** amounts of PCI-info/PII (by "massive" I mean comparable to the amount that could be obtained by hacking into the hosting servers/DB)? Also, despite all those posts describing security flaws there's a proliferation of payment services and JS crypto libraries - does that indicate that most companies/communities:   1. are unaware of browser vulnerabilities?   2. are simply disregarding the underlying issues and jumping on the bandwagon to make some dough?   3. have weighted the (possibly low) likelihood of someone going through the trouble of exploiting browsers and decided it's still worth to capture payments through browsers? EDIT Using SSL/TLS addresses some of the issues, but definitely not all. Here are a few notable issues that fall outside of the area that SSL/TLS can solve (quoted directly from the Matasano blog post): > The prevalence of content-controlled code. > >   * We mean that pages are built from multiple requests, some of them > conveying Javascript directly, and some of them influencing Javascript using > DOM tag attributes (such as "onmouseover"). > > > The malleability of the Javascript runtime. > >   * There is no reliable way for any piece of Javascript code to verify its > execution environment. Javascript crypto code can't ask, "am I really > dealing with a random number generator, or with some facsimile of one > provided by an attacker?" And it certainly can't assert "nobody is allowed > to do anything with this crypto secret except in ways that I, the author, > approve of". These are two properties that often are provided in other > environments that use crypto, and they're impossible in Javascript. > > > What else is the Javascript runtime lacking for crypto implementors? > >   * Two big ones are secure erase (Javascript is usually garbage collected, > so secrets are lurking in memory potentially long after they're needed) and > functions with known timing characteristics. Real crypto libraries are > carefully studied and vetted to eliminate data-dependant code paths --- > ensuring that one similarly-sized bucket of bits takes as long to process as > any other --- because without that vetting, attackers can extract crypto > keys from timing. > Again, my main point is that, technically, once a credit card number (or some other important piece of info) is entered into a text field of a page there's a chance that it's been compromised - and at that, compromised more easily then if it were entered in the native application.


How to name filename parameter to make clear it should contain full path?

I'm seeking vital naming of string `filename` parameter in parameter list used in various methods where **filename with full path** is expected. In many cases also UNC path can be actually supplied as full path because many libraries handle it natively. I usually call the parameter just `filename`, but it can be misleading in two ways:   * Beginners tend to think it is only name of file – without path.   * If there is a need of splitting the value into path and filename, term **filename** sticks better with filename part without path which appeared after split. Anyway, it is not easy to give that second part better name than `filename`. Alternative of splitting `filename` to `path` and `filenameOnly` looks weird to me. I think it might be better to use clearly distinguishable term for filename with path than borrowing **filename** which already has stronger meaning for something else. I was thinking about term `absoluteFilePath` or `fullyQualifiedFilename` to stand as argument names. Maybe they are good and I need only some encouragement to start using them, but I would like to understand your best practices. **EDIT:** I would still like to stick with official VB.NET naming and capitalization conventions, so the only thing I need help sharpening is clear self-documenting wording of the term. (Not whether I should use Hungarian notation or not – I cannot.)


Java GNOME bindings, are those a good idea?

What do you think of Java's GNOME bindings and I was surprised to know that the latest version of the bindings was released this month and they're backed by a company that uses them, which means that there's a considerable amount of activity in the project, and that it's not going to be ditched anytime soon Is this going to be a second chance for Java on the desktop, since GTK+ is cross platform like swing, but less bloated and more responsive Should I be learning how to develop applications using it? or it's not worth the time?


Currently in Grad School, itching to get back in the mix

I was in the software industry for 3 years before going back and pursuing my masters. I have a year of grad school under my belt with a year left and a 4.0 GPA. I'm really itching to get back into do software dev full-time. I'm doing research and an area I'm interested in, Computer Graphics, but know that I probably won't work in industry using what I've learned. I think the main benefit to finishing my degree is to pad my resume and learn certain things that I wouldn't have learned other wise. Would it be dumb for me to quit grad school and get back into the work force? Is grad school a bad decision for passionate programmers( I consider myself one )?


How do you check bugs on your client's PC's?

It seems like there are a plethora of methods for dialing in and checking out what's going on on a client's PC. But they seem to boil down to just 2. Dialing in and checking it out with VNC and Remote Desktop. VNC seems abysmal with more graphics laden OS's and it sometimes is too much to ask to get a access to a terminal server (especially when the client doesn't have one). What other methods are out there for connecting with clients to diagnose and fix bugs they they can reproduce, but may not necessarily be able to adequately describe over the phone. Alternatives to VNC and Remote Desktop are appreciated, but really looking for a better way to do it than just to dial in and check it out - or the most effective way to use VNc and Remote Desktop.


Session state provider and atomic operations

I've been thinking about this and it is blowing my mind... How does a session state provider properly works internally? I mean, I tried to write a custom session state provider based on Azure Tables or Blobs, but quickly I realized that because there is no way to ensure an atomic operation or establish a lock, race conditions are suitable to happen when several web servers do operation on that shared information. I know that there is a SQL Server Session State Provider (SQLS-SSP) and people is happy with it, so I guess that it's using some kind of transaction isolation level in order to accomplish some degree of concurrent safety, like checking is the data is lock (a simple column), locking it if not and returning the data in an atomic operation, but is that so? what does happen if the data is lock? does it returns an error? block the call for a while? returns it in read-only fashion? Cloud computing paradigms could be somehow new, but webfarms have been here for a while, so as I'm pretty new on it... do you recommend any good lecture about the topic? Thanks.


DRY code, DRY tests?

At some point I had to create some class "Class1" and that class needs a method "method". So I have the following:               Class1MethodTest: A total of N tests that check the behavior of Class1.method     Class1 method: A full implementation of the method      But a bit later I need a different class "Class2" to have a completely similar method "method". Now I have several approaches: ## Approach 1               Class1MethodTest: A total of N tests     Class1 method: Full implementation     Class2MethodTest: Another set of identical tests     Class2 method: Another full implementation      Pros: Stupid simple Cons: not DRY At least that's the first attempt and I might even write this before doing any refactoring, right? ## Approach 2:               _hidden_private_implementation_function: Full implementation of required method     Class1MethodTest: A total of N tests     Class1 method: Call hidden_private_whatever     Class2MethodTest: Another set of identical tests     Class2 method: Also call hidden_private_stuff      Pros: DRY code, still stupid simple Cons: Tests aren't DRY, "Test interface, not implementation" ## Approach 3:               MethodTest: A total of N tests     TotallyPublicCommonMethod: Full implementation of required method     Class1MethodTest: Just one test to verify that Class1 method calls the Public one     Class1 method: Call public common method     Class2MethodTest: One more test     Class2 method: Also call common method      Pros: DRY, stupid simple Cons: .. any other than "You're testing implementation, not interface"? ## Approach 4: This is where it gets a bit exotic. Python allows me to DRY the "Approach 3" directly:               _hidden_private_implementation_function: Full implementation of required method     makeTestForClass(cls): return a total of N tests for class cls     Class1MethodTest = makeTestForClass(Class1)     Class1 method: Call hidden_private_whatever     Class2MethodTest = makeTestForClass(Class2)     Class2 method: Also call hidden_private_stuff      Pros: DRY, "Don't test implementation" Cons: Not that simple. Too hard to modify if I ever decide to change something in Class1.method, but not Class2.method I can think of a couple more approaches but those are not very different from these above. Right now I have some code looking something like "Approach 1" and I am thinking on which way I should go next to make it all cleaner and better.


What is the best way to deploy commercial programs on Linux?

Due to the diversity of Linux distributions, it is quite common for programs to be distributed in source format together with scripts in order to assist the configure, make, make install sequence. When it comes to commercial programs, however, distributing the source is usually simply not possible. So if anybody wants to sell a program and deploy it to a Linux environment, what should he do? How is this normally done?


How to plan for multi-platform application development

In my earlier days of programming, I was using Visual Basic for learning. It taught me many concepts, and I was able to make some cool programs (in my opinion, anyways...). I have expanded my horizon to basic C/C++, PHP, and MySQL. One of my most favourite projects, I want to turn into a multi-platfrom (for x86/x64) windowed application, and have it open source. I decided on the license already, but I want to know, before I start developing in a new language, how can I choose which language to use, that is multi-platform, and allows for windows to be created? I do not wish to use web technologies, as the application will work with lots of local files at a time. This is **not** a question about which technology is better, but about which one would be useful for this project. I know something has to be possible, because there are apps that run as Mac OSX binaries, Windows binaries, and even Linux binaries, all in windows (i.e. VLC Media Player, Firefox (Ice Wheazel), etc)


Text Classification Implementation

I've been trying to implement a text classification system. It needs to read a text file, and extract the words and the word frequency. So far, I've been planning to parse the words, put them in a dictionary and save it to an XML file. I am using C++/CLI. Is this a good implementation or is there a simpler or better implementation? May be related question (some code implementation): http://stackoverflow.com/questions/10631309/save-dictionary-to-xml-file


What to do when you're forced to code under bad coding (design) standards

This isn't about the typical naming conventions, where to place your comments, should we use regions, etc. This is about a coding standard that discusses specifics on how a programmer should design his applications. Stuff like: (on a .NET app and not in the exact wordings)   * Make as few classes possible   * Classes should do as much as their real world counterparts can   * Modification is better than extension   * One DLL per category (One library for email functions, one library for File related functions) Everyone's had their experience with bad code and possibly bad design, but what if you were placed in a team (leaving is not an option) where they had design standards that just don't feel right. I'm unsure how to respond professionally when I feel like I'm dying inside whenever I'm asked to code this way.


How much time should I dedicate to refactoring my code?

I don't know if it's just with me, but when I start refactoring some code I waste a lot time doing that and it never ends. Every time I read the code again, I find something that can be improved, code refactoring is like my brain into a infinite loop and the end conditional is reached randomly with no satisfaction. So, how much time should I dedicate to refactoring my code?


Is The Free Lunch Over?

In his famous The Free Lunch Is Over article from 2005, Herb Sutter predicted a Concurrent Programming Revolution as big as Object-Oriented Revolution. Has this revolution really happend in years 2005 - 2013? * * * Key points in the article:   * Processor manufacturers have run out of room with most of their traditional approaches to boosting CPU performance. Instead of driving clock speeds ever higher, they are instead turning to hyperthreading and multicore architectures.    * Applications will increasingly need to be concurrent if they want to fully exploit CPU throughput gains.   * “Oh, performance doesn’t matter so much, computers just keep getting faster” statement will be wrong.   * Efficiency and performance optimization will get more, not less, important. Those languages that already lend themselves to heavy optimization will find new life; those that don’t will need to find ways to compete and become more efficient and optimizable. Expect long-term increased demand for performance-oriented languages and systems.   * Programming languages and systems will increasingly be forced to deal well with concurrency. We desperately need a higher-level programming model for concurrency than languages offer today.


Is it reasonable to expect a new graduate to be able to roll his own blogging software?

When deciding whether to hire a new graduate, is it reasonable to expect them to have a software development portfolio, where they have produced at least something equivalent in complexity to a blog software?


How much mocking is "just right?"

I titled the question jokingly because I'm sure that "it depends," but I have some specific questions. Working in software that has many deep layers of dependency, my team has become accustomed using mocking fairly extensively to separate each code module from the dependencies beneath it. Therefore I was surprised that Roy Osherove suggested in this video that you should be using mocking only something like 5% of the time. I'd guess that we're sitting somewhere between 70-90%. I've seen other similar guidance from time to time as well. I should define what I consider to be two categories of "integration tests" which are so distinct that they really should be given different names: 1) In- process tests which integrate multiple code modules and 2) Out-of-process tests which talk to databases, file systems, web services, etc. It is type #1 that I am concerned with, tests which integrate multiple code modules all in- process. Much of the community guidance I have read suggests that you should prefer a large number of isolated, fine-grained unit tests and a small number of coarse-grained end-to-end integration tests, because unit tests give you precise feedback on exactly where regressions might have been created, but the coarse tests, which are cumbersome to set up, actually verify more end-to-end functionality of the system. Given this, it seems necessary to make rather frequent use of mocking to isolate these separate units of code. Given an object model as follows: ![enter image description here](http://i.stack.imgur.com/SIvbe.png) ... Also consider that our application's dependency depth goes much deeper than I could fit in this image, so that there are multiple layers N between the 2-4 layer and the 5-13 layer. If I want to test some simple logical decision being made in unit #1, and if every dependency is constructor-injected into the code module that depends on it such that, say, 2, 3, and 4 are constructor injected into module 1 in the image, I would much rather inject mocks of 2, 3, and 4 into 1. Otherwise, I would need to construct concrete instances of 2, 3, and 4. This can be more difficult than just some extra typing. Often 2, 3, and 4 will have constructor requirements which can be challenging to satisfy and according to the graph (and according to the reality of our project), I'll need to construct concrete instances of N through 13 to satisfy the constructors of 2, 3, and 4. This situation becomes more challenging when I need 2, 3, or 4 to behave in some certain way so that I can test the simple logical decision in #1. I might need to understand and "mentally reason about" the entire object graph/tree all at once to get 2, 3, or 4 to behave in the necessary way. It often seems much easier to do myMockOfModule2.Setup(x=> x.GoLeftOrRight()).Returns(new Right()); to test that module 1 responds as expected when module 2 tells it to go right. If I were to test concrete instances of 2 ... N ... 13 all together, the test setups would be very large and mostly duplicated. Test failures might not do a very good job of pinpointing the locations of regressions failures. Tests would not be independent (another supporting link). Granted, it is often reasonable to do state-based, rather than interaction- based, testing of the bottom layer, since those modules seldom have any further dependency. But it seems that mocking is almost necessary by definition to isolate any modules above the bottom-most. Given all of this, can anyone tell me what I might be missing? Is our team overusing mocks? Or is there perhaps some assumption in typical unit testing guidance that the layers of dependency in most applications will be shallow enough that it is indeed reasonable to test all of the code modules integrated together (making our case "special")? Or perhaps differently, is our team not bounding our bounded contexts adequately?


Is C++ not suitable for OOP?

I read somewhere in one of the answers to a question here (can't remember which) that C++ is not suitable for object-oriented programming. There was some mentioning that you could make use of its feature or something like that, but not in a purely OOP sense (I actually didn't really understand what the person meant). Is there some truth in this; if so, why?


PHP-based indexing and search implementation

Is there such thing? I designed a while back a rudimentary form based app for my users. We receive from our suppliers hardware manufacturing data in XML files: file name is made of eleven fields separated by tildes, with each field having its own meaning. R&D guys wanted to be able to search each field of the file names so I used regex() with decent results. Problem is that we have now in the upwards of 2.5 million files. And my app can't hack it anymore. I looked at Apache Lucene & Solr. Though it seemed like the best solution to my problem, the fields in the filenames are not peers to the file content. Big no-no with Solr. What is the best way to implement a PHP app with indexing and search capability with such large number of files? Do I have to buy Zend and use Zend_Search? Is it the only way? Thanks for your input.


Choosing the right version control system for .NET projects

I'm getting ready for my first "bigger" .NET project (ASP.NET MVC 3/4) on which I'm going to lead another 2 programmers and right now I'm choosing the right version control system for the job (plus I'm gonna use it for my future development too). My problem is that I did't use any version control system before, so I would like it to have as fast learning curve and intuitive merging as possible. So far I quickly looked at VisualSVN (I like the Visual Studio integration in it), but I'm reading everywhere how Git is awesome and dunno which one to choose (not limited to these two).. Maybe I'm ovethinking this but I like when everything goes smoothly:) I'd like to hear some opinions from people who used multiple version control systems (preferably on VS projects) **what do you think is the less complicated and effective version control system for such a use (one to 5 man projects)?**


2D linked list vs. multidimensional array/vector

I hope that programmers is the correct stack exchange for this, as it is quite a concept based question. I'm working on a data structure in C++ that is a represents data in 3D space. The x-y plane is large (say 0 - 10 000) while the z-axis has a very small range (0 - 10). All the data is located on integer (x,y,z) points. However there can be more than one than one data point on an (x,y,z) coordinate. I have thought of three ways of approaching this subject, and don't have the necessary experience to choose between them.   1. Using a 2D linked list inside vectors (dynamic arrays) `vector<vector<structureA*>> Data` where the first list item for that (x,y) point can be accessed using `Data[x][y]`. structureA contains an its z value, its actual data, as well as a pointer to the next structure in the list (that may, or may not have a different z coordinate, but is located on the same line defined by x and y). Accessing elements at the middle and end of this list is slow.   2. Using a three dimensional array/vector: `vector<vector<vector<structureB>>> Data`. In this case the first two vectors define the x and y coordinates (as before) and the third vector gives us an array of all of the elements on that line defined by x and y. We can quickly determine how many elements are on this line (by querying the third vector) and can iterate from the back and the front. `structureB` contains, the point's z value and its data. This seems like a fairly good and safe (regarding memory allocation) solution to me.   3. Using a three dimensional array/vector and a linked list. In this case the data could be accessed as such: `Data[x][y][z]` and would point to the first element of a linked list of data that resides at this coordinate. The structure pointed to would not contain its z value here as this is already dealt with in its address in the array. However, many (x,y,z) points have no data, whereas most of those that do have data have 10+ data structures. (All lines defined by a specific (x,y) contain at least one structure). This seems the worst solution to me as in many cases I would have to iterate through empty z coordinates, before hitting a linked list to iterate through. The emphasis in this program is speed, my data set is less than 100MB on a modern computer, so even an inefficient method of storing it in RAM is fine. Option 2 seems the best to me, although in the past I've normally seen people more inclined to go with option 1. I'm interested to hear your opinions on the best way to handle this along with your reasoning. Many Thanks. **Update** Thanks for the responses, I stand to learn quite a lot from your comments as I am a hobby programmer, having taken only one short course on the fundamentals of C a few years back. @MorphingDragon The array is not jagged, all z "slices" have the same range of x and y. The values also don't seem sparse enough for a hash table (which IIRC slow down significantly on hash collision - which is guaranteed as multiple elements have the same (x,y,z)). The dimensions of the set are known on file load (they are included in the file header along with an md5 hash of the file for error checking and a few bit relevant to the analysis). @J Trana / Florian F The data set is pre-built and is infrequently modified by the program - a piece of data may need to be moved or deleted. For adjusting data particularly just adjusting its z-value (or removing it), which are the most frequent operations. The linked list will be faster as these operations are O(1) as opposed to O(n) in a vector. However, I believe these changes are infrequent enough that having O(n) for changes may be worthwhile if the lookup speed is even marginally faster (as this is the more frequent operation). The majority of the time the data will be accessed iteratively, taking an n*p slice from the x-y plane. Pseudocode example:               for each y between startY and (startY + p)       for each x between startX and (startX + n)         read all nodes in Data[x][y] //gets nodes for each z on an (x,y) line         analyse(&nodes) //possibly modify the nodes, possibly just compute something based on their values      Data access is **always** related to the (x,y) line an element is on, but we don't always need all the nodes on that line (dependant on their z). So we either have a structure that doesn't require us to retrieve all of them (just the ones we want) or we perform a secondary sort. The data on file represents a sorted list in ascending z for each (x,y). I will also look into those other data structures. I've never met them, as with very little training, my method is to use STL vectors or lists for everything. I'd like to spend the time to do this properly this time though. I spent a fair amount of time thinking about this last night after posting the question and seeing the first responses. I realised that "if one piece of data from a point (x,y,z) is required, then all elements from that point are required at the same time." This has led me to think that option 3, my least preferred when I started this yesterday afternoon, is actually the best of the options I've enumerated. If I use a three-dimensional dynamic array of pointers to linked list, I don't exactly lose much speed or heap space setting a pointer to NULL rather than attaching a struct. This also allows full access to any 3d, which while not currently _required_ may reduce some operations from O(n) to O(1). Having had a brief look over octaves/r-trees, I feel safe saying that my data set is not complex enough to require such an engineering heavy solution. When it comes down to it, i am fairly sure that any of the three options I outlined would work, even if not the fastest, but I would like to learn a good and relatively efficient method, rather than just relying on the awesome power of modern computers to brute force a problem like I normally do. Thanks for the replies and suggestions so far. :)


A scheme to check only one namespace in an XML document

I want to validate an XML document against some XML scheme, but ignore all elements (and probably attributes) which are not of a given namespace. Does such a XML scheme language exist?


Help with Abstract Factory Pattern

I need help with a abstract factory pattern design. This question is a continuation of: Design help with parallel process I am really confused where I should be initializing all of the settings for each type of medium (ex: RS232, TCP/IP, etc). Attached is the drawing on how I am setting up the pattern: ![enter image description here](http://i.stack.imgur.com/mDfjH.png) As shown, when a medium is created, each medium imposes a **ICreateMedium** interface. I would assume that the Create() method also create the proper object, such as SerialPort serialPort = new SerialPort("COM1", baud); however, TCPIPMedium would have an issue with the interface because it wouldn't need to initialize a serial port object. I know I am doing something majorly wrong here. I just can't figure it out and have been stuck for a while. What I also get confused on show the interface **IMedium** will get access to the communication object once it is created so it can write out the appropriate byte[] packet. Any guidance would be greatly appreciated. My main goal is to have the **Communicator** class spit a packet out without caring which type of medium is active.


Which approach would be better for persisting these overridable configuration keys and values? A simple key-value store, or a graph database?

I'm creating a system where there are config keys and values. So for example:               config.key = 10      Is an example of a configuration key and a value. These keys can also have overrides based on "dimensions". So for example, if we wanted to apply `config.key` to applications with the dimension `foo`, the overridden key would essentially be:               config.key.foo = 20      In future we may have multiple dimensions in arbitrary order, so this could be a possibility in future:               config.key.foo.bar = 30      A more concrete example would be if we had a key/toggle called `display.pintrest.feed` that has a `boolean` value. So the default value would be `false`, but you could have overrides like so:               display.pintrest.feed = false     display.pintrest.feed.femaleUser = true      Here `femaleUser` is a dimension (so we want to set the value of this config to `true` for only female users). This is essentially what I am trying to do. My question is regarding persistence. What would be the best way to persist this kind of data? This is data that will be queried somewhat frequently but written to less often. The naive solution would be to use MySQL or PostgreSQL and create a table like this:               +----------------------------------+-------+     |                Key               | Value |     +----------------------------------+-------+     | config.key                       | 10    |     | config.key.foo                   | 20    |     | display.pintrest.feed            | true  |     | display.pintrest.feed.femaleUser | false |     +----------------------------------+-------+      But we lose the type safety of `Value` and also have a single point of failure. We also have a lot of redundancy (the base part of the configuration key is repeated each time). So I wondered about perhaps representing it as a graph so that I could write it to a graph database. I was thinking of modeling it like so: ![enter image description here](http://i.stack.imgur.com/X8Evj.png) Is this viable or overkill? I don't mind using a simple key-value store either but it should be fault- tolerant and should be able to be clustered. Also we only really care about eventual consistency (i.e., don't mind it taking time to propagate changes to all the nodes). So my question is what kind of data store should back this kind of data? Is a simple key-value store enough or should I go for a graph database? My rationale for the latter is simply to mitigate the redundancy from keys but I don't know if that's strong rationale.


Is my sequence diagram correct?

NOTE: I am self studying UML so I have nobody to verify my diagrams and hence I am posting here, so please bear with me. This is the problem I got from some PDF available on Google that simply had the following problem statement: **Problem Statement** : A library contains books and journals. The task is to develop a computer system for borrowing books. In order to borrow a book the borrower must be a member of the library. There is a limit on the number of books that can be borrowed by each member of the library. The library may have several copies of a given book. It is possible to reserve a book. Some books are for short term loans only. Other books may be borrowed for 3 weeks. Users can extend the loans. Draw a use case diagram for a library.      I already drew the Use Case diagram and had it checked by a community member. This time I drew **sequence diagrams** for borrowing a book and extending the date of return.   Please let me know if they are correct.   I drew them using _Visual Paradigm_ and I dont know how to keep a control of the sequence numbers. If you do, please let me know :)      **Diagrams** ![Borrowing](http://i.stack.imgur.com/WebPr.png)    ![Extending the date](http://i.stack.imgur.com/6YWMt.png)


Wpf: Event driven vs MVVM design pattern

I'm a beginning coder and I've been working on a WPF app for several months now and struggled to implement anything in MVVM due to time constraits to learn so I coded my program the only way to knew how: with code behind, tight coupling, and a whole bunch of spaghetti code. My program has grown into 20,000+ lines of messy (but working) code that is mostly event driven. The app I am building will probably be used and continue to be developed for years to come, but I will be the only one working on the code. However, now that I have time to start learning MVVM, I'm wondering how useful it really is to follow the MVVM pattern. I'm considering refactoring my code into the MVVM pattern but everything seems 100x difficult to do with little documentation. With using code behind and tight coupling, I can make the UI do exactly what I want it to do and everything seems like it can be coded so much faster through the event-driven methods. How important is it to follow the MVVM design pattern for WPF apps, especially in the long run? Do you think it's a good idea for me to invest my time to redesigning this app and following an MVVM pattern?


Learning new thing and implementing new thing in a company

In my new company, I wanted to use Doctrine DBAL for data abstraction. But it's not working due to the PHP Version 5.2 we are using on our development server. Here it's all about rights issues. You don't have access to anything. I can't use anything new due to this rigidity of the product! What can I do about this? How should I talk to my TL and project manager about this?


Creating a new database with Active Record

Please tell me if this is mad, but basically, I've created a custom rake task, and before it does its thing, it gives the user a warning message:               Warning, please back up your database before continuing      Just in case something does go wrong. But I thought this would be awesome:               Warning, please back up your database before continuing. Do you wish to create it now [Y/N]      and upon pressing Y, the existing database would be replicated. I don't want to create to duplicate the tables, I literally want to create a new, pristine, isolated database so that their architecture is identical, just in-case something does go wrong. I don't want any dependencies though, I only want to use libraries included with Rails. Could I have a simple example of how to create an empty database with RoR, if this is possible? I can create a new database like this:                 require 'sqlite3'            db = SQLite3::Database.new( "test.db" )      However, this will only work if the user is using sqlite3. I can detect which database they're using with               database_type = ActiveRecord::Base.connection.adapter_name #=> sqlite3      and then use a case statement to execute slightly different commands for each database type, but that seems a bit elaborate, and not very dynamic. (Every single database will have to be thought up before-hand). So can I do it through Active Record?


Why is (f . l) not allowed and equal to (apply f l)?

In scheme when defined               (define f (lambda (a b c d) d))          (define l (list 'a 'b 'c 'd))      Why it does not do argument destructuring? I mean arguments should evaluate first, why destructuring is not part of that?               (f . l)      What are reasons that this expression is not equal with following?               (apply f l)        * Edited to make it clearer, according suggestions in comments


How do you organize highly customized software?

I'm working on a large software project which is highly customized for various customers arround the world. This means that we have maybe 80% code which is common between the various customers, but also a lot of code which has to change from one customer to the other. In the past we did our development in separate repositories (SVN) and when a new project started (we have few, but large customers) created another repository based on whatever past project has the best code basis for our needs. This has worked in the past, but we ran into several problems:   * **Bugs** which are fixed in one repository are not patched in other repositories. This might be a problem of organization, but I find it difficult to fix and patch a bug in 5 different repositories, keeping in mind that the team maintaining this repository might be in another part of the world and we don't have their test environment, neither know their schedule or what requirements they have (a "bug" in one country might be a "feature" in another).   * **Features** and improvements made for one project, which might also be useful for another project are lost or if they are used in another project often cause big headaches merging them from one code base to another (since both branches might have been developed independently for a year).   * **Refactorings and code improvements** made in one development branch are either lost or cause more harm than good if you have to merge all these changes between the branches. We are now discussing how to solve these problems and so far came up with the following ideas on how to solve this:   1. **Keep development in separate branches** but organizing better by having a central repository where general bug fixes are merged into and having all projects merge changes from this central repository into their own on a regular (e.g. daily) basis. This requires huge discipline and a lot of effort for merging between the branches. So I'm not convinced that it will work and we can keep this discipline, especially when time pressure puts in.   2. **Abandon the separate development branches** and have a central code repository where all our code lives and do our customization by having pluggable modules and configuration options. We are already using Dependency Injection containers to resolve dependencies in our code and we are following the MVVM pattern in most of our code to cleanly separate business logic from our UI. The second approach seems to be more elegant, but we have many unsolved problems in this approach. For example: how do handle changes/additions in your model/database. We are using .NET with Entity Framework to have strongly typed entities. I don't see how we can handle properties which are required for one customer but useless for another customer without cluttering our data model. We are thinking of solving this in the database by using satellite tables (having a separate tables where our extra columns for a specifiy entity live with a 1:1 mapping to the original entity), but this is only the database. How do you handle this in code? Our data model lives in a central library which we would not be able to extend for each customer using this approach. I'm sure that we are not the only team struggling with this problem and I'm shocked to find so little material on the topic. **So my questions are the following:**   1. What experience do you have with highly customized software, what approach did you choose and how did it work for you?   2. What approach do you recommend and why? Is there a better approach?   3. Are there any good books or articles on the topic that you can recommend?   4. Do you have specific recommendations for our technical environment (.NET, Entity Framework, WPF, DI)? **Edit:** Thanks for all the suggestions. Most of the ideas match those that we already had in our team, but it is really helpful to see the experience you had with them and tips to better implement them. I'm still not sure which way we will go and I'm not making the decision (alone), but I will pass this along in my team and I'm sure it will be helpful. At the moment the tenor seems to be a single repository using various customer specific modules. I'm not sure our architecture is up to this or how much we have to invest to make it fit, so some things might live in separate repositories for a while, but I think it's the only longterm solution that will work. So, thanks again for all responses!


What is spreadsheet useful for?

I have been in computer business for 15 years in various roles (sysadmin, developer, researcher), and I have never encountered someone using excel for something more advanced than for formatting tables, or as an ad-hoc database that could have been maintained in a text-file. I had to do heavy data-processing and plotting and for that I used some perl scripts + gnuplot, got tiredof it, and went over to R eventually. 2D spreadsheet just didn't seem well-suited for doing statistical analyses over 5-dimensional datasets (not to mention that it produces _UGLY_ plots). I attempted to use spreadsheet for time-tracking, and found out that I would have better been served by a relational database, so I gave up on using excel for that too. For example, it's important to consistently name tasks, and I needed to find out unique task names in a given column across several sheets (I had one timesheet for each month). How do you make such "query" in a program that essentially evaluates independent cells and has little notion of relations between them? So, what _are_ spreadsheets useful for? Why do they have a bunch of mathematical stuff built into them when, AFAICT, people use them mostly as table formatters or bad substitutes for databases?


How do I know if I have a good programming professor?

Today I begun my second programming course. The professor seemed a bit different from the others - we had some fun saying things like _"he's probably a misunderstood genius"_. He criticized some other (long gone) professors (with good reasons). Then it struck me to ask him _"how do I know if **you** are a good professor?"_ ... but I decided to save it for later... Now, however, such question has developed a lot in my mind. I'm very curious - **how do I know if my programming professor is good**? Some observations:   * Apparently, very few students do finish the course with him with aceptable scores - but it is possible it is the students' fault, not his.   * From our brief first class, I understood very well whatever he said (he talked a bit about everything). But I feel it might be because I was already prepared and had good experience programming before, and not necessarily the fact that he's good at expressing his ideas.   * He has a tendency to make jokes. Like most professors I've met. Unfortunately, he is the least funny.


Senior software developer

I'm not sure if this is the place of my question or not. I'm working in a software company as senior software engineer, but my team leader is controlling everything in the development life cycle. I can't give my opinion on anything. I'm just forced to tasks only without any discussion. I can't even apply any design patterns or UI guidelines. Is that OK in my career position now? What is the responsibilities of senior engineer?