Filtering a List

I will try to simplify my problem. Let say I have a collection (more specifically a List) with different types of elements, for explanation purpose let say we have objects "Person" with different age of birth and an ID. I will represent a person like this: `{<id>,<year>}` At some point, I want to get a sub list of all the persons born on 1988 and 1989, and **if** there is **no** persons born on that years, I want all the persons born in 1990:               [{1,1988},{2,1988},{3,1982},{4,1995},{5,1989},{6,1989},{7,1990}] ==>      [{1,1988},{2,1988},{5,1989},{6,1989}]               [{1,1990},{2,1981},{3,1983},{4,1993},{5,1981},{6,1989},{7,1990}] ==>     [{6,1989}]          [{1,1990},{2,1981},{3,1983},{4,1993},{5,1981},{6,1985},{7,1990}] ==>     [{1,1990},{7,1990}]      ## Option 0 At first I though about using the filter method on the apache commons library, but this wouldn't work as I would need to know about all the element on the list to decide if a particular element goes on the sub list or not, so I ruled this option out. ## Option 1 Then, the simplest way I can see to do this is loop through the list looking for elements that match the first condition (1988 or 1989), and then, if I can't find any, loop again to look for elements that match the second condition (1900). But I don't like this because you have to loop through the list more than once. ## Option 2 The other option I can think about is to loop through the list only once, and to have two different sub list, one with the elements that match the first condition and another with the elements that match the second condition. At the end, if the first sub list is empty, we return the second sub list. Which one of these two is better (more efficient)?   Which would you use and why?   Do you think there is a better solution than these?


Good practice for returns in Python

I was recently working on some prototype code in Python. The code worked great, then I realized that I needed a little more feedback from one of my functions so I changed the return statement from               return x      to               return (x,y)      Then going back to refactor existing code I realized that unless I search for invocation of this function across entire of the code base I won't know of any problems until run-time (and if this is some marginal case) barely ever and risking the program crashing due to uncaught exception resulting in operations on mismatched types. I contrast this with statically typed languages, where at compile time I get told about all places where the return doesn't mismatches expected type. So I was wondering whether there is some conventional wisdom associated with the return types in Python to avoid this grepping through code nonsense. P.S> Obviously better design patterns would solve this problem or not using duck typed language, but sometimes one comes across a case when you got to change the return type.


Preferred method for handling Failed CRUD operations in Entity Framework (6)?

I am using EF 6 as my ORM. I am trying to decide how to handle CRUD failures. ### Option 1: Use exceptions (custom or built-in) to inform the web layer that an item didn't correctly save. Handle the exceptions at the Web Layer as either error messages to the user or to trigger an AJAX post to try again depending on the reason for the failure. ### Option 2: Use some sort of object as a wrapper for CRUD operations. Return an enum and a message. Writer an object parser at the Web Layer as either error messages to the user or to trigger an AJAX post to try again depending on the reason for the failure. I am also open to other ideas. These are the two that I have come up with. I am using DB first on a legacy database. This database structure is poor at the very best. The current way issues are handled, is by returning an object that holds an enum and message. The majority of the applications hitting the database is used in winform apps. I just happen to be writing the web applications that hit them.


Will the Facebook apps I build still be available if I deactivate my account?

I have no desire to have a personal Facebook account, I do have one but it has been deactivated for awhile. A client of mine would like me to port over a few web apps to Facebook that are hosted on his domain, and it looks like I am unable to with my business account which makes absolutely no sense to me seeing as it is for a software development company that I own and operate. If I were to temporarily activate my personal Facebook account to create a few apps, will they still be available in the marketplace, I believe it's called "App Central", if I then later deactivate the account used to create them?


Objective-C class cluster pattern

I have many sublcasses of one class. I choose concrete class based on type (simple enum). I like idea of class cluster. Should i use it or just create factory class (but each class in objective-c is actually a factory)? What is the difference between factory pattern and class cluster pattern. When to use it in your code and why?


RESTful API design. What should I return if there are no rows?

I'm currently coding an API for a social network with the Slim Framework. My question is: What are the best practices when there are no rows to return in the json structure? Lets say that this call **/v1/get/movies** returns 2 rows from the table movie names:               [         {"name": "Ghostbusters"},         {"name": "Indiana Jones"}     ]      But, then I call **/v1/get/books** and there are no rows in that table. Should I just return an empty structure?               [     ]      ...or would it be better a message and an error code?               [         "errors": {             "message": "no matches found",             "code": 134         }     ]      Which is a better practice? (the API will be used in iOS and Android apps) Thanks!


Is it worthwhile to create a knowledge map for software?

Basically, the objective is to create a visual representation of the software specification document. This visual representation would capture various scenarios involved in the software. Benefits:   * Picture speaks louder than words   * Catch scenarios so that they need to be handled by the developer   * Becomes a knowledge map for others   * Can be used as a reference   * Can be used for knowledge transfer as well. Ideas:   * If possible, we can dynamically modify the visual representation to add scenarios when site issues are found and they were not identified initially. I do not know how to do this. But I would like to invest time to find out how to do this. But is it worth the effort?


Software failure due to maintenance oversights example/case study

I'm doing some investigation into the role of maintenance in software development and the use of metrics within the development cycle. What I am asking is for a point in the right direction or possibly a direct example in which there has been software failures due to the oversight of maintenance costs. More specifically I am looking for a case in which an implemented system has failed as the costs/effort for maintenance has been far too great as there has been poor or no projections from metrics. I understand this is a very specific question, but I've been racking my brains thinking of all the software failures I know of and none of them fit the criteria.


False friends? Keyword "static" in C compared to C++, C# and Java

To me, the use of the keyword `static` in C and languages like C# and Java are "false friends" like "to become" in English and "bekommen" in German (= "to get" in English), because they mean different things. In C `static` means, that the function or variable is only accessible via functions inside the same source file, comparable to `private` functions and members in C++, Java and C#. In C++, Java and C# `static` means, that the methods are not members of a class instance, but effectively are more or less like C functions plus namespace. IMHO these two concepts are quite different, so why did the designers of C++ and later Java and C# choose the `static` keyword for that behaviour? Is there a logical connection that I miss? **EDIT** I know, that `static` in C does not govern accessability in a way similar to `private` in C++, but can be used in that way, see http://stackoverflow.com/a/1479639/124983


How to keep .Net assemblies relevant through high-flux period

How much do you, as .Net developers, consider the changes between Windows XP, 7, & 8 when choosing your development environment and libraries? We are nearing the end of Windows XP; Windows 7 is noticeably and aggressively making it's mark; Windows 8 (Win R/T) is on the horizon. Granted, **flexibility** is completely expected from the customer's perspective. But we are faced with developing to the current OS, Windows 7 ( _understandably, some may argue the current OS is still XP_ ) ...and maintain legacy code for the outgoing OS, WinXP. So, Windows 8 and all the Win R/T goodness flares the imagination and you can't help but ask yourself, " _what will still be relevant in 5 years?_ " Well, at least I can't help but ask the question. During periods of rapid evolution of an OS, what considerations do you plan for in application design, libraries, frameworks, and choosing development environments; and, in doing so, how do you determine the length of relevance a particular design will have?


What makes a large and complex software product slow?

For a reason that is largely irrelevant, I installed Delphi 7 once again in such a long time. I have to say, I was completely blown away - in a way I haven't been for rather a while. This is not how I remember things at all. The installation took around 30 seconds. Launching it took 2 seconds, and it was immediately usable. I can press "Run" the second after it started, and less than a second later the blank program is already visible and running. Hurray for computers getting so much faster! But the reason I've been blown away like this is because usually I use Visual Studio 2010, that doesn't feel snappy like this at all. Granted, Delphi 7 is a much smaller system than Visual Studio 2010, but it does have the _appearance_ of having all the really necessary things there: a control palette, a form designer, a code editor with code completion. I realise that the language might be simpler, and the code completion might be a lot less powerful, and the IDE might not be nearly as extensible and feature-rich, but still: I do not understand how (i.e. through what mechanism) does having a lot of extra features (that I might not have even triggered yet) cause a system like Visual Studio to always feel sluggish in comparison. I would like to ask people experienced in working with systems the scale of Visual Studio: what is it that makes them slow? Is it the layers upon layers of abstractions required to keep the codebase within the human comprehension capabilities? Is it the sheer amount of code that needs to be run through? Is it the modern tendency towards programmer-time-saving approaches at the (mindbogglingly huge) expense in the clock cycles / memory usage department?


What is the best pattern for adding an existing item to a collection in REST API?

I'm designing a pragmatic REST API and I'm a little stuck on how best to add existing entities to a collection. My domain model includes a Project that has a collection of Sites. This is a strict many-to-many relationship and I have no need to create an entity that explicitly models the relationship (i.e. ProjectSite). My API will allow consumers to add an existing Site to a Project. Where I'm getting hung up is that the only data I really need are ProjectId and SiteId. My initial idea was:               1. POST myapi/projects/{projectId}/sites/{siteId}      But I also thought about               2. POST myapi/projects/{projectId}/sites      with a Site entity sent as JSON content. Option 1 is simple and works but doesn't feel quite right, and I have other relationships that cannot follow this pattern so it adds inconsistency to my API. Option 2 feels better but leads to two concerns:   * Should I create a Site or throw an exception if a new Site is posted (SiteId = 0)?   * Because I only need ProjectId and SiteId to create the relationship, the Site could be posted with wrong or missing data for other properties. A 3rd option is to provide a simple endpoint solely for creating and deleting the relationship. This endpoint would expect a JSON payload containing just ProjectId and SiteId. Please help me break out of this analysis paralysis!


What can we learn from esoteric languages?

Esoteric languages are intriguing and can make you go 'Hmmm...', but what can we really learn from them? Is there a benefit to spending more than 5 minutes trying to write an application in an esoteric language? Have you tried one, and if so, what did you learn?


Global constant values throughout MVC site

My MVC (.NET) has some constant values through out the site, such as the phone number, physical address, email address etc. I'd like to store this value once, so future updates are easier for when they change their details. To make my question simpler, I've only focused on phone number. My question is where and how to store this number and a problem I'm facing with my decision. At the moment, I've chosen to store it in the Global.asax file as a static method, eg               public class MvcApplication : System.Web.HttpApplication     {         protected void Application_Start()         {            //logic         }              public static string GetPhoneNumber()         {             return "012345 678 910";         }     }      This works very well, in my controller I can add references to this method and assign it to a ViewBag                 public ActionResult Contact()       {             ViewBag.Phone = MvcApplication.GetPhoneNumber();       }      As per many sites, the phone number will be visible at the top of every page and as such, placing it in the `_Layout.cshtml` is logical. The problem I have is there is no controller (not that I know) for the _Layout.cshtml and the only way I can pass the value is to have a ViewBag.Phone set up for every view, EG               public class HomeController : Controller     {         //         // GET: /Home/              public ActionResult Index()         {             ViewBag.Phone = MvcApplication.GetPhoneNumber();             return View();         }              public ActionResult About()         {             ViewBag.Phone = MvcApplication.GetPhoneNumber();             return View();         }              public ActionResult Contact()         {             ViewBag.Phone = MvcApplication.GetPhoneNumber();             return View();         }      This is messy and smelly but I have no idea how I can improve this. Should I be storing my global variables in a different place or is there a better approach for this as I'm sure this is a common problem.


Is is acceptable to create mediocre code now in preparation for new language features?

I'll be specific: Java 8 is promised to bring lambda expressions as well as method and constructor references among other things. As a Java developer I'm super psyched about that. In my day to day programming I see more and more opportunities where using these features would greatly simplify code that would otherwise be very verbose and tedious. In lieu of method and constructor references I started using more and more reflection and plan to migrate those code paths to Java 8 as soon as possible. I use special comments (like the well known TODO comments: JAVA8) that can be used by the IDE or grepped easily in order to find the relevant places. I also test all those cases extensively to make sure they work. But still I have to wonder whether it's good to do it like that. Is it acceptable to produce a little more brittle code now that will eventually become robust again? GA for Java 8 is September 2013 so it's not too far in the future (provided the release date doesn't slip). A kinda general example would be something like this: I want to create some container objects and fill them with data from a database. If I were to use the standard Java approach, it could look like this:               class ContainerService {       private Database database;       private final Map, ContainerInitializer> INITIALIZERS = new HashMap();            {         INITIALIZERS.put(Foo.class, new FooInitializer());       }            public Container getContainer(Class cls) {         return INITIALIZERS.get(cls).create();       }            interface ContainerInitializer {         Container create();       }            class FooInitializer implements ContainerInitializer {         Container create() {           return new Container(database.getFoo());         }       }     }      The reflective code is               class ContainerService {       private Database database;       private final Map, String> INITIALIZERS = new HashMap();            {         INITIALIZERS.put(Foo.class, "getFoo");       }            public Container getContainer(Class cls) {         Method m = Database.class.getMethod(INITIALIZERS.get(cls));         return new Container(m.invoke(database));       }     }      Note how all the intermediate interfaces and classes fall away. The Java 8 variant is something along the following lines:               class ContainerService {       private Database database;       private final Map, ContainerInitializer> INITIALIZERS = new HashMap();            {         INITIALIZERS.put(Foo.class, database::getFoo);       }            public Container getContainer(Class cls) {         return new Container(INITIALIZER.get(cls).create());       }            private interface ContainerInitializer {         Container create();       }     }      This is slightly longer again but has type safety. Also it's trivial to get from the prepared code to the final code using method references. Of course the example is a bit simple. Imagine having a lot of types the container could contain. In the first method, there would be an extra class for each of them. In the other two methods, only data has to be added. It keeps everything so much simpler.


My university doesn't provide php courses because it is an "easy" programming language?

I've met a student from the computer science department and I discovered that they only teach java and aspx. I asked him why they didn't teach php since it is the top one programming language on the net. He says that it was a "easy" (or hobbyist's) programming language. I'm not sure what that means. What's your opinion?


Which programming methodology would be a good fit for us?

Unfortunately, somebody has taught our upper management the word "Agile" and now they want us to move towards it. I have a peripheral understanding of agile (in principle) but have never used it in practice. From what I know, it will not be a good fit for our organization. Right now, things are pretty grungey. Here's how it is; We're a very small team - two developers, one DBA, one designer. The company I work for makes a disproportionately large amount of money relative to its size, and nearly 95% of that is pure online sales. From a development perspective, we are subjected to many desk invasions during a typical day (we're tech support as well as dev), work can regularly just fall out of the sky at a moments notice if a sales team member promises something to someone. We do undertake larger projects too, and they're a nightmare with the constant interruptions. Some of us are starting to tear our hair out! Project plans are drawn up by non technical managers in excel spreadsheets, where they try and break the task down into bite-sized sentences that they can understand and put a date beside each one. These dates are always hideously unrealistic and often missed, and our meetings (which we have around weekly) are regularly filled with awkward moments with people asking "why hasn't this been done yet". I am pretty sure Agile isn't the one for us. Now, given that (and i have tried) this company _will not change its ways_ , and only the dev team is willing to change, is there a development methodology that we could adopt which is a good fit for just saving us some sanity?


Violating SQL principles

I have to write a decent size database, 1GB more or less. I have only taken an introductory semester regarding SQL databases. During the course we learned that the relational model under SQL has no implied order and that therefore when querying we should always have a variable that sets the correspondant order in the table. However, when doing practical work I find 'convenient' to make already ordered small, infinite number of tables. For example, lets say that you have 5 clients and that their info will never join their data together. Is it admissible to have a potentially infinite number of tables with a table per client? For example, I append new rows already ordered to the database. The database is already ordered. Is it admissible to make an unordered query and just assume that is implicitly ordered? All this violates the principles that I know. My boss, who does not know about databases says that if it works it works and that speed is important. What shall answer to him?


Using partially implemented interfaces

Consider the following hierarchy in C++ notation:               class A         {         public:             virtual void doStuff()=0;             virtual void doOtherStuff()=0;         };          class B:public A         {         public:             void doStuff();             void doOtherStuff();         };          class C:public A         {         public:             void doStuff();             void doOtherStuff();         };      Now, assume that the code for doStuff is identical in B and C. What is the best practice of   * implementing doStuff in a class D:public A and let B and C derive from A   * Let the real task be performed in a function that is called from doStuff in both B and C Somehow the latter seems more clean, is it? It should be noted that there are other methods in B and C with common implementations as well, and that in the underlaying model, the concept of D does not exist.


What does it mean to be a game developer?

I'm a .NET developer and mostly builds GUI's but of course also pure C# due to architecture and database level needs. To me, developers of games in discussions often being simply referred to as "gaming developers". I find that a little too shallow and I'm curious what a "gaming developer" really stands for. What would we, in turn, be to a gaming developer? Are there ever conversions from one direction to another and what are the main differences in a regular development process?


Thinking of simultaneously coding the same project in two languages. Good Idea?

Is this a good way to learn a new language? Or to develop a preference of one language? I was thinking of coding a project in both Python and Java. The only foreseeable problem is trying to transfer solutions that should be rethought for each language. Or is this unnecessary? (My intentions aren't to benchmark.)


Best strategy to discover a web service in a local network?

I am currently doing some research for a project. The setup is simple, I have a computer running a service in my home network and any device connected to that same network should be able to discover the service automatically and use it. I have no specific technology requirement whether it is on the server or client side. The client knows about the service definition. Other than that I have no idea what strategy to use, what technology to look at or whether I should go for a SOAP or a HTTP based service. I think going HTTP with REST API is the best for targeting all devices but I am opened to any suggestions. Thanks.


SLF4J vs LOG4J Which one to prefer?

I have seen this question but does not answer me. It have a brand new project. I have almost always used Log4J but now I am seeing SLF4J making some waves. What is it that Log4J could not do and we needed SLF4J? Is it really an upgrade. Should I use it in a project which will also have an API for other to extend upon?


How can I find the root of confusing problems?

Several times after posting over at Stack Overflow, I have found that the problem I have is somewhat specific, and may have issues rooted elsewhere in my code. These are very difficult to solve with a question, and I often end up getting poor or irrelevant answers. When a problem is just too localized or to complex for Stack Overflow to be any use, what should I be doing to break down the problem so it can be solved? How can I approach peers or user groups about problems like these?


New PHP project, how to best architect it

I have already done a PHP project, and I did a number of things pretty wrong :) I just had all pages as scripts with php mixed in with html. I also wasn't using a framework like cakephp. And I didn't really use objects, nor had any sort of test suite. :) This time around I want to get it right. What should I do in terms of good practice approaches? And what am I ok not using? Any suggestions? Tips?


What should I study to be able to join a C++ open source project?

I am learning C/C++/Oracle/Unix. I am thinking of developing some application on my own, but I have no Idea what else is required. If you take an example of C++. I have very basic knowledge of it (data types, OOP concepts, vectors, file handling, exception handling, etc). I am not an expert though. I have just read one book about C++ and don't know much about graphics in C++. I went to codeplex.com (an open source website for programming and development) they had some projects in C++ that are looking for developers. Now this looks way beyond my knowledge but I want to buld something. If not, I want to learn more to do it but I have no clue where to begin and what material topics, books to read. There so many things involved with an application: .exe files, .dll files and many more 1) Am I thinking in the right direction? 2) Is it possible to do it alone or be a part of such big open source projects online? What are the things that I need to collect online and study? Please help, if possible please provide the topics, books, websites that might help me to study and proceed to achieve my goal.


Does "Property" in C# cost much?

I have a class created in some namespace, like `SomeNameSpace.SubNameSpace.StaticClassName` Here is a code snippet from other code file where I want to use this class many more times, so I created a property in the code file like this               //Just to provide an Alias for long name "SomeNameSpace.SubNameSpace.StaticClassName.PropertyName"     public StaticClassName ServerProxyAlias     {         get         {             return SomeNameSpace.SubNameSpace.Instance.PropertyName;         }         set         {             SomeNameSpace.SubNameSpace.Instance.PropertyName = value;         }     }      **Is there any problem in doing like this ?**


What good reasons are there to capitalise SQL keywords?

There seem to be a lot of developers who write their SQL by capitalising the keywords:               SELECT column     FROM table          INNER JOIN table          ON condition     WHERE condition     GROUP BY clause     HAVING condition      I'm wondering why people stick to this approach? Clearly, it's a long established convention - but I've never run into a RDBMS that _requires_ capitalisation. Personally, I find KEYWORDS THAT SHOUT to be calling attention to exactly the wrong part of the query, which is why I write the keywords in lowercase. Still, enough people use this convention that I figure I might be missing something, hence this question.


How do you cope with "brain farts"?

From the Jargon File: _brain fart: n.   The actual result of a braino, as opposed to the mental glitch that is the braino itself. E.g., typing dir on a Unix box after a session with DOS._ I've been working with JavaScript and Python lately and have made errors like typing, in Python,               function foo(argument1, argument2):      This isn't pure JavaScript, but it also doesn't work in Python. One of my recent posts, http://serverfault.com/questions/506403/why-is-my- root-url-serving-up-a-404-under-apache/506452?iemail=1&noredirect=1#506452, was about why a pure, simple, working, and rather small DocumentRoot contents were not showing. The answer was that I made a mistake that I do not remember making in years of dealing with Apache: I had included commas betweek ServerAlias entries, and that was why the (perfectly appropriate) DocumentRoot was giving a ServerError. (And did I mention that I've been spending a lot of time coding where separating by ", " was the appropriate way of separation?) Is this sort of thing just non-negotiable? Or are there ways to mitigate and compensate for them?


What will generate an adjacency matrix file with a specified topology for me?

I am writing an application that takes some file specifying an adjacency matrix and uses this to construct a graph (in this case, a directed social network). What I would like to do is specify the size of the matrix and then have it generate an adjacency matrix with one of these topologies: ring, hierarchical, fully-connected, random and smallworld (every node x degrees of separation from each other). Ideally a text file would be the output. I can't create these files manually because the size is in the thousands^2... Fully-connected and random aren't 100% required but they would be nice, I can just implement them in code. I read a dissertation which specified it used an application located at http://ww2.cs.mu.oz.au/~tmill/graphtastic.tgz ...but it does not seem to exist anymore so I am not sure what to do. I thought there would be loads of applications such as this out there, but I can't see any. So, is there an program out there that could generate an adjacency matrix with a configurable topology into a text file ?


Agile User Stories and acceptance criteria

I am writing some agile user stories and acceptance stories for the first time, and was hoping for some feedback from an experienced product manager or developer. I only need to capture the main points in the acceptance criteria. ## User Story AS A registered jobseeker, I WANT TO create and edit my CV on the user interface on my mobile device SO THAT employers and recruiters can view my career summary and contact details ## Acceptance Criteria   1. The user must sign into a registered account to create a CV   2. The user cannot save a CV unless all the mandatory fields on the form are complete    3. The user should be able to edit and delete the form at any time   4. Data from the saved form is stored in the CV database   5. Only registered Recruiters and Employers can view the users CV and contact details    6. The jobseekers user account is linked and synchronised on both mobile and desktop versions Does this acceptance criteria sounds suitable for the given user story? Is there any way they can be more focused, and if so how?


For definitions and examples of "state", see: http://en.wikipedia.org/wiki/Program_state , http://en.wikipedia.org/wiki/Finite_state_machine , http://en.wikipedia.org/wiki/State_diagram A diagram showing a very easy example, notice how the current state changes how the turnstile operates when the same input (inserting a coin, pushing on the turnstile) is given twice in a row: http://en.wikipedia.org/wiki/File:Turnstile_state_machine_colored.svg I thought about this question for a bit and came up with nothing other than:   1. Reduce the scope/features of the project/software.   2. Push the burden of making intelligent decisions to the user and/or supply the program with a "cheat sheet" that makes decisions easier (for example: instead of trying to write a program that drives a car using only two webcams, you could embed waypoint markers in the road every 100 ft, place special reflective markers in between lanes, and use a database of terrain maps to help the program make decisions; one would require the work of a Tesla/Newton -level genius [assuming the program can do things like (1) dodge animals, the remnants of exploded tires, etc. while taking less drastic measures for things like cardboard and plastic bottles, (2) deal with the occlusion of landmarks and indicators caused by other vehicles, (3) adjust to weather, etc. conditions, and so on] vs. someone who can write a "connect the dots" algorithm) PS: I would classify these two methods as "cheating" because you are significantly changing the input/output of the program. In the first case, you are whittling away your program to nothing, and in the second, you are shifting much of the burden of decision-making onto whoever maintains the database and transit system. Are there any valid ways of eliminating/reducing state?


Using "Context-based" CSS Class Names

This morning I found a note on my desk with some tips from a higher up developer who had been looking over some HTML/CSS I had put together. One of his suggestions was for me to "stay away from context-based class and ID names like 'left' or 'right.' Never use colors as names. Stick to semantic names based on the content." Is this valid advice? Why?


Suggestions for tree (as a visualization tool) editing software?

I'm trying to generate a call tree for code I'm working on (I didn't write it) to help me understand it. I want to be able to manually enter each function and the functions it calls (as children), thus building the tree. But I'd like it to automatically organize and position the chart so that nothing overlaps without my having to move everything around every time I add something. For example, here's the structure of the kind of data I'd want to put in, in crappy Lispesque format:               ( initAll //root node       ( //root node's children - functions it calls         ( initDisplay () ) //this child is a leaf         ( initControlBar            ( //initControlBar's children - functions it calls              ( addButtons () )              ( setUpControlBarEvents () )            )         )         ( alertUserSystemReady () )       )     )      I guess it could be a graph tool (trees being a subset of graphs, of course), but I don't imagine a graph tool would have the ability to automagically put things on the right level. What I like about organizing this data as a tree is that there are distinct levels, which helps me visualize what's going on. I've tried yEd and LucidChart, but both were too manual for me. Since the tree is going to go pretty deep, I need something that can automatically restructure with the tree data. I also tried GraphViz, but couldn't get it working (I'm on Windows and didn't know what to do after the install). Google isn't helping much on the tree editor end - it's giving me pages like http://bioinfo.unice.fr/biodiv/Tree_editors.html which just have way too many to choose from. In this case I think using others' experience would be better, so I came here. So, anybody know of any tools that would get me closer to my goal? Thanks!


how to reduce or stop duplication of relation's entry in treeview

I want to create tree-view for display or show family member's relation. For this I created 3 tables i.e following.               familyDetails->[f_id,fname,lname]     relations -> [r_id,relation] .....//e.g father,mother,son,etc.     familyRelations ->[fr_id,fk_f_id1,fk_r_id,fk_f_id2]      //to show A is Father OF b.      Here problem is, if I say A is father OF B and C than it'll make one entry in `familyRelations` table. But here it will also create one more entry for B is daughter of A. So in opposite relation (e.g father->son or son->father, etc ) it'll create entry for all case. So if there are N no of people in family then it'll create N * N entries in familyRelations table. How to define relationship with other members. This flow is right or need to change? I am confused in this. So how to solve this problem. Or is there any another way?


Package software separately from content that is CC BY-NC-SA 3.0 license

I have content that is CC BY-NC-SA 3.0 (see http://creativecommons.org/licenses/by-nc-sa/3.0/), can software that uses it still be produced commercially and just let the user download the content separately? In other words, if I have commercial software that uses the content with CC license, can the software still be distributed as commercial and just not be distributed with that content... OR, would that still violate that CC license and the software therefore can't be commercially sold? If someone knows the answer or can point me to a place to find out the answer, I would really appreciate it. Thanks!


How do I learn the right approach to implement half a feature?

I lead a development team and I want to release our product as often as possible (Continuous Delivery). In many cases, we have to implement a feature that takes longer to implement than the time between releases. I still want people to commit their code on a daily basis (Continuous Integration). Many times implementing a new feature requires existing feature to be changed and the existing features, of course, still need to work, even if the new feature is not finished yet. If the developer uses the **right approach** , they can adjust existing features carefully and all of the above is not a problem. However, what IS the right approach actually? My own programming attuned mind tells me what to do for each individual case, but I need to learn more and I need some reading material that I can read and refer team members to read. Or any other method of learning the right way to learn this approach will do. So that's the question. **How do I make sure team members learn the right approach to implement half a feature?** I've searched for people claiming to have strategies regarding this, but haven't found it yet, except people writing a few random thoughts on the topic. Perhaps I'm not using the right search words or perhaps no one has made any authoritative guidelines on this. **UPDATE** I selected the best answer, but the nature of the question made it difficult to make one clear all-covering answer.


Business Equity for Code. Is it advisable to enter into such agreements?

I have been considering this approach for a project I am about to embark upon and would like to hear from other programmers about their experience in contributing code for equity. Has anyone been truly successful in such an endeavour.


What are bit operators good for?

Programming languages often come with various bit operators (e.g. bitwise left- and right shift, bitwise AND, OR, XOR...). These don't get used though very much, or at least such has my experience been. They are sometimes used in programming challenges or interview questions, or the solution migh require them, e.g.:   * Without using any equality operator, create a function which returns `true` when two values are equal   * Without using a third variable, swap the value of two variables These then again, probably have few **real world** uses. I guess that they should be faster because they directly manipulate memory on a low level. Why are such found in most programming languages? Any real world use cases?


Bits manipulation in C

I am now studying computer system in my college, and now we are learning about bits manipulation in C. And I am just curios, how can by learning bits manipulation can help us to make a reliable code ? what is it for when it comes to the real world problem? and in what way it is very useful in our program ? thank you


Advantage of using Swing over AWT

Why is Swing preferred over AWT? Which Swing component could be used for playing a video on it?


Are there any (free) video formats that include channels for arbitrary time-dependant data?

I'm in the process of writing an image analysis pipeline and I've hit a bit of a roadblock. Here's the 30,000-ft view:   1. Images arrive as base64-encoded PNG images over standard input   2. Images are decoded, and processed. I don't think the details are particularly relevant, but I am happy to offer specifics in the form of an edit.   3. When the analysis is complete, the **entire stream** must be concatenated into a seekable, timestamped format (that is, a video file of some sort) and saved to disk. My question pertains to `stage 3`. At this final stage of the pipeline, each frame will have a set of associated features that were extracted via the image analysis performed in `stage 2`. I would like for the final output format (the video format) to preserve this information alongside the frame that "owns" it. In other words, one should think about this as a separate channel that evolves alongside the video data, locked to the same time reference. This would notably allow me to treat features as time-series. Here's a simple diagram to further illustrate what I'm trying to achieve.               -0 ms--16 ms--32 ms--48 ms--64 ms- ... n ms ->  # time channel     -F1----F2-----F3-----F4-----F5---- ... Fn --->  # video channel     -1.1---3.6----5.0----2.6----3.1--- ... 11.2 ->  # data channel 1     -100---105----120----96-----101--- ... 52 --->  # data channel 2      As you can see in the above schema, there are two data channels (although, ideally, the format should support an arbitrary number of channels) whose values evolve over time. Note that the `time` channel need not be an actual channel, _per se_ , but was illustrated as such simply to show that video and data channels are represented as a function of time. At the very least I'd like to be able to populate each "index" of each channel with an int or a float. Ideally, however, I would like to be able to hold a reference to some binary data of arbitrary length. In addition to providing the above functionality, this hypothetical codec should support some form of modern video compression. Does such a thing exist?


"Viral" license that only blocks legal actions of user and developer against each other

I was thinking a lot about software licensing lately, because I would like to do some coding. I'm not an expert in all those licenses, so I came up with my own idea, and before I will put in on paper, I would like to make sure that I didn't reinvent a wheel, so maybe I would be able to use something that exists. Main idea behind my license is to guarantee freedom of use the software, but not "freedom to" (positive) (e.g. freedom to having source code), but "freedom from" (negative) (strictly from legal actions against you). It would be "viral" copyleft license. You would be able to without fear do everything you want with the software (and binaries e.g. reverse engineering), as long as You will include information about author and/or authors, and all derivative works will be distributed with the same license. I'm not interested in anything that would restrict a freedom of company to do something like "tivoization". I'm just trying to accomplish something that would block any legal actions of user and developer, targeted against each other, with the exception of basic attribution. Does exist something like that?


What is the best solution for an API class that could have different end points? (iOS)

What is the best approach for creating a singleton API class, where different requests could call different api providers and how to manage this? For instance you might have a singleton class 'API' that could have a couple of methods such as               getProduct     getImage     getUser      What is the best way to manage this, but in theory getProduct needs to call api.website1.com getImage needs to call api.website2.com/v1/ getUser needs to call api.website2.com/v2/ But there's nothing to say that getImage might end up using website1.com in future or that getUser might end up using /v3/ I'm trying to think of a good way to manage this where the endpoints (and credentials) could potentially change for the different request, but for a developer just consuming the singleton API class, they aren't fussed where it actually comes from. I think the right approach is to make sure the requests conforms to a particular interface (regardless of where it comes from e.g type User) but I think it's the config around instantiating the correct API request type and the right credentials that I'm struggling to get my head around. I'm guessing a factory that returns the correct provider would be a good way to go, but instructing that factory to return the correct provider is proving difficult. This is iOS based, but any conceptual ideas would be appreciated thanks


When should var be used instead of declaring an explicit type?

var Id = from value in Enumerable.Range(0, 100)                                   select value;                  IEnumerable<int> ids = from value in Enumerable.Range(0, 100)                                   select value;                            foreach (var v in Id)             {                 Console.WriteLine(v.ToString());             }                  foreach (var x in ids)             {                 Console.WriteLine(x.ToString());             }      Both will do the same job, but what is the difference?


Design Application to "Actively" Invite Users (pretend they have privileges)

I am designing an application where users message one another privately, and may send messages to any `Entity` in the database (an `Entity` may not have a user account yet, it is a professional database). I am not sure how to best design the database and the API to allow messaging unregistered users. The application should remain secure, and data only accessed by those with correct permissions. Messages sent to persons without user accounts serve as an invitation. The invited person should be able to view the message, act on it, and complete the user registration upon receiving an `InviteMessage`. In simple terms, I have:               User         misc user fields (email, pw, dateJoined)          Entity (large professional dataset):        personalDetails...         user->User (may be null)           UserMessage:        sender->User         recipient->User        dateCreated        messageContent, other fields.....          InviteMessage:        sender->User        recipient->Entity        expiringUrl        inviteeEmail        inviteePhone      I plan to alert the user when selecting a `recipient` that is not registered yet, and inform that he may send the message as an invitation by providing email, phone where we can send the invitation. Invitations will have a unique, one-time-use URL, e.g. `uuid.uuid4()`. When accessed, the invitee will see the `InviteMessage` and details about completing his/her registration profile. When registration is complete, `InviteMessage` details to a new instance of `UserMessage` (to not lose their data), and assign it to the newly created `User`. The ability to interact with and invite persons who do not yet have accounts is a key feature of the application, and it seems better to separate the invitation from the private, app messages (easier to keep functionality separate, better if data model changes).   * Is this a reasonable, good design?   * If not, what would you suggest?    * Do you have any improvements?   * Am I correct to choose to create a separate endpoint for creating invitations via the API?


Are there such thing as assembly SDK's?

I've never worked in assembly, but I was just curious if SDK's exist for assembly programming. For instance, if I wanted to create a linked list, are there libraries available that have already done this, or is everything typically done from scratch?


What to include in a report on software implementation and how?

I am currently writing an extended report on a software library I have written. The reviewer will be a professor at my univeristy. He knows basically what I had to do, but the report will be evaluated. I have produced some samples results with the library which I already plan to include in the work. What I want to know know is :     * What should I write about the library itself?   * How should I structure it?   * Which points need to be emphasized? Also, the professor is as allergic to mundane implementation details as a business manager.


How to teach pointers to beginners in C?

I'll hold a little presentation about C-Pointers in a small group of people with beginners programming skills, with no CS background. Just people who would like to learn something about coding and prefer a practical hands-on approach. In fact, they are using the C-Language to do so. We are about to introduce pointers and I am very careful about the scope for the first introduction, since pointers can be quite overwhelming and confusing for the uninitiated. So I am wondering, how would you approach this topic to make it fun and interesting? Do you have great examples that really help people to understand the concept of pointers? Hint: The audience doesn't know about strings and arrays yet. Scope-wise, here is what I've got so far:   * Example: A problem that shows the limitation C without pointers and why we need something more elaborate.     * Call by reference vs Call by value example?   * Very short introduction what a pointer is and how it is denoted in C. (* and & operators )   * The difficult part: How does a pointer work? Or: How to explain a technical problem to non-technical people?     * Looking for a real work example for a referencing system. Is a library a good example?     * What is memory and how does it interact with our code and variables?     * How does a variable look like in memory? (memory allocation)     * How is this variable accessed? (address referencing)     * How can I use a pointer to access memory?   * In dire hope, people can follow this train of thought:      * Live example and practice Things I would like to omit for a part2:   * Null-Pointer   * Pointer on Pointers   * Pointer arithmetic   * Adresses vs. Pointers   * Structs   * Arrays


Estimation of your backlog

How far in advance should you estimate stories in your backlog? My concern is that estimates that are 6 months out will become out of date as you develop features in the current sprint. I thought that with agile you re- estimate your current sprint.


How common are circular references? Would reference-counting GC work just fine?

How common are circular references? The less common they are, the fewer hard cases you have if you are writing in a language with only reference counting- GC. Are there any cases where it wouldn't work well to make one of the references a "weak" reference so that reference counting still works? It seems like you should be able to have a language only use reference counting and weak references and have things work just fine most of the time, with the goal of efficiency. You could also have tools to help you detect memory leaks caused by circular references. Thoughts, anyone? It seems that Python uses references counting (I don't know if it uses a tracing collector occasionally or not for sure) and I know that Vala uses reference counting with weak references; I know that it's been done before, but how well would it work?


Are trees organised by a "firstchild, nextsibling" structure? If not, why not?

Usually, tree data structures are organised in a way that each node contains pointers to all its children.                      +-----------------------------------------+            |        root                             |             | child1            child2         child3 |            +--+------------------+----------------+--+               |                  |                |     +---------------+    +---------------+    +---------------+     |    node1      |    |     node2     |    |     node3     |     | child1 child2 |    | child1 child2 |    | child1 child2 |     +--+---------+--+    +--+---------+--+    +--+---------+--+        |         |          |         |          |         |      This seems natural, but it comes with some problems. For example, when the number of child nodes varies, you need something like an array or list to manage the childs. By using only (first)child and (next)sibling pointers instead, we get something that looks like that:                      +-------------------+            |        root       |            | child    sibling  +--->NULL            +--+----------------+               |                  +----------------+    +----------------+    +----------------+     |    node1       |    |     node2      |    |     node3      |     | child  sibling +--->| child  sibling +--->| child  sibling +--->NULL     +--+-------------+    +--+-------------+    +--+-------------+        |                     |                     |      Oviously, this kind of structure can represent trees just as well, but it also offers some advantages. Most important is that we don't have to worry about the number of child nodes any more. When used for a parse tree, it offers a natural representation for a term like "a+b+c+d+e" without becoming a deep tree. Do collection libraries offer tree structures like that? Do parsers use such a structure? If not, what are the reasons?


Testing Java as Groovy

We're looking into improving our testing process for some of our applications, and the idea that's been put forward it to write unit tests in Groovy and automatically run them with Maven. The first application to get this treatment is written in Java, but I've been told that some of the classes being tested need to be renamed as ".groovy" files * and they will then be compiled as Groovy classes, not as Java classes. This renaming can all be done using Maven and Ant, but I'm concerned that if we compile our classes as Groovy classes, we're not actually testing them as Java classes, which is how they will be deployed. During the demo, it was also shown that Groovy does not compile to the same bytecode that Java does. There was at least one Groovy-specific member that was added, called "metaClass" (there were others, I didn't get a good enough look at the screen). Apparently this is necessary for the testing framework they want to use, which is named Spock. Am I right to be concerned about this? Does it matter? * I've been told this is for technical reasons that have to do with the way the application is built. I've been told that this does not apply to _all_ classes, but to some.


Is C#-4.0 an open standard?

The Ecma-334 (ISO/IEC 23270:2006) standard corresponds to the version 2.0 of the language. Specification of version 4.0 is freely available from Microsoft, but Microsoft's open specifications list only lists the Ecma (version 2.0) version. So what about all the good features added in the later versions (LINQ, lambda functions, etc)? Can one implement them in his compiler?


Applications with duplicate data - keep separate or combine into one set?

We currently have 3 similar, but slightly different applications that use the same data. We load the (same) data into each application that uses it. The applications are similar and use the same technology (Ruby on Rails) but were developed by different programmers. In consolidating this data, our management seem the benefit to using the same tools (gems, modules, etc) but does not seem aware of many other reasons why we should consolidate things centrally. I've worked in several different organizations including one position in Data Warehousing so the centralization of data seems like a no-brainer to me. The life-cycle of the data is the following year for the current paying customer, but then also longer term as we get the data from the various organizations that have it, over the years, and we'll want to compare one org and one year to others. However I want to put together a list of all the reasons to centralize (or not) this set of data. So far I have:   * reduce duplication of effort. When we implement a function we currently may have to do it in two places, increasing both the effort to implement the function in two places and also the cost of writing it twice.   * Quality of data. Creating two data set that have similar but different contents will lead to discrepencies between the two that will grow over time, reducing the value of the data. I am looking for a list of other reasons, particularly those that relate to the overall cost.


Unit testing on visualization (3D graphics) frameworks

This is a follow up to this question. There I was asking how to do unit testing when you have a library of scientific algorithms. I have a similar problem now but with a different project. I'm working on a 3D graphics engine framework abstraction for DirectX, OpenGl, WebGl, Silverlight, WPF, and basically whatever 3D API is out there, on C#, called Rendering .NET. The scenario is the following, the project is being developed by a small team of colleagues of mine, all working in the same office. We are all computer scientists, not much into the software engineering community and practices. I even had a hard time to convince to switch from Subversion to Git, and to publish the project on Codeplex. The project is getting big (around 80K lines of C#), and it now covers most of DirectX and OpenGl up to Shader Model 5.0, so its not a one man's project like the one described in the linked question. We also want to encourage the open source community to collaborate. So far we've been testing by writing small applications that involve initializing all devices and resources, setting up a scene, and drawing. The thing is, I don't know how to make it different, I mean, how to design small test cases that test specific features of the framework, like resource allocation, primitive tessellation, shader compilation, etc., without having to recreate the entire engine initialization. For some of these cases I can think of useful mocks, but in general, how can I test the correctness of a rendering algorithm when the output is visual (an image, or an animated scene)? Right now the most clever thing we have come up is to render the same scene to a software renderer, DirectX and OpenGl, and compare them pixel by pixel, but tiny variations of the APIs make the resulting images different enough to fail the tests without being actual bugs. So, what is the "correct" testing approach here?


Why are the Java 8 java.time classes missing a getMillis() method?

Java 8 has a whole new library for dates and times in the package java.time which is very welcome thing to anyone who has had to use JodaTime before or hassle with making it's own date processing helper methods. Many classes in this package represent timestamps and have helper methods like `getHour()` to get hours from timestamp, `getMinute()` to get minutes from timestamp, `getNano()` to get nanos from timestamp etc... I noticed that they don't have a method called `getMillis()` to get the millis of the time stamp. Instead one would have to call method `get(ChronoField.MILLI_OF_SECOND)`. To me it seems like an inconsistency in the library. **Does anyone know why such a method is missing, or as Java 8 is still in development is there a possibility that it will be added later?** http://download.java.net/jdk8/docs/api/java/time/package-summary.html > The classes defined here represent the principal date-time concepts, > including instants, durations, dates, times, time-zones and periods. They > are based on the ISO calendar system, which is the _de facto_ world calendar > following the proleptic Gregorian rules. All the classes are immutable and > thread-safe. > > Each date time instance is composed of fields that are conveniently made > available by the APIs. For lower level access to the fields refer to the > `java.time.temporal` package. Each class includes support for printing and > parsing all manner of dates and times. Refer to the `java.time.format` > package for customization options... Example of this kind of class:   http://download.java.net/jdk8/docs/api/java/time/LocalDateTime.html > A date-time without a time-zone in the ISO-8601 calendar system, such as > 2007-12-03T10:15:30. > > `LocalDateTime` is an immutable date-time object that represents a date- > time, often viewed as year-month-day-hour-minute-second. Other date and time > fields, such as day-of-year, day-of-week and week-of-year, can also be > accessed. Time is represented to nanosecond precision. For example, the > value "2nd October 2007 at 13:45.30.123456789" can be stored in a > `LocalDateTime`...


What "business things" should a programmer know about their company and team?

I spend a fair amount of time reading programming blogs, and it seems to be a popular belief that having business knowledge adds value to a programmer. I can see the reasoning for this:   * Understanding the business helps programmers make wise decisions   * Might encourage less "taking too long making everything perfect" and more "getting things done"   * etc. I'm currently an intern at a major company. I've learned loads of great technical things during my time here and I've definitely developed as a programmer. However, I feel like I don't understand my team's place in the ecosystem as well as I understand the technical stuff I'm actually doing. To remedy this problem, I'm planning a meeting with my manager. This seems like a great opportunity to learn about my company/team and become a more valuable contributor. I'm trying to come up with a list of questions to ask. So far I'm thinking of things like:   * Who are all of our customers?   * Could you describe our company's relationship with other companies? I want to make the most of this time to learn about the company and my team's role in it. So, what "business aspects" of my team are most important for me to learn about? What kinds of things should I ask about? Notes about my team:     * Much of my team's work is for internal use in the company   * Not a "customer oriented" team in that sense, though our customers are other teams in the company   * Much of my team's work consists of enhancing tools (adding features rather than developing whole new products) p.s - this question is similar to this question, but is different in the sense that I'm not asking what I need to know about business in general, but what I should learn about my specific company and team


What are the advantages of showing line numbers in a text editor?

I feel weird when I'm editing code in an IDE that does not have line numbers in the text editor. The questions I have are:   1. Are line numbers visually excessive, particularly when a find by line function exists in your IDE of choice?   2. What are the uses of showing line numbers?


Is there an alternative to HTML Web Sockets, now that Firefox 4 has disabled them?

I've been checking out some of the latest multiplayer engines in HTML all supporting multi-user games (Very nice) - I believe all these engines use Web Sockets for communication. > That’s why we’ve decided to disable support for WebSocket in Firefox 4, > starting with beta 8 due to a protocol-level security issue. Beta 7 of > Firefox has support for the -76 version of the protocol, the same version > that’s included with Chrome and Safari. Beta 8 of Firefox 4 will remove that > support. Anne van Kesteren of Opera also announced that Opera are dropping > Websocket support. We are confident that other browser developers will > follow. Source: Websockets Disabled in FireFox 4 I've just come accross the above, so no sockets in Firefox 4 or Opera.... thats big. Is anyone aware of an alternate or is it Chrome or do we need to just sit and wait for the next release of the major browsers. More info : Rocket Engine appears to work with all browsers including IE8 (http://rocketpack.fi/engine/) what will it be using as a method of communication?


"I have been put into testing, what is wrong with me?"

I don't have much real life experience with project development and testing, apart from small collegeprojects. During my software engineering lecture, from a bunch of notes, a simple statement caught my eye: > Myths of testing: > >   1. I have been put into testing, what is wrong with me? >   2. .. >   3. .. > I was like: Is this really a myth? Is this not for real? Don’t people in testing team want to be developers? Won’t they think why I am into testing, but not in development? Or people in development are better than me? **Why I think in this way:** because after all these years, in the end if I don't get to write my own software, but have to debug other people's code, won't someone be disappointed? But, on the other hand, maybe I am wrong. It's not just only to sit and debug other's code... There's much more. **Am I missing something?**


benchmarks for quasi real-time software

I'm wondering if there is any benchmarks which can help to understand real- time characteristics (response time) of non-real-time software. For instance C# application on Windows or MSSQL Server. I know that Windows is not real-time OS, however it does not prevent us to use it in Real-time system if there some additional real-time layer. Let's say we have some real-time system, which reads and store data from some ADC. Data are read from ADC and timestamped on FPGA w/ some real-time Firmware. That part of the system is responsible for taking samples from ADC with some precise interval (let's w/ 10kHz frequency) and for timestamping the data. Afterwards firmware pack samples into data package (let's say 0.1 sec) transfer data via TCP/IP to application on Windows machine. Windows machine should store the data and display it. Yes, application on windows is not real- time as well as TCP/IP connection does not guarantee data delivery in fixed time. For instance   * in some case data transfer might take 0.01sec and 1 sec in another case.    * Windows may interrupt application's threads for a few second.   * application might interrupt itself when garbage collector is working so as a result we may have a few second interrupt in the part of the system which is beyond Controller/Firmware. I.e. response time from non real-time subsystem is varying in some range. However this issue could be solved if there is buffer big enough on controller, so it can accumulate data waiting for response from non real time subsystem. In order to be sure that buffer on real-time subsystem is big enough to support non-real-time subsystem we need to understand response time probability distribution. Something like:   * response time <1sec in 80% cases   * 1sec    * 2sec    * 5sec    * 10sec  That is basically the question. Any benchmarks for Windows, C# or MS SQL? Any methodic? TPC does nice benchmarks for SQL Servers performance however they total performance, and do not consider response time AFAIK.


What's the difference between static and dynamic binding?

We are learning about methods in class, and I am having trouble especially with the concept of static vs. dynamic. Wikipedia says this: > Methods can be bound to a class at compile time (static binding) or to an > object at runtime (dynamic binding). Can anyone describe what they mean here?


What do you do to get your software design robust, flexible and clear?

I am still getting mature as a software engineering/designer/architect, as you may want to call. At this point in time, I am getting small projects, private projects and so on. What I noticed is that even though I think about the SW structure, design some diagrams, have they really clear in my mind when I start coding, at the end, my software is not flexible and clear as I would like to. I would like to ask you what kind of approaches, mechanisms or even tricks do you use, to get your software (and SW design) flexible, robust and clear (easy to understand and use). So.... Any ideas to give to a beginner?


Programming language popularity: Is there data on migration trends?

I'm looking for historical statistics showing approximately how many developers of some language X switch to language Y. It should be the kind of data that answers question such as:   * Are former VB6 developers using mainly C# or VB.NET now?   * Have many Java developers switched their main development language to Scala so far?   * etc. I'm not doing a study, I'm mainly curious. Is there some website or institution that collects and publishes such data?


Azure Storage Table design with multiple query points

I have the following Azure Storage Table. **PositionData table:**               PartitionKey: ClientID + VehicleID      RowKey: GUID      Properties:  ClientID, VehicleID, DriverID, Date, GPSPosition      Each vehicle will log up to 1,000,000 entities per year per client. Each client could have thousands of vehicles. So, I decided to partition by `ClientID` \+ `VehicleID` so to have small, manageable partitions. When querying by `ClientID` and `VehicleID`, the operation performs quickly because we are narrowing the search down to one partition. **PROBLEM:** The problem here is that sometimes I need to query on only `ClientID` and `DriverID`. Because it's not possible to perform partial PartitionKey comparisons, every single partition will need to be scanned. This will kill performance. I can't have a PartitionKey with all `ClientID`, `VehicleID` and `DriverID` because queries will only ever query on `VehicleID` OR `DriverID`, never both. **SOLUTION 1:** I considered having a value stored elsewhere which represented a VehicleID and DriverID pair, and then having a `ClientID + VehicleDriverPairID` PartitionKey, but that would result in hundreds of thousands of partitions and there will be much unioning of data between partitions in my code. **SOLUTION 2:** Have a partition for `Client + VehicleID` and another partition for `Client + DriverID`. This means that updating the table is twice as much work (two updates) but both queries will be fast. Also there will be redundant data. Do any of these solutions sound viable? Other solutions?


What are your advice, methods, or practices to take out the most from a day on-site at a customer?

We just deployed a large software that affects the way the user work-day looks like in many aspects. It changes a lot of things in the way they interact between eachothers. The developers of the team are taking rounds and spending one day at the customer's site to understand better what is a typical day for our user, and the learning process they go through. In this context, what How would you approach that day, what kind of questions do you ask, how do you observe the user. Are there defined practices that exist? Also what wouldn't you do? Did you have some bad experience out of this?


Frequently in my programming experience I need to make a decision whether I should use float or double for my real numbers. Sometimes I go for float, sometimes I go for double, but really this feels more subjective. If I would be confronted to defend my decision, I would probably not give sound reasons. When do you use float and when do you use double? Do you always use double, only when memory constraints are present you go for float? Or you use always float unless the precision requirement requires you to use double? Are there some substantial differences regarding computational complexity of basic arithemtics between float and double? What are the pros and cons of using float or double? And have you even used long double?


Should we test all our methods?

So today I had a talk with my teammate about unit testing. The whole thing started when he asked me "hey, where are the tests for that class, I see only one?". The whole class was a manager (or a service if you prefer to call it like that) and almost all the methods were simply delegating stuff to a DAO so it was similar to:               SomeClass getSomething(parameters) {         return myDao.findSomethingBySomething(parameters);     }      A kind of boilerplate with no logic (or at least I do not consider such simple delegation as logic) but a useful boilerplate in most cases (layer separation etc.). And we had a rather lengthy discussion whether or not I should unit test it (I think that it is worth mentioning that I did fully unit test the DAO). His main arguments being that it was not TDD (obviously) and that someone might want to see the test to check what this method does (I do not know how it could be more obvious) or that in the future someone might want to change the implementation and add new (or more like "any") logic to it (in which case I guess someone should simply test that **logic** ). This made me think, though. Should we strive for the highest test coverage %? Or is it simply an art for art's sake then? I simply do not see any reason behind testing things like:   * getters and setters (unless they actually have some logic in them)   * "boilerplate" code Obviously a test for such a method (with mocks) would take me less than a minute but I guess that is still time wasted and a millisecond longer for every CI. Are there any rational/not "flammable" reasons to why one should test every single (or as many as he can) line of code?


The Wikipedia animation for Maze generation using DFS isn't consistent wrt the written algorithm given there, isn't it?

Please have a look at this link: http://en.wikipedia.org/wiki/Maze_generation#Depth-first_search Here, the theoretical algorithm given is: > Consider the space for a maze being a large grid of cells (like a large > chess board), each cell starting with four walls. Starting from a random > cell, the computer then selects a random neighbouring cell that has not yet > been visited. The computer removes the 'wall' between the two cells and adds > the new cell to a stack (this is analogous to drawing the line on the > floor). The computer continues this process, with a cell that has no > unvisited neighbours being considered a dead-end. When at a dead-end it > backtracks through the path until it reaches a cell with an unvisited > neighbour, continuing the path generation by visiting this new, unvisited > cell (creating a new junction). This process continues until every cell has > been visited, causing the computer to backtrack all the way back to the > beginning cell. But I don't think the animation on it's right uses the same algorithm to generate the maze, though it's not incorrect. I feel the animation uses this algorithm:   1. Start with any unvisited cell, make it a part of the maze and mark it visited.   2. Add the unvisited neighbours of that cell to the set of cells that can be considered next   3. Choose any one of cells from the set and mark it visited.   4. Check if that cell does not have any neighbours that are visited except ONE (the one which caused this cell to be added to the set in the first place). Else go to 3.   5. Continue till all cells are visited. Am I wrong?


Documents to use on project development

I am lost on how to plan the development of a iphone mobile app, when building a specific mobile app for a client, i need to make a questionnaire for that same client and i also need to have a document to accompany the project development, something like a bug report file, and a app features document. My question is, for the experienced developers, what do you guys use to plan your entire development process? do you have any doc templates that you use to address these issues?


Using version control in an IDE

I write all (well, most) of my programs in an IDE, mostly it's netbeans. Should I just use Mercurial through the IDE, or is it better if I used the CLI instead? and why?


My first SLA(Service level agreement ) as a freelancer

I started to work freelance just a couple of months ago. My first client asked me to create a web app, to improve his business. I made a little specification about what i was able to do and also an approximation about how long it will take to prepare the application. We just have some no formal agreement where i told him a deadline when i will present the progress of the project. Also we did not agree any payment at all, since he said to me that he will pay me when the program is live. What is happening now, is that the program did not meet the deadline and i will present the progress one month after what we agreed. As you see we both made a mistake(myself first), but i hope it is not to late to fix it. I want to make an SLA, to include the amount i want to get paid for my work, and also detailed information about what he will get. I would appreciate if someone more experienced than me could give me some tips on what should i include in the SLA documment and also if can i get some recommendations for not making the same mistake in the future.


How do I weigh quality of code versus quality of product when deciding whether to add my open source app to my resume?

I've made significant, well written code contributions to an open-source project. Unfortunately, the project as a whole is both unpopular, and, to put things mildly, not particularly flashy. Unlike the poster of this HN message, I'm in the opposite boat - I'm proud of my contributions, but embarrassed by the end product. How would you weigh the quality of your contributions versus the quality of the end product versus the popularity of the end product when deciding if you should include it on your resume/portfolio or not?


How to deal with the MPL in a pragmatic way?

Until recently I always avoided the use of open-source code in my applications, because of the legal headache it gives me. I rather spent a fair amount of money and not worry about attribution (since most commercial components don't require that), than paying nothing, but spending a lot of time reading legal texts, never to be sure whether I was fully compliant. However, there is a ton of code out there that would be a shame to ignore. Also, sometimes the open-source solutions are of better quality than their commercial counterparts. The license I encounter most and find hardest to grasp, is the MPL. All FAQs state that it is no problem to compile the code into a closed-source application, as long as changes to the code are made available. Assuming that I will not make changes to the code, what other things are there to keep in mind? For example, copyright notices and attribution; am I required to include a bunch of files with all the different copyright notices? Should I double- size my About dialog and list all open-source components with their vendor website and so on? How do you deal with this? Please note that I have no problem with giving authors of code the credit they deserve. I would simply like to know what is reasonable, so I can take care of it in a pragmatic way, and no longer fear at least the MPL. Hoping for your experiences. ## Update To make my question more clear, I will use an analogy. Let's say I am going to write a book A, and I would like to use some parts of a book B that someone else has written. The author of B is fine with this, as long as I credit him (very much like a clause in the MPL). But how should I do that? Am I to put his name on the cover of mine and/or in the margin of every page where I use full paragraphs from him and/or where I use full sentences from him and/or where I use a couple of words from him and/or in a dedication section with sources? Or perhaps it would suffice to print his name in black letters on a black page, or in font size .00001? Luckily, for books there aren't as many ways to do it as with software, and there is some established practice. In the field of software, I have yet to discover any, so I'm asking here if I missed something.The point is not to give as little attribution as possible, but I'm looking for what's acceptable and fair; you wouldn't like to write a book in which each page is half-filled with attributions either... Attribution is only one of the terms that I find hard to concretize. What about making the code and the license texts available if I changed nothing? Do I link to the authors website, or mirror it on my own and link to that, or put it in my installer? And, **for example** , from the Firebird Project I have most files in one place, but a couple of DLLs are spread over the folders of my application. Would you suggest just to make a single folder with license texts and list which files are relevant to each? Is that enough? Is there a better way? A complete answers addresses all requirements of the MPL. :)


How to find out what Hackathons are coming up near me?

I just went to my first hackathon (London GreenHackathon) and I want to go to lots more. Specifically, hackathons that have a theme of helping people or making the world a better place in some way. I know about Random Hacks of Kindness and a couple of others but is there some central aggregator that will help me find out about hackathons? Also, if anyone else can suggest specific hackathon initiatives I should check out that would be handy too. I'm in London but obviously for other people reading this question other locations will be of interest.


Java API vs. Other APIs

I'm more at the novice end of the software developer spectrum, but nevertheless I've had exposure to quite a few programming languages and frameworks. From all the technologies I've used, I haven't found any with an API as well-structured and user-friendly as Java's. Why is this? Why is it that robust languages such as C++, Perl and Python do not have APIs that come even close to Java's?


C++ wrapper for "releasing" a singleton object

I have a class like this                   template <typename T, typename Policy>         AutoObjectRelease {     public:         AutoObjectRelease(T& obj):obj_(obj){}              ~AutoObjectRelease(){ Policy::Release(obj_); }     private:         T&  obj_;     }      I wonder how one would you name this class, as it seems to me this could be quite a common pattern. I also wonder in which other situations you would use such a class. In my case I use the singleton object only sporadically and I wanted to make sure it doesn't remain loaded for the duration of the application. What are your thoughts on this ? Another idea would be to make the singleton object reference counted, but don't know exactly what would be the benefits for a singleton object - it might only complicate the implementation (need to make it thread safe also)


How do you manage refactoring with a large code base and many developers?

I would like to prevent a situation where two developers refactor the same code simultaneously without talking about it first, probably using a tool of some kind, maybe an Eclipse plug-in. Can you help? We've got 4.5 million lines of code, and more than 20 teams of developers on four continents. Ideally I would like the second of the developers mentioned earlier to notice that someone else is working on the same piece of code and talk to the first one before modifying anything. Do you know of a solution?


Can Google search results be reused?

I am trying to develop an application much like a search engine and I will like to use Google search results and refactor them in my application. Can I re-issue Google search results my own way and should I expect some legal troubles doing that ?


Dealing with an often occuring dependency that is not related to the class

I'm using view classes for my templating. These view classes often require the Routing class to get URI's from other pages. You could actually say that the Routing should be available to every view class. What I'm wondering how would you deal with the dependency injection. Injecting it through the constructor would mean that you will have to include it with every view class in many controllers. This would seem wrong to me. You would also include it trough class extending but I don't think all views deserve a base class for just the routing library and it would able break the SOLID rules you do it because of a dependency that is not directly related to the child class. My last option would be injecting it trough a public variable that injects it at a single place just before the template rendering. How did you guys solve this problem? I'm looking for a clean non repetitive way.


Are monolith and microkernel design patterns or strategies?

What's the difference between a design pattern and a strategy? Is the monolith actually an anti-pattern?


Writing code vs Figuring out the answer to a problem?

Why is writing code when you encounter a tricky problem considered "bad" programming practice? And why is thinking a problem completely through on paper or in your head before you write code "good" ? From what I've been working with, I'm able to see problems in multiple different ways or special cases I didn't think of at first by typing out code and debugging than solving the problem completely first ? Also, I can't really find any appropriate hashtags for this. So any help is much appreciated!


How much time do you spend actually developing vs. infrastructure activites?

When I'm working I feel like most of the time I'm not doing actual work. For example after making a change to the code in order to test it, I have to first build the project, and start the server(say JBoss). Upon testing, I find that there is another small issue. So I bring down the server, make the changes, build again and start up the server again.The building and bringing the server up/down is not very useful work. Also, the IDE (let's say Eclipse) does things such as updating Maven indexes and building the workspace which take some more time to get things done. Have you come across this kind of situation? Do you have tips on how to overcome/bypass this? Any features on the IDE/build tools that can be helpful? Any architecture/application design/technology that attempts to overcome this?


Hiring a programmer much more qualified & experienced than yourself?

My employer is hiring a programmer - more specifically, I am interviewing and selecting the person who will fill the position. The best candidate right now is far more qualified than I am, older, and a lot more experienced. Other people I've talked to have said that hiring someone more qualified than myself is a really bad idea (my family included). And I get the feeling that other technical staff here have a similar attitude (considering that this applicant is also more qualified than they are). They're saying, or thinking, that hiring someone better qualified is going to hurt my and my current colleague's efforts to move up in the company, or are afraid that a Johnny-come-lately is going to steal the spotlight and current staff will be left behind as promotions are given out and new positions open up. Personally I'd love to work with this applicant, and learn from them. I'm confident enough in myself to not be afraid that someone new and more experienced is going to come in and start making me look bad. I'd like to use this as an opportunity to grow, and I don't think that being afraid of competition or of new people like this is rational or beneficial. Or maybe I'm just being naive. What do you think? And have you ever had an experience similar to this? How did it work out for you?


Relationships in a Chen ERD

I am working on a Chen ERD to model our organizations merchandise. Our central entity is a Style. We have supplemental entities of Color and Season. I am defining our assortment as the relationship between these three entities, and this relationship itself will have attributes and is defined by the three entities which participate in the mandatory relationship. The rules are;   * Many Styles can be offered in a Season, and a Style can be offered in many Seasons.   * Within a Season, a Style can be offered in Many Colors. I then have 2 other entities, one of which I believe is a weak entity, Climate, and the other may be weak, but I am not sure, this being Transaction Channel. I am thinking of these as relationships off of a relationship? Meaning, for a given Style/Color combination offered in a Season, it can be available through 1 or more Transaction Channels. Additionally, within a season, a given Style/Color combination can be intended for 1 or more Climates. Is it valid to have relationships off of relationships? Or does this requirement dictate that I should think of this Style/Color/Season relationship as an entity itself, and define the relationships to Climate and Transaction Channel off of this entity?


Are Ruby on Rails / Grails the fastest frameworks for getting sites up quickly?

I'm considering using Grails for a new website, but am open to other/new programming languages and frameworks. I have done development using J2EE/JSF2, ASP.NET, and PHP. Is Grails or Ruby on Rails pretty much the best way to get functionality up and running quickly? Some initial thoughts:   * DJango looks similar to RoR/Grails and I'd consider it   * GWT is an interesting concept but it doesn't seem like turnaround time is quite as fast Thanks, -Jon


Resources for Test Driven Development in Web Applications?

I would like to try and implement some TDD in our web applications to reduce regressions and improve release quality, but I'm not convinced at how well automated testing can perform with something as fluffy as web applications. I've read about and tried TDD and unit testing, but the examples are 'solid' and rather simple functionalities like currency converters, and so on. Are there any resources that can help with unit testing content management and publication systems? How about unit testing a shopping cart/store (physical and online products)? AJAX? Googling for "Web Test Driven Development" just gets me old articles from several years ago either covering the same examples of calculator-like function or discussions about why TDD is better than anything (without any examples).


How would you collect the ideas that needs to be discussed during time

What is the best way of collecting and/or keep tracking of ideas/issues that needs to be discussed in details and during the time? As an example, imagine within the team you're brainstorming about going for NoSQL, or you're discussing if Node.JS is an option for your team or not? Or some people are in favor of going for Erlang but others don't. Something that needs time and lot's of discussions to be finally decided in the end. Currently we're keeping everything either on email threads or on paper, but is there any better way that you can actually extract data later on in a simpler or more intuitive way? Something like what we have as Todo/Task Managers but with discussion abilities? P.S. One option is to use a private _forum_ software, but nobody likes it in our team. Maybe because most of them look old.


help me understand Rails and attributes as class methods

This is from the _Hartl Rails tutorial_. We are automatically logging in a user in the process of creating that user with a callback to `#create_remember_token`. It works great but there are some things, I am not clear on. Please bear with me as I'm thoroughly confused to the point that I don't even know how to ask my question. I have a user model:               class User<ActiveRecord::Base     ...     ...          before_create :create_remember_token     def User.new_remember_token       SecureRandom.urlsafe_base64     end          def User.encrypt(token)       Digest::SHA1.hexdigest(token.to_s)     end          private            def create_remember_token         self.remember_token = User.encrypt(User.new_remember_token)       end      ... I am confused about the `::new_remember_token` and the encrypt being methods attached to `User`. It looks as though they are attributes of `User` like `name`, `email`, `password` etc, because they are being accessed with dot notation. But they are defined like methods and seem to return a computed value. I don't understand, why an attribute of the `User` model is referred to with `self` for assigning `self.remember_token` and `User.encrypt` for accessing the class method. * * * **My question** What's the difference between the above and the following where `User`, is replaced with `self`. ?               class User<ActiveRecord::Base     ...     ...          before_create :create_remember_token     def new_remember_token       SecureRandom.urlsafe_base64     end          def encrypt(token)       Digest::SHA1.hexdigest(token.to_s)     end          private            def create_remember_token         self.remember_token = self.encrypt(self.new_remember_token)       end      ... I'm a novice in the _ruby_ language, but pretty good with javascript, so if there's a _js_ analog it might help me to put it in those terms.


Template for Knowledge Transfer

I have been working for more than a year for this company. Now they want me to create a KT Document for reference. Is there any template available for me to document the coding done by me..


How to Deal With The "Automation is Easy" Mindset?

The title says it all. Some employees in our company believe that automated tests are "easy" and that it "should take a day" to write suites of COM and UI tests. What can be done to counter this? Note: I'm not asking about how to promote automation. That isn't the problem. Automated testing and processes are being promoted and requested all the time here. The issue is that some individuals don't understand that automation is not "easy" nor is it "fast".


Best practices working with frameworks that invent their own types [more of a C/C++ question]

Is there a correct way to handle APIs that invent their own types? For example, WinAPI, QT, Boost. Many frameworks have their own integer and boolean types, along with more complicated data-types. So, is it better to use native C/C++ type like `bool` or alternatives like `QBool/BOOL/etc`., and native container types like `std::map/std::set/std::vector` vs reinvented ones like `QList/boost::something/ATL::map/etc`. And how do those choices respond to cross platform portability. TL;DR Which one `QBool IsInteresting(const QString &str)` vs `bool IsInteresting(const std::string &str)`?


Best practice for mapping between data/business/model and etc

What is the best approach to mapping between Entity, View Model or dataContract. For example I've seen the following modelling structures for SOA. **WCF** -> DataContract distributed to client. **Middle-tier** -> Models and Interface with then mapped to repository type and eventual a concrete class which implements a ORM. In some cases I've seen reflection used, others just setting the properties and third-party libraries like AutoMapper for C#. What is the most effective way to keep your system "easy to maintain" and functional or horses for courses? **EDIT:** Question wasn't focused on Microsoft, I've used SOA for java and the same problem happens regarding mapping. I'm asking about direct mapping vs. reflection and etc? Its really got nothing to do with ORMs. e.g.                   thesolution.models.interfaces         public interface IProduct { //bundle of properties and method signatures }              thesolution.models         public abstract class Product  implements IProduct { //implementation }              thesolution.repositories.sapMD         public class Product extends Product implments IProduct { //implements and do stuff}              thesolution.repositories.sapCRM         public class Product extends Product implments IProduct { //implements and do stuff}              thesolution.controllers           public class ProductController          {           public IActionResponse Save(IProduct product)           {               //save to sapMD repository               IAction actionMd = ((thesolution.repositories.sapMD.Product)product).Save();                     //save to sapCRM repository               IAction actionCrm = ((thesolution.repositories.sapMD.Product)product).Save();                    IActionResponse response = new thesolution.message.product.ActionResponse();                response.Actions.Add(actionMd);               response.Actions.Add(actionCrm);               return response;           }               }                thesolution.DataContracts           //XSD JAXB or etc.               thesolution.Services          //your service method          public class ProductServices ... {            public thesolution.DataContracts.ResponseAction Save(thesolution.DataContracts.Product product){              // so now how do you map back to IProduct manually, reflection or etc.          }          }


Should one test for algorithmic complexity? If so, how?

Let's say I am implementing something simple like searching a sorted list/array. The function (in c#) would look similar to:               static int FindIndex(int[] sortedList, int i);      I could implement and test this in terms of functionality, but for obvious reasons I would usually prefer a binary search over a linear search or something intentionally stupid. So my question is: Should we attempt to write tests that gaurantee performance in terms of algorithmic complexity and if so, how? I have started making arguments on both sides of the "should you" part of this question, but I'd like to see what people say without my arguments to prompt them. In terms of "how", that gets very interesting:) You could see parameterizing the comparison operator and having a test whose comparison operator counts comparisons or something like that. But just because you can doesn't mean you should... Has anyone else considered this (probably)? Thanks.


Best refresher material on Java Garbage Collection?

I haven't looked at Java Garbage Collection for a while and feel the need for a refresher on it. Anyone recommend a resource or two?


Does it help to be core programmer of a product (meant for social good) for getting into a PhD program at a top university?

I am working upon a product as core developer which will be launched in USA market in few months if successful. Can this factor improve my chances for getting accepted into a PhD program at a top university (say top 20 in US)? Normally good universities like CMU, Standford, MIT, Cornell are more interested in student's profile like research work, undergraduate school, etc. I am now passed out from very good university it's ranked in top 20 of India only. Neither did I do research work till now. But being one of founding member of company and developing product for same, I want to know if this factor can help and to what extent.


Should I rewrite the git history of a non-GPL project to remove GPL code that was later removed?

I have an MIT-licensed project that used to include a GPL JavaScript library which has since been removed. Is there any legal necessity to rewrite the revision history to completely remove this code?