title: What is the etiquette of renaming an open source fork?

text: I want to fork on Github the TestNG java testing framework (Apache 2 license) so I can add/change some minor things to suit my needs. It's unlikely that all of my changes would be approved in the main project or that other people would use my fork. This would in no way be a competition to the main project. Now, in terms of naming, I want to change the artifact name (testng-mycompany) or the version (6.8.mycompany) so there's no confusion with the official version in my maven repository. Would this be considered poor etiquette? If yes, what is the best approach to distinguish your fork?


title: A Huge Database: Picking the right schema and data model

text: We want to store some genomic variant data but there are some problems, more important ones like problem of the data's immense size and variability.   1. Variant data can be huge. For example, a single individuals variant data could feasibly some day require a million rows of data in a table, or require of a gigabyte of raw storage on disk. Multiply this over several thousand individuals, and you could potentially end up with terabytes worth of information that you need to make sense of.    2. Each client and/or system we integrate with, will expose or want to see data slightly differently depending on their needs and use cases. This can potentially lead to hundreds of fields that we might need to store, all of which might need to be in different configurations based on the clients needs. So this variant data model will need to keep this in mind in order to remain easy to use, expandable and most importantly, scalable in the long term. What do you think is better for such a problem? We were thining of having some coulmns in each table that point to an external database or even a file, where we save the huge BLOB data?


title: ASP.NET MVC 4 with Entity Framework 5 and SimpleMembership integrated into Repository and Unit Of Work pattern

text: I have a ASP.NET MVC4 project in which I would like to use the SimpleMembership. The application has a Person table that holds relevant information about users in the system. I would like a link between the currently logged in user and the Person information. So I have made a foreign key in the Person table to the UserId column of UserProfile table (from SimpleMembership). I use Entity Framework 5 as ORM and have implemented a generic repository to handle CRUD methods and so on. Now I am at a point where I want to implement user profile creation. The creation consists of 2 parts parts:   * login: username and password (to be stored in SimpleMembership tables)   * personal information (to be stored in Person table) In order to create a user I guess I need to:   1. Save user information through SimpleMembership   2. Save personal information together with userId from step 1 through my PersonRepository I would like some kind of UserRepository that could save SimpleMembership data but I do not know if it's the right approach? Is there a better approach?


title: Inform caller or just let them deal with exception?

text: I'm not sure how to proceed in the following situation. say we have a function as so:               def runsATask(codes):         myDicts = [helperFunc(code) for code in codes]         for item in myDicts:             # some logic.      Here's the problem, codes is some iterable and should be either a list or a tuple, ie it should be used as so: `runsATask(['code1', 'code2', ... 'codeN'])`, but sometimes `N` is 1 and so people could call it mistakenly, like so, `runsATask('code1')` This code will still run, but later on in the `for loop` it will crap out because `myDicts` doesn't have the correct objects in it because the list comprehension that made it iterated over a `string` rather than a `list/tuple`. So should I leave it as it is or would the following be a solution:               def runsATask(codes):         if not isinstance(codes, (list, tuple)):             raise Exception("Codes should be a list or a tuple")         myDicts = [helperFunc(code) for code in codes]         for item in myDicts:             # some logic.      I'm not sure which way to go because I hear Python circles say to let callers deal with the issue, but debugging a situation like this can be annoying because the caller would deal with the issue in the for loop and had he been informed way earlier about the wrong parameter being passed, then it would save a lot of wasted time.


title: Are error codes wrong in SQL queries too?

text: I have an SQL query which does several things at once¹: it does multiple checks and then, if the checks pass, updates some data. Without entering in the domain-specific details, here's an imaginary example:               -- The user password should be updated only if the user account is not removed and     -- not locked, and the threshold was not exceeded.     if exists (select * from [People].[User] where [UserId] = @UserId)     begin         if exists (select * from [People].[User] where [UserId] = @UserId and [IsLocked] = 0)         begin             if exists (select * from [People].[User]                        where [UserId] = @UserId and [IsRemoved] = 0)             begin                 update [People].[User] set [PasswordHash] = @Hash where [UserId] = @UserId                 select 0 -- Success.             end             else             begin                 select 3 -- The account doesn't exist any longer.             end         end         else         begin             select 2 -- The account is locked.         end     end     else     begin         select 1 -- The user cannot be found.     end      The query is then used like this:               var errorCode = new SqlDataQuery(query, Program.ConnectionString)         .With(new { UserId = this.Id, Hash = this.ComputeHash() })         .ReadValue<int>();          // Error codes are used only between the database and code, and transformed into exceptions     // as soon as possible.     switch (errorCode)     {         case 1: throw new UserNotFoundException();         case 2: throw new AccountPermissionException();         case 3: throw new AccountRemovedException();     }      In general programming, error codes are considered bad and should be replaced by conventional error handling procedures, including exceptions. Is it also bad to use them in SQL queries? If yes, how should I rewrite the query to follow best practices? * * * ¹ Given the non-functional requirements related to the load and performance, there is no way to make several consecutive queries. All the checks and the update should be done in a single query.


title: How Much Logic in Getters

text: This question has been asked in different ways, but nothing that's actually what I want to know. Got me confused at work now. They tell me there should be as little logic as possible in getters and setters. Yet, I am convinced that a lot of stuff can be hidden in getters and setters to shield users/programmers from implementation details. An example of what I do:               public List<Stuff> getStuff()     {        if (stuff == null || cacheInvalid())        {            stuff = getStuffFromDatabase();        }        return stuff;     }      An example of how work tells me to do things (they quote 'Clean Code' from Uncle Bob):               public List<Stuff> getStuff()     {         return stuff;     }          public void loadStuff()     {         stuff = getStuffFromDatabase();     }      Any suggestions? How much logic is appropriate in a setter/getter? What's the use of empty getters and setters except a violation of data hiding?


title: DMCA as a license for closed-source javascript code

text: I have a proprietary project, with parts of it written in javascript. We would like a software license to include in the header file for this code which ensures the work remains:   * proprietary    * cannot be reverse engineered (as it will be obfuscated / minimized)   * cannot be reused elsewhere   * cannot be linked to does the DMCA do all of this? Does anyone use the DMCA in this way? I looked at this other question, Best existing license for closed-source code, about other possible language, but want to know specifically about the benefits and failings of the DMCA as a license.


title: Is functional decomposition really an antipattern?

text: While I was reading The worst anti-patterns you have came across, I clicked on the link in this post to land on the web site about anti-patterns. And the http://sourcemaking.com/antipatterns/functional-decomposition page got me wondering. How bad this anti-pattern is, and is it an anti-pattern at all? Because, although I am doing mostly OOP programming nowadays, I still feel a reluctance against pure OOP-everything languages like Java, and also the design practices that they bring. And I guess, I still have some traits of the functional programming while I write the code. And this brought up a question, am I doing wrong by sticking to OOP+Functional style, or is it common in industry and is not actually that bad. What I do know from experience, is that OOP+Functional style is not completely compatible with pure OOP developers. But at the same time, while OOP developers have problems with OOP+Functional development, the counterargument is that OOP solutions are quite often over-engineered and too hard to use, and from my experience, were not even a single bit easier, and actually introduced some blind spots for VERY serious bugs to hide. So, even though I had discussion with my colleague about these topics, I came to conclusion that none of the ways is actually perfect. And I still have the question unanswered. The OOP problem was also reinforced by a link from another post in the same thread. The link looks at the Java style OOP http://chaosinmotion.com/blog/?p=622 So what is the general attitude toward mixing functional programming with OOP? And what is the balance a developer should strive to achieve?


title: Quality vs Time

text: I have heard of developers who work with code which is a complete mess because originally the code was quickly developed and the quality was not there in the first place. Its always good to get maintainable, reusable code but I was wondering if it was best to sacrifice some of this due to time constraints. A common problem I come up against is over engineering something and wasting a lot of time. We all know in the real world due to time constraints its going to be very difficult to get near perfect code. I was wondering if there was a general rule for getting good quality if there is not much development time? Do you find this a common problem in development balancing code quality and time?


title: Storing data in code

text: A few times in my past I've wanted to store data in code. This would be data that seldom changes and is used in places where access to a database isn't possible, practical, or desirable. A small example would be storing a list of countries. For that you could do something like:               public class Country     {         public string Code { get; set; }         public string EnglishName {get;set;}     }          public static class CountryHelper     {         public static List<Country> Countries = new List<Country>             {                 new Country {Code = "AU", EnglishName = "Australia"},                 ...                 new Country {Code = "SE", EnglishName = "Sweden"},                 ...             };              public static Country GetByCode(string code)         {             return Countries.Single(c => c.Code == code);         }     }      I've got away with doing this in the past because the data sets were relatively small and the objects pretty simple. Now I'm working with something that will have more complex objects (5 - 10 properties each, some properties being dictionaries) and around 200 objects total. The data itself changes very rarely and when it does change it's really not even that important. So rolling it into the next release version is perfectly fine. I'm planning to use T4 or ERB or some other templating solution to turn my data source into something that is stored statically in the assembly. It seems my options are   1. Store the data in XML. Compile the XML file as an assembly resource. Load data as needed, store loaded data into a Dictionary for repeat-use performance.   2. Generate some kind of static object or objects that are initialized at startup. I'm pretty sure I understand the performance implications of option 1. At least, my hunch is that it wouldn't have stellar performance. As for option 2, I don't know what to do. I don't know enough about the internals of the .NET framework to know the best way to actually store this data in C# code and the best ways to initialize it. I poked around using .NET reflector to see how `System.Globalization.CultureInfo.GetCulture(name)` works, since this is actually a very similar workflow to what I want. Unfortunately that trail ended at an `extern`, so no hints there. Is initializing a static property with all the data, as in my example, the way to go? Or would it be better to create the objects on demand and then cache them, like this?                   private static readonly Dictionary<string, Country> Cache = new Dictionary<string,Country>();               public static Country GetByCode(string code)         {             if (!Cache.ContainsKey(code))                 return Cache[code];                  return (Cache[code] = CreateCountry(code));         }              internal static Country CreateCountry(string code)         {             if (code == "AU")                 return new Country {Code = "AU", EnglishName = "Australia"};             ...             if (code == "SE")                 return new Country {Code = "SE", EnglishName = "Sweden"};             ...             throw new CountryNotFoundException();         }      The advantage to creating them at once in a static member is that you can use LINQ or whatever else to look at all the objects and query them if you want. Though I suspect doing this has a startup performance penalty. I'm hoping someone has experience with this and can share their opinions!


title: How should I group these variables?

text: I have a shape that will be defined by:               char s_type;     char color;     double height;     double width;      These variables are scanned in from a request string sent to my server and passed into my printing function, which then prints out the shape. Currently they are just local variables sitting in my `main()`; however, I was wondering if there would be any advantage in creating a struct containing these variables, and then passing the struct to my printing function? or how else might I improve my program's structure/style, would passing a struct by reference have any kind of performance benefit if there were many requests and therefore many printing function calls?               printer(char st, char cr, double ht, double wd);          int main()     {         // Other main functionality.              char s_type;         char color;         double height;         double width;              sscanf (serv_req, "GET /%c/%c/%lf/%lf", &s_type, &color, &height, &width);              printer(s_type, color, height, width);              // Other main functionality.              return 0;     }      It seemed "neater" if I had a struct or something that didn't leave me with declarations in the middle of everything else going on in main. I'm interested in structure/style as well as performance. EDIT: didn't mean to put printer declaration inside main.


title: How to keep word document, html and pdf documentation aligned

text: Is there a way to write documentation in a WYSIWYG editor which can then export into HTML, WORD and PDF and keep copies synchronized? This documentation are mostly technical notes and some contextual help for some softwares so they must contain images and some styling, they are not programmer's documentation (API list or functions list) for which probably a program like Javadoc or Doxygen would be the best choice. For example how do companies with hundreds different software lines and thousands of programmers deal with this? I have several solutions but they all seem lacking in some aspect:   * Latex/Tex : very good pdf and html export, not very user friendly and no full-blown WYSIWYG editor available.   * LibreOffice/OpenOffice : full blown WYSIWYG editor however html export not so good (need to edit manually exported html which needs to be maintained separately )   * Mediawiki or any other wiki : could be keeping documentation in wikitext format, so html is automatically generated, pdf exportation is quite good with many available plugins. Again however need some formation for the staff to use it and need to setup a server for this. Notice I'm not asking for software A vs software B, I'm asking for general advice, big companies procedures for documentation and yes some software product names if available.


title: Why is it called Just In Time?

text: I know what the JIT compiler is but how about why is it called that, it obviously catches exceptions _Just in Time_ , but how and why should it be called this? Sorry if this sounds a bit vague.


title: Pair Programming with Scrum

text: I'm on a team that is currently using Scrum, and we're considering adding pair programming to help improve the cross-functional skills of the team, as well as help reduce defects with a "two heads are better than one" philosophy. On our team, each team member typically signs up for a full workload during sprint planning (with "full" being a number that is less than 40 hours a week, allowing for meetings, collaboration, etc.), with a single dedicated owner for each task. I believe this is fairly common on Scrum teams but may not necessarily be by the book. In particular, I'm looking to avoid a situation where team members are hesitant to pair because they have their own tasks to work on, which I'm afraid is likely to happen if the team simply self-organizes without time set aside for pairing. Given this, what is the best way to account for effort/hours/story points in a pairing scenario, to make sure we have appropriately allotted time for pairing? Some options considered are:   1. Allow two people to sign up for each task and (roughly) double the number of estimated hours   2. Only the "hands on keyboard" team member signs up for each task, which is estimated based on that person's estimated hours. Anyone on the team who will be supporting pairing will sign up for fewer tasks in the sprint to allow time to support pairing.


title: What will be the better way for data retrieval on application that needs to handle limited amount of data.?

text: This is not really a coding question since, I am not adding any code in here. Since, adding my code snippets itself would make this question really long. Instead, I am pretty interested in knowing a better ways for data retrieval on application that needs to handle limited amount of data which isn't updated regularly. Let's take this example: I am writing an application which gets a schedule as an XML from server. I have written a logic in order to parse XML version and update database only if the version is newer than the local version. Although the update is checked automatically/manually on daily basis based on user preference, the actual version update happens only once per few months or so. Since, this is done by some other authority which doesn't provide API but, rather inform publicly on their changes. The actual XML contains a "(n number of groups) _(days in a week)_ (n number of schedule)" . The group is usually 6 and the number of schedule is usually 2. So basically there would usually be only around 100 strings. Now although I have used SQLite at the moment. I want to know how to make update on database. **Should I show progress dialog that the application is updating and exit the app when it's done?** Since, my updates are infrequent i don't think this will really harm user experience but, **is there any better ways to do it?** Because I don't want update to be made when user is searching which is done using database. This will cause an database already open exception. Atleast I have faced this problem before. **Is it better to rather parse XML every time when user wants to view certain things or to use SQLite?** Since, I make lots of use of adapter in my app to create lists, will that degrade the performance? It would really be a great help if anyone can give me better overview about it. Or may be counter argument against each. Many thanks!


title: Reason behind multi-line declaration style?

text: I'm a little curious about the reason behind the Windows header file declaration styles. When I read them, I see multi-line declarations such as the following:               WINBASEAPI     HANDLE     WINAPI     GetStdHandle(         IN DWORD nStdHandle         );      What is the primary reason why they're not written as something like:               WINBASEAPI HANDLE WINAPI GetStdHandle(IN DWORD nStdHandle);      i.e. in a single line?


title: Does this situation call for well specified associations, single table inheritance, or polymorphic association?

text: I'm building a web-app where users can keep track of who owes whom money. I have users and debts. Given a user I want to be able to find out all the debts to other users, and all the loans to other users. Given a debt I want to be able to find out who the debtor and lender are. The asker of this question ran into a similar situation, but I don't belive our situations similar enough to warrant just using the top answer: http://stackoverflow.com/questions/4729725/how-do-i-do-two-has-many-belongs- to-relationships-between-two-models Taken from that question, the three paterns sugested there are   * well specified associations   * single table inheritance   * polymorphic association What pattern should I use in my situation? One of these three, or is there an even more appropriate one?


title: How to hunt for software developer jobs if it is hard to travel on site interview

text: I am a software developer with 3 years of experience in different domains. I was trying to find a job via online sites. Particularly I tried to send motivation letter with CV to UK vacancies. All companies which responded back to me asked to go to the interview on site. I explained them that I am from another country and maybe it is possible to do it over the phone/skype? Everyone replied that it is not possible. Could anyone suggest me what to do in this situation? Maybe I am doing something wrong? Any help would be the most welcome. P.S. it will really hit my pocket to go for every interview over there.


title: Storage and naming of log data

text: I'm in the process of rewriting a small application from console mode to a GUI mode. The input is a file with log data from a measuring device:               ...     00029;00044;00076;00044;00021     00309;00032;00037;00000;65535     00013;00016;00008;00007;00005     ...      Each row of data represents 5 counters which summarize the range in which the measure fell, i.e. first column is "<40%", 2nd column is "[40-50[", and so on... First row as example:               29 counts below 40% | 44 counts between 40% and 60% | 76 counts between 60% and 80%     44 counts between 80% and 90% | 21 counts between 90% and 100%      In the console application I used an array of integers to store each data row, putting each row array in a list. So far, so good... The application then used a for-loop to print out the values with descriptions to the console. **My problem:** I wanted to create a GUI with WPF and apply databinding. But I have a conceptual issue with how to create the data binding to the arrays of integers and visual elements. I have not had problems with data binding to single properties. The challenge is due to the arrays. I think I should create a class like this (could also be used as a ViewModel):               public class CounterRecords     {         public List<CounterRecord> DataRecords { get; set; }     }      But how should I go about the `CounterRecord` class?   What's a clean / clear implementation of this object that I can bind to?               public class CounterRecord     {         public int Range40 { get; set; }         public int Range40_60 { get; set; }         public int Range60_80 { get; set; }         public int Range80_90 { get; set; }         public int Range90_100 { get; set; }     }


title: Use of `is` and `as` in multiple conditions

text: Quite recently, I thought about the use of `as`, `is` and direct cast in C#. Logically, is it a better idea to use :                var castedValue = value as type;      if (null != castedValue)      {          // Use castedValue.      }      than :               if (value is type)     {         var castedValue = (type)value;         // Use castedValue.     }      But I still have issues when dealing with this kind of pattern:               if (value is Implementation1)     {         var castedValue = (Implementation1)value;         // Use castedValue in a first way.     }     else if (value is Implementation2)     {         var castedValue = (Implementation2)value;         // Use castedValue in a second way.     }     else if (value is Implementation3)     {         var castedValue = (Implementation3)value;         // Use castedValue in a thrid way.     }     // And so on...      How can I improve this code to prevent casting two times when OK, and is it really necessary to cast twice? I don't want to make the code unreadable, but the idea is not to test a cast if a previous one succeeded. I had several ideas to fix this, but none of them seems to really satisfy the conditions... **Edit:** Here is a case I've got... There is this object that is created by a lower part of teh code I do not have control on. This object can be of several inherited types. In my layer, I do want to create a specific object depending on this type. I do have this constructor class:               public static IHighLevelObject MakeHighLevelObject(LowLevelObject lowLevelObject)     {         IHighLevelObject highLevelObject;              if (lowLevelObject is LowLevelObject1)         {             highLevelObject = new HighLevelObject1((LowLevelObject1)lowLevelObject);         }         else if (lowLevelObject is LowLevelObject2)         {             highLevelObject = new HighLevelObject2((LowLevelObject2)lowLevelObject);         }         else if (lowLevelObject is LowLevelObject3)         {             highLevelObject = new HighLevelObject3((LowLevelObject3)lowLevelObject);         }         // And so on...              return highLevelObject;     }      How do I solve this case ?


title: Are exceptions an OOP concept?

text: Having read a post yesterday, I realized I did not know much about the origin of exceptions. Is it an OOP related concept only? I tend to think it is, but again there are database exceptions.


title: Branching model suggestion for same project multiple clients

text: We have a very big project that includes several applications that acts as the base for different clients. Every client has its own personalization of the product, different milestones, different requirements and so on, and thus each project will evolve independently based upon its own needs. The core of the project, is _similar_ (but not equal) in every project and the organization is made so that there are teams that handle each client independently (but with communication among them as needed). So far, I've been unable to find any scheme that suits our needs, either by searching the internet or coming up with some brilliant idea :) So far, we've been working by getting the product as a suit all needs, with specific branches for needed changes but, though the product has a good architecture, it's slowly becoming a big problem. Here are the main problems we face:   * Different milestones for each client: Which means each team has to produce versions as different times without the rest of the commits affecting the stability or their product.   * Different requirements, which may or may not affect the core of the system in some cases.   * Large teams (20+ team members)   * Handling bugs in the system: What do you do if a team finds a bug in his project that might affect other clients? **Note:** We're talking about a project that has 10+M LOC. **Note:** We're using Team Foundation System, Visual Studio 2008 and C# (mainly). Any suggestions, sources or ideas about how to address the situation? Is there any model in the market that has a similar problem?


title: Book or resources to gain a better DB understanding

text: Please see this response I'm creating a website that has the potential to become extremely reliant on its data, and would need to be, eventually, serving up lots of data fast. When I read the above answer, I feel that perhaps MySQL isn't the best DB for me to be using. The problem is that I don't really know much about databases in general. I'm this atypical "Web 2.0" programmer who thinks MySQL is great because, well, it's all I've ever used. I have some questions:   * What should I know about databases so that I may make a more informed decision in the future? What resources would you recommend?   * Can I still use a PHP Framework, such as CakePHP, while choosing "alternative" databases? Is this a recipe for disaster?


title: Determining if language/framework/technology is 'Future-proof'

text: I'm a PHP developer and I recently started to work with CodeIgniter. It seems that whenever I search for something related to CodeIgniter, the blog posts and what not are usually from '09 or '10, so it got me thinking, is CodeIgniter still relevant and is it going to be in the future? Is there another framework that is taking it's place? The same goes for other languages and frameworks as well. At what point do you abandon learning certain languages or frameworks? Is there any easy way to find those that are emerging and worth picking up?


title: Writing recursive functions

text: I am having a lot of trouble writing recursive functions related to trees. I can't just use google for these functions as they are not general and I won't be able to use google in an exam setting! Is there some 'trick' to successfully coming up with an algorithm/writing psuedocode for recursive functions? Is there a certain way I should think about/approach this? **Example** : Write a recursive function that determines whether a given binary tree has a structure consistent with a valid AVL tree. **Solution Expected** :               template <typename Type>     bool is_avl (const Binary_node<Type> * tree)     {     if (tree == NULL)     {     return true;     }     return is_bst (tree)     && is_avl (tree->left()) && is_avl (tree->right())     && std::abs(height(tree->left()) - height(tree->right())) <= 1;     }


title: Address search from large text file

text: Basically I want to develop a Address lookup(part of my project) using C# (and I can use SQL if necessary). I have a very large text file which have all the UK address and postcodes. Addresses needs to be looked up from this text file. For example, as soon as a user type in the first letter of the postcode it should list all the postcodes starting with that letter and as they type in further, the list should narrow down. Could you guys please how I can do this search very fast and list the results in a efficient way. If you guys know any methods and technologies pls do advice.


title: Catering for client's web-hosting needs, minus the headaches?

text: I'll be trying to sell my Ruby on Rails development skills to _small local businesses_. It seems I'd be shooting myself in the foot if I couldn't manage to put their apps into production, in fact catering for this would be a selling point. However, **I do not want to bill every client monthly for the cost of their hosting** , they would have to be the contract holders with the hosting service, and _I'd only consult if they needed technical help when scaling_. I've looked on one hand at cloud platforms, like engine yard, which seem like they would be too costly for the smaller clients, and on the other hand at vps providers which seem they would not be client friendly enough. Has anyone faced the same issue and come up with a decent solution ?


title: The future for a .net developer after the BUILD conference

text: Looking back on Microsoft's BUILD conference and everything that came out of it, I'm not sure what direction I'm supposed to take as a developer? If I understood it right MS is putting HTML5 before WPF, Silverlight and Flash, and there's also talk about WinRT and Metro UI. I'm going to buy a couple of courses in the winter but I'm not sure what to choose? **I KNOW**   WinForms   MVC3   LINQ   CSS2   jQuery   json **LEARNING**   HTML5   CSS3 What else?


title: About to graduate from good school without any progamming skills

text: I am about to graduate from a good US school with a Computer Science degree, having good grades and high GPA. I have no freaking clue how to write a good program, how to properly test it... nada, zero. We were never taught how to write software. Yeah, sure the Computer Architecture class is important, and I can tell you a lot about how MIPS processor works, and I can tell you about Binary Trees and Red-Black Trees and running time of operations in Big Oh, but it has nothing to do with programming in "real" life. Heavens to Betsy, none of my classmates know how to use STLs or write templated code! To be honest, I found many of my classes to be a waste of time. What should I do? How do I step into real life and learn how to program ?


title: When should one give source code to a client?

text: I am a member of a small team who developed software to control the hardware of a robotic device. Now the customer demands to see our commercial code. Our promise was just to develop the software and make his machine work. (He failed to program the robot himself, that is why he hired us). But the project did not start as a hiring agreement, more as a develop and make it work, we did lots of research to make his robot even possible to work I wonder if we should give the source code? I have serious doubts about releasing the code. I believe the customer is planning to steal our c++ / c# code. We provided him the executables installed on the finished programmed robots. Our code wasn't developed just for his robotics device, but is part of our libraries we use commonly in various projects. When can a customer claim that he owns software? And when he does what does it mean. I mean having the c++ code, having a disassembler code, having c# code? Where does it end? We gave our software to an escrow agent, and we believe that is fair. But giving them our code seams to us unfair, knowing that customer will then go on to develop based upon our code. Parts of the code also use a home developed software protection, which we cannot give due to that it is used in other products.


title: delivering ebook throught mobile app

text: I have designed the interface of a mag app which would deliver digitized magazine in the size of A3 paper to the mobile phone. My choice of fileformat is jpg of each of the pages, but is there any better way to do this that using jpeg format. The file for one sample magazine was 16MB, and I'm stuck weather to deliver page by page or as a whole file which can be flipped


title: What to do if a co-worker is editing your code just to change the appearance?

text: What should you do, if a co-worker is editing your code? Without the purpose of adding functionality or fixing bugs, just to change how it looks...


title: Creating a voting platform for submissions during timeperiod

text: I have a site where stories are submitted at any time by users. The staff would like the ability to create a voting period at any time. For example, they can choose to open up voting from today until next week. The staff also gets to choose which stories are put into the voting ring to allow votes. During that period, people have the ability to vote one time on a story. Once they vote, they can no longer cast a vote. I am thinking way to hard about how to program this and I don't know why. From a database standpoint, I already have a table that contains all of the submissions. I need to then have a table that stories which stories are voting allowed to be voted on. I then need to have a table that contains the stories that are voted on by the users. Is there an easy process you can think of to accomplish this? Some times a little discussion is all I need to get out of my current mindset. Thanks


title: Subrepositories (submodules) as a dependency tracking solution - yes or no?

text: What do you think about SCM-based (subrepositories in mercurial, submodules in git) dependencies management? Is it definitely a good way of managing dependencies? Or definitely bad way? Should I prefer some build system (ant/phing/rake) over subrepositories? Some particular example for you to have a context: I have several web applications that share across reusable components, say jquery plugins.


title: How to begin writing a relational SQL database

text: I was wondering about how databases like MySQL and SQLite are developed to run as quickly and as well as they do. I'm looking for answers to questions **like** :   * How is SQL token-ized? Do you build an AST and compile/interpret like any other language?   * How should one handle connections to the database? TCP? IPC? How do big-name databases do it?   * How is the data is these fast relational databases stored? I know SQLite uses a flat file -- seems like a synchronization nightmare. Obviously, I don't expect anyone to just explain all of relational database theory to me -- but I've been looking around and I'm really at a loss for references to start learning about this stuff. To answer the inevitable "why don't you just use MySQL?": (a) because I'm curious and (b) maybe someday I'll want to design my own database with a specific use in mind. EDIT: I guess I should've made this more clear. I realize this is a broad topic. I am not looking for someone to say "oh, you design a database by..." If this is a topic covered in a large number of books, what are those books? If this is covered well in a P.h.D. thesis you know of, what is that thesis? I am very aware that this is a broad topic -- I'm not asking for a specific answer for a broad question, I'm asking for specific resources for a broad question. As always, thanks for all the help!


title: I target short projects, but fail miserably on projects that requires persistence

text: I know this is kind of time-management question. I do well in short assignments, but fail miserably, when it comes to projects that require hours and hours of work to be done day after day. I cannot code more than 10 minutes, unless there is a deadline. I kinda wander and come back and code. It takes me ridiculously large amount of time even for simple project. I kinda lack persistence. I have my thesis coming up in December. The more time I spend, the better my publication will be. I was wondering, may be I could get some help on how to code persistently? I just get out of my chair and start doing other things, when I see a bug or when I have a module that requires thinking and it takes me long time to come back sit and put my thought back to the code. Any advice on how to improve my persistent coding skills?


title: Is changing the type of a variable partway through a procedure in a dynamically typed language bad style?

text: In Python (and occasionally PHP) where variables do not have fixed types, I'll frequently perform 'type transformations' on a variable part-way through my code's logic. I'm not (necessarily) talking about simple casts, but about functions that change the type of a variable while leaving it basically representing the same value or data. For example, I might write code like this when doing a web request, using the `response` variable to store an addurlinfo object, then the string content of that object, and the dictionary returned by parsing the string as JSON:               response = urlopen(some_url)     assert response.info().type == 'application/json'          response = response.read()     logger.debug('Received following JSON response: ' + response)          response = json.loads(response)     do_something(response)      (Okay, it's a slightly contrived example, but I think it demonstrates the idea fine). My feeling is that this is better than using three separate variable names because a) it conveys that the `response` variable contains basically the same information, just 'transformed' into a different type, and b) it conveys that the earlier objects aren't going to be needed any further down the function, since by reassigning over their variable I've made them unavailable to later code. The tradeoff, I guess, is that the reader could become confused about what type the variable is at any given moment. Is this bad style, and should I be using three different variables in the above example instead of reassigning to one? Also, is this standard practice in dynamically typed languages, or not? I haven't seen enough of other people's code to know.


title: Term for a single C++ endpoint/object file

text: I have heard several terms for a C++ "Codepoint" (which is what I've heard used the most often), or a `.cpp` file that is compiled into an object file. For instance, `.cpp` files can include other `.cpp` files (or any other file, really, so long as it compiles), but during compilation, there is really only one 'main' code file that is used/generated. I know there is a widely accepted term, I just can't recall what it is. What is the accepted term for the final `.c`/`.cpp` file used to generate an object file?


title: How to determine if a programming language is verbose or terse?

text: Programming languages can often be described as **verbose** or **terse**. From my understanding, a verbose language is easy to read and understand, while a terse language is concise and neat, but more difficult to read. _Should there be other things to consider in the definitions?_ It seems much of the popular programming languages of today are verbose, and these terms two terms are only used to describe a language as being more or less, relative to than another language. _How do we determine if a programming language is more verbose/terse over another?_ Example: Is C# more verbose than Java?


title: Parallelization: Choice of communication model

text: **Disclaimer:** If you're not into parallelization (on clusters), this question is probably not interesting to you and probably not worth a read. **TL;DR:** I search for a communication model (preferably compatible with `MPI`) that efficiently assures that each data line is processed once. Read the next paragraph as well to know what I mean by data line. Consider the following problem: An algorithm takes a data line (in my case, an array of integers with fixed size) and produces various data lines which then need to be processed by the same algorithm. Each _unique_ data line only needs to be processed once, since the outcome is purely deterministic. The set of unique data lines is finite, so after a finite number of recursive calls of this algorithm it produces the whole set. The goal is to find this set. I've already implemented the algorithm and I've also implemented a parallelization. Obviously, since we need to process each _unique_ data line, at each time all currently unprocessed data lines may be processed by different processors in parallel. On the other hand, parallelization introduces the problem of keeping the different processors from doing redundant work. A trivial implementation would send data lines to processors, collect all results and distribute again. This may be inefficient since the (possibly large) result lists have to be merged before any further work may be done. If all lists are returned around the same time, the master is overwhelmed by the sheer amount of data while all slaves idle until all merging is done. My (as far as I think, improved) communication model is still basically Master-Slave: This is what the Master does:               Distribute initial chunk of data lines to slaves     While there is at least one active slave       for each active slave         Request data line         if slave doesn't have a data line           set slave inactive, break         else           if the data line was previously processed             break           endif           if there is an inactive slave             send the data line to inactive slave and mark that slave as active             send the sending slave a notification to not process the data line           else             notify the slave to process the data line it just sent           endif         endif       endfor     endwhile      Each slave does this:               while true      wait for request      if data line available        send it        wait for master to say if the line should be processed here        process if necessary        go back to beginning      else        notify master        wait for master to send a data line        process the received line        go back to beginning      endif      The slave manages its own local list of processed and unprocessed data lines. For each request, one element of the unprocessed ones is moved to the processed ones. Only unique entries among both lists are stored. In conclusion: Only the master knows about the full set of processed lines. a slave processes a data line if and only if the master says that it wasn't previously processed. The Master doesn't know about the results for each data line until it has requested all available lines from each slave. As far as I can think, this model of communicating the list of processed data lines is pretty efficient, but I'm new to the world of parallelization, especially in the world of parallelization on a cluster. What are other ways of efficiently communicating data lines among several processors to assure that each data line is processed exactly once? This question is basically not bound to the combination of `C++` and `MPI`, though any answer reflecting the way the Message Passing Interface works are greatly appreciated.


title: Clarification of Python Functional document

text: I'm rereading this http://docs.python.org/2/howto/functional.html document and hit this line, '...Unfortunately, proving programs correct is largely impractical and not relevant to Python software. Even trivial programs require proofs that are several pages long; the proof of correctness for a moderately complicated program would be enormous, and few or none of the programs you use daily ( **the Python interpreter** , your XML parser, your web browser) could be proven correct. Even if you wrote down or generated a proof, there would then be the question of verifying the proof; maybe there’s an error in it, and you wrongly believe you’ve proved the program correct.' /Emphasis mine on the Python interpreter part/ What does that mean that the Python Interpreter cannot be proven correct? Is that because it would be a long proof or that it in principal can't be proven correct, ala Godel like theorem? Is using the Interpreter then a useful fiction that all the while we use it, it could be wrong all the while, and what would being wrong mean? I mean, the interpreter has given me correct answers on integral arithmetic, so far... Clarification much appreciated.


title: Letters of recommendation from customers?

text: I am leaving my job soon and am looking for letters of recommendation. My problem is, I've worked more closely with my customers than my project lead (not technical) or manager (the customers usually talk to me first and rarely even if CC my lead if I don't). So in this case, the customer has seen my work more closely than my leadership and can better attest to my abilities, communication skills, and performance. Are recommendations from customers viable, or will they be largely dismissed? Secondarily, can they be more useful than letters from managers that don't really know your work at all? Note: I already have a letter from the only coworker I've really worked with, but I'm looking to get more than one for good measure.


title: Legal aspects of Java specification implementations in other programming languages

text: I am planning to implement an official Java specification in a different programming language. Would this be a copyright violation? Hypothetical examples:   * a **JMX** "wrapper" library for C++ which can control a Java application over JMX, and uses similar concepts and class/method names as the Java implementation   * a **JavaMail** API and implementations (for different .Net network libraries) for C#


title: Making big changes incrementally

text: Currently working on a complete front-end and back-end overhaul of our webapp. We did this because a lot of changes needed to be made to the database schema as well as the user experience. Now we are almost done with the overhaul and I'm thinking if we could have taken a more incremental approach? We started a new codeline for this overhaul and now we have to figure out a good data migration plan to make sure the old data is transferred over to the new schema properly. We made the decision to do a separate codeline because we thought that if we did incremental changes to the schema, there would be more downtime to the site. A separate development cycle for it would reduce that downtime to the final day when we do the data migration. And of course that carries more risk. What are some good approaches to this problem for the future if we ever need to do another major overhaul? Incremental approach would be desirable.


title: event listener pattern in api - what should adding the same listener twice do?

text: In designing an API that provides an event listening interface, it seems there are two conflicting ways of treating calls to add/remove listeners:   1. Multiple calls to addListener will only add a single listener (like adding it to a set); can be removed with a single call to removeListener.    2. Multiple calls to addListener will add a listener each time (like adding it to a list); must be balanced by multiple calls to removeListener. I've found an example of each: (1) - The DOM addEventListener call in browsers only adds listeners once, silently ignoring requests to add the same listener a second time and (2) - jQuery `.on` behaviour adds listeners multiple times. Most other listener APIs seem to use (2), such as SWT and Swing event listeners. If (1) is chosen, there's also the question of whether it should fail silently or with an error when there is a request to add the same listener twice. In my implementations, I tend to stick with (2) since it provides a cleaner setup/teardown type interface and reveals bugs where 'setup' is unintentionally being done twice, and is consistent with most implementations I've seen. This leads me to my question - Is there a particular architecture or other underlying design that lends itself better to the other implementation? (ie: why does the other pattern exist?)


title: I keep failing hands on part of the interview, suggestions?

text: So I have a couple of software/site in my portfolio. They make money but not a whole lot. So I decided to get some job experience, mainly applying to Java/PHP junior development positions. The problem is that I answer all the technical questions correctly and we schedule to do a coding "test", the final phase of the interview. I can never relax and over think things and end up doing the test very slowly. OR sometimes I just hit a block and find it very difficult to think on my feet. I don't understand this because other stuff I had written were solving far more complex problems while the "Test" is actually brutally simple such as writing and testing palindrome. Other times, they will give me a logic test with flows to math operations and again I won't be able to do it in the time they assign. I know I can write sellable software/websites that can generate small revenues and find ways to solve problems but I have great difficulty with simple coding tests in interviews. Any suggestions?


title: I'm looking for recommendations or advice on how to improve our workflow?

text: I'm working within a team and corporate is breathing down our necks to become more efficient, as projects are on average taking us 6+ months to complete. I was only recently hired (back end development) and it feels very unorganized to me. Unfortunately, being the newcomer, I don't have much of a voice. I'd like to propose a new workflow and was hoping to get some advice that might help make a positive impact / impression? **Current work flow:**   1. Sales - makes a sale. Discusses any potential issues with development before hand.   2. Sales, design and copy meet with client for strategy session. Development is only invited when programming related questions are expected to come up.   3. Design creates a few mockups which are then approved by the client.   4. Copy writes / proof-reads the content, creates a list of keywords for SEO, also approved by the client.   5. Design creates the inner pages and lays the copy into the PSD.   6. Front end development creates the template including all content, and all client-side functionality, approved by client.   7. Back end development creates the databases, programs the website and hooks up CMS / content management.   8. Development trains the client on the back end and if approved, adds analytics and launches the site.   9. Development continues to provide client support if necessary. **Proposed work flow:**   1. Sales - makes a sale. Discusses any potential issues with development before hand.   2. Sales, design, copy and development meet with the client for strategy session, regardless of whether or not programming is involved.   3. Design creates a few mockups which are then approved by the client.   4. Development reviews approved mockup and discusses any potentional issues with CMS / inner page design.   5. Design can now work on the inner pages while both copy writes content and front end development creates the initial template.   6. After inner pages and / or copy is complete, front end finishes the template. Both copy and front end can be simutaneously approved by the client.   7. Back end development creates the databases, programs the website and hooks up CMS / content management.   8. Development trains the client on the back end and if approved, adds analytics and launches the site.   9. Development continues to provide client support if necessary.


title: Commercial vs Personal software licenses

text: If I work for a company and write code for them but I choose to buy a tool for myself and use it to write code for the company, do I need a commercial or personal license? Specifically, in this case, I am asking about WebStorm IDE JetBrains have Commercial (For companies and organizations) and Personal (For individual developers). I am an individual developer working for a company!


title: Testing UI for azure web app on iPad

text: I am working on debugging my mobile application. There is a specific requirement/issue that I am having related to a drag and drop touch interface on an iPad. I am at the trial and error phase of trying to figure out how to fix this (meaning I have no idea how to fix the issue I'm seeing). The only way I have been able to figure out how to test my app on a mobile device is to deploy it to my azure test instance because the azure compute emulator always runs sites under 127.0.0.1. This is really annoying since each deploy to azure takes 10+ minutes. So my question is, how the heck to people do mobile development on this platform? I've have found some people suggesting I could set up a reverse proxy using fiddler to allow remote connections but so far I haven't been able to get this to work. Is there some sweet ios simulator that I haven't been able to find? Am I missing something?


title: Code Review tools - to use or not?

text: On my dev team, we're doing code reviews, however not in a proper way i believe. The issues our process suffers from:   1. Not enough time is allocated for proper code review.   2. Doing reviews is not mandatory - many times it is simply not done.   3. Devs sit together for reviews, due to lack of another easy mechanism for doing it "offline" without spending both developers' time. My question is: can integration of a tool for code reviews improve the points mentioned above? Is it not needed? I would love to hear from positive/negative experiences.


title: Is the financial sector any different from other sectors in terms of language fragmentation?

text: ## Language Choices of Large Corporations Having spent almost 12 years working in the financial sector, at both large and small companies, my overriding impression, with the exception of Goldman Sachs, is that **fragmentation** (or, putting a more positive spin on things, **diversity** ) is the name of the game. Within a single company, we might see C, C++, Smalltalk, Java, J++, Perl, C# and more. Even now, I hear about large swings _towards_ using languages which have been around for 30 years but which are not widespread within the company (i.e. avoidable fragmentation; if the language wasn't appropriate 5 years ago, why now?) I guess I'm interested by   * Are large, technology-focused companies outside the financial sector as fragmented as those within it?    * Why has this fragmentation happened?   * Are _software companies_ as fragmented? ## The position of Java My impression is that Java largely “won” the first decade of this century in the financial sector, which (probably) saw the biggest historical expansion of systems. By "won", I simply mean that it was the most popular choice for new systems during this decade. I'd be grateful to be pointed towards any **evidence** as to these points, and especially sector-comparisons. _PS. My reasons for asking this question are that I will be giving a talk to students in London about building financial IT systems. I would like to be able to place my experiences of financial IT in a wider context, and I do not want to make sweeping generalizations._


title: Users and roles: Where to put queryUsersWithRole()?

text: I have two model classes `User` and `Role` and two managers/DAOs (`UserManager` and `RoleManager`) plus a method which gives me all users with a certain role (`List<User> getUsersWithRole(Role)`). In which manager does this method belong and why?


title: How to choose between git and Mercurial

text: Both Git and Mercurial are DVCS, and that's great. I wonder if there is a list of particular situations when one of those systems are preferable, something like 'In mobile development for many platforms git is better because ...'.


title: What is the most basic and simple platform for collaborative development (PHP project)?

text: I need to work with 4-5 programmers on a fairly average PHP application using codeigniter. We're in 5 different locations in one city, and all of the programmers are all not too well educated and I'm assuming that most of them have never used any version control system. Can you recommend some very very easy-to-get-into platform for collaborating on a project like this? I'm talking about something that is only a tad more sophisticated than a shared dropbox folder.


title: Google Analytics and customers privacy

text: I work in a company that sells SaaS web applications for HR and financial issues. Our customers are key accounts to which we guarantee the privacy of their data, for obvious reasons. We need to make usage statistics of our applications by its customers (which links are clicked the most? Which browsers are used the most? What is the average screen resolutions? etc). I personally use Google Analytics on my sites. GA is a very powerful and complete solution for this. But it raises questions of privacy.   * Have you already had this problem?   * Were you able to impose on your customers? how?   * If not, did you use an alternative? or did you develop your own measurement tools of statistics?


title: ASP.NET Web Forms is bad, or what am I missing?

text: Being a PHP guy myself I recently had to write a spider to an asp.net site. I was really surprised by the different approach to ajax and form-handling. For example, in the PHP sites I've worked with, a deletion of a database entry would be something like:               GET delete.php?id=&confirm=yes and get a "success" back in some form (in the ajax case, probably a json reply). In this asp.net application you would instead post a form, including all inputs on the page, with a huge __VIEWSTATE and __EVENTVALIDATION. This would be more than 10 times as big as above. The reply would be the complete side again, with a footer containing some structured data for javascript to parse and display the result. Again, the whole page is sent, and then throwed away(?) since it's already displayed. Why not just send the footer with the data to parse (it's not json nor xml but a | separated list). I really can't see why you would design a system that way. Usually you've a fast client, and a somewhat fast server but a really slow connection. Why not keep the datatransfer to a minimum? Why those huge __VIEWSTATE and __EVENTVALIDATION? It seems that everything is done way to chatty and way to complicated. I really can't see the point and that usually means that I'm missing something. So please tell me, what are the reasons for this design and what benefits (and weaknesses) does it have? (Yes I know that __VIEWSTATE is used to tell what type of form-konfiguration should be sent back to the server. But WHY is this needed?) Please keep this discussion strictly technical and avoid flamewars. * * * Update: Please excuse the somewhat rantish question. I tried to explain my view to be able to get a better answer. I am _not_ saying that asp.net is bad, I am saying that _I_ don't understand the meaning of those concepts. Usually that means that I've things to learn instead of the concepts beeing wrong. I appreciate the explanations about that "you don't have to do this way in asp.net", I'll read up on MVC and other .net technologies. However, there most be a reason for this site (the one I referred to) to be written the way it is. It's written by professionals for a big organisation with far more experience than what I've. Any explanation about their (possible) design choice would be welcome.


title: How difficult is Python and Django to pick up for a Java/.NET web developer?

text: I just started a new job a couple months ago at a small company where I am currently leading all development efforts present and future. I personally have years of experience in software design and development from mostly Java but also a .NET perspective. I picked up .NET later in my career with great ease and required literally no training to hit the ground running, and on top of that it helped me to truly grasp and appreciate the universality of many best practices and common themes by seeing two different perspectives to solving the same problem. My boss has a startup company on the side, and without divulging too much information, he had a need of a moderately sophisticated web application that integrates into Google Maps to build routes. He contracted out the web application to which they overpromised, majorly underdelivered, and ran over the deadline, he is currently in a fight to try and recover at least some of the money he invested. He has the source code for the site as it is right now but has a laundry list of things he would like fixed and added before he goes live with it. He asked me if I would like to do this on the side for some extra cash but the problem is that the site was written in Python using Django, which I have no experience in whatsoever. I told him that I am really not the best person for this because I no virtually nothing about Python or Django and would have to learn it from scratch. I feel it wouldn't be fair for me to bill him hourly for my time if I am using that time learning a language and platform. Based on the summary of my experience level how difficult or how much time would you guess it would take for me to pick this up? If you think its a waste of time could anybody recommend a suggestion for where to find experienced Python web developers? Money is a concern for him right now so he doesn't have the biggest budget anymore. Thanks for your suggestions!


title: Should I just always Convert.ToInt32 my integers to account for potential nullable integers?

text: If my MSSQL database contains a data type that is NULL (i.e. null is allowed) then ORMs, such as EntityFramework in my case, create .NET objects that are nullable. This is great, and the way I use nullables is like this: **C#**               int? someInt = 5;          int newInt = someInt.Value; // woot      **VB.NET**               Dim someInt As Integer?          Dim newInt As Integer = someInt.Value ' hooray      However, recently I had to make a change to the database to make an Id field no longer NULL (nullable). This means that `.Value` is now broken. This is a nuisance if the Id property is used a lot. One solution that I thought of is to just use `Convert.ToInt32` on Id fields so it doesn't matter if an int is nullable or not. **C#**               int newInt = Convert.ToInt32(someInt); // always compiles      **VB.NET**               Dim newInt As Integer = Convert.ToInt32(someInt) ' always compiles      Is this a bad approach and are there any alternatives?


title: Easy way of engaging non-programmers (i.e. designers) into using version control?

text: What are some key ways of getting your team involved in using version control during development, web development or otherwise? I refuse to work without it, which means anyone involved in the project must also use it. It's just good practice. GUIs like Tower have helped, but the concept of it is either met with anger ('not my job!' kinda attitude), timidness, or just straight up not using it (using FTP instead, circumventing version control for say, dev or deployment). Edit: I should have clarified a little that I don't just mean images/PSDs.


title: In API design, when to use/avoid ad hoc polymorphism?

text: Sue is designing a JavaScript library, `Magician.js`. Its linchpin is a function which pulls a `Rabbit` out of the argument passed. She knows its users may want to pull a rabbit out of a `String`, a `Number`, a `Function`, perhaps even a `HTMLElement`. With that in mind, she _could_ design her API like so: # The strict interface               Magician.pullRabbitOutOfString = function(str) //...     Magician.pullRabbitOutOfHTMLElement = function(htmlEl) //...      Each function in the above example would know how to handle the argument of the type specified in the function name/parameter name. Or, she could design it like so: # The "ad hoc" interface               Magician.pullRabbit = function(anything) //...      `pullRabbit` would have to account for the variety of different expected types that the `anything` argument could be, as well as (of course) an unexpected type:               Magician.pullRabbit = function(anything) {       if (anything === undefined) {         return new Rabbit(); // out of thin air       } else if (isString(anything)) {         // more       } else if (isNumber(anything)) {         // more       }       // etc.     };      The former (strict) seems more explicit, perhaps safer, and perhaps more performant -- as there are little or no overheads for type checking or type conversion. But the latter (ad hoc) feels simpler looking at it from the outside, in that it "just works" with whatever argument the API consumer finds convenient to pass to it. **For the answer to this question** , I'd like to see specific pros and cons to either approach (or to a different approach altogether, if neither is ideal), that Sue should know which approach to take when designing her library's API.


title: Why is Inversion of Control named that way?

text: The words `invert` or `control` are not used at all to define Inversion of Control in the definitions that I've seen. ## Definitions Wikipedia > inversion of control (IoC) is a programming technique, expressed here in > terms of object-oriented programming, in which object coupling is bound at > run time by an assembler object and is typically not known at compile time > using static analysis. ~http://en.wikipedia.org/wiki/Inversion_of_control Martin Fowler > Inversion of Control is a common pattern in the Java community that helps > wire lightweight containers or assemble components from different projects > into a cohesive application. ~ _based on_ > http://www.martinfowler.com/articles/injection.html _(reworded)_ * * * So why is Inversion of Control named Inversion of Control? What control is being inverted and by what? Is there a way to define Inversion of Control using the terminology: **_invert_** and **_control_**?


title: Interesting non programming tasks for programmers

text: This question is related to my another questions asked to HN community http://news.ycombinator.com/item?id=2450143 Here is the summary of above thread: I asked HN community if we should give 2nd and 4th Saturdays off to our developers? Right now we have 1st and 3rd Saturdays off only and we work on others. OR We should have some fun, events, pet projects, movies, informal one to ones etc on those 2 Saturdays? What should be a better option for our 7 years old, small IT service company of 50 developers? I got lot of good responses. Most of them says "Give them OFF" :) I still want to try giving these 2 Saturdays to developers to do their own stuff. They can improve communication, writing skills, write blogs, work on pet projects etc etc. I wanted to know what are the other non-programming activities we can do for programmers. I am sure I am gonna get lot more good answers from this community :) Update: Well I guess that didn't go very well with everyone. Thanks for commenting and answering anyway. But I think, it will be very hard for you to understand the context I am coming through. It is my mistake that I could not explain it properly here. It is pretty common to work on Saturdays in developing countries like India. You guys are fortunate to be liberated much earlier than us (Assuming you are from US and developed European countries). Your grand fathers and great grand fathers built your country working probably 7 days a week and you are earning benefits of their hard work now by working 5 days a week. And some of you may be proposing 4 days a week too now. We still have to play catch up game and we can not afford to have leisure of working limited number of hours every week. Probably our children or grand children will enjoy working 4 or 5 days a week consistently. I am not against 5 days a week or 4 days a week here. But we have many more areas to improve up on as programmers and as individuals. English not being our native language, we have to work hard on improving English. Writing skills, Technical improvements, there are so many things we have to work on. And not every programmer is as motivated to do on his/her own. They need some guidance. We want to spend those 2 days helping them do that for their own good. Company is not going to earn from those 2 days. Yes in long term it will benefit company as well but it will be more beneficial to them. So I came here to understand from experts like you guys, what programmers can do to improve up on. We as a company will help them do that. No offense to anyone, but I hope this clarifies, why I asked this question.


title: Effective template system

text: I'm building a content management system, and need advice on which theming structure should I adopt. A few options (This is not a complete list):   1. Wordpress style:     * the controller decides what template to load based on the user request, like: home page / article archive / single article page etc.     * each of these templates are unrelated to other templates, and must exist within the theme     * the theme developer decides if (s)he want to use inner-templates (like "sidebar", "sidebar item"), and includes them manually where (s)he thinks are needed.   2. Drupal style:     * the controller gives control to the theme developer only to inner-templates; if they don't exist it falls back internally to some default templates (I find this very restrictive)   3. Funky style:     * the controller only loads a "index.php" template and provides the theme developer conditional tags, which he can use to include inner-templates if (s)he wants. Among these styles, or others what style of template system allows for fast development and a more concise design and implementation.


title: Does MVC apply only to web

text: It is almost and instantaneous whenever I talk to developers about Model View Controller ( **MVC** ) they say you make a request to a url the server builds a entity (MODEL) and provides you with visual representation of that model.   * So does this mean MVC **is only for the web** or have I been meeting people who are just developers who employ MVC for writing web applications?   * Are there usages for MVC on desktop style applications?   * I for one am new to paradigm and would like to know of any super-set to MVC


title: Using .exe of program with GNU General Public License version 2.0 for commercial

text: I have a question to somebody who is expert about "GNU General Public License version 2.0" license. I am making program and my code is using another program ("HoboCopy") inside which have this one license. I downloaded just a .exe of this one program and I am wondering if its ok with license if my boss will sell program which I made without code of course, he wants to sell it like a normal program, just .exe to use. I checked out for question like that, and no matches. Sorry I know that in a big licence documentary is probably wroten answer for my question, but forgive me, that I dont want to read it all, maybe somebody already know it and can tell me or eventually tell me the exactly piece of licence documentary where I can found answer for my question. Thanks in advance. EDIT: After published my post I read this one: GNU GENERAL PUBLIC LICENSE as part of commercial product. Looks like I got answer that he can sell it. And I dont have to give my source, and HoboCopy source (even I dont have it). Just maybe somebody can make me sure.


title: Arithmetic Coding vs. Machine Numeric Precision

text: When subdividing intervals for arithmetic coding, the worst case scenario is that the final interval will have size `2^(1-n)`, where `n` is the number of unique symbols you are encoding. This will reach the limits of machine precision, when using regular datatypes, really quickly: For instance, I've made a JavaScript implementation and it breaks after encoding around just 15 characters! As this is pretty limiting, how do codecs get around this?   * Encode [very] short blocks, within the machine's limits, and concatenate them together? That will add overhead.   * Use non-native types with arbitrary precision? This will be slow.   * Something else?...


title: Copyrights concerning code snippets and larger amounts of code

text: I am designing a public code repository. Users will be allowed to post and edit whatever amount of code they want, from code snippets to **entire multi- file projects**. I have a few major legal concerns about this:   * **Not getting sued/shut down** \- I feel the site would be a much easier target than tracking down an individual user to sue. I have looked around a bit and see links to legal info in the footer of each page is common. What specific things should I do--and what does does a site such as YouTube (which I see copyrighted material on all the time) do--for protection?   * **Citing sources and editing sourced code** \- If a user wants to post code that isn't theirs, what concerns/safeguards should I have? Will a link suffice, and what do I need further to allow the code to be edited (to improve it for example)? What can happen if a user posts copyrighted code without citing it?   * **Large chunks of code** \- What legal differences should I look out for as the amount grows?   * **Not having a mess of licenses for the site** \- I would like to have a single license (like RosettaCode) that keeps things simple for interaction on the site. I want the code to be postable _and editable_. I have looked into StackOverflow's CreativeCommons license a little and it says that > If you alter, transform, or build upon this work, you may distribute the > resulting work only under the same or similar license to this one. And on RosettaCode: > All software found on Rosetta Code should be considered potentially > hazardous. Use at your own risk. Be aware that all code on Rosetta Code is > under the GNU Free Documentation License, as are any edits made by > contributors. See Rosetta Code:Copyrights for details. What other licenses are like this?   * **Commercializing the site** \- In what ways can I and can't I make money off of a site that contains code like this? All code will be publicly visible. Initial thoughts are having ads or making money by charging for advanced features.


title: Logistically, how do you manage embedded SQL?

text: My current application is running into issues with its ORM, and we're relying on some pretty hairy SQL to express queries that the ORM can't. Are there best practices in terms of how to manage the SQL queries? For example, where do these usually live in relation to other parts of the code? Are they in separate `.sql` files, or do you edit them directly in your other source files? If the latter, does your IDE (or editor) allow syntax highlighting? Are there schemes for Vim or Eclipse which will perform SQL syntax highlighting given a set of tags (like `#begin sql` and `#end sql`, or something similar?)


title: Matching up articles with similar ones

text: I am creating a site where people can write on a niche topic. It is almost like a blog, however the area as I mentioned is a small niche with (hopefully) passionate users. I want a functionality where once someone posts his article. People with similar experience can be notified, so that they can read about. Now my question is - how to determine similar articles? I know that tagging is a way - just like here in stackexchange and I will be implementing it. But suppose people do not tag, or tag incorrectly, the whole user experience will be hard to indulge in. Does anyone have any pointers on how to match up articles other than the tagging method?


title: How to organise utility scripts inside a development team?

text: Inside my development team there are a lot of tooling/utility scripts around all members. Those scripts are mainly for specific tasks and shouldn't be part of our SCM (perforce). How should we organize those tooling scripts and snippets to spread them and let other members have access to them? Are there any good tools to share, organize and documentate scripts and snippets inside a team? Cheers.


title: Sort an array in a specific order - not ascending/descending

text: I'm working on an algorithm that works best if the inputs are passed to it in a particular order, so I want to sort them that way. The difference is drastic enough for me to consider re-sorting the array. Consider an array `a` with length `n`. I want to sort it the following way, and return the array of indices of `a` instead of the values: I define another array `w`, also of length `n`. I want to sort such that the first element is closest to the first element of `w`. Then, from the rest of the elements (excluding the one already sorted), the second element is closest to the second element of `w`, and so on. For example `a = {5.5, 6.5, 2.4, 3.1}`, `w = {1, 2, 6, 5}`. `2.4` is closest to `1`, so `output[0] = 2`, the index of `2.4`. `2.4` is closest to `2`, but already processed, so choose `3.1`, `output[1] = 3`. Next come `0` and `1`, in that order. `0` is chosen because it comes first, although both are equidistant. So, `output = {2, 3, 0, 1}` and the sorted array would be `sorted = {2.4, 3.1, 5.5, 6.5}` (each index is used to find the corresponding element). I can only think of brute-forcing this algorithm. Can there be a more efficient way to do it?


title: Pattern or solution for using classes with different interface the same way

text: What I would like to achieve is to use classes (now two, later more) with different interface the same way, so I would like avoid using decisions based on the interface on upper levels for instance, I don't want to see things like this:               if ($class instanceof 'ThisInterface') {         $thisInterfaceImplementation->doStuff();     }      Instead, I would like to call the method like $class->doStuff() and put the decisions into a wrapper like class. I would like to avoid empty methods also. I'm thinking about to use Wrapper or Adapter (and maybe Observer), but I'm curious, maybe there is a better way to do this. To be more clear here is a small explanation what I try to solve. We are building an application that has to communicate with printing houses. This means we have to add an additional page(s) to the print sheets (or not, or maybe different way), maybe we have to rename the pdf files on ftp this or that way, or not at all. We have a couple decisions to made based on the printers (on our interfaces), but at different steps or processes, therefore I think Strategy pattern wouldn't be a good fit (and I would have to create empty methods or use those ifs) The Observer pattern seems to solve all my "problems", but it might be an overkill in this case. With this, I could simply dispatch events at the points I have to make a decision and only the observers subscribed to this event would do the necessary things. No empty methods, not much problem with different interfaces. On the other hand, we would dispatch every event only one place in the code, so this seems to be a "miss usage" of this pattern. Any advice would be appreciated!


title: Communication between a C# application and C++ DLL

text: I am currently building an audio streamer and I have a CPP .dll that I use functions of inside the WPF C# GUI. The program needs to deal with sorts of events such as   * Lower/Increase Volume   * Manipulate Equalizer Bands To this point I have used named events to deal with this issue. What would be a better way of handling all those events from the GUI to the .dll? The events system I use (.dll spawns a thread which while-s on a WaitForMultipleObjects), or would it be better/smarter/more-beneficial or just better-practice to use a named pipe instead?


title: Is this mini-DSL for hiding URI passwords compatible with the URI spec?

text: # Passwords exposed in URIs An application stores URIs to be used for file transfers via SFTP, FTP, FTPS and SCP. Many of these URIs contain passwords, for example:               sftp://someuser:sekrit@host.example.com/      These URIs are visible to too many people. We cannot hide email addresses from these people. # A mini-language to get passwords out of URIs Using a mini-DSL, we can specify the parts of the email address we don't want to show:               sftp://someuser:<<CONFIG:customers/widgitco/password>>@host.example.com/      The program that does the file transfer would look for instances of this mini- DSL in the URI, parse them, look up the appropriate strings from restricted sources, and substitute those strings into the URI. For example, supposing that restricted source contains this key/value pair:               customers/widgitco/password: moresekrit      Then, after replacement, the URI should be:               sftp://someuser:moresekrit@host.example.com/      Each instance of the mini-DSL within the URI would be delimited with `<<` and `>>`. Details of the mini-DSL between the `<<` and `>>` would be free to vary in order to meet future requirements; the only requirement would be that it contain no `>>`. This would achieve my goal of reducing the exposure of these passwords. # Is this mini-language fragile?   * Are there valid FTP/FTPS/SFTP/SCP URIs which will break this scheme?   * Are they at all likely?   * What mini-DSL is less likely to be broken by valid URIs?


title: Is it improper to have an application wide source for dropdown binding

text: The WPF Combobox needs to bind a collection to it's ItemsSource and something to bind the selected item or value to. Until now, I've included both the collection and the selected value properties that I'm binding on the ViewModel that is responsible to the given view hosting the Combobox. Lately, I've been reviewing how I've implemented MVVM in my past projects, and I've noticed some things that I'm not happy with. One of them is that if multiple views need the same ComboBox, then each associated ViewModel had it's own copy of the collection. I was thinking that it would be better to expose the collection at an application level, and just provide a property for binding the selected value in each pertinent ViewModel. The way I see it working is to have a singleton ViewModel that is kept alive for the entire lifetime of the application. This ViewModel would have all of the standard collections that aren't specific to individual ViewModels. As I'm using Entity Framework, it would have it's own context, so the Selected Item properties would have to bind to the foreign key of the entity instead of the navigation property since the various ViewModels wouldn't share contexts. From there, I could encapsulate the various collections within a ResourceDictionary as a set of StaticResources, and then use those to bind to the ItemsSource of various ComboBoxes throughout the application. My question is this; Is this crazy/stupid? I taught myself WPF/MVVM from a number of sources, and I'm never sure if I'm straying from generally accepted practices. My thoughts behind all of this was that having the one source would allow multiple viewmodels to have a synced set of drop down collections. If I change the collection in one spot, the rest would show the same changes, as they all are bound to one source. Before, I needed a mediator to maintain consistency between ViewModels. Additionally, it would provide a simple, centralized and bindable singleton class to store application scoped variables, such as the currently logged in user. So, is there an obvious flaw to this that I might be missing? In the past, I implemented my MVVM pattern without any external validation. It works, with only a few growing pains... but I'm sure that it could have benefited greatly from some peer review.


title: Is it a good practice to name the returned variable "result"?

text: Is it a good practice to call the variable a method returns with a variable name `result`? For instance:               public Zorglub calculate() {         Zorglub result = [...]         [...]         return result;     }      Or should I name it by its type?               public Zorglub calculate() {         Zorglub zorglub = [...]         [...]         return zorglub;     }      I have seen both in the wild, if I need to choose one what reasons could make me prefer the former or latter (or any better name)? I am mainly thinking about Java.


title: Count unique visitors by group of visited places

text: I'm facing the problem of counting the unique visitors of groups of places. Here is the situation: I have _visitors_ that can visit _places_. For example, that can be internet users visiting web pages, or customers going to restaurants. A visitor can visit as much places as he wishes, and a place can be visited by several visitors. A visitor can come to the same place several times. The places belong to _groups_. A group can obviously contain several places, and places can belong to several groups. Given that, for each visitor, we can have a list of visited places, how can I have the number of unique visitors per group of places? Example: I have visitors A, B, C and D; and I have places x, y and z. I have these visiting lists:               [      A -> [x,x,y,x],      B -> [],      C -> [z,z],      D -> [y,x,x,z]     ]      Having these number of unique visitors per place is quite easy:               [      x -> 2, // A and D visited x      y -> 2, // A and D visited y      z -> 2  // C and D visited z     ]      But if I have these groups:               [      G1 -> [x,y,z],      G2 -> [x,z],      G3 -> [x,y]     ]      How can I have this information?               [      G1 -> 3, // A, C and D visited x or y or z      G2 -> 3, // A, C and D visited x or z      G3 -> 2  // A and D visited x or y     ]      Additional notes :   1. There are so many places that it is not possible to store information about every possible group;   2. It's not a problem if approximation are made. I don't need 100% precision. Having a fast algorithm that tells me that there were 12345 visits in a group instead of 12543 is better than a slow algorithm telling the exact number. Let's say there can be ~5% deviation.   3. I have a finite number of visitors and a finite number of places. I don't have so much places (approximately 60 for now, but it can grow to 200) but I have quite many visitors (estimated to 50 millions and this number could grow to 200 millions in the next months). Is there an algorithm or class of algorithms that addresses this type of problem?


title: Can we reduce confusion in line-based diff tools by annotating the code with some unique tokens?

text: Let's say I have               procedure1() {         --body of first procedure--     }      Then I rename it into `procedure2` and create a `procedure1` above it:               procedure1() {         --body of second procedure--     }          procedure2() {         --body of first procedure--     }      Not once a line-based diff tool has highlighted the code from `--body of second procedure` all the way to `procedure2() {` as **new code** inside `procedure1`. This is bound to happen, since most diff tools are oblivious of the underlying structure of the source code. AST-based diff tools can't work very well either, because of several reasons and I know what people really want is a _semantic_ diff tool, but that's not going to happen. I haven't seen a discussion though, about whether or not it would be practical to annotate the code in such a way that a line-based diff tool would understand the underlying structure of the source code. For example, I could throw in some UUIDs in the code, like this:               //BeginBlock{E999A3BF-626E-428F-A2C1-6AFF0CD22BF2}     procedure1() {         --body of first procedure--     }     //EndBlock      And the modified code would look like this:               //BeginBlock{7C734F0A-92F4-45EB-B653-DBB9A0F18354}     procedure1() {         --body of second procedure--     }     //EndBlock          //BeginBlock{E999A3BF-626E-428F-A2C1-6AFF0CD22BF2}     procedure2() {         --body of first procedure--     }     //EndBlock      The point is to assign some tokens (unique within a file or project) to some marks that would reflect part of the structure of the source code. An IDE could update those annotations automatically and they could help a diff tool better detect structural changes. The tool would scan the code once to identify the sections of the program (and how they've been moved around) and then compare those blocks having the same ID. Do you think this approach is practical?


title: Does Scrum make sense when implementing a new compiler backend?

text: I have an existing language that I need to port to a new platform. I'll probably attempt this by changing the backend of the existing compiler. It is a significant amount of work to re-write the backend. I can't see a way breaking this down into sensible stories without violating INVEST criteria. I can't see how each story can be Negotiable - they are all required for a working compiler. The stories are all of equal priority and it doesn't matter what order I deliver them. I need to do them all. There are some parts of the software I'm implementing that are lower priority than others and I can see that we can deliver that incrementally. However, there is a significant core that is Must Have. I plan on trying to follow Scrum, but am I just going through the motions? Are there recommended practices for this kind of project?


title: Software Architecture - From design to sucessful implementation

text: As the subject goes; once a software architect puts down the high level design and approach to a software that is to be developed from scratch, how does the team ensure that it is implemented successfully? To my mind the following things will need to be done   * Proper understanding of requirements   * Setting down coding practices and guidelines   * Regular code reviews to ensure the guidelines are being adhered to   * Revisiting the requirements phase and making necessary changes to design based on client inputs if there are any changes to requirements   * Proper documentation of what is being done in code    * Proper documentation of requirements and changes to them    * Last but not the least, implementing the design via object oriented code where appropriate Did I miss anything? Would love to hear any mistakes that you have learned from in your project experiences. What went wrong, what could have been done better. Thanks for taking the time..


title: What is a good estimation technique for initial, high-level estimates?

text: I'm currently using Planning Poker to do our detailed estimates. This works great but relies upon a fairly detailed work breakdown. Often it takes 6-8 weeks to get a sufficiently detailed design and work breakdown. I've found the 6-8 weeks of analysis are often wasted as the estimate comes out so high it doesn't make economic sense to continue the project. I think providing a high-level estimate up front with a wide range might be better to weed out these shaky business cases. What tools and techniques exist for high-level initial estimates? Right now I just pick a previous project that "feels" the same and provide a -50%/+100% range.


title: Advanced .NET Generics, and where to start?

text: I have been reviewing C# code that has a lot of generics (and generics with generics...) and its taking me longer to grok the code. I know the gang of four patterns, and I know some of the fowler enterprise patterns (learning them as I go).   1. Are there any techniques you could suggest when tackling understanding systems like this?   2. Are there any resources on developing systems like this?


title: Java naming conventions vs. C++/C naming conventions

text: I am a Java developer who is starting to pick up more and more C++/C (yes I know they're different, bear with me). One thing that struck me as odd was the different naming conventions used by these languages. In Java, is is very common to see something like this:               int someVariable = someFunction(someParameterToPass);      However, in C++/C, it would look a bit different:               int some_variable = some_function(some_parameter_to_pass);      The reason I ask is because I (alone, no team) have just started a large project using C++, and right now am using Java naming conventions in my code (it's what I'm used to). But then I add in some external libraries to my code and it mixes the naming conventions together. I understand the code easily, and use the differences to tell my code apart from library code. Should I switch my naming convention for the sake of readability to others (while the LOC is relatively low), or stick with what I'm doing now (since I am the only developer)? **Note -** my code has been peer reviewed, however, the reviewers mainly focused on the function of the code. They didn't mention mixed conventions, and I did not specifically ask them about this. They also didn't have experience with switching naming conventions.


title: In javascript and other languages which lack a compiler, is unit testing a good method to ensure correct syntax and variable naming?

text: I've been working on a medium sized web application that makes very heavy use of javascript. I tend to introduce common errors per 10 lines of code with either an unknown variable name or function name from another module\namespace or forgetting a return and other common errors. I'm noticing I'm getting quite a lot of feedback in fixing these errors as a side effect of my qunit testing. Is unit testing a typical way to make up for a compiler in dynamic languages?


title: How to improve programming environment for optimal productivity?

text: As a beginner programmer I find myself spending hours and sometimes even days on my desk reading code, writing code, focusing, getting headaches and whatnot. I've documented myself on computer health and such, purchased an ergonomic keyboard & mouse, however since I wish to take a career in programming, this question keeps coming in my mind. We all know programming is a tough job especially from a health point of view. Programmers spend hours and sometimes don't even sleep, they develop health problems and eating disorders because they _have_ to get the job done. My example could be purely unique. The question however is not necessarily for health as it is for productivity. I've read articles which said therapy music could help your brain think sharper and be more productive. The real question is, as the title suggests (hint hint): how to improve programming environment for optimal productivity? Are there any specific rules I should be following when programming to help me focus and keep my mind sharp so I develop better code?


title: Trying to do some Obfuscation, How should I approach this particular case?

text: I currently have an assignment that is really pushing my limits so I need some help on how to approach this.   1. We have a set of 25 results   2. We are using a jquery plugin to vertically scroll through these 25 results, the container displays five results at a time.    3. When viewing the source code of the page, you can see the html for all 25 results. Obviously the jquery plugin is what is making them visible or not.   4. The task is to make it so that only five of the result set are displaying at any time during a source code viewing. All the rest of the results must come from javascript or some other technique. So I somehow have to either:   1. Send a pool of 25 results to JS and have it generate the div info on the fly OR   2. Some type of timed script that grabs five results at a time and displays them. But this all has to continuously scroll vertically so that is a consideration also. So I am trying to get my head around how I should approach this: One idea I had was to run an ajax call every five or ten seconds that has a php script generate five new results, then display them in the appropriate div. This is slow and would basically mean a page that is constantly sending out ajax calls. the random results are coming from a php script that is parsing an xml feed. I am really just looking for a roadmap or some conceptual directions on how this could be approached.