title: What is the historical basis of using Javascript in web programming?

text: I come from a scientific biology background where we also use Python a lot. Now that I've begun to start with Web development, I've consistently found myself wondering just why it is that JavaScript is the primary client-side language on the Web. Is JavaScript's predominance a historical accident or something else? Also, I'm curious if there are any hurdles to integrating Python into client-side scripting?


title: Back button after doing posts on the same page

text: I have 3 pages to my site. The 1st page allows you to select a bunch of options. Those options get sent to the 2nd page to be displayed with some data about those options. From here I can click on a link to get to page 3 on 1 of the options. On page 3 I can create a new/edit/delete all on the same page where reloads come back to page 3. I want a "back" button on page 3 to go back to page 2, but retain the options it had from the original page 1 request. Page 1 has a bunch of check boxes which are passed to page 2 as arrays to the controller. My thought is that I have to pass these arrays (I converted them to lists) to page 3 (even thought page 3 directly doesn't need them) so that page 3 can use them in the back link to it can recreate the values page 1 sent to page 2 originally. I'm using asp.net MVC and when I pass the converted array it seems to convert it to the type instead of actually showing the values: "types=System.Collections.Generic.List" (where types is a List. **Is this what is needed or are there other options to getting a "back" button in this case to go back to page 2.** It's sort of a pain to pass information to page 3 that isn't really relevant to page 3 except the back button.


title: Please explain the benefit(s) of using an XML-based syntax (e.g. XAML) instead of normal source code (e.g. WinForms)?

text: First off, please note that this question is not about WPF vs. WinForms. What are the highest-ranking benefits that led Microsoft to invent XAML in favour of the “old” approach of generating compilable C# code? My impression is that other developers seem to find a lot of downsides to it, but Microsoft went with it regardless, which must mean that there is a benefit that I am not seeing. I would like you to explain to me what it is that I am missing.


title: Automated out going ACH transfers

text: Our team is working on a market place web application where the application will collect payments from individual users then deduct a small percentage fee before paying the balance to the users chosen service vendor. We've encountered problems finding a service provider that will allow outgoing ACH. We've asked both several merchant accounts and banks looking for a solution. Although out going ACH is possible through some banks, we are so far unable to find a bank that exposes an API for automating the process. We're hoping the community has found a viable solution for the redistribution of funds as described. We're certainly not stuck on any particular technology or method such as ACH. Your thoughts, idea or solutions are greatly appreciated.


title: learning on the clock

text: Some might argue this question is too general, but because keeping up seems especially relevant to programming, is anyone's experience that:   * do employers expect you to stay current? what is the "industry standard" of expected time a programmer should spend keeping up-to-date?    * is it generally acceptable that a programmer can spend some time during working hrs on meeting the expectation to keep skills current? If not, how do most programmers find the time?  -


title: Choosing the right branching strategy for releases

text: Starting with a new dev team on a new project and we have to define our Branching strategy for our source repository ( _e.g. Microsoft Team Foundation Server 2010_ ). We've run into a sticky discussion over whether or not to... **A**. Have one **Release** branch from which we do production builds and then **Label** when something is actually released OR **B**. Have a new **Release** branch for each new Release into production ( _Ex. Version 1, 2, 3, etc..._ ) Option **A** seems pretty straight-forward but we're not sure if this will lead to problems in the long run. Option **B** seems like it just creates lots of one-time long-lived branches that just pile up over time. Does anyone have any experience either way that could help us decide? Specifically, I'm looking to hear where the pain-points are for any one choice. Feel free to provide specific experience relative to TFS and/or Release-Management implications.


title: What does Software Engineer in Test do?

text: Normally unit tests were written by developer who write the code, i.e. Test Driven Development. So what does Software Engineer in Test do?


title: Should a developer adhere to the class diagrams produced during system design?

text: The class diagram is modeled on the system requirements, and it is important to create solutions based on those requirements. If I have said class diagram should I strictly adhere to it? What about refactoring? What if the diagram did not provide some design principle that I feel were left out?


title: How is a committer expected to behave?

text: In _open source projects_ there is typically a set of devs that have permissions to commit code - the committers -, and others that "pull request" or send patches, the "general public". I find a annoying when   1. the committer signs the commit with its own name, and writes in the commit message a "Thanks to ...".   2. the committer changes the patch before commit without asking if the original author agrees. Given this two annoyances, I'm compelled to think that I should put myself in the other side and ask how should a core committer behave. Are these two particular situations expected? I mean, is this the correct behaviour for building and maintaining an active community of "general public"? EDIT: I'm not asking if they have the right to do it or are legally obliged to do so. IMO a committer should not content himself to follow the law, but should be interested in building/maintaining the community within the project objectives constraints. That is what I'm asking for: how he should behave to accomplish this.


title: Website Internationalisation approaches

text: I'm currently working on a project that the client wants to deliver to different countries. The application is a website. We started out using resource files to change the text the user sees when visiting pages based on their locations. But this isn't enough. In the English version of the site we have a page that states "page x of y". In the Chinese version of the site, it's not enough to do " x y" The syntax for the language doesn't match the placeholders that were created for the English language. The only other option I can think of is to have a completely separate site, serving different content. Are there any other options to solve this issue?


title: Dealing with not knowing parameter names of a function when you're calling it

text: Here's a programming/language problem I'd like to hear your thoughts on. We have developed conventions that most programmers (should) follow that aren't a part of the languages syntax but serve to make code more readable. These are of course always a matter of debate but there's at least some core concepts that most programmers find agreeable. Naming your variables appropriately, naming in general, making your lines not outrageously long, avoiding long functions, encapsulations, those things. However, there's a problem that I have yet to find anyone commenting on and that just might be the biggest one of the bunch. It's the problem of arguments being anonymous when you call a function. Functions stem from mathematics where f(x) has a clear meaning because a function has a much more rigorous definition that it usually does in programming. Pure functions in mathematics can do a lot less than they can in programming and they are a much more elegant tool, they usually only take one argument (which is usually a number) and they always return one value (also usually a number). If a function takes multiple arguments, they are almost always just extra dimensions of the function's domain. In other words, one argument isn't more important than the others. They are explicitly ordered, sure, but other than that, they have no semantic ordering. In programming however, we have more freedom defining functions, and in this case I'd argue it isn't a good thing. A common situation, you have a function defined like this               func DrawRectangleClipped (rectToDraw, fillColor, clippingRect) {}      Looking at the definition, if the function is written correctly, its perfectly clear what's what. When calling the function, you might even have some intellisense/code completion magic going on in your IDE/editor that will tell you what the next argument should be. But wait. If I need that when I'm actually writing the call, isn't there something we're missing here? The person reading the code doesn't have the benefit of an IDE and unless they jump to the definition, they have no idea which of the two rectangles passed as arguments is used for what. The problem goes even further than that. If our arguments come from some local variable, there might be situations where we don't even know what the second argument is since we only see the variable name. Take for example this line of code               DrawRectangleClipped(deserializedArray[0], deserializedArray[1], deserializedArray[2])      This is alleviated to various extents in different languages but even in strictly typed languages and even if you name your variables sensibly, you don't even mention the type the variable is when you're passing it to the function. As it usually is with programming, there are a lot of potential solutions to this problem. Many are already implemented in popular languages. Named parameters in C# for example. However, all that I know have significant drawbacks. Naming every parameter on every function call can't possibly lead to readable code. It almost feels like maybe we're outgrowing possibilities that plain text programming gives us. We've moved from JUST text in almost every area, yet we still code the same. More information is needed to be displayed in the code? Add more text. Anyways, this is getting a bit tangential so I'll stop here. One reply I got to the second code snippet is that you would probably first unpack the array to some named variables and then use those but the variable's name can mean many things and the way it's called doesn't necessarily tell you the way it's supposed to be interpreted in the context of the called function. In the local scope, you might have two rectangles named leftRectangle and rightRectangle because that's what they semantically represent, but it doesn't need to extend to what they represent when given to a function. In fact, if your variables are named in the context of the called function than you're introducing less information than you potentially could with that function call and on some level if does lead to code worse code. If you have a procedure that results in a rectangle you store in rectForClipping and then another procedure that provides rectForDrawing, then the actual call to DrawRectangleClipped is just ceremony. A line that means nothing new and is there just so the computer knows what exactly you want even though you've explained it already with your naming. This isn't a good thing. I'd really love to hear fresh perspectives on this. I'm sure I'm not the first one to consider this a problem, so how is it solved?


title: Do .NET 4.0 Code Contracts have a role to play in solo-programmer projects?

text: I often find myself wondering what programming best practices apply to solo programming, since most of the time, I'm the only programmer on a project. I just started experimenting with C# 4.0 Code Contracts, and I thought I'd ask the community what utility they may have for a solo programmer. Here's where I'm coming from with this. Most of the time, when I encounter an exception, it means there's a bug in my code. There are definite exceptions (no pun intended) to this, such as when I'm dealing with something external, such as a text file, database, or service, but for the most part, exceptions mean _I_ did something wrong. Take this simple method:               public void MapEntity(PersonModel model, PersonEntity entity)     {         entity.Name = model.Name;         entity.Age = model.Age;         entity.Updated = DateTime.Now;     }      If either `model` or `entity` are null, this method will throw a `NullReferenceException`. As the only consumer of my code, I know that I shouldn't pass in a null reference, but if I somehow do, I _want_ an exception to be thrown, and I _want_ the debugger to jump right to the source of the error so I can see what happened. That said, I could write:               public void MapEntity(PersonModel model, PersonEntity entity)     {         Contract.Requires(model != null);         Contract.Requires(entity != null);         entity.Name = model.Name;         entity.Age = model.Age;         entity.Updated = DateTime.Now;     }      This has the advantage of explicitly indicating (to myself) that the two arguments are not allowed to be null. However, it's very unlikely I would make this mistake (because I know what the method does). Further, if I understand properly what `Requires()` does, the behavior at runtime if a null argument is encountered would be pretty much the same. So, I can't help but wonder, what have I gained besides two lines of code? As a counterpoint, here's a case where I see definite value in being explicit:               public User FindUser(string emailAddress)     {         if (string.IsNullOrWhiteSpace(emailAddress)) return null;         var users = DbContext.Users.Where(u => u.EmailAddress == emailAddress);         Contract.Assert(users.Count() <= 1,                         "The database appears to be corrupted:                         More than one user was found for the provided email address.                         Email addresses are supposed to be unique.");         return users.SingleOrDefault();     }      But in this case, the reason I see value in using a coding contract is to indicate that something that has gone wrong that is not a bug per se (though it could have resulted from a bug elsewhere in the system). I'd like to know if I'm on the right track with my thinking, or if there is more value in code contracts than I realize. Does it pay to use contracts when you can examine and debug the code yourself or only when the code is going to be used by a third party?


title: I'm a iOS developer and I want to learn game programming

text: I programmed for the iphone (and a bit for mac) for the last 1 or 2 years and now I want to learn Java. I know OOP and am also farmiliar with a bit of the c syntax! Are there any books like java for objective-c programmers or some stuff like that? If you think c++ would be a better idea than Java (for game programming) please also give me tips for that. I'd really like to stay in OOP.


title: Correlation between two curves

text: I am trying to solve a mathematical problem in two different ways and output is a curve in both the cases. I want to compare these output curves for similarity in python. Is there any function or framework which provides this functionality? Thanks.


title: Settle an Argument: String vs. Array?

text: True or False: A string is the same thing as an array. I had an interview the other day and the above question was asked. I said false, but the interviewer said it was actually true. I explained to her that a string is a data type and an array is an object that holds multiple instances of a variable, and that they aren't even similar concepts. But, she was an HR person who was just reading tech questions that were handed to her, so she couldn't elaborate or relate to my point. A coworker later explained the True answer by stating that a string is actually a character array... thus, a string is an array. Now, if a string is a character array, that doesn't mean that document arrays or integer arrays qualify as strings. Thus, a string is not the same thing as an array. But even so, (considering C#) a string isn't even a character array. In order to do character manipulation on a string (without using concatenation methods), you have to convert the string to a character array. Now, if a string was synonymous with a character array, why would you need to convert it? Wouldn't you just be able to call each character in the string implicitly as you would a character array? No! Why? Because a string is not a character array! I liken it to asking, "Is a primary key the same as a unique identifier?" The answer is false. Reason being: A primary key is a unique identifier, but you can have unique identifiers in a table without setting them as keys. What do you all think? Is a string (data type) the same thing as an array (object type)? If so, why?


title: Plugin Architecture: How to Handle Databases and Logging?

text: I am in the process of designing an architecture for a plugin based application and I have some questions about how to handle database access and logging. The goal of my application is to allow a device my company is manufacturing to send messages over any number of third-party protocols and to any number of third party devices. Because of the nature of my application, I need to log every message that is sent via my system in reasonable detail. Here's what I am thinking on the Database side: There will be a global message table which stores all of the implementation agnostic data we have, and then there will be a table (or set of tables) for each messaging plugin _as defined by the plugin writer_ which references the Global Message table via a foreign key. It is handling these other tables that I am having a hard time figuring out how to design safely. On the one hand, I don't particularly want to give the plugins full access to the database (I want them to have the fewest possible privileges), on the other hand I want the plugin developers to have full reign to log any data they need to tables that they define similarly to how plugins work in Wordpress. Additionally, I don't want logging to the Database to be optional at all: Good logging is crucial to my application. Things I have considered:   * Designing a logging infrastructure which allows a plugin to define (maybe in an XML file) the tables it needs in the DB and a mapping between those tables and objects that they will return, and using those mappings and table definitions to write to the DB the results from method calls.   * Making a naming convention for Stored Procedures in the DB that each plugin must define when defining their tables and automatically calling those stored procedures after sending a message.   * Allowing each plugin to implement a logging method which returns a String holding the proper SQL query. Each of the above solutions makes me a little uncomfortable, but I'm not sure what other approaches might exist. Any Suggestions? Implementation Details: I am writing my application in Java, and I am using a hand-rolled plugin solution, so I have a pretty decent amount of flexibility. Since none of the actual code has been written (other than some proof-of concept code which is really just for reference), I can make fairly major changes to my plan without great cost.


title: Algorithm to order array

text: Take for example this input array:               [2,7,1,4,9]      For this input, I need to produce an array of total 23 elements which contains two elements of 2, seven elements of 7, one element of 1, four elements of 4 and nine elements of 9. Example of output array:               [2,2,7,7,7,7,7,7,7,1,4,4,4,4,9,...]      However, this array **needs to be ordered in the way that minimizes the number of same elements appearing next to each other**. The example of such array would be something like this:               [7,2,9,4,9,1,7,...]      The primary goal is to minimize the number of the same adjacent elements. Secondary goal is to distribute elements unbiased across resulting array if possible. Any pseudo code or C#, java, ... would be helpful.


title: Nesting Linq-to-Objects query within Linq-to-Entities query –what is happening under the covers?

text: var numbers = new int[] { 1, 2, 3, 4, 5 };             var contacts = from c in context.Contacts                       where c.ContactID == numbers.Max() | c.ContactID == numbers.FirstOrDefault()                       select c;              foreach (var item in contacts) Console.WriteLine(item.ContactID);       Linq-to-Entities query is first translated into Linq _expression tree_ , which is then converted by Object Services into _command tree_. And if Linq-to- Entities query nests Linq-to-Objects query, then this nested query also gets translated into an _expression tree_. a) I assume none of the operators of the nested Linq-to-Objects query actually get executed, but instead _data provider_ for particular DB (or perhaps Object Services) knows how to transform the logic of Linq-to-Objects operators into appropriate SQL statements? b) _Data provider_ knows how to create equivalent SQL statements only for some of the Linq-to-Objects operators? c) Similarly, _data provider_ knows how to create equivalent SQL statements only for some of the non-Linq methods in the Net Framework class library? **EDIT:** I know only some Sql so I can't be completely sure, but reading Sql query generated for the above code it seems data provider didn't actually execute `numbers.Max` method, but instead just somehow figured out that `numbers.Max` should return the maximum value and then proceed to include in generated Sql query a call to **TSQL's build-in MAX function**. It also put all the values held by `numbers` array into a Sql query.                SELECT CASE              WHEN (([Project1].[C1] = 1)                    AND ([Project1].[C1] IS NOT NULL)) THEN '0X0X'              ELSE '0X1X'            END                      AS [C1],            [Extent1].[ContactID]    AS [ContactID],            [Extent1].[FirstName]    AS [FirstName],            [Extent1].[LastName]     AS [LastName],            [Extent1].[Title]        AS [Title],            [Extent1].[AddDate]      AS [AddDate],            [Extent1].[ModifiedDate] AS [ModifiedDate],            [Extent1].[RowVersion]   AS [RowVersion],            CASE              WHEN (([Project1].[C1] = 1)                    AND ([Project1].[C1] IS NOT NULL)) THEN [Project1].[CustomerTypeID]            END                      AS [C2],            CASE              WHEN (([Project1].[C1] = 1)                    AND ([Project1].[C1] IS NOT NULL)) THEN [Project1].[InitialDate]            END                      AS [C3],            CASE              WHEN (([Project1].[C1] = 1)                    AND ([Project1].[C1] IS NOT NULL)) THEN [Project1].[PrimaryDesintation]            END                      AS [C4],            CASE              WHEN (([Project1].[C1] = 1)                    AND ([Project1].[C1] IS NOT NULL)) THEN [Project1].[SecondaryDestination]            END                      AS [C5],            CASE              WHEN (([Project1].[C1] = 1)                    AND ([Project1].[C1] IS NOT NULL)) THEN [Project1].[PrimaryActivity]            END                      AS [C6],            CASE              WHEN (([Project1].[C1] = 1)                    AND ([Project1].[C1] IS NOT NULL)) THEN [Project1].[SecondaryActivity]            END                      AS [C7],            CASE              WHEN (([Project1].[C1] = 1)                    AND ([Project1].[C1] IS NOT NULL)) THEN [Project1].[Notes]            END                      AS [C8],            CASE              WHEN (([Project1].[C1] = 1)                    AND ([Project1].[C1] IS NOT NULL)) THEN [Project1].[RowVersion]            END                      AS [C9],            CASE              WHEN (([Project1].[C1] = 1)                    AND ([Project1].[C1] IS NOT NULL)) THEN [Project1].[BirthDate]            END                      AS [C10],            CASE              WHEN (([Project1].[C1] = 1)                    AND ([Project1].[C1] IS NOT NULL)) THEN [Project1].[HeightInches]            END                      AS [C11],            CASE              WHEN (([Project1].[C1] = 1)                    AND ([Project1].[C1] IS NOT NULL)) THEN [Project1].[WeightPounds]            END                      AS [C12],            CASE              WHEN (([Project1].[C1] = 1)                    AND ([Project1].[C1] IS NOT NULL)) THEN [Project1].[DietaryRestrictions]            END                      AS [C13]     FROM   [dbo].[Contact] AS [Extent1]            LEFT OUTER JOIN (SELECT [Extent2].[ContactID]            AS [ContactID],                                    [Extent2].[BirthDate]            AS [BirthDate],                                    [Extent2].[HeightInches]         AS [HeightInches],                                    [Extent2].[WeightPounds]         AS [WeightPounds],                                    [Extent2].[DietaryRestrictions]  AS [DietaryRestrictions],                                    [Extent3].[CustomerTypeID]       AS [CustomerTypeID],                                    [Extent3].[InitialDate]          AS [InitialDate],                                    [Extent3].[PrimaryDesintation]   AS [PrimaryDesintation],                                    [Extent3].[SecondaryDestination] AS [SecondaryDestination],                                    [Extent3].[PrimaryActivity]      AS [PrimaryActivity],                                    [Extent3].[SecondaryActivity]    AS [SecondaryActivity],                                    [Extent3].[Notes]                AS [Notes],                                    [Extent3].[RowVersion]           AS [RowVersion],                                    cast(1 as bit)                   AS [C1]                             FROM   [dbo].[ContactPersonalInfo] AS [Extent2]                                    INNER JOIN [dbo].[Customers] AS [Extent3]                                      ON [Extent2].[ContactID] = [Extent3].[ContactID]) AS [Project1]              ON [Extent1].[ContactID] = [Project1].[ContactID]            LEFT OUTER JOIN (SELECT TOP (1) [c].[C1] AS [C1]                             FROM   (SELECT [UnionAll3].[C1] AS [C1]                                     FROM   (SELECT [UnionAll2].[C1] AS [C1]                                             FROM   (SELECT [UnionAll1].[C1] AS [C1]                                                     FROM   (SELECT 1 AS [C1]                                                             FROM   (SELECT 1 AS X) AS [SingleRowTable1]                                                             UNION ALL                                                                       SELECT 2 AS [C1]                                                             FROM   (SELECT 1 AS X) AS [SingleRowTable2]) AS [UnionAll1]                                                     UNION ALL                                                               SELECT 3 AS [C1]                                                     FROM   (SELECT 1 AS X) AS [SingleRowTable3]) AS [UnionAll2]                                             UNION ALL                                                       SELECT 4 AS [C1]                                             FROM   (SELECT 1 AS X) AS [SingleRowTable4]) AS [UnionAll3]                                     UNION ALL                                               SELECT 5 AS [C1]                                     FROM   (SELECT 1 AS X) AS [SingleRowTable5]) AS [c]) AS [Limit1]              ON 1 = 1            LEFT OUTER JOIN (SELECT TOP (1) [c].[C1] AS [C1]                             FROM   (SELECT [UnionAll7].[C1] AS [C1]                                     FROM   (SELECT [UnionAll6].[C1] AS [C1]                                             FROM   (SELECT [UnionAll5].[C1] AS [C1]                                                     FROM   (SELECT 1 AS [C1]                                                             FROM   (SELECT 1 AS X) AS [SingleRowTable6]                                                             UNION ALL                                                                       SELECT 2 AS [C1]                                                             FROM   (SELECT 1 AS X) AS [SingleRowTable7]) AS [UnionAll5]                                                     UNION ALL                                                               SELECT 3 AS [C1]                                                     FROM   (SELECT 1 AS X) AS [SingleRowTable8]) AS [UnionAll6]                                             UNION ALL                                                       SELECT 4 AS [C1]                                             FROM   (SELECT 1 AS X) AS [SingleRowTable9]) AS [UnionAll7]                                     UNION ALL                                               SELECT 5 AS [C1]                                     FROM   (SELECT 1 AS X) AS [SingleRowTable10]) AS [c]) AS [Limit2]              ON 1 = 1            CROSS JOIN (SELECT MAX([UnionAll12].[C1]) AS [A1]                        FROM   (SELECT [UnionAll11].[C1] AS [C1]                                FROM   (SELECT [UnionAll10].[C1] AS [C1]                                        FROM   (SELECT [UnionAll9].[C1] AS [C1]                                                FROM   (SELECT 1 AS [C1]                                                        FROM   (SELECT 1 AS X) AS [SingleRowTable11]                                                        UNION ALL                                                                  SELECT 2 AS [C1]                                                        FROM   (SELECT 1 AS X) AS [SingleRowTable12]) AS [UnionAll9]                                                UNION ALL                                                          SELECT 3 AS [C1]                                                FROM   (SELECT 1 AS X) AS [SingleRowTable13]) AS [UnionAll10]                                        UNION ALL                                                  SELECT 4 AS [C1]                                        FROM   (SELECT 1 AS X) AS [SingleRowTable14]) AS [UnionAll11]                                UNION ALL                                          SELECT 5 AS [C1]                                FROM   (SELECT 1 AS X) AS [SingleRowTable15]) AS [UnionAll12]) AS [GroupBy1]     WHERE  [Extent1].[ContactID] IN ([GroupBy1].[A1], (CASE                                                          WHEN ([Limit1].[C1] IS NULL) THEN 0                                                          ELSE [Limit2].[C1]                                                        END))      Based on this, is it possible that Linq2Entities provider indeed doesn't execute non-Linq and Linq-to-Object methods, but instead creates equivalent SQL statements for some of them ( and for others it throws an exception )? Thank you in advance


title: What are some JavaScript selectors?

text: I was at an interview recently and although they knew that I was a beginner in javascript they asked me what selectors I used before? I didn't know what to say. I came back home and searched for it but can't find a clear definition. Isn't a selector something like a .class or #id?


title: Is Using Locking/Unlocking in Version Control an Anti-Pattern?

text: Recently I've started using Git at work. Previously I've only ever used VSS (which has some problems) and so far, Git is orders of magnitude better. The key differences here is that Git is distributed while VSS has a centralized "server" version, and that VSS uses a "checkout-lock-checkin" workflow while Git doesn't. The biggest problems we've had on working with code on our team relate to code being checked-out and unavailable to other people. This slows down work considerably, but I also know this isn't unique to VSS. Other source control systems like CVS apparently also lock files as part of their workflow. Is there any good reason for locking to be part of a version control system? Or even a development workflow? Or perhaps locking practices should be considered bad practice and discouraged?


title: success:/failure: blocks vs completion: block

text: I see two common patterns for blocks in Objective-C. One is a pair of success:/failure: blocks, the other is a single completion: block. For example, lets say I have a task that will return an object asynchronously and that task might fail. The first pattern is `-taskWithSuccess:(void (^)(id object))success failure:(void (^)(NSError *error))failure`. The second pattern is `-taskWithCompletion:(void (^)(id object, NSError *error))completion`. ### success:/failure:               [target taskWithSuccess:^(id object) {         // W00t! I've got my object     } failure:^(NSError *error) {         // Oh noes! report the failure.     }];      ### completion:               [target taskWithCompletion:^(id object, NSError *error) {         if (object) {             // W00t! I've got my object         } else {             // Oh noes! report the failure.         }     }];      Which is the preferred pattern? What are the strengths and weaknesses? When would you use one over the other?


title: What does "recursive" mean for a program which processes files and directories?

text: I know what recursion is in programming. I do understand the basics of version control systems (have used svn that is). But I have often wondered what the meaning of "recursion" or "recursive" is with respect to version control systems. What does a function calling itself have to do with working with files and directories in a version control system?


title: What use is a Business Logic Layer (BLL)?

text: In reading up on good practice for database applications I've frequently come across advocates of so-called "business logic layers" and I'm trying to decide if it's best for my project to use one (it's a small personal project). My issue lies in the fact that I can't think of anything for the BLL to do that the DAL can't already handle (executing queries and mapping results to objects), so my BLL just calls the DAL without doing anything itself. Maybe I'm wrong about exactly what the DAL should be doing too. But regardless, what sorts of functionality should be expected of a BLL in a database management application?


title: Are there benefits to deriving versions from SCM branch?

text: Currently, we have a versioning scheme following the major.minor.patch pattern. Development is done in a branch (i.e. - branches/b4_2); a release is a tag (tags/r4_2_0). To determine the version inside the code, we have a class which can parse the SCM URL (FooVersion.java). If the URL represents a branch, the SVN revision is appended (for QA builds). We're re-evaluating versioning and, more pointedly, what sort of environments we have up. The big change here is adding the concept of a beta environment for our "super users". Along with this, I'm rethinking this potentially over- engineered version derivation system. How do you determine, in the code, what the version of the software is? Creating a release is already a manual process (create tag, check in JARs for the related libraries we develop, etc.) which could probably be scripted, so is there a benefit to the way we do it over having a text file which is updated when a version is cut?


title: Filling a scene with cubes

text: I am trying to design a solution for simulating gaseous fluids in confined areas, I am using naiver-stokes equations for fluid dynamics but since it only covers incompressible fluids like liquid, i needed to find a way to simulate compression Recently, I came up with the solution which is, creating a field storing pressure data for each volumetric partition and I thought it would be a good idea to construct this field as a composition of cubes where each cube has homogeneous pressure value within itself. I tried to inflate a cube from a point and create other cubes from its surfaces recursively minding the collision with surfaces inside that scene, but this algorithm fails because there are lots of detailed cases involving complex holes and notches on the object. Is there a better way to construct this field?


title: Are there any subversion "dash board" web applications that can show me a list of recent commits from all my repositories?

text: I am looking for something like a subversion dashboard that at the very least can show me commits from across a group of repositories. Is there anything like this available? Since it could just as well be dead simple and I can't find anything immediately I am thinking if just scratching my own itch here, but I am hoping someone has wanted this before? Are there any subversion "dashboards" that an show me even a simple twitter-like list of commits from across my repositories?


title: Online Poker Game Programming

text: I am trying to write a massive online multiplayer client for a poker site, where one user can be on a Flash client and the other on say an iOS client (iPhone / iPad), and would like to know how can interaction between two users be visible on both clients. What would be better to use?   * Should I use MSMQ?    * AJAX?    * Something other?  I need the messaging layer (client interaction messages) to scale up to 100K+ online users to begin with. In other words; What scalable technology can I use to make game interactions between online users visible to all game participants?


title: A local/internal deployment of something like Campfire for developers

text: I've been looking at Campfire by 37Signals and it looks like a great tool for collaboration between developers but we need something that can be deployed internally. Any good options out there?


title: PHP, when to use iterators, how to buffer results?

text: 1. When is it best to use Iterators in PHP, and how can they be implemented to best avoid loading all objects into memory simultaneously?   2. Do any constructs exist in PHP so that we can queue up results of an operation for use with an Iterator, while again avoiding loading all objects into memory simultaneously?      1. An example would be a curl HTTP request against a REST server   3. In the case of an HTTP request that returns all results at once (a la curl), would we be better off to go with streaming results, and if so, are there any limitations or pitfalls to be aware of?      1. If using streaming, is it better to replace curl with a PHP native stream/socket? My intention is to implement Iterators for a REST client, and separately a document ORM that I'm maintaining, but only if I can do so while gaining benefits from reduced memory usage, increased performance, etc. Thanks in advance for any responses :-)


title: How do I capture information from a website that doesn't provide an API?

text: Do you know any good tutorials, frameworks, anything that can help me to write code that captures information from a website that don't have a public API, or hasn't been written in a RESTful way? I've heard there's a Ruby gem that simulates a browser, but I forgot its name and couldn't find any information about it anymore.


title: How do you keep track of large projects?

text: When dealing with a project that has many different files, I always seem to loose track of how the parts interact with one another. I've never really had much of a problem understanding smaller components in isolation, but as the complexity of the project increases, I find myself unable to mentally construct an understanding of what is going on. I notice this especially with OOP projects, as the number of methods and source files increase. My background: I'm a self-taught web programmer. I've dealt mostly with python for quick and dirty scripts, but I've also done a few basic django projects. I like web frameworks such as flask, because in the simplicity of a single-file layout, I can easily keep track (mostly) of what is going on. I now find myself in a situation where I need to interact with a large Zend Framework PHP project that someone else developed, and I'm overwhelmed with trying to understand the code spread out to numerous files. **What techniques and processes have you found useful to understand a large code base that someone else has developed? Is there any particular diagram that you find helps you grasp the larger picture?**


title: What is the difference between a pointer pointing to 0x0 location and a pointer set to NULL?

text: Is a pointer pointing to 0x0000 the same as a pointer set to NULL? If NULL value is defined in the C language, then what location does it physically translate to? Is it the same as 0x0000. Where can I find more details about these concepts?


title: Name for use of methods that return rather than set

text: There exists a general OOP principle that methods should return local variables rather than set object fields. For instance, say I have the following piece of code (example in Java):               public class Number {         public int myNum;     }          public class Horrible {         public static void areYouSerious(Number num){             num.myNum = 47;         }     }          public class Test {         public int num = new Number();              public void doHorribleThings(){             Horrible.areYouSerious(num);         }              public static void main(String[] args){             Test test = new Test();             test.doHorribleThings();         }     }      Obviously this style of programming can go sideways very quickly, and becomes a massive headache for anyone attempting to maintain it. A more correct way of doing this would be the following:               public class Number {         public int myNum;     }          public class NotAsBad {         public static int getDefaultVal(){             return 47;         }     }          public class Test {         public int num = new Number();              public void doHorribleThings(){             num.myNum = NotAsBad.getDefaultVal();         }              public static void main(String[] args){             Test test = new Test();             test.doHorribleThings();         }     }      The first example is modifying a passed in reference, whereas the second is generalizing the static setting function, making it return a value which can be used to set the object field. **Is there a name for the principle that the second method should be preferred over the first? A sort of "modularity" principle?** Just as `encapsulation` is the term for restricting variable manipulation, I would like a term for limiting the scope of the effects of some piece of functionality. If there is no existing term, I am going to call it _consequence localization_.


title: How do I build a highly scalable user/profile service?

text: Question -- I currently have a large monolithic Java application which I am working to break up into services components. One of the components I want to separate out is the service which handles and presents users and profiles. Currently the core service uses a MySQL backend and is written in Java, and is only hosted on one set of servers (web, app, db). My primary goal is to get the user/profile service to be n+ scalable across multiple web, and app servers and trying to figure out a way to do it across the database layer. What are some of the best practices to achieve high scalability with this environment? (We currently have a few million users, but expect to grow past that). Thanks!


title: Do unfamiliar frameworks make you nervous?

text: Our company is a small (non-technical) startup who is currently going through a developer transition, and we considered bringing in a local web development firm to work with us on a project basis. I sat down with a developer from one of these firms, and gave him a tour of our code base. He seemed like a pretty bright guy, and while he admitted no experience with our particular PHP framework (rhymes with 'Bend'), he appeared to be a totally capable developer. We found out the next day that they didn't want to work with us because of our choice of framework. For people who do consulting or work for development, how much does a client's choice of framework influence your decision for taking the client? Obviously, language and platform make a huge difference (I wouldn't expect a PHP shop to write C#), but as a developer I would always pick the client using any framework, over one that does not. I know everyone has their own comfort level and areas where they specialize, but do you feel comfortable tackling a new technology armed with only some API docs and google? Do you try to make this as clear as possible to the client? What are some reasons you would turn down someone for their choice of framework (assuming it fell into your basic realm of knowledge)? And with all the frameworks out there, how is one developer ever expected to pick something others can support?


title: Possible holes in a spam-registration prevention approach?

text: I was thinking of creating some login code (probably to work with BrowserID so users don't need to store their passwords with my site while also ensuring the supplied email account belongs to them) which required any user accounts to be an email address in the ".name" or possibly ".me" TLD (or in any other TLD that was intended for individuals or individual corporate employees only-- i.e., not open to public registration) and perhaps disallowing subdomains (as it might be tempting for some companies to purchase a generic domain and lease out the personalized subdomains); of course it wouldn't stop a company from leasing out names like user123@spam-friendly-site.name, but as the TLD is intended for individuals, it would hopefully be easier to blacklist any such bad behavior-enabling sites wholesale. The purpose would be two-fold:   1. Raise the threshold for spammers as they would have to either purchase a new domain any time they wanted a new spam account (and any abusing _domains_ could be blacklisted and shared as a public list) or obtain control of a legitimate user's email account or browser/system.   2. Encourage people to throw off the yoke of dependency on fixed third parties for emails as well as website hosting, chatting, etc. by getting their own domains. One wouldn't want a phone number like 555-123-1234@att.com because one could not freely change providers. And there are no doubt many would-be content creators who would share more freely if they had a site belonging to them. If one wanted to be anonymous, one could reserve domains like anonymous567.name (e.g., me@anonymous567.name) -- and this would be fine with me as my purpose is not to positively ID people outside of the context of confirming they control the email address they give me but to raise barriers to spammers. It would add a small price to do content creation on the site as users would have to purchase a domain and configure email on it and would cost more so to become truly anonymous (e.g., to purchase separate domains for each site to avoid tracking between sites), but I think the burden should not lie on content websites to deal with spam registrations. If this really gets going, one might also be able to set up one's email filters to block anyone not belonging to such a personalized domain as well, giving an auto-reply of how to register for one. Does anyone have feedback on the idea, specifically any unexpected barriers I might encounter (such as ways it could be circumvented)? I know of course that it will raise barriers for some users, but any potential technical challenges?


title: VB stand alone application or ASP web application

text: I have experience developing software and web applications and I have decided to do some freelance work on the side. Well, I met with my first client and they are requesting a relatively simple, custom system that (without being long winded) tracks client’s paperwork as it progresses through the business’s different manual processes. It is a small business that has about 10 employees, but all of the employees will interact with the client’s paperwork, therefore everyone would need access to the new system. When I say **track** I literally mean that the employees will **check as complete** on a simple page the increases a progress bar at different stages for the paperwork. Now I am %110 capable of coding the custom system that meets their needs, but I am unsure about how I should go about doing it. The information that is being tracked in the new system and stored in the DB is confidential information that they are very protective of. My main question is how should I be developing this to be as secure as I can?   * They have their own server in house, so should I develop an application (VB and SQL) for the server and require employees to log on remotely to use it? Can more than one person access/use the application at a time?   * Or should I develop a web application (ASP.Net/VB and SQL) that is only accessible on their network to their employees? They plan to expand offices, could they set up a VPN to access the site? I’m leaning towards a web application, but I have not done too much in term of security. What specific options do I have for security that aren't too complex. Basically I’m looking for pros and cons for either option or any suggestions on what I should.


title: Is testability and mockability really that important in web development?

text: I'm reading this series on Laravel, and it's in great depth dealing with making everything testable, using _Repository_ instead of just using the _Models_ , using _Dependency Injection_ and other obscure techniques. I've got a feeling that adding all this extra complexity in the name of Testability may not be the right thing. Writing unit tests for everything, that sounds plain silly. I have used Laravel before, without all this "testability" stuff, and it just worked. Is "testability" worth the effort and making code harder to understand? (note that I'm posting here instead of StackOverflow, for this is kind of opinion based. I hope I won't be frowned upon for asking it.)


title: Setting fields with correct default value

text: When writing constructors, I regularly encounter a situation where some fields already have approperiate (default) values, such as `false` for boolean values and `0` for integers. What are reasons to emphasize these values, for example like: `state = 0;` Do you appreciate it when reading someones code? On one side I feel like expressing implementation details explicitly, on the other side I find it pointless to set a field when I'm sure it is already correct.


title: Why doesn't layered architecture translate easily to tiered architecture?

text: Basically, I'm trying to understand why layered and tiered are that different, and why they don't translate easily to each other. I understand that layered could be 3 separate class files for UI, BL and DAL. Whereas tiered can be a Project for the UI, which links to a BL project which links to a DAL like entity framework, and then a database. So why are/aren't they easily translatable? Hope that makes sense, Thanks.


title: Cron'ing PHP scripts that write to other files.

text: So the client I am working for right now is really big on load time speed, so we try to shave every micro second possible. We found a file the other day that was pulling some word press blogs and it was adding a solid second to the load time. Now I didn't write that particular script and perhaps I can go optimize it later, but for now, what I did was make a script that writes the output of the wp script to another file, then I simply reference that file when we need it. We run a cron on the script I wrote so it checks the wp script every so often and outputs any updates if needed. That obviously really made things faster but I just have never done it before so I am curious about it:   * obviously we have a file with 777 permissions, what are my security concerns for this?   * Is this a good strategy to cut down in the future when the processing doesn't have to be done at the time of load?


title: How to name your application version so a user don't find out that it doesn't change during an update

text: I know it's a strange requirement but we want to create some version string which wouldn't change and that would prevent a user to notice that after an update, the version is the same as before. Example               asfkl1sd35f1s3df15s53dfs1df3sd15s3fsf      But this is quite ugly and may attract too much attention :) Simple strings on the other hand are easily distinguishable and one may notice that it does not change in time... So basically we want to have the same version but we don't want to hear users complaining that they updated the application and the version is the same. Any ideas?


title: Copyright/Licensing on a complete rewrite

text: There was an application for PalmPilots that I liked back when PalmPilots were a thing. I want to recreate it (or at least what I remember of it) for modern mobile devices. The problem is, after scouring the internet for any information on the application or the original author, I am unable to find anything. I can't even find any binaries for the app. Since I have absolutely nothing but memories to work with, I'll have to write this from scratch, but my intention is to make it as similar as possible to the original. Since I have no idea who the original author was or what the original license was (I do know that it was at least freeware), I wonder to what extent I can do this. I don't plan on charging for my rewrite and I would like to license it under the GPL or similar. I know this is probably a gray issue, but is it closer to light gray or dark gray? EDIT: I should also add that I know for a fact that any text or graphics (ie. anything except code/functionality/UI layout/general concept) would have been licensed to the author in such a way that, without question, I would also be able to use them.


title: Does a repository belong in this project?

text: I have a project that gets all of its data from API calls. The server that hosts this API connects with it's own database (not even sure what DB it is, etc). More or less the idea of a repository is to separate data and map it, right? I shouldn't be concerned where my data comes from. But if, at the end of the day, they are API calls, should the repository itself be doing all the api calls within its methods? For example if we had a FindBY method in the repository, should that method be the one making the API call?


title: A good substitute for ASMX web service methods, but not a general handler

text: The best thing I like about ASP.NET MVC, is that you can directly call a server method (called action), from the client. This is so convenient, and so straightforward, that I really like to implement such a model in ASP.NET WebForms too. However, in ASP.NET WebForms, to call a server method from the client, you should either use **Page Methods** , or Web Services, both of which use SOAP as their communication protocol (though JSON can also be used). There is also another substitution, which is using Generic Handlers. The problem with them however is that, a separate Generic Handler should be written for each server method. In other words, each Generic Handler works like a simple method. Is there anyway else to imitate MVC model in ASP.NET WebForms? Please note that I can't change to MVC platform right now, cause the project at our hand is a big project and we don't have required resources and time to change our platform. What we seek, is a simple MVC model implementation for our AJAX calls. A problem that we have with Web Services, is the known problem of SoapException, and we're not interested in creating custom SoapExctensions.


title: Sorting an ArrayList by a Split Value

text: I am attempting to create an list which should be sorted by a particular field in a colon separated string. I have an array of strings with the following values:               name1:535     name2:697      After sorting this list, I would have it sorted by the number in the second field:               name2:697     name1:535      How should I go about doing this, are there any issues I should be aware of when sorting this List of Strings?


title: What should I put in comments while commiting to the Source Control?

text: I am a lone developer and maintain a SVN server for source control. So far, I haven't followed anything specific while committing my changes. I was just reviewing my previous commits, and couldn't make any sense of my comments. What do you put in comments while committing your checkins?


title: Moving our web application from a windows development environment to linux environment seamlessly

text: I am trying to develop a web application on a windows machine using apache wicket, java, jquery etc. Apache wicket comes with an embedded jetty server. I am using eclipse as the IDE. The application needs to access some resources like configuration files etc that are present on remote machine (linux server) to which we could ssh, once development is complete we would like to deploy this application on a tomcat server hosted on this linux server. How to move seamlessly from the windows development environment to the linux server deployment? Right now we do the development by copying over the latest config files from the server, however this is error prone as it becomes difficult to keep track of the latest config files, this leads to unexpected behavior when the application is deployed. Our team is located in India and our servers are located in US, mapping the config files and accessing them do not have good response times.


title: PaypalCheckout object is composed of PaypalQuery objects. Hide PaypalQuery objects to users of PaypalCheckout?

text: I have a `PaypalCheckout` object that handles the checkout process: from initiating API calls, to providing an interface for front-end code (e.g. View/Controller). The `PaypalCheckout` object handles: gathering price details from a basket, to redirecting to paypal for payment, to getting the customer's address details from Paypal, sending payment confirmation to paypal and finally determining the status of the payment. It does so by instantiating children of an abstract `PaypalQuery` class such as `PaypalQuery_StartCheckout`, PaypalQuery_GetAddressDetails`,`PaypalQuery_ConfirmPayment`. **My question is about how to organise methods in`PaypalQuery_ConfirmPayment` and 'PaypalCheckout':** At present, my `PaypalQuery_ConfirmPayment` objects have methods such as:   * `public function isPaymentSuccessful();`   * `public function isPaymentPending()`   * `public function hasItemNotReceivedProtection()`   * `public function getPendingReason()` And I was hoping to hide all `PaypalQuery` object methods from front-end code. The problem is, that would involve making methods in `PaypalCheckout` which blindly call and return methods in the `PaypalQuery` class(es). While not exactly much of a hassle, it 'smells'. Although what the smells are, let alone the best solutions, elude me. I am hoping to keep this simple - while I may add other payment options besides Paypal in the future, I am comfortable refactoring at that later date. Also, in case it makes a difference, I don't think I am using any traditional framework patterns such as MVC - (although I have taken ideas from them). I am doing this in PHP. What solutions could I use? Thanks


title: CI runner on same server of GitLab?

text: I'm setting up a GitLab server in my company and now I'm adding GitLab CI to it. Before start this task I'd like to understand if there are any disadvantages running my runners on the same server used by GitLab and GitLab CI. I've read that there are security concerns but we use it only internally so I don't think this could be a problem. Am I missing something?


title: How to best organize spaghetti Javascript on the client with an MVC server architecture?

text: A LAMP project I am currently working on is pretty well organized on the backend. However, there are a ton of pages that just have a diarrhea of javascript and html squirted all over numerous locations with little discernible architecture, rhyme, or reason. In a few cases, some kind of javascript prototype was created for a common control, and the MVC framework in place is taking care of templating pages. How do we start to get all this spaghetti code under control? On backend projects I would start with getting some unit testing in place, CI, refactor common MVC or model/mapper code out etc..


title: Good resources for web form design and usability

text: Can anyone suggest good resources about web form design and usability for web applications?   Especially complex forms with 15+ fields etc.


title: Should I start making connections even if I'm not ready for a job yet?

text: The first job is always the hardest to get and I'm no exception. I'm 23 years old and I have no college degree but planned on going to college this year if all goes well (CS of course). I'm self-studying java right now. I know most of the topics related to the language besides the more advanced topics and I'm beginning to look at open source projects. I would like to find a job (at least a part time job) after a year or two when I'll gain more experience and learn more about java technologies and other technologies that interest me. Finding a job will be a bit difficult because most of the people (or a lot of them at least) at my current age already have 2 years or more of experience, so I will be somewhat disadvantaged. Should I start building connections and joining websites such as linkedin ? I never bothered to look into it because I'm not much of a social network person. If I start contributing to open source projects and create personal projects for 2 years could I apply for jobs that require 1-2 years of experience? Does this experience count ?


title: Equal Gifts Algorithm Problem

text: Problem Link - http://opc.iarcs.org.in/index.php/problems/EQGIFTS > It is Lavanya's birthday and several families have been invited for the > birthday party. As is customary, all of them have brought gifts for Lavanya > as well as her brother Nikhil. Since their friends are all of the erudite > kind, everyone has brought a pair of books. Unfortunately, the gift givers > did not clearly indicate which book in the pair is for Lavanya and which one > is for Nikhil. Now it is up to their father to divide up these books between > them. > > He has decided that from each of these pairs, one book will go to Lavanya > and one to Nikhil. Moreover, since Nikhil is quite a keen observer of the > value of gifts, the books have to be divided in such a manner that the total > value of the books for Lavanya is as close as possible to total value of the > books for Nikhil. Since Lavanya and Nikhil are kids, no book that has been > gifted will have a value higher than 300 Rupees... For the problem, I couldn't think of anything except recursion. The code I wrote is given below. But the problem is that the code is time-inefficient and gives TLE (Time Limit Exceeded) for 9 out of 10 test cases! What would be a better approach to the problem? Code -               #include<cstdio>     #include<climits>     #include<algorithm>     using namespace std;          int n,g[150][2];          int diff(int a,int b,int f) {         ++f;         if(f==n) {                    if(a>b) {                            return a-b;                    }                    else {                         return b-a;                    }         }         return min(diff(a+g[f][0],b+g[f][1],f),diff(a+g[f][1],b+g[f][0],f));     }          int main() {         int i;         scanf("%d",&n);         for(i=0;i<n;++i) {                          scanf("%d%d",&g[i][0],&g[i][1]);         }         printf("%d",diff(g[0][0],g[0][1],0));     }      Note - It is just a practice question, & is not part of a competition.


title: Scientific evidence that supports using long variable names instead of abbreviations?

text: Is there any scientific evidence that the human brain can read and understand fully written variable names better/faster than abbreviated ones? Like               PersistenceManager persistenceManager;      in contrast to               PersistenceManager pm;      I have the impression that I get a better grasp of code that does not use abbreviations, even if the abbreviations would have been commonly used throughout the codebase. Can this individual feeling be backed up by any studies?


title: Share Mulitple Classes as one dll or a lib with Mulitple Projects

text: Currently I have some shared class files(.cpp and .h) which I include them in around 20 Projects. Currently I have to include them in all of the projects. So if I get some business requirments and I change some of the shared(.cpp or .h) files I have to include them in all the 20 Projects which is kind of tedious. Is there a way where I can create a shared dll or library and include it all of my Projects. So if I have to change it, I just have to change it once and then just Add Reference to include that dll or library which contains all the shared(.cpp, .h) files. Any help/recommendations regarding the same, will be highly appreciated. I am using VS2012 for VC++.


title: Might I run into any trouble if I plug into an existing service/application with my own application and charge for it?

text: I know this is more of a lawyer question, however I figure someone here has probably done this and can give me a quick answer. Lets take a moderately extreme case. I build an adapter for a website that translates the requests and markup into a more formal API. I then take this API I developed and build a mobile app on it. So in short I take a site that doesn't support mobile. Build a mobile application, and then charge for the mobile application. I am not talking about charging for any of the original product. Simply the extension to the product. I ask because there is a site I would really like to build a mobile app for, because it would make my life easier, and it would be pretty gravy if I could earn some cash on the side from the work as well.


title: File system implementation in MongoDB with GridFS

text: I am working on two projects that will both implement a Webdav server backed by a MongoDB GridFS. In each case, there is the potential for the system to store tens of millions of files spread across thousands of hierarchical directories. I can come up with two different ways of storing the directory structure:   * As a "true" hierarchical file system, with directories containing the IDs (`_id`) of subdirectories and regular files. The paths will be separated by slashes (`/`) as in a POSIX-compliant file system.     * The path `/a/b/c` will be represented as a directory `a` containing a directory `b` containing a file `c`.   * As a flat file system, where file names include the slashes.     * The path `/a/b/c` will be stored as a single file with the name `/a/b/c` What are the advantages and disadvantages of each, with respect to a "real" folder-based file system?


title: Best alternative of Property file in Java

text: Hey I an working on the product which is live at multiple portals. The product is developed in GWT, JAVA, Hibernate. **My question is :** Whether there is any alternative of using property file in java. **My Requirement :**   1. For one property key there are multiple values in live portal for each different portal.   2. Each time I change property file, I need to make the war again.   3. The loading of any of the property should not be time-consuming. Any help or suggession would be apprecialble !!!


title: Concept of bit fields

text: Whenever I read a code like this:                 struct node       {               int x : 2;               int p : 4;        }n;      with bit fields involved, I get really confused, as to how they are represented in memory, what is `sizeof(n)` etc., how does it differ with normal members of structures? I tried referring K&R and http://en.wikipedia.org/wiki/Bit_field but they little to remove my confusion. What concepts of bit fields am I failing to grasp?


title: Is having some logic in source code in order to perform some tests a good practice?

text: The question is not about changing the method/function visibility or extract local variable into instance variable in order to perform unit tests. There are cases where we could include some logic in the source code in order to help us performing some functional tests or end-to-end tests. Generally speaking, these code interact with main logic directly and if the test code is defective, the business logic is affected. One example could be that we have some test code around date/time logic so that if the testers make server and client time different, this code could help them to perform some tests. So how bad you think having this is, if there is no other easy(ish) way to test this part of business logic? Please comment if this plain explanation is too vague and you need more examples.


title: Many Arguments in Case Classes

text: I have generally read that having many (>4) arguments to a function/constructor is a bad practice.   1. Is this still considered a bad practice? And is there a non-obvious reason?   2. In something like a Scala Case Class where there may be many fields what can be done to avoid such a construction? (Not sure if this is best fit for here, SO, or CodeReview)


title: Passing member variable as a method parameter

text: In a project, I've found a code like this:               class SomeClass     {         private SomeType _someField;              public SomeType SomeField         {             get { return _someField; }             set { _someField = value; }         }              protected virtual void SomeMethod(/*...., */SomeType someVar)         {         }              private void SomeAnotherMethod()         {             //.............             SomeMethod(_someField);             //.............         }          };      How do I convince my teammates that this is bad code? I believe this is an unnecessary complication. Why pass a member variable as a method parameter if you already have access to it? This is also a violation of encapsulation. Do you see any other issues with this code?


title: Why is prefixing column names considered bad practice?

text: According to a popular SO post is it considered a bad practice to prefix table names. At my company **every column** is prefixed by a table name. This is difficult for me to read. I'm not sure the reason, but this naming is actually the company standard. I can't stand the naming convention, but I have no documentation to back up my reasoning. All I know is that reading AdventureWorks is much simpler. In ~~this~~ our company DB you will see a table, Person and it might have column name: Person_First_Name   or maybe even   Person_Person_First_Name (don't ask me why you see person 2x) Why is it considered a bad practice to pre-fix column names? Are underscores considered evil in SQL as well? * * * Note: I own Pro SQL Server 2008 - Relation Database design and implementation. References to that book are welcome.


title: Would adding award points or game features to workplace software be viewed poorly amongst the programming community?

text: So one of my responsibilities at work is to build an internal tool that helps the workers enter in all their information. It's an enterprise application that is similar to a Windows forms database tool. So it's not much different than like developing a Word + Excel combo application, but the average person in this workgroup is a 20-40 year old woman or a random chatty male type. Plus I know all of these people are heavily involved with Facebook on a daily basis. How bad would it be if I styled my new interface to be similar to what Facebook does. People could get award points and stuff when they fill out different types of forms and basically compete against each other like it was a game. When people had completed one, it would be posted on their wall and everyone could comment/like stuff just like in Facebook. And it would be like they are doing peer reviewing for fun. The rewards would be outstanding I would imagine. These people are so into Facebook and Facebook games that productivity would rise due to them trying to compete and earn points and achievements. Would this be taking advantage of the people by 'tricking them into working harder by giving them a game' or would it be viewed as something that would improve happiness at work?


title: Arrays vs Objects in view template

text: I am wondering, in view templates, what would contribute to me choosing between using arrays or objects for getting things printed out in arrays `{{$user->zip_code}}` vs `{{$user['zip_code']}}` I'm working in blade templates in Laravel/PHP fwiw. My feeling is that it makes sense to use objects: we can use methods if we need to to display/format data, it looks a lot cleaner in the views, and bc of how PHP works fails gracefully if the item isn't set (an unset array value will puke, so you either need to make sure all possible properties are present but false, or do a `{{(isset($user['zip_code'])) ? $user['zip_code'] : ''}}` for everything you use in a view. However, I have encountered some contrasting opinions like: the less the view knows about the layers below it, the better. As such, "flat" values (arrays) are better to use in the view. We should not trust the view not to explode if a value is not set, that should be handled in the controller. Because our object properties are not encoded in the models in this system, we can't rely on each object always having the same info in a model level. Wondering if there are other factors at play here. Orr.. Does it not matter


title: Uncomfortable terminology

text: I couldn't imagine using terminology like "code smell", scrum "chickens", "pigs" at my workplace. These types of terms just wouldn't fit in to my environment. My co-workers would look at me, and tell me to grow up, or stop being offensive or similar. Does anyone else find terminology used on this site, or other related terminology uncomfortable to use at work?


title: Can relational algebra/calculus proofs be used to test/verify SQL?

text: Is it feasible or even possible to use relational algebra and/or relational calculus in the form of proofs to test/verify the correctness of SQL statements, functions, and stored procedures? It seems to me like it should be at least possible, but I don't know if there's a detail I'm missing that makes a 1:1 mapping between the proof and the code incorrect. Have any of you tried a method like this? Did it work? What were your experiences like?


title: Writing-Reading a hashtable to a text file

text: I'm implementing a hashtable structure for a dictionary. Dictionary is in a text file. There are 2 words on each line. I'm generating the hashtable by using the first word as a key. I'm holding the hashtable on a list. I want to save the hashtable to a text file to use it every time. What kind of structure should I use? Is there a way to do this without reading the whole hashtable from text file?


title: Which languages are more conducive to telecommuting, and also less concerned with pairing?

text: I don't know that it may even make a difference, and I reckon if it did the differences would be cultural rather than technical, but if one were going to set out today (2011) to learn a language, and specifically wanted to telecommute (so they could live in two different places during the year), are there any languages whose culture looks more favorably upon telecommuting than other languages / cultures? For example, I get the impression (and I am probably completely wrong) that in the Ruby community, you are more likely to be expected to be on-site and doing pair programming (though I suppose you can do pairing remotely too). As a corollary question, are there languages / communities where pair programming is less important, for people who wanted to program in part because they aren't social butterflies?


title: What language is used to program nano quadrotor behaviour?

text: Just watched this fascinating and terrifying video. I'm curious what programming language / paradigm is used to control these beasties?


title: How to implement software for my vehicle

text: I'm developing a Driver Safety Monitoring System which is kind of small software which would be implemented inside a car with connections to few cameras. What I want to know is **to implement this software inside the vehicle what kind of computer can I use?**


title: Parsing scripts that use curly braces

text: To get an idea of what I'm doing, I am writing a python parser that will parse directx .x text files. The problem I have deals with how the files are formatted. Although I'm writing it in python, I'm looking for general algorithms for dealing with this sort of parsing. .x files define data using templates. The format of a template is               template_name {        [some_data]     }      The goal I have is to parse the file line-by-line and whenever I come across a template, I will deal with it accordingly. My initial approach was to check if a line contains an opening or closing brace. If it's an open brace, then I will check what the template name is. Now the catch here is that the open brace doesn't have to occur on the same line as the template name. It could just as well be               template_name     {        [some_data]     }      So if I were to use my "open brace exists" criteria, it won't work for any files that use the latter format. A lot of languages also use curly braces (though I'm not sure when people would be parsing the scripts themselves), so I was wondering if anyone knows how to accurately get the template name (or in some other languages, it could just as well be a function name, though there aren't any keywords to look for)


title: Most difficult subject/theory in Computer Science?

text: Which is the most difficult CS subject/theory that you studied but important to the field? And the reason please?


title: Is it OK to live without knowing how the program you created works?

text: I mean, there are really useful libs that can solve problems when you are stuck and do not know how to solve this or that with your knowledge of programming language you use... For example, Boost for C++ or JQuery for JavaScript or Spring for Java... They solve problems in seconds and you do not really care how they did it (despite that they are written in the very same language you are programming in)... So I wonder am I alone in using libs while not being capable to write solutions for my problems from scratch or is it standard practice?


title: "Property Container" design-pattern in-depth definition

text: Could anybody, please, explain what is a `Property Container` or at least where can I get information about that pattern **on the Internet**? I've found that it exists as one of the `Fundamental` patterns in this article. Unfortunately, it is not described in the corresponding English article. The only thing is a short description in Wikipedia that I've tried to approximately translate below: > This pattern allows to add additional properties for the class in container > (inside the class), instead of extending the class with the new properties. If a short example is possible in PHP / C# / C++ or Java, it would be quite useful for understanding. P.S.: It seems like it has been described in "SanFrancisco(TM) Design Patterns: Blueprints for Business Software", but I don't have access to it. Google does not help or I'm searching with the wrong keywords...


title: How to approach multiple page form with just one save option

text: The screen shot shows the magento product upload page. The left nav allows you to switch to different options for the product. Basically each option in the left nav appears as a different page. However when you save and close, it will save all the updates made on each page. Using Foundation4, html, css, js - what would be the best approach to replicating something similar? Say I want 3 pages and one save button option. Using http://foundation.zurb.com/docs/components/section.html#panel2 and having the save buttons the top line form level seems a possible option. ![Magento screen shot](http://i.stack.imgur.com/7BRce.jpg)


title: Problems with Corba

text: I have a software engineering midterm tomorrow and as I was going through the past exams I saw this question: True or False with justification: One of the problems with CORBA is that distributed systems created using it must be written using the same programming language. I don't remember my professor saying anything about CORBA in class so I am having hard time answering this question even though I searched for CORBA online , so it would be great if you could help me understand the question. Thanks in advance


title: How could Clang release under BSD license?

text: I found that llvm could only generate assembly code. If someone want generate and link assembly code to native executable code, they should use external tool(GNU as/ld, for example. Currently lld is not ready, and there no more information about llvm-mc). This question's answer and other answers imply that Clang use Binutils(as and ld) to generate and link native code(I'm not quite sure about this). If so, how could Clang release under BSD like license? I can't find any license exception(like Bison Exception) about ld or as. If I misunderstand some concepts, please forgive me! BTW, could we use GNU as and ld in programmatically way? **EDIT:** Thanks for these answers. It seems that clang still not a standalone toolchain and have to use VS or GNU tools. Does it mean if someone write a compiler based on llvm. If users didn't install GNU or VS tools. The compiler is not a out-of-the-box compiler?


title: Do paint programs also need database?

text: I was thinking about how would a paint software works. Firstly I thought that it might not use any database but when I started thinking about the undo function I realized that it might be that the data is somehow stored in the database. Can anyone please help me out by telling me how the images are stored in a normal paint program(say MS-PAINT of Windows).


title: planning the same app for both OSX and iOS

text: I would like to ask which is the best strategy for creating an application that will be developed both on Mac and iPad, so to make minumum effort to port it from one platform to the other, starting from iPad, for example, but rather trying to make both at the same time. The application, in fact, would be an iPad-style one on the Mac too. How should I have to plan the project? Which are the main tricks to easily get the goal?


title: Need to include Calendar and Email in own CRM system. Whose?

text: I am writing a web based application that needs to have some elements of CRM in it but I cannot use an of-the-shelf CRM to do what I want. (Honestly we have been through it all and it will not work). Now while Tasks, Calls, Meetings and Notes are straightforward the idea of reinventing Mail and Calendars seems a waste of time and effort and also unproductive as most users already have their own and it simply adds to the complexity of my application and hacks users off. My thoughts are going around using Outlook and or GMail/iCal and or Mac Mail/iCal and or Thunderbird and importing the relevant data or if possible integrating it into the application. Any thoughts? Anyone got any experience of this can point me in a few directions. N.B. Not looking for an answer as too complex just some pointers and thoughts. Thanks. p.s. We did look at Sugar CRM as the basis for our project and it is useful to get best practice from but as I say it was not useable due to how we are structuring our software, not Sugar's fault.


title: Internationalization of non-english application

text: I know there are lots of posts for internationalization, but this is something I didn't found while searching. I have a PHP Web application, which is pretty big right now. It's developed actively for 4 years and wasn't built with internationalization in mind. Text is everywhere - in plain HTML, in PHP variables, in echo's, in the DB... Now I'm familiar with the concept of gettext and this is what i plan to use for the internationalization project of the application. However the app is not written in English and here is my question: Should I first translate everything to English while wrapping every string in gettext() function, or I can use my native language as a base? P.S. also any quick suggestions (links maybe) on making my life easier with the whole i18n project will be greatly appreciated!


title: Need advice for approach for a web-based app that loads excel worksheet but exposes only the charts

text: I'm looking for suggestions on the Visual Studio approach to take for a web application that is in the conceptual stage. My environment has a lot of tools:   * Windows Server 2008 R2 Standard 64bit   * Visual Studio 2010 Professional Edition   * Sharepoint 2010 Server Enterprise Edition   * SQL Server 2008 R2   * Office 2010 Professional I know I will need this app to retrieve data from a database (or a web service - not sure exactly at this point). The data needs to be placed in an Excel workbook dynamically. The app will need to have a nice user interface (standard web controls - perhaps with some Javascript effects). The Excel ribbon and worksheet grid will need to be hidden. Some web control(s) will cause the Excel chart(s) to be rendered. I am thinking this sounds like Visual Studio Tools for Office (VSTO) so as to leverage .Net and hide Excel. Can you offer suggestions regarding: One ASP.Net Web App Project One Class Library Project for Excel or perhaps which one of the several different Excel 2010 project types (addin, template, document) Would Excel Services for Sharepoint be useful (or required) ? I am feeling a little overwhelmed with so many choices at this early stage of conceptualizing the app. Can you suggest some ideas for this sort of thing? Also, I am a bit more experienced with C# but I've read VB.Net is better for work with the Excel object model. What are general advises with regard to tool choice and overall approach tradeoffs?


title: What's new in PL/I, DB2, and S/390 assembler?

text: I have an upcoming technical interview with a former employer that will focus on PL/I, DB2, and ISPF. The job will be with systems that I architected and wrote myself 20 years ago. The few years of professional programming that I did since then was all assembly language. The problem is that I haven't programmed professionally in 15 years, and the personal programming that I've done since then has been in other "modern" languages. My question is whether there are new features in PL/I and DB2 that I should be aware of. (When browsing through the latest "Principles of Operation" I saw machine instructions to support C style strings that weren't there in ancient times - cool.)


title: Separating merged array of arithmetic and geometric series

text: Given an array of positive integers in increasing order. Separate them in two series, an arithmetic sequence and geometric sequence. The given array is such that a solution do exist. The union of numbers of the two sequence must be the given array.   Both series can have common elements i.e. series need not to be disjoint.   The ratio of the geometric series can be fractional. Example:               Given series : 2,4,6,8,10,12,25     AP: 2,4,6,8,10,12     GP: 4,10,25      I tried taking few examples but could not reach a general way. Even tried some graph implementation by introducing edges if they follow a particular sequence but could not reach solution.


title: Function overloading? Yes or no

text: I'm developing a statically- and strongly-typed, compiled language, and I'm revisiting the idea of whether to include function overloading as a language feature. I realized that I'm a little bit biased, coming mainly from a `C[++|#]` background. What are the most convincing arguments _for_ and _against_ including function overloading in a language? * * * **EDIT:** Is there nobody who has an opposing opinion? Bertrand Meyer (creator of Eiffel back in 1985/1986) calls method overloading this: (source) > a vanity mechanism that brings nothing to the semantic power of an O-O > language, but hampers readability and complicates everyone's task Now those are some sweeping generalizations, but he's a smart guy, so I think it's safe to say he could back them up if he needed to. In fact, he almost had Brad Abrams (one of the CLSv1 developers) convinced that .NET shouldn't support method overloading. (source) That's some powerful stuff. Can anyone shed some light on his thoughts, and whether his viewpoint is still justified 25 years later?


title: Load Test Methodology

text: I'm currently writing a load test for a cache which should test how a cache will react to persistent requests. A colleague and I had differing opinions on how this load testing should be performed. I believe that a load test should be as random as possible. It should model real-world load as much as possible, and the way towards that is randomality. So I have created this random test as follows:   * Test data is held in spreadsheets and is loaded into TestRunner objects at startup      * The test data is **not** random   * The load test will run 10 random TestRunners in individual Threads at the same time   * The object returned by the cache will be tested to make sure it is sensible, it is not thoroughly tested      * Any tests that fail will be output at the end and each test has a unique ID to easily find failed tests   * At random intervals, the cache will be cleared to model the real-world requirement of the cache being cleared at any time.   * The load test will run for a configurable amount of time My colleague's idea of what a load test should do is:   * Test data is held in spreadsheets and is loaded into TestRunner objects at startup   * All TestRunner objects are run in a sequential manner   * Each time the load test is run, it will run the TestRunner objects in the same order Which methodology do you feel would produce the most reliable load test? I personally think the random test will produce a more reliable load test as it will model real-world usage. It is not known what order requests will come in when this is released to production, so it should be tested with that unknown element taken into account. However, running all tests in the same sequence each time will make any failures reproducable, which is important during testing.


title: 8yr+ .Net developer interested in game programming - should I learn C++?

text: I've been writing .Net code since 2003 and so I am very comfortable with it now and have a fairly deep knowledge surrounding the .Net framework that I have built over the years, plus feel very comfortable with advanced programming concepts and programming in general. I want to get into some game programming, but the last C++ I wrote was at a beginner-to-intermediate level around 2001-2002. I know that there is a lot of support for game development in .Net languages these days, but I also know that there are a lot of game libraries, resources and commercial products built on or around C and C++. Would learning C++ at this stage be a practical endeavour for me, or would the amount of time required to become competent with C++ outweigh the productivity advantage I'd get from sticking with .Net? One of my considerations is that I'm concerned about the massive and growing impact Apple is having on the tech world and the general complacency Microsoft seems to have with winning consumer and developer mindshare these days, which leaves me wondering, if I were to focus my efforts on .Net technologies (particularly in view of the fact that the Mono team was recently laid off after Novell's acquisition), am I probably severely limiting my potential future audience for any games I create?


title: Reasons for separate source and generated trees

text: What are the reasons for putting the generated files in a tree parallel to the source trees? For example, in Eclipse I usually choose to put the sources to `.../src` and the compiler generated files in `.../classes`. _Mixing both in a single tree looks dirty to me, however I can't find any advantage in the separation_ :   * Theoretically, I could backup the sources more easily, but that's not true. I'm using git and ignoring all `*.class` files everywhere is just trivial. With other version control systems it should be very easy, too.   * Theoretically, it helps to find a given source file faster as the tree is not polluted by the class files. Actually, I seldom need it (the IDE offers much faster ways). For looking at the classes I'm using the Class View, which abstracts from the directory structure.   * Theoretically, there may be tools requiring that, but I'm not aware of any. There's two disadvantages of the separation:   * The IDE copies all non-java files ("resources") from the source tree to the generated one. If the IDE doesn't notice a changed resource, then there's an old version on the classpath (i.e., in the generated tree) and I'll find myself running a program working with the old version... this may cost me quite a lot of time.   * Once upon a time, I need to find the class-file corresponding with a given java-file (or vice versa), which takes quite a lot of time. _So what are the real advantages of the separation?_ This question is not Java (Eclipse) specific. However, in Java the problem of navigating to a parallel tree is aggravated by the fact that the trees tend to be very deep (because of the directory structure mirroring the package structure and because of the world-wide package naming convention).


title: Approach to simplifying an algorithm

text: For completely random reasons*, I wrote some code that calculates and displays the following expression: > P=1*(2+2) _(3+3+3)_ (4+4+4+4) _.._ (n+n...… Which is equivalent to `(n!)^2` The version I wrote (listed below the line) isn't terribly efficient; especially not in how it calculates the inner product. **How should I go about simplifying the algorithm so it will operate faster and be more easily understood?** And yes, I know I should use something other than `int` for the variables. That aspect of my code isn't as interesting as re-working the algorithmic approach. * In the spirit of full disclosure this off-topic question sparked my working on the code  * * *               int sequence(int n)     {       int i, accum, prod, j;            accum = 1;       for (i = 2 .. n)       {         prod = i;         for (j = 1 .. i-1)         {           prod += i;         }         accum *= prod;       }       return accum;     }


title: Designing a universal database driver class

text: I have a homebrew MVC framework that I have been using for a while, and it has been working great, but I am planning an upgrade to it for its ORM classes. So far, it only supports SQL databases by creating statements dependent on what function is being called. The ORM class includes field structure and validation, computed fields, indices and joined classes (for associations, `1-1`, `1-*`, `*-1` and `*-*`), and that provides enough functionality for selecting any data and fetching associated rows in the database. But I would like to extend it to support XML, LDAP and NoSQL databases (i.e. MongoDB). My ideas for implementing this would be to modify the functions within the ORM class to interact with a custom driver (for each database type) in a common format. Unfortunately, I haven't had enough experience with using these other formats enough to adequately design an interface class that could be used by the ORM for any type. So, are there any universal database drivers that would support all of these database types so I can learn by example? The current interface I am working by is:               interface DBDriver {       function connect($host, $un, $pw, $persist = false);       function disconnect();       function selectDB($db);       function charset($charset);       function insert($table, $values);       function select($table, $fields, $joins, $where, $group, $having, $order, $limit);       function update($table, $where, $values, $where, $order, $limit);       function delete($table, $where, $order, $limit);       function transactionBegin();       function transactionCommit();       function transactionRollback();     }      But I am concerned that although this will provide enough for creating SQL statements, it might not be sufficient, or perhaps even overkill for other methods such as XML or NoSQL.


title: Taking scalability to the next level. What methods can help me make sure I do the right thing?

text: Myself and a fellow PHP dev are starting to research a new web app that we think (hope) will have a global reach. The trouble is that, whilst we both consider ourselves capable, we are concerned with the sheer size of the potential traffic (neither of us has done anything with a reach beyond a few thousand. This site will hopefully serve millions) and wonder what we can do along the way to ensure we have tested things for scale. The site will be dependant on mass simultaneous log ins, uploads of relatively large files (3-10mb audio, >4mb images) and also streaming of audio.


title: Data Synchronization in mobile apps - multiple devices, multiple users

text: I'm looking into building my first mobile app. One of the core features of the application is that multiple devices/users will have access to the same data -- and all of them will have CRUD rights. I believe the architecture should involve a central server where all the data is stored. The devices will use an API to interact with the server to perform its data operations (e.g. adding a record, editing a record, deleting a record). I imagine a scenario where synchronizing the data will become a problem. Assume the application should work when it is not connected to the Internet, and thus cannot communicate with this central server. So:   1. User A is offline and edits record #100   2. User B is offline and edits record #100   3. User C is offline and deletes record #100   4. User C goes online (presumably, record #100 should get deleted on the server)   5. User A and B goes online, but the records they edited no longer exist All sorts of scenarios similar to the above can come up. **How is this generally handled?** I plan to use MySQL, but am wondering if it's not appropriate for such a problem.


title: SQL Server: When to use SSIS vs T-SQL for ETL Tasks

text: When should I use one versus the other? For instance, let's say I have 20 comma delimited, denormalized text files and I want to transform the data and load it into normalized SQL Server tables.