title: How do I reduce the number of WCF config files in a SOA?

text: After embracing the whole SOA thing, I've found that I'm gradually drowning in a sea of web.config and app.config files. As an example, one system has 2 services that it interacts with. Each service has 3 config files - one for dev, one for staging and one for production. That's 6 config files. Then each application (3 different ones) that use these services needs three config files again, that's another 9. So that's 15 config files just for a relatively simple system. How can I go about simplifying my configuration? Is there a better way of doing this? Should I try to make my config files environment agnostic? Should I investigate the whole WCF Discovery? Should I use the web.config transformation syntax?


title: Why is it bad to write something in language X as if you're writing a program in language Y in terms of using a shared coding paradigm

text: A while ago, I asked a question on SO about something written in C++, but instead of getting an answer to the problem at hand, the comments went all crazy on my coding style, even when I indicated that it was a WIP piece of code and that I meant to clean it up later when I had the base case running. (I got so many down votes that I decided to pull the question, as my rep on SO already is near-abysmal) It made me wonder why people adopt such a hard line "you're a noob, go fuck yourself" attitude. I was being accused of writing C++ as if it was Java. Something that I cannot understand, and that still baffles me. I've been programming in quite a few OOP languages for a number of years now, albeit in intervals. I choose the language to use in terms of its available libraries and optimal execution environments for the job at hand. I adopt design patterns in OOP code and I'm quite confident that my use of patterns is sound and that OO wise, I can hold my own. I understand the OOP toolbox, but choose to use the tools only when I think it's really required, not to just use a neat trick to show my coding wits. (Which I know are not top notch, but I think aren't at n00b level either). I design my code before I write a single line. To define tests, I list the goals of a certain class, and the test criteria that it has to adhere to. Because it is easier to me to create sequence diagrams and then write code, I chose to write my tests after the interface has become obvious. I must admit that in the piece of code I posted in the question, I was still using pointers, instead of using smart pointers. I use RAII whenever I can. I know proper RAII means safeguarding against nullpointers, but I work incrementally. It was a work in progress and I meant to clean it up later. This way of working was condemned strongly. In my view, I should have a working example first so I can see if the base case is a viable way of thought. I also happen to think that cleaning up the code is something that is typical of the refactoring phase of agile, after the base case has been proven. I must admit that although I'm slowly getting the Cxx standard, I prefer to use what I understand, instead of taking the risk of using concepts that I have yet to master in production code. I do try new stuff once in a while, but usually in play projects that I have on the side, just for that purpose. [edit] I'd like to clarify that gnat's suggestion [1] did not show up in the search I did before I started to ask my question. However although his suggestion does cover one aspect of the question, the question he linked to does not answer the heart of my question, just part of it. My question is more about the response I got to my coding style and the professional aspects of handling different coding styles and (apparent) levels of skill. With my previous question on SO and it's response as a case in point. [/edit] The question then is: why scoff someone that doesn't use your coding style? The matters/subdivisions at hand for me are:   * Why would it be a bad programming practice to use more error prone code in prototype situations, if refactoring makes it more robust afterward?   * How would can program written in C++ be like it was written in Java? What makes it a bad program, (considering that I indicated the intent of the current style and the planned work to improve?)   * How would I be a bad professional if I chose to use a construct that is used in a certain programming paradigm (e.g. OOP/DP)? [1] Develop fast and buggy, then correct errors or be slow, careful for each line of code?


title: How do I improve my logic in general and programming in particular?

text: I'm good with understanding technology and implementing it. At least that is what I feel. But it seems that when I come across experienced programmers they point out that my logic is weak. I feel that I would need some time with real programming to improve it. But nobody is ready to give that time to me. I'm just about starting my carer and it often feels disheartening to hear this. I want know how can I improve my logic and also does this sort of thing happens to others too?


title: Is the "One Description Table to rule them all" approch good?

text: Long ago, I worked (as a client) with a software which use a centralized table for it's codified element. Here, as far as I remember, how the table look like :               Table_Name (PK)     Field_Name (PK)     Code (PK)     Sort_Order     Description      So, instead of creating a table every time they need a codified field, they where just adding row in this table with the new Table_Name and Field_Name. I'm sometime tempted to use this pattern in some database I design, but I have resisted to this as from now, I think there's something wrong with this, but I cannot put the finger on it. It is just because you land with some of the structure logic within the Data or something else?


title: Do modular PHP frameworks really improve applications?

text: One of the goals of modular frameworks like Kohana or Alloy is to make it easy to add and remove components (i.e. "plugins" or "modules"). However, in all the larger projects I have ever worked - the system often becomes dependent on the modules it is built on. After all, that is why they are there - to build with them. **So, I'm wondering if the concept of building distinct separate sections of a web application as independent modules is even a good idea to begin with?** For example, we may build a general user, forum, and blog module - but each project is different and usually involves building many layers of abstractions to add new features - or editing the files directly to customize them. I can't re-use the same module on multiple projects. In other words, they are no longer just a _plug-in-play_ add-on to the site. _Now I'm not confusing this with proper class design to ensure un-coupled MVC and library logic_. But I'm wondering if "MMVC" was a superfluous effort to apply proper class design concepts to application design as well. After all, many migration systems or database libraries like Doctrine require all the relations spelled out in the models from day one, thereby linking the entities. Is it one of those things that sounds like a good idea when the project starts, but eventually is shown to be a useless feature? Do modules have their place in systems like wordpress - but not in frameworks where you are obviously building something custom?


title: How to show confidence during an interview?

text: I got into an interview which I knew what I am trying to explain or have some idea on the question of the interviewer. What's the best way to explain it and show my confidence?


title: C# Interview Preparation - References?

text: This is a specific question relating to C#. However, it can be extrapolated to other languages too. While one is preparing for an interview of a C# Developer (ASP.NET or WinForms or ), what would be the typical reference material that one should look at? Are there any good books/interview question collections that one should look at so that they can be better prepared? This is just to know the different scenarios. For example, I might be writing SQL Stored Procedures and Queries, but I might stumble when asked suddenly Given an Employee Table with the following column(s). EmployeeId, EmployeeName, ManagerId Write a SQL Query which will get me the Name of Employee and Manager Name? NOTE: I am not asking for a Question Bank so that I can learn by rote what the questions are and reproduce them (which, obviously will NOT work!)


title: How would you quantify quality?

text: What should be the core functions of games which represents an excellent game? What quality goals it should achieve to become successful game? Any concise formed answer will get me on track.


title: Does OO, TDD, and Refactoring to Smaller Functions affect Speed of Code?

text: In Computer Science field, I have noticed a notable shift in thinking when it comes to programming. The advice as it stands now is   * write smaller, more testable code   * refactor existing code into smaller and smaller chunks of code until most of your methods/functions are just a few lines long   * write functions that only do one thing (which makes them smaller again) This is a change compared to the "old" or "bad" code practices where you have methods spanning 2500 lines, and big classes doing everything. My question is this: when it call comes down to machine code, to 1s and 0s, to assembly instructions, should I be at all concerned that my class-separated code with variety of small-to-tiny functions generates too much extra overhead? While I am not exactly familiar with how OO code and function calls are handled in ASM in the end, I do have some idea. I assume that each extra function call, object call, or include call (in some languages), generate an extra set of instructions, thereby increasing code's volume and adding various overhead, _without adding actual "useful" code_. I also imagine that good optimizations can be done to ASM before it is actually ran on the hardware, but that optimization can only do so much too. Hence, my question -- how much overhead (in space and speed) does well- separated code (split up across hundreds of files, classes, and methods) actually introduce compared to having "one big method that contains everything", due to this overhead? UPDATE for clarity: I am assuming that adding more and more functions and more and more objects and classes in a code will result in more and more _parameter passing_ between smaller code pieces. It was said somewhere (quote TBD) that up to 70% of all code is made up of ASM's MOV instruction - loading CPU registers with proper variables, not the actual computation being done. In my case, you load up CPU's time with PUSH/POP instructions to provide linkage and parameter passing between various pieces of code. The smaller you make your pieces of code, the more overhead "linkage" is required. I am concerned that this linkage adds to software bloat and slow-down and I am wondering if I should be concerned about this, and how much, if any at all, because current and future generations of programmers who are building software for the next century, will have to live with and consume software built using these practices. **UPDATE: Multiple files** I am writing new code now that is slowly replacing old code. In particular I've noted that one of the old classes was a ~3000 line file (as mentioned earlier). Now it is becoming a set of 15-20 files located across various directories, including test files and not including PHP framework I am using to bind some things together. More files are coming as well. When it comes to disk I/O, loading multiple files is slower than loading one large file. Of course not all files are loaded, they are loaded as needed, and disk caching and memory caching options exist, and yet still I believe that `loading multiple files` takes more processing than `loading a single file` into memory. I am adding that to my concern.


title: Why isn't there parallel reduction in the Standard Template Library?

text: Alexander Stepanov stated in talks and interviews that his realization that eventually lead him to generic programming and the Standard Template Library, was from the case of the parallel reduction algorithm. Why isn't there parallel_reduction(begin,end,associativeop) in the STL? Or something that could easily be turned into it with an operator overload (inner_product does only one pass and accumulate does the operations asymetrically). I could not even find such in the SGI-version, nor in the numeric section. Examples of what I am thinking: parallel reduction of [a,b,c,d,e,f,g,h] with binary operator ~ is               ((a ~ b) ~ (c ~ d)) ~ ((e ~ f) ~ (g ~ h))      as opposed to accumulate               (((((((a+b)+c)+d)+e)+f)+g)+h)      and with inner_product you can get only               (a*e)+(b*f)+(c*g)+(d*h)      if I am not mistaken.


title: Is there such a thing as API documentation management?

text: So I started thinking, what is the best practice for publishing generated documentation (e.g. Doxygen, NaturalDocs, etc.) in terms of infrastructure? I would be generating it through continuous integration:   * Should it be put in a regular web server?, or should I use something like Sharepoint or some other content publishing software?   * Should the documentation be available for each build?, or just stable releases   * Should I put a full copy of each documentation iteration?, or should I put it in version control overwriting itself? (a repository separate to the project code, of course) For some weird reason I find hard to think that I should just put it in a web enabled server, but this is how I see most do it: http://docs.spring.io/spring/docs/ However, what happens when your company works on tenths if not hundreds of projects?, most documentation generation tools AFAIK just give you the final HTML output, but it is up to you to manage it. So, what gives?, is there a better practice/solution than just putting it in the "doc server"?


title: Necessity of Interfaces for Small Projects

text: Is it necessary to use interfaces for small projects? I work at a shop writing small custom applications for clients, primarily data manipulation. I'm mostly self-taught but also took some programming classes in college. I've been trying to apply more OO concepts to my coding practices, but I really don't see the need for interfaces in the work that I do. My largest project so far had around 10 classes in it. Are interfaces necessary for small projects/applications or only for large- scale software systems? EDIT: This is not a duplicate. I'm asking about using interfaces in general for small projects, not using an interface for when there is only a single implementation...


title: What are some algorithms that can assist with reservation time scheduling?

text: Here's the gist of the problem: There are multiple service providers who each have their own schedules of availability. There are multiple customers who seek their services. Customers need to be able to book a reservation time for the service but they should only be able to book times in which _some_ service provider is available (ie they don't really care which particular provider they get so long as they get a provider). Unfortunately, service providers may change schedules between when the customer registers and when the service is provided, meaning that even with the reservation safeguards in place there could still end up being too many reservations for a given time. I would like to know what work has already been done on this sort of problem, and additionally:   1. Should providers actually be "assigned" to customers in a persistent way even though providers are interchangeable?   2. Depending on the answer to the previous question, how might I determine the provider's "next assignment" based on the current time, other providers' schedules, and scheduled reservations? I've thought a lot about this problem but I am stumped and left with unsatisfying solutions. As someone with no CS background I would appreciate some insight and/or a better way to think about the problem.


title: Should the views or front-end server call the RESTful API layer

text: I need to build a new web application and I am looking for advice on how to manage communication to my API layer. My goal is to have complete separation between the front-end and back-end code. Like most, I plan on having a front- end server to serve the views, while the back-end server will expose my API layer. I am a bit confused on how to approach pulling data from the API.   1. Should the node server handle all the calls to the API and provide that data to the views?   2. or Should the views be able to call the API directly and letting the server manage OAuth magic? I am curious what others have done to approach this. Let me know what your thoughts are, and I would be really interested if you have any good materials to read.


title: Protecting API Keys

text: Iv'e moved this from SO as it's more of a design question than a code one. In many applications third party websites/programs can access the website via a key. For example, a web application hosts applications each of which have a unique API key. These keys are issued to the various developers to ensure they don't make too many requests based on their contract. However, the 3rd party applications often make requests in the form: > http://www.thewebapplication.com/my.api?key=TheKey&parameter=SomeValue These can be seen by a myriad of technologies (fiddler, traffic snoopers). Even worse these requests may be placed in Javascript and made available to everyone. How can you design an API system which helps to protect your clients' API keys?


title: Does license matter if I host a maven repository?

text: * If I make a maven repository available for others to use, do I have to get permission form the authors of those software that I host in my repository even if they are free software?   * Can I host free software libraries under any license or should they have compatible licenses?


title: Books to learn to develop Rails Plugins

text: I am using Ruby on Rails 3.0.7 and I would like to learn to write "advanced" plugins for the current versione of the framework. In order to do that I would like to buy some books but what I have seen on the Amazon website are two or three year old... Do you know and\or advice some books for this matter? P.S.: Also link to good on-line guides are welcome in answers.


title: Derivations in BNF

text: I get how to do a derivation of a BNF. My text books do a good job of explaining it (much better than the on-line lecture notes of many profs etc). Example below then my questions:               <program> => begin <stmt_list> end     <stmt_list> => <stmt>                        | <stmt>; <stmt_list>     <stmt> => <var> = <expression>     <var> => A | B | C;     <exression> => <var> + <var>                        |<var> - <var>                        |<var>      Generates:               <proogam> => begin<stmt_list> end           => begin<stmt>;<stmt_list> end           => begin<var> = <expression>;<stmt_list>end           => begin a = <expression>;<stmt_list>end           => begin a =  <var> + <var>;<stmt_list>end           => begin a = b + <var> ; <stmt_list>end           => begin a = b + c ; <stmt_list> end           => begin a = b + c; <var> = <expression>; <stmt_list>end           => begin a = b + c; b  = <expression>; end           => begin a = b + c; b = <var> + <var>;<stmt_list> end           => begin a = b + c; b = c + <var>; <stmt_list> end           => begin a = b + c; b = c + a; <stmt_list> end           => begin a = b + c; b = c + a; <var> + <expression>           => begin a = b + c; b = c + a; c = <expression>;           => begin a = b + c; b = c + a; c = <var>;           => begin a = b + c; b = c + a;  c = b;      I get the how mostly and I know the benefit of BNF. But regarding derivations, why do we do them token by token when it's quite obvious what the resultant code would be? Also, with BNF derivation, when an OR is used in the syntax how do we translate this? Such as:               <if_stmt>  if (<logic_expr>) <stmt>|                         if (<logic_expr>) <stmt> else <stmt>


title: How successful is GPL in reaching its goals?

text: There are, broadly, two types of FOSS licenses when it relates to commercial usage of the code - let's say the GPL-type and the BSD-type. The first is, broadly, restrictive about commercial usage (by usage I also mean modification and redistribution, as well as creating derived works, etc.) of the code under the license, and the second is much more permissive. As I understand, the idea behind GPL-type licenses is to encourage people to abandon the proprietary software model and instead convert to the FOSS code, and the license is the instrument to entice them to do so - i.e. "you can use this nice software, but only if you agree to come to our camp and play by our rules". What I want to ask is - was this strategy successful so far? I.e. are there any major achievements in the form of some big project going from closed to open because of GPL or some software being developed in the open only because GPL made it so? How big is the impact of this strategy - compared, say, to the world where everybody would have BSD-type licenses or release all open-source code under public domain? Note that I am not asking if FOSS model is successful - this is beyond question. What I am asking is if the specific way of enticing people to convert from proprietary to FOSS used by GPL-type and not used by BSD-type licenses was successful. I also don't ask about the merits of GPL itself as the license - just about the fact of its effectiveness.


title: MVVM / API design: who is responsible for what in the example inside?

text: Note: this question is about the MVVM pattern in general and not related to any specific MVVM framework. I am wondering what the best design approach for the requirements below is (hypothetical example). I will also leave out all interfaces, dependency injection etc to keep it simple. Requirements:   * View A: user enters a password and has to confirm it. The password's hash value is then stored in a database. The password is asked from the user every time he starts the application.   * View B: user has to enter his username. The username is supposed to be encrypted with the password entered in View A. In terms of MVVM, I would create two view models: **ViewModelA:**   * `string Password`   * `void SaveHash()` **ViewModelB:**   * `string Username`   * `void SaveEncrypted()` However in order to save the username, **ViewModelB** will need to know the password, so it can derive a key from it and do the encryption. And here is where I start to ask myself if the "correct" solution (if something like that exists) is:   * Pass **ViewModelA** in the constructor to **ViewModelB** so that saving can use the information required?   * To change `void SaveEncrypted()` to `void SaveEncrypted(string password)` and only pass the relevant information?   * To change `void SaveEncrypted()` to void `SaveEncrypted(ViewModelA passwordViewModel)` and pass the complete view model that contains the information required? This would prevent abuse of the method by applying some other password.   * To remove the `void SaveEncrypted()` method from ViewModelB and create another interface that is responsible for saving the information, like:  Interface responsible for saving **ViewModelB**                interface IViewModelBSaver             {               void SaveEncrypted(ViewModelB usernameViewModel, ViewModelA passwordViewModel);             }      I could ask similar questions for ViewModelA because there the password's hash is stored.


title: How do you manage config with dependency injection?

text: I am a big fan of DI/IOC. It is great for handling/abstracting away hard dependencies, and makes life a little easier. However I have a small gripe with it, which I am not sure how to solve. The basic idea in DI/IOC is that when an object is instantiated, all of its dependencies are pre-filled within the constructor. However IMHO there are several types of parameters for constructors (especially when your objects are immutable).   1. Dependencies (Objects required for your object to do work)   2. Configuration (information about the environment required to do work)   3. Parameters (Data that work is done on) I find that IOC works well with dependencies. But I am still trying to work out the best way to deal with the other two. However, since the constructor is run meant to be run by the IOC container, it seems I need to place these items into the IOC container. I'd like to know what strategies/patterns people employ and what advantages and disadvantages people have found. NB. I am aware this is a highly subjective question, and have tried to make it a "good" subjective question as per SE guidelines.


title: Will taking two years off for school in a related field destroy a mid level development career?

text: I know some people have asked about getting back into programming after a break and this is a potential duplicate. I just am in a position where I can go back to school for a graduate degree in Stat/Applied Math. But I'm very worried about the impact it will have on my career and ability to find a job afterwards. I have 3 years experience in .NET on top of a couple of years in PHP. Right now, I'm a senior software engineer. Do you think taking two years off to do math is going to dramatically hurt my marketability?


title: What are best practices for testing programs with stochastic behavior?

text: Doing R&D work, I often find myself writing programs that have some large degree of randomness in their behavior. For example, when I work in Genetic Programming, I often write programs that generate and execute arbitrary random source code. A problem with testing such code is that bugs are often intermittent and can be very hard to reproduce. This goes beyond just setting a random seed to the same value and starting execution over. For instance, code might read a message from the kernal ring buffer, and then make conditional jumps on the message contents. Naturally, the ring buffer's state will have changed when one later attempts to reproduce the issue. Even though this behavior is a _feature_ it can trigger other code in unexpected ways, and thus often reveals bugs that unit tests (or human testers) don't find. Are there established best practices for testing systems of this sort? If so, some references would be very helpful. If not, any other suggestions are welcome!


title: Is there an opposite for the term "Backporting"?

text: As I understand, the term "Backporting" is used to describe a fix which is applied in a future version which is also ported to a previous version. Wikipedia definition is as follows: > **Backporting** is the action of taking a certain software modification > (patch) and applying it to an older version of the software than it was > initially created for. It forms part of the maintenance step in a software > development process... For example:   * A problem is discovered and fixed in V2.0. The same fix is ported and applied to V1.5. What is the term when this is done in the opposite direction?   * The problem is discovered and fixed in V1.5. The same fix is ported and applied to V2.0. Would the term "Backporting" still apply? Or is there a term such as "Forwardporting" (which amusingly sounds a lot like "Port Forwarding")?


title: Should business services cross bounded contexts?

text: Firstly, I am following the convention that a bounded context is synonymous to a department, or possibly one department has 1 to many bounded contexts. We have a client consultancy department that has a Documentation Service. Documents are stored in the Document Store Service (which is where all documents in the company are stored - it is a utility service), and the Documentation Service stores information about that document (a business service). As it was designed for the client consultancy, it is information relevant to them. Now health and safety need somewhere to store information about a document. This is different information to client consultancy, but I have been instructed to extend the existing service to account for this extra information. I feel this service is now crossing a bounded context. My worry is that all departments will eventually store there information in here and the service will become bloated, trying to be all things to all departments. Each document record will only store a subset of the information because it will only belong to one department. It will get worse when different departments want to store the same information but refer to it in a diferent ways, or when two departments want to store different information that they refer to in the same way. In my understanding, this is exactly the reason for bounded contexts. I feel each department should have it's own business service for information about a document, but use the same utility service to actually store the document. What would be the correct approach?


title: Switch or a Dictionary when assigning to new object

text: Recently, I've come to prefer mapping 1-1 relationships using `Dictionaries` instead of `Switch` statements. I find it to be a little faster to write and easier to mentally process. Unfortunately, when mapping to a new instance of an object, I don't want to define it like this:               var fooDict = new Dictionary<int, IBigObject>()     {         { 0, new Foo() }, // Creates an instance of Foo         { 1, new Bar() }, // Creates an instance of Bar         { 2, new Baz() }  // Creates an instance of Baz     }          var quux = fooDict[0]; // quux references Foo      Given that construct, I've wasted CPU cycles and memory creating 3 objects, doing whatever their constructors might contain, and only ended up using one of them. I also believe that mapping other objects to `fooDict[0]` in this case will cause them to reference the same thing, rather than creating a new instance of `Foo` as intended. A solution would be to use a lambda instead:               var fooDict = new Dictionary<int, Func<IBigObject>>()     {         { 0, () => new Foo() }, // Returns a new instance of Foo when invoked         { 1, () => new Bar() }, // Ditto Bar         { 2, () => new Baz() }  // Ditto Baz     }          var quux = fooDict[0](); // equivalent to saying 'var quux = new Foo();'      Is this getting to a point where it's too confusing? It's easy to miss that `()` on the end. Or is mapping to a function/expression a fairly common practice? The alternative would be to use a switch:               IBigObject quux;     switch(someInt)     {         case 0: quux = new Foo(); break;         case 1: quux = new Bar(); break;         case 2: quux = new Baz(); break;     }      **Which invocation is more acceptable?**   * Dictionary, for faster lookups and fewer keywords (case and break)   * Switch: More commonly found in code, doesn't require the use of a Func<> object for indirection.


title: What to learn and how?

text: I am a Java (Web) Developer. Having knowledge about c#, PHP and Ruby. I am getting confused how to keep myself updated with very fast changing the programming language and their implementation. Like, in the mobile, you can see around 7-8 OS. There are very much finer example of event-driven programming to make scalable application like node.js, Ember, Require etc.. Then WebSockets, Socket.io, HTML5. Python and C once again climbing on the top. Scala and clojure are becoming very popular languages. Haskell and Erlang are also a great language too.. With so many programming language and platform, it is sometimes i feel very bad that i am missing some good things in my career. I am just confused what to learn and how to co-op with this fast-changing world. Please suggest.


title: Should the syntax for disabling code differ from that of normal comments?

text: For several reasons during development I sometimes comment out code. As I am chaotic and sometimes in a hurry, some of these make it to source control. I also use comments to clarify blocks of code. For instance:               MyClass MyFunction()     {         (...)         // return null; // TODO: dummy for now         return obj;     }      Even though it "works" and alot of people do it this way, it annoys me that you cannot automatically distinguish commented-out code from "real" comments that clarify code:   * it adds noise when trying to read code   * you cannot search for commented-out code for for instance an on-commit hook in source control. Some languages support multiple single-line comment styles - for instance in PHP you can either use `//` or `#` for a single-line comment - and developers can agree on using one of these for commented-out code:               # return null; // TODO: dummy for now     return obj;      Other languages - like C# which I am using today - have one style for single- line comments (right? I wish I was wrong). I have also seen examples of "commenting-out" code using compiler directives, which is great for large blocks of code, but a bit overkill for single lines as two new lines are required for the directive:               #if compile_commented_out         return null; // TODO: dummy for now     #endif     return obj;      So as commenting-out code happens in every(?) language, shouldn't "disabled code" get its own syntax in language specifications? Are the pro's (separation of comments / disabled code, editors / source control acting on them) good enough and the cons ("shouldn't do commenting-out anyway", not a functional part of a language, potential IDE lag (thanks Thomas)) worth sacrificing? **Edit** I realise the example I used is silly; the dummy code could easily be removed as it is replaced by the actual code.


title: What are the algorithms behind low pause GC?

text: Some languages, for exemple java, introduced a low pause GC. Those GC can do most of the work without pausing the whole world. This is obviously a quite hard problem because it require to analyze the memory when thread are modifying it, resulting in data that can be used in the begining of the process and not anymore when it finishes, or data that appears to be garbages but because the reference was moved in memory and never appeared where the GC was looking. So basically, what is the algorithm(s) behind that ? Research papers or really technical article's link would be considered as valid answer, as this topic is really technical.


title: How do you get developers to want to write good code they can be proud of?

text: In a team of developers, how do you get the developers to feel pride in their code and write good code (I realize this is subjective and everyone is different, but there is a point when I write code that i can say, this is a good piece of code that I am happy to show off). To often I hear we have no time to write good code and all that matters is getting the defect fix closed. How do I change this outlook and make the coders create code they can be proud of. This seems to be more prevalent in the younger coders, not all but most.


title: Why do old C-style method names continue being used in modern languages?

text: I understand that in the earlier days of computing, shorter method names like `printf` made sense, because storage was limited. But why do modern languages like Python and Go still use the less readable names from the C APIs? Why don't they switch to a more readable form like print_format, the same goes for other names. I wouldn't mind having to write `make_directory` instead of `mkdir` in go.


title: How can I test an application that depends on specific hardware

text: I have written an Android application. The application requires a Bluetooth connection to a very specific piece of hardware, currently a prototype. The only way I can test the app at present is to drive hundreds of miles to see if it works. If I end up with an ANR it can be very embarrassing in front of my client. The connection type and the mechanics of this app are very tightly tailored to this hardware. I am not permitted to bring a laptop, root my phone, or connect to any other device on the premises. Is there any way to test this application at home, or step through the activities to ensure I don't have another ANR on the second activity while the client looks at me horrified? I should point out I am not an experienced programmer and this is a new idea that I am helping someone with, as hiring staff is not on the cards at present, so I am undoubtedly missing some of the very basic concepts of developing this.


title: Should I remove unreferenced code?

text: I'm working on a medium sized (100k lines) code base, it's all relatively recent code (less than a year old) and has good unit test coverage. I keep coming across methods which are either no longer used anywhere or only referenced in unit tests which only test that specific method. Should I remove this code if I'm certain that it's no longer needed? **Reasons to remove it:**   * Less code, less bugs   * Less code is easier for others to digest   * It's still under source control **Reasons to keep it:**   * Can be used as reference   * It may be useful sometime   * It may have been written to 'round-out' the functionality for a class


title: UIDocumentInteractionController in iOS for Whatsapp Integration

text: I was looking for a way to share my application created files through Whatsapp. I found we can chat using custom URL scheme provided by whatsapp. But, to share files of my app, I read that I have to use `DocumentInteractionController`. Is there any sample available? Also, when I read about this on Apple docs, it says: > Create an instance of the UIDocumentInteractionController class for each > file you want to interact with. Is it necessary to create an instance for each file? I just want to share the files as and when I receive them through my service to my app.


title: How many Angular Controllers and/or Directives is too many?

text: I'm building a large, editable data table with angular, and I'm trying to figure out what the best practice is. The table will be a couple of hundred rows, with a couple of dozen columns, so upwards of 2000 cells. Each cell needs to be editable inline. My first thought was to have directives at the cell level, so it would look something like:               <editablecell model="some model expression"></editablecell>      But I'm concerned about the performance of creating thousands of directives instances, each with its own scope, controller, and event listeners. I'm worried that if the table needs to be redrawn (you change the sorting, for instance) the performance will suffer. Is it a better idea to maybe have a per-row directive that has a meatier controller and template to handle all the data binding and event handling at a higher level, and thus create fewer child scopes and event listeners?


title: Redis vs Zookeeper

text: It seems silly to compare these two servers considering that they're meant for very different things. But if you think about it, they can do lots of similar things: store configuration data, distributed locking, queueing, etc. I've got an instance of Redis that I'm using for some production-related things, but would like to do some simple synchronization between servers (mostly configuration changes that don't require pushing up code and simple locking between servers). What does Zookeeper give me that Redis wouldn't?


title: How can I actually apply the javascript I am learning

text: I am a front end programmer. I'm good with design, html, css, and jquery, but I want to learn javascript more than anything. I've taken a couple of courses, read books and tutorials online and feel like I have a good grasp of the core principles: variables, logic etc. This is where I see to differ from all the other "What's the best way to learn js" questions on the web. What I can't seem to do is put this into actual practice. I can't take the jump from knowing the bits and pieces to figuring out how they work together to become a program. What's the best way to get actual applied knowledge with js? I assume becoming an apprentice or being tutored would be the best, but you don't hear about those sorts of things often.


title: Why don't schools cover debuggers?

text: After yet another homework question on SO. It seems like that vast majority of students have no idea what a debugger is or how to use one. I feel that knowing how to use a debugger is almost as important as other fundamental of programming.   * The question is shouldn't debugging and how to use modern debugging tools be taught alongside programming fundamentals? If not why not.


title: Naming convention: is it good that all subclasses have same prefix or suffix or not?

text: I'm bothering about a naming problem. Given that I got an interface which got named Extension, and there will be lots of implementations, like Radio extension, video extension, music extension, etc. First I have them all named with same suffix, "ext", e.g., RadioExt, VideoExt, etc. Moment later I realized the suffix was redundant since they all realized the same single interface Extension, and I should describe them in more literal manner. So I removed all suffixes. However, there was debate among my colleagues, some argued that suffix was more clear and more readable. Actually, I think it's right at some extent. So I'm confused which naming is better. Any opinions? **UPDATE**   I'm targeting Android and iOS. As what you guys said, language support would be preferable. The fact that obj-c doesn't support namespace is really a pain. Furthermore, looks like prefixes in iOS programming is more official way to solve name collision, I'd have to apply this guide anyway for trying keeping consistent for all my ports.


title: Why do many people think Mac will become a closed platform because of the App Store?

text: Isn't the App Store basically just Steam but for general applications?


title: Do you have a metaphor for cache/data latencies?

text: From this answer about latencies, we have some numbers (yes, caveat caveat) for latencies when coding (slightly edited):   * L1 cache reference 0.5 ns   * Branch mispredict 5 ns   * L2 cache reference 7 ns   * Main memory reference 100 ns   * Send 2K bytes over 1 Gbps network 20,000 ns   * Read 1 MB sequentially from memory 250,000 ns   * Disk seek 10,000,000 ns   * Read 1 MB sequentially from network 10,000,000 ns   * Read 1 MB sequentially from disk 30,000,000 ns   * Send packet CA->Netherlands->CA 150,000,000 ns Do you have a metaphor that puts this in human terms? For example, a human might find a value in a table on their desk (L1) in 15s, so the equivalent time to go find the same thing if the page is still in the book on the shelf (L2) would be 14x longer, or 3.5 minutes. I know this seems like an ELI5, but I think most programmers (including me) lack a real grasp of how the orders of magnitude vary, making it hard to reason about whether to memoize some function or pre-cache some data. I'll expand the example in an answer. If you have a handle on CPU pipelining and cycles instead, that would be a great boon for understanding CPUs. Also mutex performance, SIMD paralellism, multi-threading, multi-core...


title: Is the database the bottleneck or not? High Scalability talk

text: I found an interesting article on high scalability web site where it talks about EBay scalability and especially a specific passage struck me: > "(Ebay strategies)...Move work out of the database into the applications > because the database is the bottleneck. Ebay does this in the extreme. We > see it in other architecture using caching and the file system, but eBay > even does a lot of traditional database operations in applications (like > joins)." and the above is no mistake because again in the same article: > "Move cpu-intensive work moved out of the database layer to applications > applications layer: referential integrity, joins, sorting done in the > application layer! Reasoning: app servers are cheap, databases are the > bottleneck." Any explanation on this? If the above were true then I should only use the database for retrieving data and do all other operations in the programming logic. I was always told the opposite: "databases are optimized for operations on data and complex selects so use them". Any insight?


title: Efficient algorithm for joining sieves

text: I'm trying to find an efficient algorithm for the following algorithm. I have a sequence consisting of lists of indices denoting indices to be removed. The semantics are such that each sequence must be performed in order. I want to take these sequences and flatten them into one sequence of absolute indices to be removed. This can be achieved by performing a series of sieves (somewhat akin to the Sieve of Eratosthenes). The caveat is that this technique is slow (quadratic). Thus this group of relative indices:               R0: 0 3 10 15     R1: 2 7 20     R2: 1 11 12 14 17     R3: 0 1 2      Would correspond to this group of absolute indices:               A0: 0 3 10 15     A1: 4 9 22     A2: 2 17 18 20 24     A3: 1 5 6      And when merged into one sequence of absolute indices, I would have the following:               A': 0 1 2 3 4 5 6 9 10 15 17 18 20 22 24      There may be any number of relative sequences, each of which may contain any number of elements and may have large gaps between indices. The input relative sequences are sorted in increasing order any may not contain duplicates. Obtaining the intermediate `A#` lists is unnecessary. I only care about the list `A'` from the inputs `R#`. * * * Clarification on the algorithm Let's take the list of non-negative integers               0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 ...      And remove the indices given by R0 Then we have               1 2 4 5 6 7 8 9 10 11 12 13 14 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 ...      The removed values yield A0 (`0 3 10 15`) Now remove the indices given by R1               1 2 5 6 7 8 10 11 12 13 14 16 17 18 19 20 21 23 24 25 26 27 28 29 30 ...      The removed values yield A1 (`4 9 22`) Now remove the indices given by R2               1 5 6 7 8 10 11 12 13 14 16 19 21 23 25 26 27 28 29 30 ...      The removed values yield A2 (`2 17 18 20 24`) Now remove the indices given by R3               7 8 10 11 12 13 14 16 19 21 23 25 26 27 28 29 30 ...      The removed values yield A3 (`1 5 6`)


title: How to manage your personal ssh keys?

text: I understand that ssh keys are a cryptographically secured way of authenticating yourself to a service or to another person, but beyond that I'm frankly at a bit of a loss. What confuses me is that I see many developers mention their public key on their site, but how does one have just one key? I have a few for different things. And if my computer crashed, I would have to generate new ones. I obviously can't remember the key. Do people just save it somewhere, the sequence of numbers/letters, like in their email? And then use that one key for everything? How does someone get a _personal_ key? I just feel like I'm missing something about this whole theater of operations. I mean, we walked through RSA in university; I understand the principle, but I never used it in practice until I signed up for github and heroku and few months ago and they forced me to generate some keys, something I didn't even realize I could do before then.


title: How to deal with programming projects that fail?

text: It's not uncommon for projects to fail. As a programmer, how do you deal with projects that fail? Some definitions of failure:   * Misses deadline.   * Code and functionality does not do what it's supposed to.   * Software becomes vapor-ware or endless number of phases, essentially undeliverable. Or maybe you have your own definition(s) of failure. Do you start pointing fingers? Do you blame yourself, the requirements, the technology, the management, the client, etc? Do you do a lessons learned session as a team?


title: Modern browser features that allow a web application to behave like a local application?

text: I'm almost three years in to a career as a web application developer. It's my first "real" programming job". We use ASP.net at my shop, but I've been making it a point to constantly strive toward mastery of client-side scripting. My primary pet peeve about web application development is the disconnect between what is happening client-side and what is happening server-side. Of course, the primary issue with web development is that for the last 20 years, we have built the web on extensions to what is essentially a text-file viewer. I have a more experienced co-worker who tells me that he used to be a non-web application developer. He says that moving from application development to web application development, his concern is to make the web application behave as much as feasibly possible as if it were a local application. I agree that my users would like this, too. I frequently learn about modern tools that I can add to my toolbox to accomplish this: jquery-ui, for example. This morning, I learned about using the new CSS position:fixed value to make elements appear static on my page as a user scrolls. I'd like to ask, what are the best tools that I can use to make my web applications more responsive and interactive; what can I use to make my web application be perceived to be like a locally running application.


title: What's a good scheme for multi-user database synchronization?

text: I'm working on a system to allow multiple users to collaborate on an online project. Everything is fairly straightforward, except for keeping the users in sync. Each user has their own local copy of the project database, which allows them to make changes and test things out, and then send the updates to the central server. But this runs into the classic synchronization question: how do you keep two users from editing the same thing and stomping each other's work? I've got an idea that should work, but I wonder if there's a simpler way to do it. Here's the basic concept:   * All project data is stored in a relational database.   * Each row in the database has an owner. If the current user is not the owner, he can read but not write that row. (This is enforced client-side.)      * The user can send a request to the server to take ownership of a row, which will be granted if the server's copy says that the current owner is `NULL`, or to release ownership when they're done with it.     * It is not possible to release ownership without committing changes to the server.   * It is not possible to commit changes to the server without having first downloaded all outstanding changes to the server.   * When any changes are made to rows you own, a trigger marks that row as Dirty. When you commit changes, the database is scanned for all Dirty rows in all tables, and the data is serialized into an update file, which is posted to the server, and all rows are marked Clean. The server applies the updates on its end, and keeps the file around. When other users download changes, the server sends them the update files that they haven't already received. So, essentially this is a reinvention of version control on a relational database. (Sort of.) As long as taking ownership and applying updates to the server are guaranteed atomic changes, and the server verifies that some smart- aleck user didn't edit their local database so they could send an update for a row they don't have ownership of, it should be guaranteed to be correct, and with no need to worry about merges and merge conflicts. (I think.) Can anyone think of any problems with this scheme, or ways to do it better? (And no, "build [insert VCS here] into your project" is not what I'm looking for. I've thought of that already. VCSs work well with text, and not so well with other file formats, such as relational databases.)


title: Why can't the IT industry deliver large, faultless projects quickly as in other industries?

text: After watching National Geographic's MegaStructures series, I was surprised how fast large projects are completed. Once the preliminary work (design, specifications, etc.) is done on paper, **the realization itself of huge projects take just a few years or sometimes a few months**. For example, Airbus A380 "formally launched on Dec. 19, 2000", and "in the Early March, 2005", the aircraft was already tested. The same goes for huge oil tankers, skyscrapers, etc. Comparing this to the delays in software industry, I can't help wondering why most IT projects are so slow, or more precisely, why they cannot be as fast and faultless, at the same scale, given enough people? * * * Projects such as the Airbus A380 present both:   * Major unforeseen risks: while this is not the first aircraft built, it still pushes the limits if the technology and things which worked well for smaller airliners may not work for the larger one due to physical constraints; in the same way, new technologies are used which were not used yet, because for example they were not available in 1969 when Boeing 747 was done.   * Risks related to human resources and management in general: people quitting in the middle of the project, inability to reach a person because she's on vacation, ordinary human errors, etc. With those risks, **people still achieve projects like those large airliners in a very short period of time** , and despite the delivery delays, those projects are still hugely successful and of a high quality. When it comes to software development, the projects are hardly as large and complicated as an airliner (both technically and in terms of management), and have slightly less unforeseen risks from the real world. Still, **most IT projects are slow and late** , and adding more developers to the project is not a solution (going from a team of ten developer to two thousand will sometimes allow to deliver the project faster, sometimes not, and sometimes will only harm the project and increase the risk of not finishing it at all). Those which are still delivered may often **contain a lot of bugs, requiring consecutive service packs and regular updates** (imagine "installing updates" on every Airbus A380 twice per week to patch the bugs in the original product and prevent the aircraft from crashing). How can such differences be explained? Is it due exclusively to the fact that software development industry is too young to be able to manage thousands of people on a single project in order to deliver large scale, nearly faultless products very fast?


title: Composing programs from small simple pieces: OOP vs Functional Programming

text: I started programming when imperative programming languages such as C were virtually the only game in town for paid gigs. I'm not a computer scientist by training so I was only exposed to Assembler and Pascal in school, and not Lisp or Prolog. Over the 1990s, Object-Oriented Programming (OOP) became more popular because one of the marketing memes for OOP was that complex programs could be composed of loosely coupled but well-defined, well-tested, cohesive, and reusable classes and objects. And in many cases that is quite true. Once I learned object-oriented programming my C programs became better because I structured them more like classes and objects. In the last few years (2008-2014) I have programmed in Ruby, an OOP language. However, Ruby has many functional programming (FP) features such as lambdas and procs, which enable a different style of programming using recursion, currying, lazy evaluation and the like. (Through ignorance I am at a loss to explain why these techniques are so great). Very recently, I have written code to use methods from the Ruby Enumerable library, such as map(), reduce(), and select(). Apparently this is a functional style of programming. I have found that using these methods significantly reduce code volume, and make my code easier to debug. Upon reading more about FP, one of the marketing claims made by advocates is that FP enables developers to compose programs out of small well-defined, well-tested, and reusable functions, which leads to less buggy code, and low code volume. QUESTIONS:   1. Is the composition of complex program by using FP techniques contradictory to or complementary to composition of a complex program by using OOP techniques?    2. In which situations is OOP more effective, and when is FP more effective?   3. Is it possible to use both techniques in the same complex program?    4. Do the techniques overlap or contradict each other?


title: One dimensional cutting algorithm with minimum waste

text: Can anybody point me to some resources about "cutting algorithm"? The problem:   * have rods with length of `L` meters, e.g. 6 m   * need cut smaller pieces of different lengths, e.g. need:      * 4 x 1.2m     * 8 x 0,9m     * etc... (many other lengths and counts) How to determine the optimal cutting, what will produce the minimum wasted material? I'm capable write an perl program, but haven't any idea about the _algorithm_. (if here is already some CPAN module what can help, would be nice). Alternatively, if someone can point me to some "spreadsheet" solution, or to anything what helps. Ps: in addition, need care about the "cutting line width" too, whats means than from the 6m long rod is impossible to cut 6 x 1m, because the cutting itself takes "3mm" width, so it is possible cut only 5 x 1m and the last piece will be only 98.5 cm (1m minus 5 x 3mm cut-width) ;(.


title: Is the author of an open-source application obliged to make the "open-sourceness" visible?

text: What are the legal obligations to put into evidence that my application (I am the author) is open-source (especially when it is derivate), if I want to sell copies of it? I mean, could my open-source application be sold, with all the licensing stuff and source code inside and not hidden, but without saying so in the advertising for the app in the app-store?


title: Is every object rounded to the same size in Java?

text: According to this answer every object in Java is of the same size? Is the answer talking about the object itself or the reference to the object? Here's the statement: > every object size is rounded to 16 bytes in Hotspot, so an object with a > single byte field will take up precisely the same space as a single object > with a long or double field; I am completely baffled by the claim in this statement. So many upvotes to this answer further befuddled me. Can some one please explain what is meant by the above statement?


title: Does it make sense to break fluid interface if a bad argument is passed?

text: If I chain some setters together and one of them does not return $this, then I will get a fatal error. But maybe that is a good thing.               $object = new object();     $object->set('name','foo')->set('number',12)->set('color'=>'brown');          class object {       protected $name;       protected $number;       protected $color;            protected $allowed_to_set = array('name','color');            public function set($property,$value) {         if(!in_array((string)$property,$this->allowed_to_set)) {           return false;         } else {           $this->$property = $value;           return $this;         }       }     }


title: Naming conventions for instance, local and parameter variables

text: I was discussing with a senior developper coding conventions to apply to our projects (mainly Java/JEE projects). I disagreed with one convention he proposed: > Instance variable names should start with "_", local variables with "loc", > and method parameters with "par", so it would be easy to identify a variable > origin and scope. While he put forward arguments for short-term memory and readability, I disagreed on the fact that it rather decreases readability, IDEs like Eclipse format variables differently depending on their type, and this problem would be avoided with a good class and method design. Do you have any opinion, arguments or studies that supports my point (or opposes it)?


title: Is it okay to call a model method in my view?

text:
In the interest of keeping my Controller's skinny, I put a `headline` method in a Model.               # My Model     class Property       def headline          "#{name} | #{address}"       end     end      _(Then, Property Controller for context...)_               # My Controller         class PropertyController       def show         @property = Property.find(params[:id])        end     end      Question: As far as MVC is concerned, is it okay to call that Model method from my View, like so?               # My View
<%= @property.headline %>


title: Do support sites like Stack Overflow upset the paid-support open source model?

text: In order to stay relevant in the marketplace, I'm researching new business models for my software company. The open source model with paid support seems like a good fit for our product, but I have concerns about whether or not a paid support model is viable in an era where top-notch help is readily available for free on sites like those in the Stack Exchange network. Case in point -- I moved my employees to Ubuntu last year because I didn't want to pay for Win 7 licenses and new hardware (plus, the mono platform was highly attractive). My staff had no Linux experience, but were able to achieve relative competency in about 120 days with the help of AskUbuntu, Stack Overflow, and a few "For Dummies" books. We did employ an Ubuntu consultant for 7 days to provide training and support, but beyond that spent $0.00 on any kind of paid expertise. In regards to my due diligence, I ran a 3 month beta of the freemium-paid- support model with one of our smaller customers, and achieved mediocre results. I'd like to think its because our software is so stable and easy to use that the customer didn't need much paid support, but I suspect that they circumvented the terms of our SLA in the same manner that we did with the move to Ubuntu. Does anyone out there has any thoughts, advice, or experience relevant to the move I'm considering? What worked, what didn't, etc?


title: Adding object properties using functional programming

text: I am currently learning functional programming using Underscore.js. What I want to do is add two co-ordinates together. Let P1 = (0, 0) and P2 = (1, 1). Therefore, P1 + P2 = (1, 1) I have a solution, but it seems so convoluted that I'm sure I'm doing something wrong:               // Base 2D Cartesian Point     var Point = function(x, y) {       this.x = x;       this.y = y;     }          Point.prototype.add = function(delta) {       return _.object(_.keys(this),         _.map(           _.zip(             _.values(this),              _.values(delta)),              function(point) {               return _.reduce(point,                  function(memo, num) { return memo + num; }, 0);             }         )       );     }      Is this the proper implementation of the add function for points using Underscore.js or is there a better solution?


title: How to work as a team of two

text: I work in a team of 2 developers, my partner is the founder of the company, in the beginning he did everything on his own. He hired me about 3 years ago to help him get things done quicker and satisfy our customer needs. Often I get small project to do all by my own, as long as it works great (and it usually does...) he doesn't care much on what I did or how I did it. But if the customer calls him up asking why something doesn't work as expected and I'm not around to forward the call to me, he could get very angry on why he doesn't have an idea on how that program works. I don't keep anything as a secret, if he asks me on something how I did it I'm happy to explain as long as he's willing to listen (which isn't long), but I don't know why I need to say it in first place, in developing software everything is written down clearly. Most of the time I work on projects he wrote and I don't need to ask him anything (it happens maybe once a month that I ask him how something works, just because I don't have the time to look it up). I've read a lot on that great site about small teams that usually means 7-12 people. I couldn't find how 2 people work as a team; we don't have project managers, reviewers or testers. I feel that the fact he don't have time to review the code on his own is not my problem, so the question here is am I doing something wrong? Do I need to walk over to him and give him a lecture on what I did even he doesn't ask me?


title: Where did the T in wchar_t come from?

text: In many native types, a common suffix (and sometimes prefix) of `t` or `_t` is used to denote platform-independent types (such as `wchar_t`, `int32_t`, etc.) What was the logic behind the letter `t` as opposed to other letters (or none at all, especially in the case of `wchar_t`)? Does it stand for something?


title: What is referential transparency?

text: I have seen that in imperative paradigms f(x)+f(x) might not be the same as: 2*f(x) But in a functional paradigm it should be the same. I have tried to implement both cases in Python and Scheme, but for me they look pretty straightforward the same. What would be an example that could point out the difference with the given function?


title: Learning curve for web development

text: At the moment our team has a huge challenge, we're being asked to deliver a new GUI for an embedded controller. The deadline is very tight and is set on April 2013. Our team is very diverse, some people are on the level of procedural/structured programming (mostly C), others (including myself) have mastered object oriented programming (C++, C#). We built a prototype for Android, although it has its quirks, it is mostly just OO. For the future there is a wish to support multiple platforms (Windows, Android, iOS). In my opinion a HTML5 app with a native app shell is the way to go. When gathering more information on the frameworks to use etc., it became obvious to me a paradigm shift is needed. None of us have a web background so we need to learn from the ground up. The shift from functional to OO took us about 6 months to become productive (and some of the early subsystems were rewritten because they were a total mess). Can we expect the learning curve to be similar? Can this be pulled off with a web app? (My feeling says it will already be hard to pull off as a native app which is at the edge of our comfort zone).


title: Is code that terminates on a random condition guaranteed to terminate?

text: If I had a code which terminated based on if a random number generator returned a result (as follows), would it be 100% certain that the code would terminate if it was allowed to run forever.               while (random(MAX_NUMBER) != 0): // random returns a random number between 0 and MAX_NUMBER        print('Hello World')      I am also interested in any distinctions between purely random and the deterministic random that computers generally use. Assume the seed is not able to be known in the case of the deterministic random. Naively it could be suggested that the code will exit, after all every number has some possibility and all of time for that possibility to be exercised. On the other hand it could be argued that there is the random chance it may not ever meet the exit condition-- the generator could generate 1 'randomly' until infinity. (I suppose one would question the validity of the random number generator if it was a deterministic generator returning only 1's 'randomly' though)


title: fast n-gram access data structure

text: **TL;DR** Is there a data structure that'd quickly let me match words at any point (e.g., 'foo' matches 'foobar' and 'zoofoo'), and, ideally, returns a list of "characters that show up after the needle" (e.g., 'foo' should return ['b', $]). * * * I'm implementing an algorithm that generates random words from a training set of other words. In simple terms, it's basically like this:   1. Choose an arbitrary starting point.   2. Choose the longest suffix of the current word that is contained in at least 2 other words   3. Choose one of those words at random, and append the next character to the current wor.   4. GOTO 2 until "next character" is EOW e.g., if the current word is 'tat', some valid options would be 'potato' and 'tattoo'; if the current word is "ophtalmi", the only option is "ophtalmic", so we search if any words contain "phtalmi", "htalmi", "talmi", and so on. I've tried a couple of implementations: in one, I've used a trie populated with every suffix of every word. This is very fast at generating words, but populating the trie is VERY slow (~4 million words have not finished in over 10 hours). In another, I've generated a hash of:               for word in words:         for suffix in tails(words):             for prefix, suffix in prefixes(words): # prefixes("foo") = [("f","oo"),("fo","o"),("foo","")]                 ngrams[prefix].add(suffix) # this is a set      and it's much faster at reading the training set, and very fast at generating, but it takes a lot of RAM. And, finally, the dumb option, of simply searching               candidates = [word for word in words if string in words]      which takes very little memory, but is much slower. Is there a data structure with the behaviour I need?


title: GPL and confidential business rules in a single page application

text: I am designing a web app for a client who wants to keep some of his business rules private, we have an NDA. In a nutshell, customers use the app to book a service, and employees use it to keep track of bookings. Since the front end is public (and untrustworthy), all of the decisions that are determined by business rules have to happen on the server. Now, if I use a very nice GPLv3 licensed module, then that SPA has to be licensed under a compatible license, like MIT, because the app (including the module) is being distributed to everyone who visits the site. That's fine, it isn't possible to hide anything on the front end anyways. I don't contribute enough back to the community, and I would love to release an example of a production grade SPA as open source. It would be a great way to start a blog. The server would implement a publicly defined API, and the front end would work with any server that implements the API. I would include a simple server with the GPL licensed app so that it can be run by anyone. The server doesn't depend on the client, because could it could be replaced with curl. What I am wondering is, in this scenario, could I keep my client's unique business rules private in a server app without violating the rules or intentions of the GPL?


title: How to line-break an email address?

text: After some discussion, I have come across a rather complicated situation. Say I intend to display an email address. I have, obviously, limited space available on the screen - be that browser or application UI. Email addresses are, however, limited to 64 + 1 + 255 = 320 characters by RFC5321, while the same RFC also caps the path at 256 (which leads to an actual 254) characters. That's quite a lot for most screens - the lines I'm writing right now contain less than a hundred characters each. So, that poses a bit of a problem when trying to display email addresses. At this character count, sufficiently large containers would seem huge for a "default-sized" email address (my average is a bit below 30 characters right now), while a smaller container would lead to overflow. At first the option to use a smaller container but introduce line-breaks on longer addresses seems like a good idea.   Which brings me to the first important question to this: **Where do I break?** After a set/relative amount of characters? Before or after the `@`?   And the second question follows right after: **How do I break?** Zero-width space? `<wbr>` in HTML? Insert a dash or not? There seem to be reasons for and against any of these, but I can't for the life of me find any sources to go off in my decision. It seems as though nobody ever actually dealt with this situation (that is, the physical cap on estate is never exhausted). The best I can find are some online publishing styleguides preferring an email address in one line and adjusting surrounding elements to make that work. Well, we might just not have that option under some circumstances.


title: Can Google use my users data?

text: I have a webapp that uses Google App Engine and Google Cloud Datastore services. But reading the new Google Cloud terms of services I notice this part: > Further, Customer will notify its End Users that any Customer Data provided > as part of the Services will be made available to a third party (i.e. > Google) as part of Google providing the Services. and this: > “Customer Data” means content provided, transmitted, or displayed via the > Services by Customer or its End Users; but excluding any data provided as > part of the Account. Does that mean Google can access the data stored in the Datastore of my End Users to, for example, improve their advertising system? Are the terms of Amazon AWS like that too? And what about Windows Azure?


title: Would leading a major refactoring effort appeal to a senior developer?

text: My company is inheriting a large code base for two products that's fragmented into different applications using different languages and technologies, with a significant portion of it spaghetti code. I'm the only in-house IT person, and while I'm confident I could maintain the software for current operations, I don't have the expertise to refactor it into a more maintainable form. With the approach and development choices being entirely malleable, would a role like this appeal to a senior developer or would "we have a bunch of bad code" cut off "and are intent on improving it correctly"?


title: Where can I ask for an accessibility review for a site?

text: I'm not _too,_ too far (I hope) from finishing a site. I want to have it reviewed with an eye to its accessibility. The site's job is to display streaming, up-to-the-10-second-period stock- option data. Does anyone know of a group or forum where I can post a request for a review of the site's accessibility? Thanks!


title: Proper workaround for multiple inheritence in Java (Android)

text: I have a conceptual problem with a proper implementation of code which seems require multiple inheritance, that would not be a problem in many OO languages, but as the project is for Android, there is no such thing like multiple `extends`. I have a bunch of activities, derived from different base classes, such as simple `Activity`, `TabActivity`, `ListActivity`, `ExpandableListActivity`, etc. Also I have some code fragments which I need to place into `onStart`, `onStop`, `onSaveInstanceState`, `onRestoreInstanceState` and other standard event handlers in all activities. If I have a single base class for all activities, I'd place the code into a special intermediate derived class, and then create all activities extending it. Unfortunately, this is not the case, because there are multiple base classes. But placing the same portions of code into several intermediate classes is not a way to go, imho. Another approach could be to create a helper object and delegate all calls of the abovementioned events to the helper. But this requires the helper object to be included, and all handlers to be redefined in all intermediate classes. So there is no much difference to the first approach here - still a lot of code duplicates. If a similar situation occured under Windows, I'd subclass base class (something that "corresponds" to the `Activity` class in Android) and trap appropriate messages there (in a single place). What can be done in Java/Android for this? I know there is interesting tools such as Java instrumentation (with some real examples), but I'm not a Java guru, and not sure if it's worth trying in this specific case. If I missed some other decent solutions, please, mention them. **UPDATE:** For those who may be interested in solving the same problem in Android I've found a simple workaround. There exist the Application class, which provides, among other things, the interface ActivityLifecycleCallbacks. It does exactly what I need allowing us to intercept and add some value into important events for all activities. The only drawback of this method is that it's available starting from API level 14, which is not enough in many cases (support for API level 10 is a typical requirement today).


title: What are some interesting but not too difficult projects for a beginner kernel hacker?

text: Having taken a course in Operating Systems I'm interested in expanding my knowledge of the Linux kernel and practice working with a big system. What are some interesting but not overly difficult projects I can try my hand at? EDIT: a bit of background on what I did do with the kernel.   * Implemented a new scheduling policy   * Implemented User Threads and a corresponding mutex library (not really kernel hacking but contained kernel related theory)


title: Whiteboard "testing" during an interview: legitimate way to back up your (whiteboard) code?

text: As I get it, **having an error (even a typo like or missing ";") in your whiteboard code will often cost you some interview points**. Avoiding that will inevitably make one proof-reading code again and again (losing time and possibly neural energy / concentration) or even using a simpler (and thus less effective) algoritm -- and both these ways are "costy" again! So, **why not just fast write code** as elegant and effective as you would having a (unit) testing framework at your disposal **and then just normally test it it (just on the whiteboard)** ? Has anyone tried / seen this approach? Is the whole idea worthy? **[this also applies to the pen-and-paper case of course]**


title: The 10 minutes technical interview

text: I must do a quick assessment of dozens of fresh students very quickly. I have 30 minutes meeting with each of them (in two or three days). I want to use most of the time to discuss non technical aspects. So I plan to use 10 minutes for technical questions. The same questions for all of them. They are all _hired_ already (they are students), what I need to know is the average level in order to prepare a training. Ideally, the difficulty `must be progressive` in order to set a level for each. Level I will average, and I'll do an average on each question too. **If you had only 10 minutes and 10 questions to ask to a candidate, what would be your top 10 ?**


title: Modifying the MIT license for modified source code?

text: I have made a large number of modifications to some MIT-licensed source code to tailor it to the requirements of my project. Since this is JavaScript (for a website) the minified source code is naturally attainable by anyone viewing the site. Whilst I am happy for people to use the source code under the terms of the MIT license, I feel that the body text of the license may lead to confusion since this is a highly modified version. Is it acceptable to amend the license text? What is the correct etiquette ? **Original Text:**               The MIT License (MIT)          Copyright (c) 2009 - 2014 Adriana Palazova     http://www.adipalaz.com          ...      Full license in question (for a jQuery accordion control): http://www.adipalaz.com/docs/mit-license.txt **Proposed Change:** Add my name to the copyright notice in the MIT license:               The MIT License (MIT)          Copyright (c) 2009 - 2014 Adriana Palazova, 2014 {{My Name Here}}     http://www.adipalaz.com          ...      And then change the header in the minified JavaScript file to the following:               /*!       * Nested Accordion (Modified by {{My Name Here}})      * Copyright (c) 2009, 2010, 2011, 2012, 2013 Adriana Palazova      * Copyright (c) 2014 {{My Name Here}}      * Licensed under the MIT (http://{{My URL Here}}/mit-license.txt) license.      */


title: Unit tests, write them before or after the framework?

text: This is my first question here, so i'll make it short and to the point. When Writing unit tests, should you write them before or after you have made the underlying framework for them? This came up in a discussion between my CEO and President, and I wanted your opinion on this. Personally, I have always wrote the code first, then wrote the unit tests, but what about you?


title: Would you put your stackoverflow profile link on your CV / Resume?

text: If applying for a new job, would you put your stackoverflow profile link on your resume? This would show the employer you're an active member of the development community and also provide an insight into your knowledge + how well you convey your ideas. However it would feel a bit gimmicky to me?


title: How to effectively manage source control for project with both open and closed source?

text: I'm currently working on a project that has both an open-source "community edition" and a set of closed-source features for paying clients. One of the pain-points right now is figuring out how to handle keeping the shared source in sync between projects. We use Mercurial for source control, and the open-source piece is pushed to both CodePlex and Kiln, while the closed-source piece is pushed only to Kiln. We're presently keeping them in separate repositories with project references into the open-source repository where applicable. Is this really the best way to handle this kind of situation, or if there's something I'm missing (like using a subrepository within the closed-source repository to contain the open-source portion) that might be easier and cleaner to work with?


title: Is it any good to use binary arithmetic in a C++ code like "C style"?

text: I like the fact that the C language lets you use binary arithmetic in an explicit way in your code, sometimes the use of the binary arithmetic can also give you a little edge in terms of performance; but since I started studying C++ i can't really tell how much i have seen the explicit use of something like that in a C++ code, something like a pointer to pointer structure or an instruction for jumping to a specific index value through the binary arithmetic. Is the binary arithmetic still important and relevant in the C++ world? How i can optimize my arithmetic and/or an access to a specific index? What about the C++ and the way in which the bits are arranged according to the standard? ... or i have taken a look at the wrong coding conventions ... ?


title: Balancing time learning theory and time practicing

text: I'm currently learning C++ from Stroustrup. At the same time I'm practicing C++ by doing some little projects (Project Euler, a bit of SDL with Tetris, etc). But I have a tough time balancing. What should be a good balance, fifty-fifty? A bit more theory, a bit less practice?


title: Can I use open source libraries in trialware?

text: I have written a small Java program which i'd like to distribute on my website. I have used a few external librarys which declare following licences: Apache License (2.0), LGPL and one API doesn't declare any licence.. It's open source though. I have spent a lot of time and effort developing my program. That's why I thought of distributing the software so that only donators (no matter how much or little they donate) can use it to it's fullest extent. Non donators get to see a nag screen now and then with a suggestion to donate and can only download one file at a time instead of simultanious downloads. (Yeah my program does some downloading) Can I do that without getting legal issues? On one hand I would like to distribute the complete source of my project but on the other hand that would render the limitation of functions for non-donators useless, because they could simply remove the part with the serial nr check and redistribute my software.. Under what licence should i distribute my program?


title: Unit and Integration testing: How can it become a reflex

text: All the programmers in my team are familiar with unit testing and integration testing. We have all worked with it. We have all written tests with it. Some of us even have felt an improved sense of trust in his/her own code. However, for some reason, writing unit/integration tests has not become a reflex for any of the members of the team. None of us actually feel bad when not writing unit tests at the same time as the actual code. As a result, our codebase is mostly uncovered by unit tests, and projects enter production untested. The problem with that, of course is that once your projects are in production and are already working well, it is virtually impossible to obtain time and/or budget to add unit/integration testing. The members of my team and myself are already familiar with the value of unit testing (1, 2) but it doesn't seem to help bringing unit testing into our natural workflow. In my experience making unit tests and/or a target coverage mandatory just results in poor quality tests and slows down team members simply because there is no self-generated motivation to produce these tests. Also as soon as pressure eases, unit tests are not written any more. My question is the following: Is there any methods that you have experimented with that helps build a dynamic/momentum inside the team, leading to people naturally wanting to create and maintain those tests?


title: How to fundamentally approach creating a 'financial planner' application?

text: I want to create a financial planning application (for personal use), for which the overall functionality will be this:   * User (me..) can create different 'scenarios'.   * Each scenario is configured with different incomings/outgoings.   * Scenarios can be 'explored' in a calendar format with projections taking into account tax, interest (on both debt and savings) and so on and so forth. My problem lies in how to fundamentally approach the project. I've considered:   * When creating incomings/outgoings for a script to apply them to each day in a 'days' table of a database, acting as a method of caching. This means that if I wanted to look at January 14th, 2074 there aren't thousands of cycles of calculations to run through and the result can just be pulled.   * Do each calculation dynamically, but again, I'm finding it hard to visuallize how I would handle different tax allowances (I'm based in the UK by the way), payrises and 'changes' to my incomings/outgoings. I've sat on this for a couple of days and am struggling to come up with an elegant approach to my problem. There may well be software out there that does what I'm looking to do (in fact I'm sure it is) but I would like to develop this myself for learning purposes, to be able to add it to my personal life 'toolset' and to allow me to expand on it in the future. Many thanks to all who have any input on my dilemna.


title: To be an interviewer - Java

text: The internet is full of references on how to get prepared for an interview. Many websites are loaded with questions and answers. But I can't find any useful information about what exactly an interviewer should do to evaluate a candidate. What I mean is not just collecting good questions to be asked. I am asking about strategy for evaluating a candidate and find out if he is really good or just learnt the questions and answers well. I wonder if someone can share his experience in interviewing SWES, and what do you think about the following   * What to expect from a junior java developer? what he should know?   * What to expect from a senior java developer? what he should know?


title: how to architect this to make it unit testable

text: I'm currently working on a project where I'm receiving an object via web service (WSDL). The overall process is the following: Receive object -> add/delete/update parts (or all) of it -> and return the object with the changes made. The thing is that sometimes these changes are complicated and there is some logic involved, other databases, other web services, etc. so to facilitate this I'm creating a custom object that mimics the original one but has some enhanced functionality to make some things easier. So I'm trying to have this process: Receive original object -> convert/copy it to custom object -> add/delete/update -> convert/copy it back to original object -> return original object. Example:               public class Row     {         public List<Field> Fields { get; set; }         public string RowId { get; set; }         public Row()         {             this.Fields = new List<Field>();         }     }          public class Field     {         public string Number { get; set; }         public string Value { get; set; }     }      So for example, one of the "actions" to perform on this would be to find all `Fields` in a `Row` that match a `Value` equal to something, and update them with some other value. I have a `CustomRow` class that represents the `Row` class, how can I make this class unit testable? Do I have to create an interface `ICustomRow` to mock it in the unit test? If one of the actions is to sum all of the `Values` in the `Fields` that have a `Number` equal to `10`, like this function, how can design the custom class to facilitate unit tests. Sample function:               public int Sum(FieldNumber number)     {         return row.Fields.Where(x => x.FieldNumber.Equals(number)).Sum(x => x.FieldValue);     }      Am I approaching this the wrong way?


title: Generating different combinations from a list of muscles

text: Suppose we have a model of a human muscular system containing the following muscles each within a specific muscle group:   * **Arms**     * Biceps     * Triceps     * Forearms   * **Torso Front**     * Abs     * Chest     * Shoulders   * **Torso Back**     * Trapezius     * Lats     * Rear Shoulders     * Lower Back   * **Lower Body**     * Quads     * Hams     * Hip & Butt     * Calves Now, given a list of selected muscles, I need to find combinations following the given rules: **If all muscles are selected from a group:**               Full body (All muscles)      Arms      Torso     Torso Front     Torso Back     Lower Body      **If there are full groups together:**               Arms and torso     Arms and torso front     Arms and torso back     Arms and lower body     Torso and lower body     Torso front and lower body     Torso back and lower body      When both the front and back of the torso is selected it can be considered just "torso". **If there are more than 2 muscles selected from a group but not all:**               Parts of torso (This is the case where there are muscles selected from both front- and back-torso)     Parts of torso back     Parts of lower body      "Parts of torso front" and "Parts of arms" never occur on their own as they only have a total of 3 muscles, **thus those cases can be represented by their names: eg. "biceps and triceps", etc.** **Combinations of these aforementioned "parts"**               Parts of arms and torso     Parts of arms and lower body     Parts of torso and lower body     Parts of  arms, torso and lower body.      Parts = groups are not full and there are more than 2 muscles selected. This "rule of 2" is the most important one. * * * **Examples of output** **biceps, triceps and chest:** parts of arms and torso **biceps, triceps, calves, tai biceps, triceps, quads, hams, hip & butt:** Parts of arms and lower body **biceps, abs, calves:** Parts of arms, torso and lower body **biceps, triceps:** Biceps and triceps **biceps, triceps, forearms:** Arms **chest, shoulders, abs, trapezius, lats, rear shoulders, lower back:** Torso and so on, there are multiple possible variations. * * * Now my problem is that I have no idea how to write this as clean and modular as possible, so that rules can be added or removed if necessary. I could just write a massive if-elseif-else pile that would consider all cases, but you know why I won't. How would **you** tackle this kind of task?


title: Best way to learn Java if you already have an OOP background, like ActionScript 3?

text: I'm looking to learn Java, but I don't want to get a book that is going to tell me what an object is, how OOP works, etc. I know this from my existing ActionScript 3 work. One idea is to look at all the areas Java covers, pick one that is of interest to me and delve into that. Is this a good idea? Any other suggestions?


title: Functional/nonfunctional requirements VS design ideas

text: ### Problem domain   * Functional requirements defines **what** a system does.     * Non-Functional requirements defines quality attributes of what the system does as a whole.(performance, security, reliability, volume, useability, etc.)      * Constraints limits the design space, they restrict designers to certain types of solutions.  ### Solution domain   * Design ideas , defines **how** the system does it. For example **a stakeholder need** might be we want to increase our sales, therefore we must improve the usability of our webshop so more customers will purchase, a requirement can be written for this. (problem domain)      Design takes this further into the solution domain by saying "therefore we want to offer credit card payments in addition to the current prepayment option".      My problem is that the transition phase from requirement to design seems really vague, therefore when writing a **software requirement specification** I am often confused whether or not I incorporated design ideas in my requirements, that would make my requirement wrong.      Another problem is that I often write functional requirements as what a system does, and then I also specify in what timeframe it must be done. But is this correct? Is it then a still a functional requirement or a non functional one? Is it better to seperate it into two distinct requirements? Here are a few requirements I wrote: > ### FR1 Registration of Organizer > > _FR1_ describes the registration of an Organizer on _CrowdFundum_ > >   * **FR1.1** The system **shall** display a registration form on the > website. >   * **FR1.2** The system **shall** require a Name, Username, Document number > passport/ID card, Address, Zip code, City, Email address, Telephone number, > Bank account, Captcha code on the registration form _when_ a user registers. >   * **FR1.4** The system shall display an error message containing: > “Registration could not be completed” to the subscriber within 1 seconds > after the system check of the registration form was unsuccessful. >   * **FR1.5** The system shall send a verification email containing a > verification link to the subscriber within 30 seconds after the system check > of the registration form was successful. >   * **FR1.6** The system shall add the newly registered Organizer to the > user base within 5 seconds after the verification link was accessed.   > > > ### FR2 Organizer submits a Project   > > > > > **FR2 describes the submission of a Project by an Organizer on CrowdFundum**   >   >  - **FR2** The system shall display a submit Project form to the Organizer > accounts on the website.< - **FR2.3** The system shall check for > completeness the Name of the Project, 1-3 Photo’s, Keywords of the Project, > Punch line, Minimum and maximum amount of people, Funding threshold, One or > more reward tiers, Schedule of when what will be organized, Budget plan, > 300-800 Words of additional information about the Project, Contact details > within 1 secondin after an Organizer submits the submit Project form. - > **FR2.8** The system shall add to the homepage in the new Projects category > the Project link within 30 seconds after the system made a Project webpage   >  - **FR2.9** The system shall include in the Project link for the homepage : > Name of the Project, 1 Photo, Punch line within 30 seconds after the system > made a Project webpage. Questions:   **FR 1.1** : Have I incorporated a design idea here, would " the system shall have a registration form" be a better functional requirement?   **F1.2 ,2.3** : Is this not singular? Would the conditions be better written for each its own separate requirement   **FR 1.4** : Is this a design idea? Is this a correct functional requirement or have I incorporated non functional(performance) in it? Would it be better if I written it like this:   FR1 The system shall display an error message when check is unsuccessful.   **NFR:** The system will respond to unsuccesful registration form checks within 1 seconds. Same question with FR 2.8 and 2.9.   **FR2.3:** The system shall check for "completeness", is completeness here used ambigiously? Should I rephrase it?   **FR1.2:** I added that the system shall require a "Captcha code" is this a functional requirement or does it belong to the "security aspect" of a non functional requirement. I am eagerly waiting for your response. Thanks!