How are atomic operations are a dynamic language feature?

I was told that atomic operations are a dynamic language feature. I was too afraid to ask in that context what this actually means because I didn't want my coworkers to think I'm stupid. But I actually don't really understand this statement. My understanding of the term "atomic operations" is any operation that is either wholly executed or wholly not executed; you will definitely never be halfway through the operation when the thread context switches. What does this have to do with dynamic vs static typing?


Difference between an architecture and a framework

A terminology question appeared when I was comparing EJB 3 and Spring. Wikipedia says that > Enterprise JavaBeans (EJB) is a managed, server-side component architecture > for modular construction of enterprise applications. and also > The Spring Framework is an open source application framework and inversion > of control container for the Java platform. "EJB 3 in Action" suggests that > Together, the components, or EJBs, and the container can be viewed as a > framework that provides valuable services for enterprise application > development. Is any framework an architecture? If not, what is the difference between these terms? Could EJB be considered a framework?


Should OAuth token be shared to implement SSO?

What's a commonly accepted way of implementing SSO using a third party OAuth provider? I have a server with user resources associated with server's user ID, the user ID also has a Facebook user ID associated. Would it be a good approach to authenticate a client to the server if the login was redirected to, say, Facebook where it would return an OAuth token and the token is then shared with the client? Suppose SSL is implemented, the OAuth token would then act in the same way as a session cookie that gives permission to user resources on the server. The same user an different client can then reauthenticate with Facebook which would return the same Facebook ID, which gives access to the same user's resources and a different OAuth token which expires independently and removing the app on Facebook can callback the server with a deauthenticate request to keep things synchronised. Is this a good policy to use? Is it safe against attacks like session sidejacking, cross site reference etc?


What do you absolutely have to know about a candidate before hiring him?

What **essential questions** do you have to know the answer for, about a prospective software development candidate, before hiring him/her? I'm not seeking specific interview problems (e.g. sort this 3D array of numbers in O(1) complexity), but simply for things you need to find about, for yourself, about a new hire. (e.g. which source control systems / languages / frameworks / OS has he used?) Cross-posted to Quora


Memory read/write access efficiency

I've heard conflicting information from different sources, and I'm not really sure which one to believe. As such, I'll post what I understand and ask for corrections. Let's say I want to use a 2D matrix. There are three ways that I can do this (at least that I know of). **1** :               int i;     char **matrix;     matrix = malloc(50 * sizeof(char *));     for(i = 0; i < 50; i++)         matrix[i] = malloc(50);      **2** :               int i;     int rowSize = 50;     int pointerSize = 50 * sizeof(char *);     int dataSize = 50 * 50;     char **matrix;     matrix = malloc(dataSize + pointerSize);     char *pData = matrix + pointerSize - rowSize;     for(i = 0; i < 50; i++) {         pData += rowSize;         matrix[i] = pData;     }      **3** :               //instead of accessing matrix[i][j] here, we would access matrix[i * 50 + j]     char *matrix = malloc(50 * 50);       In terms of memory usage, my understanding is that **3** is the most efficient, **2** is next, and **1** is least efficient, for the reasons below: **3** : There is only one pointer and one allocation, and therefore, minimal overhead. **2** : Once again, there is only one allocation, but there are now 51 pointers. This means there is `50 * sizeof(char *)` more overhead. **1** : There are 51 allocations and 51 pointers, causing the most overhead of all options. In terms of performance, once again my understanding is that **3** is the most efficient, **2** is next, and **1** is least efficient. Reasons being: **3** : Only one memory access is needed. We will have to do a multiplication and an addition as opposed to two additions (as in the case of a pointer to a pointer), but memory access is slow enough that this doesn't matter. **2** : We need two memory accesses; once to get a `char *`, and then to the appropriate `char`. Only two additions are performed here (once to get to the correct `char *` pointer from the original memory location, and once to get to the correct `char` variable from wherever the `char *` points to), so multiplication (which is slower than addition) is not required. However, on modern CPUs, multiplication is faster than memory access, so this point is moot. **1** : Same issues as **2** , but now the memory isn't contiguous. This causes cache misses and extra page table lookups, making it the least efficient of the lot. First and foremost: Is this correct? Second: Is there an option **4** that I am missing that would be even more efficient?


When to use (Or not) C# myVariable { set; get; }

I have been trying to wrap my head around the finer points of this today. Essentially I have fallen in love with this format for booleans:               Class {     public static bool myBool {set; get;}         private static void Method()         {             if (!myBool)              {                 myBool = !myBool;                 // stuff that needs to be done              }         }     }      Obvious things like do not use a public when a private will work and scoping properly applies. But when is this a best practice vs using a simpler:               Class {     bool myBool = true;         private static void Method()         {             if (!myBool)              {                 myBool = !myBool;                 // stuff that needs to be done              }         }     }      Or do I have this backwards completely? I understand that by using the format `public static bool myBool {set; get;}` I doing the following:               public static bool myBool     {        get        {            return myBool;           }        set        {            myBool = valuePassedIn;        }     }      I feel like the first method is the best approach, but I have no idea why I think this. Is there a best from these choices? Am I doing something horribly wrong, or all three methods equivalent?


Is Haskell's type system an obstacle to understanding functional programming?

I'm studying Haskell for the purpose of understanding functional programming, with the expectation that I'll apply the insight that I gain in other languages (Groovy, Python, JavaScript mainly.) I choose Haskell because I had the impression that it is very purely functional, and wouldn't allow for any reliance on state. I did not choose to learn Haskell because I was interested in navigating an extremely rigid type system. My question is this: Is a strong type system a necessary by-product of an extremely pure functional language, or is this an unrelated design choice particular to Haskell? If it is the latter, I'm curious what would be the most purely functional language that is dynamically typed. I'm not particularly opposed to strong typing, it has its place, but I'm having a hard time seeing how it benefits me in this educational endeavor.


Data structure for grid with negative indeces

Sorry if this is an insultingly obvious concept, but it's something I haven't done before and I've been unable to find any material discussing the best way to approach it. I'm wondering what's the best data structure for holding a 2D grid of unknown size. The grid has integer coordinates (x,y), and will have negative indices in both directions. So, what is the best way to hold this grid? I'm programming in c# currently, so I can't have negative array indices. My initial thought was to have class with 4 separate arrays for (+x,+y),(+x,-y),(-x,+y), and (-x,-y). This seems to be a valid way to implement the grid, but it does seem like I'm over- engineering the solution, and array resizing will be a headache. Another idea was to keep track of the center-point of the array and set that as the topological (0,0), however I would have the issue of having to do a shift to every element of the grid when repeatedly adding to the top-left of the grid, which would be similar to grid resizing though in all likelihood more frequent. Thoughts?


API Caching Layer

**Primer:** We have a mobile app being served by an API (written in PHP). The main point of the app is to display products from a large items table in the database, in a multitude of different configurations. Categories, suggested items, user compiled feeds, "similar to" feeds. Basically most, if not all of the display data comes from a single table, however the filtering and sorting is really what the app does. Some feeds are fairly simple such as "get all items that are in one of these categories using an items to category link table". Others are more complex using fulltext search to filter, along with category filters and stock filters and sometimes we may even require that the results have an additional filter such as "exclude items from any category that doesn't have 10 matching items in that category" (sort of like a self regulating, category filter invalidation). * * * We are now in the process of trying to speed up the API and looking to start putting the tech in, to allow us to scale. We've already decided on certain things like seperated search engines (i.e. elasticsearch for fulltext replacement e.c.t.). However one thing which i'm a little "new" in, is caching the API feeds. My only caching experience has been either caching full webpage outputs in things like magento/wordpress. Or caching complex objects that are built from several queries and processes. I've decided, object caching probably isn't suitable here, as most of the final object data comes from a single table. So object caching would not provide much speed improvement. I'm currently figuring i need to cache the final output collection of objects, as its really the complex filtering and sorting which slows everything down. But that's where i get stuck... First of all, should we cache the entire collection of objects, or just store a collection of the object id's, and still go to the database to do the final data lookup (my theory being, that with all the different compilation of feeds, the memory usage would grow quite quickly caching all the objects themselves). Secondly, do we cache the very final output of the feed, or do we try and find a common point at which we can create a cached copy of the feed that isnt quite right. So for example, rather than caching "similar products to X where the similar products are in 1,2,3 categories", we would instead cache "similar products to X", then on each request, get the collection from cache, and do the additional filtering manually after retrieving the "base collection". Hopefully that all makes some sort of sense,a nd apologies if its a little rambly. I'm a little out of my depth with this one, but im keen to learn. No doubt whatever solution i decide to implement first, will need many, many iterations before we deem it "correct". But at the moment, i just don't have any experience in this, to give myself a suitable, appropriate starting point, to start development.


xml based programming languages

I was looking at wikipedia - Category:XML-based programming languages. Why would someone take this approach for designing a language?   What are the advantages of it? I can only think of disadvantages.   * hard to maintain   * hard to read   * hard to write


.NET MVC project architecture / layering

When planning the architecture for a mid-large scale MVC web application how do you implement the layers to be as decoupled as possible and easy to test? (basically follow best practices) Let's say I'm using code first as my data access. I struggle with what to define "business logic" as, and how it is meant to interact with the data layer. Taking a vehicle sales application as an example, would business logic be classes that performed tasks such as calculating the tax band for given vehicles, comparing mile per gallon statistics etc? As for the business entities (e.g. Cars, Vans, Motorcycles) I would put these in the data layer along with my datacontext class. Also what would constitute application logic as opposed to business - I'm guessing things like session / user input validations? So for example, a car controller might return an action/view result that lists the top ten cars filtered by type and best mpg. So let's say I have an ICarRepository 'carRepo' injected into my controller(using the repository pattern / DI), I filter my cars from an action method parameter e.g. var cars = carRepo.getCarsByType("hatchback"); So I've kept the data access knowledge out of my controller using a repository, now to keep the business logic out of the controller using a domain model - var result = new MpgCalculator(cars); - Let's say I need the calculator class because it needs to perform additional logic to calculate the best fuel efficiency, more than just loading / filtering entities from the DB. So now I have a data set for my view to render that used a repository to retrieve from the data access layer, and domain specific object to process and perform business related tasks on that data. Am I making mistakes here? do we still need to use the repository pattern or can I just code against an interface to decouple the ORM and test? On this topic, as my concrete data access classe(s) dbcontext are in the data layer, should the interface definitions go into the domain/business layer meaning that if the data access technology is ever changed, my other layers aren't effected? From what I have studied thus far my structure looks like this: MVC Internet Application - The standard internet project - models in here are ViewModels Domain/Business layer - business specific classes/models that controllers can use to process domain entities from the data layer before passing on to the relevant views Repository abstraction necessary? - I hear lots of debate on this, especially when using an ORM Data layer - Entity classes (Car, Van, Motorcycle), DbContext - Concrete data access technology layer Apologies if my examples do not make sense, I'm trying to learn the best patterns without making applications unnecessarily complicated!


Clean way to use mutable implementation of Immutable interfaces for encapsulation

My code is working on some compost relationship which creates a tree structure, class A has many children of type B, which has many children of type C etc. The lowest level class, call it bar, also points to a connected bar class. This effectively makes nearly every object in my domain inter- connected. Immutable objects would be problematic due to the expense of rebuilding almost all of my domain to make a single change to one class. I chose to go with an interface approach. Every object has an Immutable interface which only publishes the getter methods. I have controller objects which constructs the domain objects and thus has reference to the full objects, thus capable of calling the setter methods; but only ever publishes the immutable interface. Any change requested will go through the controller. So something like this:               public interface ImmutableFoo{              public Bar getBar();         public Location getLocation();     }          public class Foo implements ImmutableFoo{              private Bar bar;         private Location location;              @Override         public Bar getBar(){             return Bar;         }              public void setBar(Bar bar){             this.bar=bar;         }              @Override         public Location getLocation(){             return Location;         }      }           public class Controller{          Private Map<Location, Foo> fooMap;               public ImmutableFoo addBar(Bar bar){              Foo foo=fooMap.get(bar.getLocation());                   if(foo!=null)                  foo.addBar(bar);                   return foo;          }     }      I felt the basic approach seems sensible, however, when I speak to others they always seem to have trouble envisioning what I'm describing, which leaves me concerned that I may have a larger design issue then I'm aware of. Is it problematic to have domain objects so tightly coupled, or to use the quasi- mutable approach to modifying them? Assuming that the design approach itself isn't inherently flawed the particular discussion which left me wondering about my approach had to do with the presence of business logic in the domain objects. Currently I have my setter methods in the mutable objects do error checking and all other logic required to verify and make a change to the object. It was suggested that this should be pulled out into a service class, which applies all the business logic, to simplify my domain objects. I understand the advantage in mocking/testing and general separation of logic into two classes. However, with a service method/object It seems I loose some of the advantage of polymorphism, I can't override a base class to add in new error checking or business logic. It seems, if my polymorphic classes were complicated enough, I would end up with a service method that has to check a dozen flags to decide what error checking and business logic applies. So, for example, if I wanted to have a childFoo which also had a size field which should be compared to bar before adding par my current approach would look something like this.                public class Foo implements ImmutableFoo{               public void addBar(Bar bar){              if(!getLocation().equals(bar.getLocation())                 throw new LocationException();                   this.bar=bar;          }      }           public interface ImmutableChildFoo extends ImmutableFoo{          public int getSize();      }           public ChildFoo extends Foo implements ImmutableChildFoo{                private int size;                @Override           public int getSize(){               return size;           }                @Override           public void addBar(Bar bar){               if(getSize()<bar.getSize()){                   throw new LocationException();                    super.addBar(bar);           }      My colleague was suggesting instead having a service object that looks something like this (over simplified, the 'service' object would likely be more complex).                public interface ImmutableFoo{          ///original interface, presumably used in other methods          public Location getLocation();          public boolean isChildFoo();      }      public interface ImmutableSizedFoo implements ImmutableFoo{          public int getSize();      }          public class Foo implements ImmutableSizedFoo{          public Bar bar;               @Override          public void addBar(Bar bar){              this.bar=bar;          }               @Override          public int getSize(){              //default size if no size is known              return 0;          }                @Override           public boolean isChildFoo              return false;           }      }           public ChildFoo extends Foo{                private int size;                @Override           public int getSize(){               return size;           }                @Override           public boolean isChildFoo();              return true;           }      }           public class Controller{          Private Map<Location, Foo> fooMap;               public ImmutableSizedFoo addBar(Bar bar){              Foo foo=fooMap.get(bar.getLocation());              service.addBarToFoo(foo, bar);                   returned foo;          }               public class Service{                   public static void addBarToFoo(Foo foo, Bar bar){                      if(foo==null)                    return;                 if(!foo.getLocation().equals(bar.getLocation()))                     throw new LocationException();                 if(foo.isChildFoo() && foo.getSize()<bar.getSize())                     throw new LocationException();                      foo.setBar(bar);              }        }     }      Is the recommended approach of using services and inversion of control inherently superior, or superior in certain cases, to overriding methods directly? If so is there a good way to go with the service approach while not loosing the power of polymorphism to override some of the behavior?


Want to use a lib for my project, confused with license (AGPL vs MIT License)

Im working on a Java Software and there is a need to use some extern libraries. I found two relevant libs. The one is on an AGPL and the other on the MIT License. Now Im asking my self, can I use these libs if:   * I would make a non-opensource-nonfree-software or   * I would make a non-opensource-free-software I dont really understand the whole license stuff, could somebody tell me which one of the libs for what kind of software would be better? Thank you


Events where junior-level developer/CS student can prove himself?

I spotted a "Google Summer of Code" announcement recently, and though eager to join, I see my chances are plainly poor. I'm short on time to shape my ideas and study the source code. I just wonder - Are there any similar events that provide an opportunity for students to develop real working projects? Especially ones that are worth mentioning in one's CV?


Introducing Programming To a Mathematician

I currently am a programmer, I'm almost 16 years of age and have pretty much narrowed my careers down to something involving a Computer Science degree or Electrical Engineering degree (I know they are quite different but this question is about my friend) but my friend isn't so sure. He is very interested in maths and is very good at it and I think he would enjoy programming but he isn't willing to try it ( **edit** he _is_ willing to try but has never done before). Can anyone give me an suggestions for a language or tool that he could dabble in programming (at a reasonably basic level I assume) to solve maths problems or involve some kind of maths. As I say he enjoys maths a lot but I think he would enjoy programming, the problem is I don't want him to be put off by the stuff that isn't relevant at introductory levels such as memory allocation et al. I know that is very important but the point is that I want him to learn a bit of programming with maths then hopefully if he is interested enough he can start learning programming as programming. **Edit:** Its not that he's completely uninterested - more that he hasn't actively explored the area before, maybe because he isn't informed about it. I wouldn't want to force him to do something he doesn't want to, I see this as more of a little push so that he can learn about programming. If he doesn't like it - fair enough, I can't control that and don't want to but if he turns out to enjoy it - this push will have been the right thing.


How do I handle 3rd party search result data (via cache)

I have a search function on my site and it is taking data from 6 different 3rd party resources. The problem is, it takes too long requesting the data over and over again on the results page. I've read for questions like this on SO about session not being a good choice but for me **'memcache'** is not an option, because the server doesn't have memcached installed and I have no way to install it now. Is there any other approach to do this? Storing in the database seem inappropriate because the data depends on the search terms requested. What I've been thinking is writing a file on the server that would act as a cache for this file but I don't know how I would know when to delete it after.


Servicing background tasks on a large site

We're dealing with an interesting problem on StackOverflow. We've got a whole bunch of little "needs to be done soon-ish" tasks. An example is updating "Related Questions" lists. What we've done in the past is to piggy-back those tasks onto some users' page loads. This was never ideal, but it wasn't really noticeable. Now that SO has passed the 1,000,000 question mark, those unlucky users are starting to feel it. The natural solution is to actually push these tasks into the background. There are two broad ways of doing this I'm considering. ### 1. In IIS as a custom Thread-Pool/Work-Queue Basically, we spin up a few (non-ThreadPool, so as to not interfere with IIS) threads and have them services some collections we're shoving Funcs into. The big pro here is simplicity. We don't have to worry about marshaling anything, nor do we have to make sure some external service is up and responding. We also get access to all of our common code. The con is, well, that we shouldn't use background threads. The objections I know of are all centered around starving IIS (if you use ThreadPool) and the threads dieing randomly (due to AppPool recycling). We've got existing infrastructure to make the random thread death a non-issue (its possible to detect a task has been abandoned, basically), and limiting the number of threads (and using non-ThreadPool threads) isn't difficult either. ~~Am I missing any other objections to in IIS process thread-pooling/work- queues?~~ Moved to StackOverflow, as it wasn't really addressed here. ### 2. As a Service Either some third-party solution, or a custom one. Basically, we'd marshal a task across the process boundary to some service and just forget about it. Presumably we're linking some code in, or restricted to raw SQL + a connection string. The pro is that its the "right way" to do this. The cons are that we're either very restricted in what we can do, or we're going to have to work out some system for keeping this service in sync with our code base. We'll also need to hook all of our monitoring and error logging up somehow, which we get for free with the "In IIS" option. **Are there any other benefits or problems with the service approach?** In a nutshell, are there unforseen and insurmountable problems that make approach #1 unworkable and if so are there any good third-party services we should look into for approach #2?


Is linq more efficient than it appears on the surface?

If I write something like this:               var things = mythings         .Where(x => x.IsSomeValue)         .Where(y => y.IsSomeOtherValue)      Is this the same as:               var results1 = new List<Thing>();     foreach(var t in mythings)         if(t.IsSomeValue)             results1.Add(t);          var results2 = new List<Thing>();     foreach(var t in results1)         if(t.IsSomeOtherValue)             results2.Add(t);      Or is there some magic under the covers that works more like this:               var results = new List<Thing>();     foreach(var t in mythings)         if(t.IsSomeValue && t.IsSomeOtherValue)             results.Add(t);      Or is it something completely different altogether?


How to get different resources in a single endpoint in RESTful?

I have a REST webservice that have a couple of resources, like Company and User. But now I need to make a modification to the API to return a special list combining company, user and maybe other type of resource. Like a list of recommendations with various type of resources. Which is the best approach to solve this? I need to make a new endpoint (resource), something like: `/recommendations`? I already have the `/company` endpoint, and the `/user` endpoint returning the corresponding objects. This is fine. But now I need some way to return an array with a combination of users and companies. Also I'm thinking that the json will look like an array of objects, but how the client can know which type of object is parsing if every object in the array is a different resource? **EDIT** I want that my client could show a recomendations screen in the app. The problem is that this list can combine multiple types of data (users, companies). It doesn't matter if this resources have a relationship or not. The client shoud recive a json like that:               "recomendations": [         {             "id_user": 1             "name": "Jean"             ...         },         {             "id_company": 2             "name": "Starbucks"             ...         },         ...     ]


Messaging technologies between applications ?

Recently, I had to create a program to send messages between two winforms executable. I used a tool with simple built-in functionalities to prevent having to figure out all the ins and outs of this vast quantity of protocols that exist. But now, I'm ready to learn more about the internals difference between each of theses protocols. I googled a couple of them but it would be greatly appreciate to have a good reference book that gives me a clean idea of how each protocol works and what are the pros and cons in a couple of context. Here is a list of nice protocols that I found:   * Shared memory    * TCP    * List item   * Named Pipe    * File Mapping    * Mailslots    * MSMQ (Microsoft Queue Solution)    * WCF I know that all of these protocols are not specific to a language, it would be nice if example could be in .net. Thank you very much.


What can go wrong if the Liskov substitution principle is violated?

I was following this highly voted question on possible violation of Liskov Substitution principle. I know what the Liskov Substitution principle is, but what is still not clear in my mind is what might go wrong if I as a developer do not think about the principle while writing object-oriented code.


Career Confusion

For someone who has not worked anywhere in Java Technology except learning just the core concepts in his Masters (MCA) and Graduation (BCA, bachelor degree course):   1. Is it possible to get job anywhere in Java technology? Considering he/she has not studied it in regular college and not First Class throughout except BCA, MCA (in case of Indian or international companies).   2. How will he/she get his/her dream job (in the Java field) and what are the prospects for his/her career life?   3. If the knowledge he received in his grad/univ is not enough, than what more should he do to make this his specialty before getting started for the search job or to increase job offers? All kinds of suggestions are welcome. And thanks very much for kind suggestions.


Blaming the ills of today on the technical debt of yesterday

A surprising number of quality, scalability, and load problems have been occurring on an application I currently support that I did not originally write. Thankfully I have new projects that I have been doing from the ground up to retain some semblance of my sanity. The original team consisted of 20 some developers (most of them with outdated skill sets), no business requirement documents or quality assurance testers, and poorly managed from the very beginning in a waterfall fashion. The early days of production were an embarrassing nightmare that involved patching brittle procedural-like code with even more brittle fixes. Features were added later that were sledgehammered into a datamodel that was never meant to support them and it is not uncommon to see the same code duplicated 10 times over and to see resources not being safely closed and ORM queries that fetch tens of thousands of entities just to throw out all but a handful. It is just me now and everytime there is a new problem that crops out I rewrite a module to better standards and make it MUCH more stable but Management needs a proper explanation as to why all of this is occurring. They seem shocked and perplexed at the notion that this application is of poor quality and drowning in technical debt. Fortunately they understand the concept of technical debt and support me in my quest to eradicate it and they are very supportive and appreciative of me, but I feel as if I just keep **blaming** the original team (who all left to ruin another project in a different division). The bottom line is that I don't want to be _"That Guy"_ who always complains about the developers on the project before him. I have seen this attitude before from people in my career who I personally felt were being ignorant and not considering the circumstances and design influences that encouraged things to be the way that they were. Usually I see this attitude of blaming the previous team for poor design and implementation from idealistic junior developers who have not had the life experiences that more senior members have had and benefitted from. Do you feel that there is a better way, perhaps softer way of doing of reporting these kinds of problems to management without stepping on the reputation of the person/team before you?


Recommended secure approach to confirming an URL is called by a legitimate caller

I'm using a CRON on AppEngine and the cron calls my web app at a specific app. I only want to execute functionality when called by my AppEngine app. What's is/are recommended approach to confirming that the caller is legitimate? I don't wish to rely on no one else knowing the specific URL.


Purpose of ending tags in SGML/HTML/XML?

There are those tags which have immediate effect (< br >) and those which affect what is between them ( < a > < / a > ). Closing tag is **verbose** , and I believe also **redundant** :               <tag parameters> ... </tag>      ## verbose Compare to LISP's s-expresions.               (tag parameters)      ## redundant Ending tags are not even necessary. These language are context-free and this is not possible there:               <tag1> <tag2> </tag1> </tag2>      Basically these should be equivalent:               <tag1> <tag2> </> </>     <tag1> <tag2> </tag2> </tag1>             ## questions Are ending tags there to aid readability? What is purpose of redundancy in closing tags? I want to understand inside the logic behind desing of this. Thanks. :)


Is it a security flaw to log the class and method name when an exception occurs?

I have the following :               public class doCheck(){              public void performCheck(){             try {                 perform all checks......             }             catch(Exception e){                 logger.error("Exception occured in class doCheck in method performCheck");                 thrown new MyNewException(e.getMessage());             }         }     }      Is it safe to log the class and method name?


Are there coding tests to recruit a QA engineer?

I'm a software engineer in a small company and we are currently recruiting our first QA engineer. The guy will have to write as many as possible automated tests on our web-based tools suite. As I've participated in the recruitment of almost all the developers of our engineering team, the QA manager has asked me to interview the candidates. Most of them sound really smart. When they explain their past experiences, they give the feeling that they know what they were talking about, even when they give a lot of details on the framework or tools they are familiar with (like selenium or ohter stuff). However at the end of the interview I like to challenge them with a small coding test. I know we aren't recruiting a developer but as he'll have to _code_ tests, I believe that he has to be a bit skilled in that domain. I systematically ask the same question: "In the language of your choice, could you write a the body of the function that takes in input a integer and return its string representation.   For instance in C#, the prototype of the method could be something like `public string itoa(int n)`" And unfortunately, until now, 100% of the candidates have failed... So, is it because the question is somehow out of scope for a QA engineer? and in this case could you propose a better exercise?   Or is it just unacceptable and we still have to look for someone that would be at least able to pass the test? Thank you for you answers.


Is object oriented really good for kids?

I read, that Smalltalk was designed for kids or for education. So was it good at it? Better than the other languages? Was it good/easy also for average kid (I read that bright kids enjoyed). Is there any study to back it up? Or is Your experience it is good?


What advantages does Linux give me when developing in PHP for the web?

I'm about to begin a big PHP project with a friend. It's my first time using PHP and I've been wondering wether I should try developing on Linux since it's so popular.   I've had some past experience with Linux and the choice of an editor won't be hard since I know vim (though I've looked at VS.PHP and it's putting me back from the change).   Does using Linux when developing PHP (or any web language) give me an advantage?


Is functional programming strongly related to mathematics?

Is functional programming so related to mathematics because much of the functional programming is depicted with mathematical notions? Is it a MUST to have a strong base of maths to learn & understand functional programming for a programmer with a imperative background?


Do Fortran compilers really generate faster code than C compilers?

When I was studying in the university I often heard the idea that Fortran compilers produced faster code than C compilers for an equivalent program. The key reasoning went like this: _a Fortran compiler emits on average 1,1 processor instruction per line of code, while a C compiler emits on average 1,6 processor instruction per line of code_ - I don't remember the exact numbers but the idea was that C compilers emitted noticeably more machine code and therefore produced slower programs. How valid is such comparison? Can we say that Fortran compilers produce faster programs than C compilers or vice versa and why does this difference exist?


Where do you use ROT13?

I was reading through the docs for vim, and noticed there's a shortcut, for example `g?w` would transform the next word using ROT13. I also know that you can change the encoding of a Python file to ROT13. Here's my question: Why? It seems like it wouldn't be that useful, aside from prank programs like Django FUNserver.


If the model is validating the data, shouldn't it throw exceptions on bad input?

Reading this SO question it seems that throwing exceptions for validating user input is frowned upon. But who should validate this data? In my applications, all validations are done in the business layer, because only the class itself really knows which values are valid for each one of its properties. If I were to copy the rules for validating a property to the controller, it is possible that the validation rules change and now there are two places where the modification should be made. Is my premise that validation should be done on the business layer wrong? # What I do So my code usually ends up like this:               <?php     class Person     {       private $name;       private $age;            public function setName($n) {         $n = trim($n);         if (mb_strlen($n) == 0) {           throw new ValidationException("Name cannot be empty");         }         $this->name = $n;       }            public function setAge($a) {         if (!is_int($a)) {           if (!ctype_digit(trim($a))) {             throw new ValidationException("Age $a is not valid");           }           $a = (int)$a;         }         if ($a < 0 || $a > 150) {           throw new ValidationException("Age $a is out of bounds");         }         $this->age = $a;       }            // other getters, setters and methods     }      In the controller, I just pass the input data to the model, and catch thrown exceptions to show the error(s) to the user:               <?php     $person = new Person();     $errors = array();          // global try for all exceptions other than ValidationException     try {            // validation and process (if everything ok)       try {         $person->setAge($_POST['age']);       } catch (ValidationException $e) {         $errors['age'] = $e->getMessage();       }            try {         $person->setName($_POST['name']);       } catch (ValidationException $e) {         $errors['name'] = $e->getMessage();       }            ...     } catch (Exception $e) {       // log the error, send 500 internal server error to the client       // and finish the request     }          if (count($errors) == 0) {       // process     } else {       showErrorsToUser($errors);     }      Is this a bad methodology? # Alternate method Should maybe I create methods for `isValidAge($a)` that return true/false and then call them from the controller?               <?php     class Person     {       private $name;       private $age;            public function setName($n) {         $n = trim($n);         if ($this->isValidName($n)) {           $this->name = $n;         } else {           throw new Exception("Invalid name");         }       }            public function setAge($a) {         if ($this->isValidAge($a)) {           $this->age = $a;         } else {           throw new Exception("Invalid age");         }       }            public function isValidName($n) {         $n = trim($n);         if (mb_strlen($n) == 0) {           return false;         }         return true;       }            public function isValidAge($a) {         if (!is_int($a)) {           if (!ctype_digit(trim($a))) {             return false;           }           $a = (int)$a;         }         if ($a < 0 || $a > 150) {           return false;         }         return true;       }            // other getters, setters and methods     }      And the controller will be basically the same, just instead of try/catch there are now if/else:               <?php     $person = new Person();     $errors = array();     if ($person->isValidAge($age)) {       $person->setAge($age);     } catch (Exception $e) {       $errors['age'] = "Invalid age";     }          if ($person->isValidName($name)) {       $person->setName($name);     } catch (Exception $e) {       $errors['name'] = "Invalid name";     }          ...          if (count($errors) == 0) {       // process     } else {       showErrorsToUser($errors);     }      # So, what should I do? I'm pretty happy with my original method, and my colleagues to whom I have showed it in general have liked it. Despite this, should I change to the alternate method? Or am I doing this terribly wrong and I should look for another way?


voting system to select next set of product features

My product just deployed 2.0. Now there are many thing to plan for next sprint. From the list of 5-10 items, we need to ask everyone of our staff to order these 10 items based on importance. It all should be single vote and anonymous. Is there any site giving this service? It could be made in an hour but it wont appear anonymous to the staff, no matter what I say. (Sorry, if its the wrong place to ask. I could not find other.)


Creating a site just for URL redirecting (.NET MVC) due to changing domains and URLs

I'd just like to hear about any experience creating a (simple) site for redirecting requests. Basically we have multiple domains, but as we add more domains and change URLs, there is a huge problem of maintaining old links. When discussing this we are considering using one constant site to determine where the present url is located. The idea would be pretty simple, just e.g. `links.url.com` and then a parameter to find a database row which would contain e.g. domain, parameters, and any other necessary fields to redirect successfully. for example: `links.url.com/id=12345` would read the new domain e.g. `url2.com` and the `parameters id=324324324&id2=34234` so the controller would just redirect to `url2.com/id=324324324&id2=34234`. Is this a good way to handle changing URLs as the domains and URLs change? Are there downfalls to this approach, or better ways to go about URL change?


What is pattern based programming?

Can somebody explain the obsession with patterns and anti-patterns in programming? I ask because I have absolutely no idea what any of the patterns mean. When faced with a programming task I think about the problem for a little bit, write down some data structures that I think will be relevant, prototype a solution, separate out some modules and iterate. Nowhere in the process do I think "Oh, I need FunkyLookyTastic pattern here".


Java vs. C# - Productivity perspective

If you have a number of years experience in working with Java and a number of years experience in working with C# and .NET, I would value your opinion on software development productivity differences between these two environments. One of our customers is considering replacing their existing software solution. As the replacement will require approx. 10 - 15 man years work, a choice for Java or .NET, based on productivity differences between the them, may significantly influence the investment required and time-to-market. Would you be able to provide us, an indication of software development productivity differences between Java and C#/.NET? I would prefer to receive an answer as follows: > My experience is based on X years experience working with Java and X years > experience working with C#/.NET. Java is X% more productive then C#.NET or > C#/.NET is X% more productive than Java if you take the the following into > account.


Hiring at start-ups vs established companies

I have always wondered about this and perhaps experienced folks here can comment on this. I always read that big established software companies such as Google, Microsoft, etc are always wary of hiring software engineers/(or other related professionals) who don't exactly meet the job requirements, and would rather turn down a close "Yes/Maybe" decision. There's also the general perception that start-ups are generally more willing to hire such "less-than-perfect" employees. But to me this sounds counter- intuitive: start-ups are generally much smaller and resource constrained so they would actually need a "10/10" hire while established companies with bigger teams and more resources would be willing to take a (small) risk on a hire. Anyone have any comments on this from first-hand experience? Thanks,


How to verify the code that could take a substantial time to compile?

As a follow up to my prev question: What is the best aproach for coding in a slow compilation environment To recap: I am stuck with a large software system with which a TDD ideology of "test often" does not work. And to make it even worse the features like pre- compiled headers/multi-threaded compilation/incremental linking, etc is not available to me - hence I think that the best way out would be to add the extensive logging into the system and to start "coding in large chunks", which I understand as code for a two-three hours first (as opposed to 15-20 mins in TDD) - thoroughly eyeball the code for a 15 minutes and only after all that do the compilation and run the tests. As I have been doing TDD for a quite a while, my code eyeballing / code verification skills got rusty (you don't really need this that much if you can quickly verify what you've done in 5 seconds by running a test or two) - so I am after a recommendations on how to learn these source code verification/error spotting skills again. I know I was able to do that easily some 5-10 years ago when I din't have much support from the compiler/unit testing tools I had until recently, thus there should be a way to get back to the basics.


How important are daily builds?

One of the criteria of the Joel Test is daily builds. The idea is that if the build is broken, whoever broke it is around to fix it up. If the build cannot be fixed, everyone will have to check out an old version and work on that. I can understand how this can be pretty bad on centralised version control where it is important to avoid merging and branching as much as possible, but this only sounds like a minor nuisance for distributed version control. Do you agree with this? Are there other reasons why daily builds are important?


Is Objective-C an Interpreted or Compiled language?

I want to know if Objective-C is an interpreted or a compiled language.


Moving from C# to C++, and tips?

I've been using `C#` for a while now, and for the sake of furthering my career and extending my knowledge of programming, I want to get into `C++`. `C#` is very useful, and fast to work with, but since my team and I will be making large scale projects I need to consider working at a lower level language for several reasons. Most commercial companies use `C/C++` due high performance and portability. Of course, `C#` isn't necessarily bad compared to `C` or `C++`, but I just prefer to have a different tool for each job. So I read C++ is harder because it is a low level language, machine code, and doesn't have memory management. But the fact that it is machine code also reduces the amount of memory consumed. The language is hard to work with, but in a way difficulty makes it a powerful language. It was made to be fast and efficient, machine code, but this makes it harder to understand and learn "since it is closer the the machine". * * * I've made up my mind, and I want to learn `C++`, so what are some tips to keep in mind while learning? It's best to avoid getting into bad habits rather than to try and break them later, safe than sorry. I plan to use the resources stated here, but I would prefer any personal recommendations, books or online guides, possibly those that can be easily understood by someone who has fair knowledge of `C#`.


what is a phone interview?

So..I am going to have a phone interview with a company tomorrow. I never had a phone interview before so I don't know anything about it except that I am going to talk to someone over the phone. This is a PHP developer position. Is she/he going to ask PHP questions only? or is she/he going to ask any other questions? Please advise me!


What do I need to know to develop a paperless application using .NET?

I want to develop a paperless application in .NET to reduce paper usage at my university. It will contain Exchange data and reporting. What do I need to study before I start?


Possible hack aftermath

After being hacked companies often give numbers and details on how much of their data was compromised e.g "13K user and passwords". After a possible intrusion how do you know what the hacker did in your server?


Which one is better offline method for large scale application

We've a big data management website used by several property. Some of our customers have downtime (they can't access net for an hour or two). We want our site to support offline data viewing and inventory management (typical data search and add/remove) and when the user goes online we can sync the changes back to our central database. Customers use several platforms like Windows, iOS, etc. We've been looking into several different options, here are the major choices - Develop offline web app supported in HTML5. Develop a 'fallback' mechanism and interact with data from the app cache as explained in here (http://www.htmlgoodies.com/html5/tutorials/introduction-to-offline-web- applications-using-) Develop a desktop based cross platform solution. I remember the old MONO which has been popular. Here's a post (What do you suggest for cross platform apps, including web cross-platform-apps-including-web) and another one (Technology choice for cross platform development (desktop and phone)? platform- development-desktop-and-phone?rq=1) I realize the the desktop solution might be hard to maintain and result in some compatibility issues and demand test environments. Can HTML5 handle moderate to high level complexity and data flow? Or would it be better to rely on a desktop based app for better scalability & performance?


Is automatically checking code quality via metrics possible?

For several years now I am a big fan of using static code analysis tools for checking the source code quality. We are mostly doing C# development so NDepend was the best way to go for me. Most of the time I manually perform the analysis, for example once every two weeks. Lately I have had a discussion with a college whether we should include NDepend in our continuous integration process so that the build automatically turns red if for example a method has a too high complexity. My opinion hereby is that it's not possible to define metrics that are valid for the whole code. I think that you would either get way to many "false complaints" - code that generally is ok but does not match the metrics. The following code for example has a very high complexity, even if I think that sometimes you can't prevent it.               if (remoteResult == RemoteResult.Dummy1 || remoteResult == RemoteResult.Dummy2 ||          remoteResult == RemoteResult.Dummy3 || remoteResult == RemoteResult.Dummy4 || ...      Of course it would also work to increase the thresholds of the metrics, but in this case I would loose valuable information. Another example for example is the maximum number of members for a class. I would like to keep this lower than 10 for classes with lots of logic. But on the other hand there are many "domain models" with more than 10 properties. I wouldn't like to extract another class just because of the metric - as this would lower the readability and does not improve it which should be the goal of code quality metrics. Do you think automatically checking code quality via metrics is possible? If yes, for all or only for specific metrics? (A list of common NDepend metrics can be found at http://www.ndepend.com/Metrics.aspx )


syncing code with repo/backup

I am doing a small software project on my local PC. I'm the only person working on this. I'd like to back this up to the cloud every day so that if anything happens to my HDD I have a various copies going back in time. I have a box account although that seems to want to sync continuously and with constant file changes with code I don't really want this. Can anyone recommend any site or software that will allow me to back up to an external location online? I'm happy to manually kick off this process at the end of each day.


Why do binary files load quicker than alphanumeric text files?

I've noticed that when I load/store large data files in a binary format, the program runs much faster than if I load data from an ASCII encoded file. Why is this the case? The data in my case is plain, with limited parsing involved other than `read()` or `fscanf()`.


How to understand the beauty of UNIX?

Some of my friends say that UNIX is beautiful and simple. But I really don't know what they mean. Why are they saying so? For me, UNIX is just a boring command prompt with different shells. How can I experience the beauty of UNIX? Can you share any experience?


Pythonesque global variable assignment

I'm designing a language with Pythonesque syntax, including casual creation of variables by assignment. I'm wondering at the moment exactly how to deal with assignment to global variables (and object/class variables, since I'm implementing classes as scopes). In Python itself, by default the attempt will create a local variable instead:               x = 1     def f():         x = 2 # creates a local variable      but you can override this with a `global` declaration:               x = 1     def f():         global x         x = 2 # updates the global variable      I'm going to implement a prefix `.` for referring to variables in outer scopes (somewhat akin to prefix `::` in C++, but will probably jump one scope instead of all), so that could be written as:               x = 1     def f():         .x = 2 # updates the global variable      Would it be better to have just that one way of doing things, or would it be clearer or more convenient to have the mechanism of declaring variables as global the way Python does it?


Working with a remote developer

My company is going to hire an external developer to write some simple PHP modules and some minor bugfixing in our software. We have never hired an external developer by the hour before. How can we measure external developer's productivity and coordinate with them? I thought about using a combination of http://worksnaps.net/ and https://github.com/. Any better ideas?


Steps after SQL Injection detected

I've come across SQL injection vulnerabilities on my companies ecommerce page. It was fairly poorly put together. I believe I have prevented future attempts however we are getting calls about fraudulent credit card charges on our site and others. This leads me to believe that someone was able to get a list of our credit card numbers. What doesn't make sense is that we don't store that information and we use Authorize.net for the transaction. If someone was able to get the CC#s, what should I do next? Inform ALL of our customers that someone broken into our system and stole their information? I have a feeling that will be bad for business.


How do you find local fellow programmers?

I'm a self-tought programmer living in a small town. Except for the occasional meetups at the other end of the country, I rarely talk face-to-face with other programmers. I'm well aware of the merits of pair programming, feedback, discussion with other programmers and all... What do you do to get in contact with other local programmers? p.s. If you live near Loenen (gld), Netherlands, I'd like to have contact ;)


What is the most accurate/frequent report on browser usage on the Internet?

I'm determining which browsers a new site should support. I'm looking for a respected and accurate (as possible) report on the browser versions that are currently in use. This report should, at minimum cover the % of people who use what browsers, and versions of that browser. Is there a widely accepted source for this kind of report? If so, are they regularly released and available for free? Bonus points for other metrics such as breaking down by OS, Flash versions, JS versions, etc.


function works fine without return value in c++

I forgot to write `return 'a';` in function and `return 0;` in main function but its works fine in Code::Blocks.               #include <iostream>          using namespace std;          char show()     {          cout<<"this is show function"<<endl;     }          int main()     {         show();     }      i am using Code::Blocks 10.05 in Ubuntu 12.04. Why this happen and why does the same thing cause an error in TURBO C++?


Layout of mathematical views (iOS)

I am trying to figure out the right way to encapsulate graphical information about mathematical objects. It is not simple. For example, a matrix can include square brackets around its entries, or not. Some things carry down to sub-objects -- for example, a matrix might track the font size to be used by its entries. Similarly, the font color and the background color would carry down to the entries. Other things do not carry down. For example, the entries of the matrix do not need to know whether or not the matrix has those square brackets. Based on all of the above, I need to calculate sizes for everything, then frames. All of this can depend on the properties stored above. The size of a matrix depends on the sizes of its entries, and also on whether or not it has those brackets. What I am having a hard time with is not the individual ways to calculate sensible frames for this or that. It is the overall organizational structure of the whole thing. How can I keep track of it all without going crazy. One particular obstacle is worth mentioning -- for reasons I don't want to go into here, I need to calculate the sizes and frames for everything before I instantiate any actual views. So, for example, if I have a Matrix object, I need to calculate its size before I make a MatrixView. If I have an equation, I need to calculate the size of the view for the equation before I create the actual view. So I clearly need separate objects for those calculations. But I can't figure out a sensible class structure for those objects. If I put them all into a single class, I get some advantages because copying then becomes easy. But I also end up with a bloated class that contains info that is irrelevant for some objects -- such as whether or not to include those brackets around the matrix. But if I use a lot of different classes, copying properties becomes a real pain. If it matters, this is all in Objective C, for an iOS environment. Any pointers would be greatly appreciated. EDIT: To clarify: I have model objects that contain mathematical information and can compute the text that will be displayed. I also _think_ it will make sense to have style sheet objects that will know the font size. Therefore, between the two, I can compute everything. This still leaves the issue of how to keep track of the resulting information. I don't want to call the "compute- your-size" methods more than necessary as they are expensive. So I have to cache some things. But where? And how do I manage that caching?


Backbone/JQuery, ExtJs 4.... is there something else worth looking?

Im currently evaluating a front-end architecture for a big app that will be developed by a team of about 6 developers + 1 web designer so that said, having a robust SVN friendly architecture is a must. So far I'm evaluating this two options:   * A mixture of JQuery/UI/Mobile + Backbone/Underscore + Require JS + Twitter-Bootstrap   * ExtJS 4 This are the requirements the architecture needs to meet:   * SVN Fiendly (or Friendly depending on you previous experiences)   * Active community and extensive documentation   * Extensible   * Easy to learn and to maintain (nice to have)   * Cross-browser support (most of the time at least)   * Support for Mobile devices   * Easy to maintain (MVC, MVVM)   * OpenSource (nice to have) The previously mentioned ones meet most of the requirements in different levels and so far they are the only ones I've found about, am I missing any others?


what programming languages and skills are necessary to learn hypervisor development?

I would like to know the skills and programming languages necessary to learn hypervisor development and any good resource to start learning?


Why are Javascript for/in loops so verbose?

I'm trying to understand the reasoning behind why the language designers would make the `for (.. in ..)` loops so verbose. For example:               for (var x in Drupal.settings.module.stuff) {         alert("Index: " + x + "\nValue: " + Drupal.settings.module.stuff[x]);     }      It makes trying to loop over anything semi-complex like the above a real pain as you either have to alias the value locally inside the loop yourself, or deal with long access calls. This is especially painful if you have two to three nested loops. I'm assuming there is a reason why they would do things this way, but I'm struggling with the reasoning.


What have you learned from the bugs you helped discover and fix?

I liked the core of this question, and wanted to re-ask it in a way that made it less about 'fun' and more about 'What do these past mistakes tell us about how we can write and test software better?' As an SDET, I'm always looking for anecdotes about new and interesting ways that programs can fail. I've learned a lot from these tales in the past, and would like to get that from the intelligent people in this community as well. I'd be interested in hearing what the issue was, how it was caught, if you think there was anything that could have reasonably done to catch it earlier or to avoid the same issue on later projects, and any other interesting lessons you took away from this bug. Please only write about bugs you _personally_ were involved with, ideally on a project you worked on (e.g., no "10 years before I was born, this happened and it was FUNNY!" answers). Please vote up answers that are thought-provoking or could change how you develop or test in some way, so this isn't just 'social fun'. Try to avoid voting up something just because it was funny. Edit: Please also focus on concrete examples of bugs or classes of bugs, not general discussion of what you've generally learned. They don't have to have been super-difficult or extremely weird, just something that made you go, "huh".


Office design and layout for agile development

(moved from stackoverflow) I have found lot of discussions here on about which keyboard, desk, light or colored background is best - but I can't find one addressing the layout of the whole office. We are a company with about 20 employees moving to a new place, something larger. There are two main development practices going on here with regular combination, the back end people often needing to work with the mobile people to arrange web services. There are about twice as many back end people as mobile people. About half of the back end developers are working on-site at any time and while they are almost never all in the office at once at least 5-10 spaces need to be provided - so most of the time the two groups are about equal. We have the chance to arrange desks, partitions and possibly even walls to make the space good. There won't be cash for dot-com frills like catering or massages but now's the time to be planning to avoid ending up with a bunch of desks in a long line. Joel on Software's Bionic Office is an article I've remembered from way back and it has some good ideas but I* (and more importantly the company's owners) are not completely sold on the privacy idea in an environment where we are supposed to be collaborating. This is another great link - The Ultimate Software Development Office Layout - I hadn't even remembered enclosed meeting rooms until reading this. Does the private office stand in the way of agile development? Is the scrum enough forced contact and if you need to bug someone you should need to get up and knock on their door? What design layouts can you point to and why would you recommend them? *I'm not against closed offices at all but would be happy if some other solution can do just as well. If it can't... well, that's what this question is all about. * * * Two updates - April 2013. The first move was to an office that was "funky". Basically open but with weird features like one wall carpeted, half the floor carpeted, half the floor polished concrete. Everyone seated on the concrete wanted to be on the carpet. It looked OK but in practise I would recommend not carpeting only half the office, the people who felt the cold really hated it. For standups it was fine - huge whiteboards occupied one wall, plenty of space to talk and break out. Then I moved to a very crowded place mixed in with another company (same owners) whose function was all about collaboration, design, phone calls, maintenance and installation of physical things. That sucked. Then we moved to new premises and someone decided warehouse/industrial was cool. Hard surfaces everywhere, glass and polished concrete. Developers sharing one big table in the middle of the highest traffic area right next to a kitchenette and dishwasher, not even in an alcove, just out there. Next to the people who spent all day on the phone. It sucked and continued to suck despite bandaids like noise absorbing panels. It sucked for agile because there was no space designed in for the board or for the standup and the acoustic characteristics of the place made hearing any one person above the clatter very difficult - as well as that feeling, during quiet moments, of shouting in a cathedral. Nobody ever listened to the complaints. I quit and so did a few others. Oh, it didn't help that the person who insisted on being "product owner" never bothered to show up.


Algorithm for compression of a dictionary (words and definitions)

The theoretical situation is this: Let's say that we have a digital dictionary (by which I mean a traditional list of words and definitions, not an associative array). For the sake of simplicity, let's also say that each word can be replaced by its exact definition, and still make sense in a sentence; for example, if this dictionary holds the definition of the word "ocean" to be "large body of salt water", then the following passage:               "We ourselves feel that what we are doing is just a drop in the ocean."       could be modified to:               "We ourselves feel that what we are doing is just a drop in the large body of salt water."      without any loss of logic or meaning. Now my question is this: given a dictionary with all of the words in the English language, what is an algorithm that could be applied to compress the dictionary, through the replacement of all the occurrences of a given word with its definition, and in doing so find a base set of words through which all of the meanings of the original language could be expressed? To clarify even more; if "sadness" is defined as "an unhappy emotion", then the word sadness can be completely removed from the dictionary by replacing all instances of the word "sadness" that occur in the definitions of other words with its definition. The definition of "depression", for example, might change from "a sustained period of sadness" to "a sustained period of an unhappy emotion". In this way, the algorithm would eventually arrive at a base set of words from which all other words could be represented. Are there any algorithms that exist that can do this, or something similar? How might this be done programmatically, without using brute force? Any insight is appreciated.


What license is best for this: Software is open source and free to use as long as you don't charge your customers

I'm releasing an open-source jQuery plug-in that is free to use, modify and redistribute as long as you don't directly or indirectly charge your customers. Your software doesn't need to be open-source, it just need to be free. If you charge your customers, you need a commercial license. I'm not sure about the licensing. http://www.turnjs.com/ is a plug-in that is similarly licensed and it is `Non-comercial BSD license`. But I can't find the definition for this license online. Can anyone help me determining the best license for me based on my description? Thanks.


MorphAdorner Licensing confusion

I want to use the MorphAdorner library available free for commercial use. But it uses several other libraries that restrict commercial use (like Gate etc). Can I use this library in my application?


Why does void in C mean not void?

In strongly-typed languages like Java and C#, `void` (or `Void`) as a return type for a method seem to mean: > This method doesn't return anything. Nothing. No return. You will not > receive anything from this method. What's really strange is that in C, `void` as a return type or even as a method parameter type means: > It could really be anything. You'd have to read the source code to find out. > Good luck. If it's a pointer, you should really know what you're doing. Consider the following examples in C:               void describe(void *thing)     {         Object *obj = thing;         printf("%s.\n", obj->description);     }          void *move(void *location, Direction direction)     {         void *next = NULL;              // logic!              return next;     }      Obviously, the second method returns a pointer, which by definition could be anything. Since C is older than Java and C#, why did these languages adopt `void` as meaning "nothing" while C used it as "nothing or anything (when a pointer)"?


Questions over Excel programming

I have always heard about the powerful programming capabilities of Microsoft Excel (not VBA, I am referring to the formulas of Excel itself), but have never seen it.   * Does it really have all that power on formulas or have I misunderstood?   * If it does, what is the extent of Excel's programming capabilities?   * How is it done (what does serious, complex programming looks like in terms of syntax, patterns, styles, etc.)?   * Does it pertain to a paradigm (say, functional programming)?   * Do Excel programmers exist?   * What is it mainly used for?


Future of SOAP, with REST?

Considering that more and more Web Services are implementing a RESTful interface, I am wondering what the future of SOAP will be? I'm looking for any kind of papers, statistics, articles or publications from official sources (e.g. books, articles and journals) which provide information on the future of SOAP. Thanks in advance!


Is there any legal issue for copying javascript code to website

I am making one website and i want to use mortgage repayment calculator. I have seen many real estate sites using that. I want to know that i copy their `javascript calculator` code and style my form differently , will that be an legal issue there


How could RDBMSes be considered a fad?

Completing my Computing A-level in 2003 and getting a degree in Computing in 2007, and learning my trade in a company with a lot of SQL usage, I was brought up on the idea of Relational Databases being used for storage. So, despite being relatively new to development, I was taken-aback to read a comment (on Is LinqPad site quote "Tired of querying in antiquated SQL?" accurate? ) that said: > [Some devs] despise [SQL] and think that it and RDBMS are a fad Obviously, a competent dev will use the right tool for the right job and won't create a relational database when e.g. flat file or another solution for storage is appropriate, but RDBMs are useful in a massive number of circumstances, so how could they be considered a fad?


Is my DFD accurate?

This is my first ever DFD that I made after my fair share of learning but I have no way of verifying whether it is correct or not. Although I have taken utmost care to make sure it is right, I may be wrong. **Here is the scenario:** Bebop Records is a mail-order company that distributes CDs and tapes at discount prices to record club members. When an order processing clerk receives an order form, he or she verifies that the sender is a club member by checking the Member file. If the sender is not a member, the clerk returns the order along with a membership application form. If the customer is a member, the clerk verifies the order item data by checking the Item file. Then the clerk enters the order data and saves it to the Daily Order file. The clerk also prints an invoice and shipping list for each order, which are forwarded to Order Fulfilment. **And here is my diagram:** ![enter image description here](http://i.stack.imgur.com/FnD6D.png)


How much overhead is there in persistent connections?

Ok so I'm musing over a little side project I want to start. Essentially its a multi-session web based FTP client. Multi-session in that you can log into several FTP servers at the same time and perform operations like moving a file from one FTP server to another. I'm doing this mainly to brush up on the new webdev technologies, particularly websockets. I'm using node.js + socket.io to keep a persistent bi-directional connection between the web browser and the web server. The web server will also have persistent connections to each FTP server the user has logged into. So if there are 100 concurrent users each logged into 5 ftp accounts, the web server will have 100 websocket connections + 500 ftp connections. Is servicing 600 connections a lot? I know it depends on the hardware resources of the server but is something like this doable on a budget? Are there more efficient means of doing something like this? I know its unlikely that this project will really get popular but I want it to scale well regardless. Thanks for any help, I've still got a lot to learn.


what is a "proxy based" framework?

I just started reading about spring , and a book mentioned "Spring AOP is a Proxy based framework" . What is meant by "Proxy based" framework.


Is it a good idea to build a library on top of somebody else's library?

Is it a good idea to use somebody else's library as a base and build your own library over that. I want to make a JavaScript Canvas framework for a animation player on top of KineticJS. Should I do it? Do I need permission from the author of KineticJS? Do I just say to users to donwload KineticJS before my library, or do I just copy paste the kineticJS code in my library?


Why do almost all Java jobs (postings and from recruiters) say J2EE rather than the newer JEE versions?

I'm still fairly new to Java but have definite comfort now working within the framework I am used to which would mainly be focused on Spring, Hibernate and JEE 6. It seems like every time I talk to a recruiter all they do is throw around the keyword "J2EE", they need someone with J2EE experience, etc. I am aware that legacy systems would still be using J2EE but it seems like at least some jobs would be advertising JEE now. Just curious if they are just stuck with some keyword that they can't seem to wrap their heads around it having a newer version or what. Having not done Java all that long, I haven't used J2EE specifically but wouldn't it be fairly easy to adapt having used the newer enterprise edition? Just curious to hear anything about this from someone with more experience.


Best/Bad practices for code sharing?

The more I explore Github, the more I like it. I really enjoy how coding is becoming more social. I'm curious as to if there are _any bad practices_ that programmers should avoid in sharing their code with each other. And in naming bad practices, **what are the best practices for code sharing**? For example: Is it a bad practice for a single repo to have multiple scripts/projects named **'MiscProjects'**? Where this repo, as the name suggest, is a collection of miscellaneous small scripts and projects. This may resemble how a programmer organizes projects on his/her local storage, but it's possibly not optimal for code sharing? Maybe if a good README/documentation is done, it would be better? Or as long as it's well documented, anything goes?


How do you communicate improvements in tools and process to the development team?

My team does a lot of internal tooling and infrastructure work - you can think of us as a small scale version of the teams Facebook, Etsy, Netflix, etc. who build all the infrastructure for scaling their services up to thousands/tens of thousands of servers and supporting millions of users. Lately, we've been running full steam ahead improving much of the tools we use internally, like tools for automatically creating new servers, setting up new application instances, etc. An end result of this has been decreased developer frustration, but increased 'ignorance' by most of the developer team about how to use our tools correctly and effectively. More often than not, my team will be asked by other teams to help them use the tools. Solutions we've thought up or things already in place: * * * **All our code is relatively simple and self-explanatory, with good comments where necessary, so developers could read the scripts.** Counterargument: You can guess this isn't a particularly good idea, having people read our tools' code to figure out how to use it. * * * **All our code is committed to Subversion with very detailed commit messages about changes, developers could read the commit emails.** Counterargument: Expect the developers to read all our commits? Ludicrous. * * * **Wiki - we have an internal company wiki, that we try to maintain with up to date information, but as we are moving so fast, the wiki has to keep pace as well.** Counterargument: As mentioned, we move fast in my team, as more improvements on our tools are added daily. Again still relies on people to read something that might change constantly. * * * **Email the team? We could email the team when we have a glut of improvements to communicate.** * * * So as you can all see, we are trying to find new ideas, and explore options we haven't thought of yet. Anyone else ever been in a similar situation and have some guidance?


Is it ok to replace optimized code with readable code?

Sometimes you run into a situation where you have to extend/improve some existing code. You see that the old code is very lean, but it's also difficult to extend, and takes time to read. Is it a good idea to replace it with modern code? Some time ago I liked the lean approach, but now, it seems to me that it's better to sacrifice a lot of optimizations in favor of higher abstractions, better interfaces and more readable, extendable code. The compilers seem to be getting better as well, so things like `struct abc = {}` are silently turned into `memset`s, `shared_ptr`s are pretty much producing the same code as raw pointer twiddling, templates are working super good because they produce super lean code, and so on. But still, sometimes you see stack based arrays and old C functions with some obscure logic, and usually they are not on the critical path. Is it a good idea to change such code if you have to touch a small piece of it either way?


Design pattern to handle queries using multiple models

I am presented with a dilemma while trying to re-designing the class structure for my PHP/MySQL application to make it more elegant and conform it to the SOLID principle. The problem goes like this: Let as assume, there is an abstract class called `person` which has certain properties to define a generic person, such as `name`, `age`, `date of birth` etc. There are two classes, `student`, and `teacher`, that implements this abstract class. They add their own unique properties to it. I have designed all the three classes to include all the operational logic (details of which are not relevant in context of the question). Now, I need to create views/reports/data grids which contain details from multiple classes, for example, say, a list of all students doing projects in Chemistry mentored by a teacher whose name is the parameter to the query. This is just one example of a view, there are many different views in the application, which uses data from 3-4 tables, and each of them have multiple input parameters to generate them. Considering this particular example, I have written the relevant query using JOIN and the results are as expected and proper, now here is the dilemma: Keeping in mind the single responsibility principle, where should I keep this query? It does not belong to either `Student` class, or `Teacher` class or any other classes currently present. a) Should I create a new class, say `dataView` class, and design it as a MVC pattern and keep the query there? What about the other views? how do they fit in this architecture? b) Should I not keep the query in code at all, and make it DB View ? c) Am I completely wrong in the approach? If so what is the right approach? My considerations are as follows: a) should be easy to add new views later on if requirement comes, without having to copy-paste-modify code b) would like to make it as loosely coupled as possible so that if minor db structure changes happen, it does not break I did google searches on report design and OOP report generators, but all the result seem to focus on the visual design of the report rather than fetching the data. I have already taken care of the visual aspect of the report using MVC with html templates. I am sure this is a very fundamental problem with known solution, but I am somehow not able to find it (maybe searching with wrong keyword). **Edit1: Modified the title to make it more relevant** **Edit2: The accepted answer got me thinking in the right direction and identify my design flaws, which eventually led me to findthis question and the solution in Stack Overflow which gave me the detailed answer to clear the confusion.**


Is there any evidence that one of the current alternate JVM languages might catch on?

There's been a lot of enthusiasm about JRuby, Jython, Groovy, and now Scala and Clojure as the language to be the successor to Java on the JVM. But currently only Groovy and Scala are in the TIOBE top 100, and none are in the top 50. Is there any reason to think that any of this bunch will ever gain significant adoption? My question is not primarily about TIOBE, but about any evidence that you might see that could indicate that one of these languages could get significant backing that goes beyond the enthusiasts.


DI/IoC in Java for a .NET'er used to Castle.Windsor

Is there a Java DI container that works in a similar way to the most excellent Castle.Windsor container on the .NET side? The Java containers I've had a look at all seem to rely on annotations (Guice) within my services, which I don't dig all that much - I'd like to go POJO all the way if possible. Spring on the other hand can do without the annotations, but it requires a lot of XML. XML configuration != maintainability. One of the really nice things about Castle.Windsor is the wiring you're able to set up in code with Installers, auto wiring based on naming conventions and whatnot. Ideally the container should also support lifecycle management and configuration; i.e. registering components as transient, singleton, pooled etc. Another bonus would be support for interceptors. Any tips would be greatly appreciated.


Annotate source code with diagrams as comments

I write a lot of (primarily c++ and javascript) code that touches upon computational geometry and graphics and those kinds of topics, so I have found that visual diagrams have been an indispensable part of the process of solving problems. I have determined just now that "oh, wouldn't it just be **fantastic** if I could somehow _attach_ a hand-drawn diagram to a piece of code as a comment", and this would allow me to come back to something I worked on, days, weeks, months earlier and far more quickly re-grok my algorithms. As a visual learner, I feel like this has the potential to improve my productivity with almost every type of programming because simple diagrams can help with understanding and reasoning about any type of non-trivial data structure. Graphs for example. During graph theory class at university I had only ever been able to truly comprehend the graph relationships that I could actually draw diagrammatical representations of. So... No IDE to my knowledge lets you save a picture as a comment to code. My thinking was that I or someone else could come up with some reasonably easy-to-use tool that can convert an image into a base64 binary string which I can then insert into my code. If the conversion/insertion process can be streamlined enough it would allow a far better connection between the diagram and the actual code, so I no longer need to chronographically search through my notebooks. Even more awesome: plugins for the IDEs to automatically parse out and display the image. There is absolutely nothing difficult about this from a theoretical point of view. My guess is that it would take some extra time for me to actually figure out how to extend my favorite IDEs and maintain these plugins, so I'd be totally happy with a sort of code post-processor which would do the same parsing out and rendering of the images and show them side by side with the code, inside of a browser or something. Since I'm a javascript programmer by trade. What do people think? Would anyone pay for this? I would.


Design in "mixed" languages: object oriented design or functional programming?

In the past few years, the languages I like to use are becoming more and more "functional". I now use languages that are a sort of "hybrid": C#, F#, Scala. I like to design my application using classes that correspond to the domain objects, and use functional features where this makes coding easier, more coincise and safer (especially when operating on collections or when passing functions). However the two worlds "clash" when coming to design patterns. The specific example I faced recently is the Observer pattern. I want a producer to notify some other code (the "consumers/observers", say a DB storage, a logger, and so on) when an item is created or changed. I initially did it "functionally" like this:               producer.foo(item => { updateItemInDb(item); insertLog(item) })     // calls the function passed as argument as an item is processed      But I'm now wondering if I should use a more "OO" approach:               interface IItemObserver {       onNotify(Item)     }     class DBObserver : IItemObserver ...     class LogObserver: IItemObserver ...          producer.addObserver(new DBObserver)     producer.addObserver(new LogObserver)     producer.foo() //calls observer in a loop      Which are the pro and con of the two approach? I once heard a FP guru say that design patterns are there only because of the limitations of the language, and that's why there are so few in functional languages. Maybe this could be an example of it? EDIT: In my particular scenario I don't need it, but.. how would you implement removal and addition of "observers" in the functional way? (I.e. how would you implement all the functionalities in the pattern?) Just passing a new function, for example?


Would it be a good idea to work on letting people add arrays of numbers in javascript?

I am a very mathematically oriented programmer, and I happen to be doing a lot of java script these days. I am really disappointed in the math aspects of javascript:   * the Math object is almost a joke because it has so few methods   * you can't use ^ for exponentiation   * the + operator is very limited, you cant add array's of numbers or do scalar multiplication on arrays Now I have written some pretty basic extensions to the Math object and have considered writing a library of advanced Math features, amazingly there doesn't seem to be any sort of standard library already out even for calculus, although there is one for vectors and matricies I was able find. The notation for working with vectors and matricies is really bad when you can't use the + operator on arrays, and you cant do scalar multiplication. For example, here is a hideous expression for subtracting two vectors, A - B:               Math.vectorAddition(A,Math.scalarMultiplication(-1,B));      I have been looking for some kind of open-source project to contribute to for awhile, and even though my C++ is a bit rusty I would very much like to get into the code for V8 engine and extend the + operator to work on arrays, to get scalar multiplication to work, and possibly to get the ^ operator to work for exponentiation. These things would greatly enhance the utility of any mathematical javascript framework. I really don't know how to get involved in something like the V8 engine other than download the code and start working on it. Of course I'm afraid that since V8 is chrome specific, that without browser cross-compatibility a fundamental change of this type is likely to be rejected for V8. I was hoping someone could either tell me why this is a bad idea, or else give me some pointers about how to proceed at this point to get some kind of approval to add these features. Thanks!


Expanding existing DVCS Wiki

A portion of my job is to maintain technical documentation for a rapidly expanding manufacturing company. Because it is only a portion of my job and the company's product line is expanding so quickly, I can't stay on top of the documentation. As a result, I've been yearning for an information management system with a handful of specific features. I've found many products that have a subset, but none that have all the features I'm looking for. I'm at the point of picking an existing product and expanding it to cover my desired feature set, however, this will be a pet project and I will be learning the underlying language as I go. So, the main question is which existing product will be the easiest to expand to cover the full feature set and has a relatively easy to learn language? Alternatively, have I missed another existing program that will cover the feature set or should be in my list of "close, but not quite there"? ### Feature Set   * web interface   * based on a distributed version control system (e.g., git)   * easy to edit by logged in novices (e.g. wiki, multimarkdown)   * outputs in more traditional formats (e.g., doc, odt, pdf)   * edits held in queue until editor/engineer/manager approves them (e.g., MS Word editing) [this is the really big elephant in list - suggestions on where to start appreciated]   * edits held in queue specifically for engineer approval [extra limb of the elephant in the list]   * well-supported in the open source community ### Closest, but not quite there ikiwiki - http://ikiwiki.info (php)   * lots of awesome functionality and extensions, including easy to edit and based on DVCS   * lacks a review/forward for review queue   * appears to be well-supported within the OSS community gitit - http://gitit.net/ (haskell)   * easy to edit and based on DVCS   * lots of outputs in traditional formats   * a great web-based gui diff interface   * lacks a review/forward for review queue   * appears to be primarily maintained by one individual


Should I create a separate table for every derived type?

We are having a debate and I am struggling to decide which side to come down on. Basically we have an event type lets say like like this (simplified example).               public class Event     {         public virtual int EventId { get; set; }         public virtual DateTime DateTimeOccurred { get; set; }     }      Many different events in our system can inherit from this so we could have:               public class UserUpdatedEvent : Event     {         public virtual User User { get; set; }     }      So basically any event can inherit from the base event and then we can track what is happening in our system which we need to do as tasks occur off these events, etc. My question is should we have a table in the DB for every event so we can enforce foreign keys in this example to the user using table per type with each sub type referencing the base Events table. Or should we have a single table and a column, maybe linking to an enum saying what the event is and then another column containing the primary key to that object but we won't be able to enforce referential integrity (maybe with a trigger but not ideal and not full proof). The pros for a single table are speed, no joins, simpler to build/maintain, etc. The cons are no referential integrity, we are using EF and table per type does work very well, on the other hand we produce a lot of reports and these are direct SQL sprocs for speed and the joins will become pretty heavy. How do people normally come down on a situation like this? Many thanks for any insight into existing systems with similar problems and helping us settle this decision.


Is Extreme Programming (XP) incompatible with ideas expressed in Peopleware?

I have just finished reading Peopleware (DeMarco, Lister) and have researched on Extreme Programming (XP) a little before. As I see it now, the two approaches are almost exclusive to each other. Peopleware suggests to isolate programmers from any disturbance and sets priority on uninterrupted work in order to help programmers to achieve flow. XP on the other hand proposes to ensure as much communication as possible, even suggesting for programmers to "sit together", code in pairs and generally work in the same room (generating a lot of noise). Are those two competing schools of thought, is perhaps one of them proven right/wrong or is there an effective compromise? I can see the points both sides make, but can't see any reasonable compromise. I am very new to studying software development management, so it's possible that I just misunderstood something. All comments welcome. P.S As an added mini-question, as a programmer, which would you find more productive?


How to deal with tautology in comments?

Sometimes I find myself in situations when the part of code that I am writing is (or _seems to be_ ) so self-evident that its name would be basically repeated as a comment:               class Example     {         /// <summary>         /// The location of the update.         /// </summary>         public Uri UpdateLocation { get; set; };     }      (C# example, but please refer to the question as language-agnostic). A comment like that is useless; what am I doing wrong? Is it the choice of the name that is wrong? How could I comment parts like this better? Should I just skip the comment for things like this?


How to implement Facebook leaderboard game for mobile?

I am in the final stages of developing an indie C# mobile game that I will deploy to iPhones and Androids using Mono. I wish to add push notifications and a Facebook leader board feature into the game, such that the user will be presented with a list of all his/her friends that are playing the game and their weekly scores in the main screen. I have **ZERO** experience with web development/networking/databases. I recently started researching the field and formed a basic understanding. Facebook has SDKs in PHP, JavaScript, obj-c and java, tho reading the documentation examples still feels cryptic to me since it involves web/server tech. After researching some more, I understood that my options for server side are basically PHP or ASP.Net. It seems that ASP.Net is more favorable in my case since I am already proficient with C# (but there is no ASP.net SDK from Facebook... I am not sure if this implies that I cant interact with Facebook using ASP.Net). On the down side some have mentioned higher costs for ASP.Net, tho I havent looked further into that aspect yet. I also understood that JavaScript is client side technology. I started going through tutorials of ASP.Net, I was thinking that ASP.Net is a purely server side management language, but it started feeling more like WPF as those tutorials started getting into very lengthy discussions about creating website interfaces and styles. I am not interested in that, I just want to have a web server which my app can somehow communicate with and get friends/scores. Am I learning the right technologies for my goal? should I be learning something else? I am posting this in hopes that someone who knows this field well can see through my problem and help guide me, otherwise I could spend months studying something that might not be the right solution to my goal. Thanks.


Best Ruby Git library?

Which is the best Git library in Ruby to use?   Git, Grit, Rugged, Other? Background: I'm the current maintainer of TicGit-ng which is a distributed offline ticket system built on git, and I've read and heard over and over again that Grit is the one I should use because it supersedes the Git gem, but there seems to be either a lack of documentation or a lack of features because myself and others have failed in trying to switch from the deprecated-but- functional Git to the newer Grit gem.