How would you quantify quality?

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.


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

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.


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

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.


Is there such a thing as API documentation management?

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"?


Necessity of Interfaces for Small Projects

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...


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

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.


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

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.


Protecting API Keys

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?


Does license matter if I host a maven repository?

* 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?


Books to learn to develop Rails Plugins

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.


Derivations in BNF

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>


How successful is GPL in reaching its goals?

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.


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

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.


How do you manage config with dependency injection?

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.


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

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?


What are best practices for testing programs with stochastic behavior?

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!


Is there an opposite for the term "Backporting"?

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")?


Should business services cross bounded contexts?

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?


Switch or a Dictionary when assigning to new object

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.


What to learn and how?

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.


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

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.


What are the algorithms behind low pause GC?

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.


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

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.


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

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.


How can I test an application that depends on specific hardware

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.


Should I remove unreferenced code?

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


UIDocumentInteractionController in iOS for Whatsapp Integration

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.


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

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?


Redis vs Zookeeper

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?


How can I actually apply the javascript I am learning

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.


Why don't schools cover debuggers?

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.


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

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.


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

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


Do you have a metaphor for cache/data latencies?

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...


Is the database the bottleneck or not? High Scalability talk

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?


Efficient algorithm for joining sieves

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`)


How to manage your personal ssh keys?

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.


How to deal with programming projects that fail?

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?


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

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.


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

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.)


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

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?


Composing programs from small simple pieces: OOP vs Functional Programming

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?


One dimensional cutting algorithm with minimum waste

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) ;(.


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

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?


Is every object rounded to the same size in Java?

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?


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

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;         }       }     }


Naming conventions for instance, local and parameter variables

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)?


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

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 %>


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

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?


Adding object properties using functional programming

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?


How to work as a team of two

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?


Where did the T in wchar_t come from?

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?


What is referential transparency?

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?


Learning curve for web development

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).


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

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)


fast n-gram access data structure

**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?


GPL and confidential business rules in a single page application

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?


How to line-break an email address?

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.


Can Google use my users data?

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?


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

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"?


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

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!


Proper workaround for multiple inheritence in Java (Android)

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).


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

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)


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

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]**


The 10 minutes technical interview

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 ?**


Modifying the MIT license for modified source code?

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.      */


Unit tests, write them before or after the framework?

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?


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

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?


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

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?


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

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 ... ?


Balancing time learning theory and time practicing

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?


Can I use open source libraries in trialware?

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?


Unit and Integration testing: How can it become a reflex

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?


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

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.


To be an interviewer - Java

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?


how to architect this to make it unit testable

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?


Generating different combinations from a list of muscles

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?


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

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?


Functional/nonfunctional requirements VS design ideas

### 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!


Deployment Tools that Integrate with TFS?

So I have this issue. The Operations team where I work has taken over TFS because they are using MS Build to build and deploy code to production servers. As a result developers have lost A LOT of functionality from TFS (see earlier question.) Essentially the operations team has taken owner ship of Trunk in order to manage their deployments. The development cycle thus goes something like this:   1. Request Operations Team to create a Branch from Main for development work.   2. Perform Development work on development branch.   3. Merge from Trunk to development branch prior to release (basically make sure that the development branch has all of the latest changes)   4. Request Operations Team merge to Trunk from development branch (Developers do not have permissions to do this) -> this request will cause Operations to not only to merge to Trunk but also to deploy to the development environment.   5. Perform integration Testing, fix defects found in development branch.   6. Repeat steps 3 - 6 as necessary.   7. Request Operations Team merge from Trunk to a QA branch (there is only ONE on-going QA branch per project) -> this request will cause a deployment into the QA environment (An MS Build template is used to compile the code from QA branch and then deploy to QA servers)   8. QA tests, fix defects found in development branch.   9. Repeat steps 3 - 8 as necessary.   10. Request Operations Team merge from QA branch into PROD branch (there is only ONE on-going PROD branch per project) -> this request will caus a deployment into the PROD environment (Again an MS Build template is used to **re-compile** the code from PROD branch and then deploy to PROD servers) As a result of the Ops team using an MS Build template to deploy to Production servers, the Development team has now lost the "Builders" role. We cannot create our own MS Build templates, we cannot create or edit a Build definition, and we cannot queue a build -- Even in the Development Environment -- because the Build process runs under a service account which has access to Production servers (since it is use to deploy to production servers). Besides the removal of TFS permissions, I have some issues with this process:   1. The assemblies which were compiled and tested in the QA environment are not the assemblies being deployed into the Production environment. Because the MS Build process is being used to deploy to production, code is recompiled and deployed from the Production branch. In theory, the resulting assemblies should be the same, however this is depenent upon a) the operations team (who are not developers) properly merging the code from the QA branch to the PROD branch (human error potential) b) the build environment not changing in such a way as to affect the way assemblies are compiled (since this is primarily .Net improbable but not impossible)   2. Since there is only ONE QA branch, if I have a production issue which needs a "hot fix" after other work has been merged to QA, I have to wait for Ops to rollback changes to the QA branch, merge my changes in and perform the build and then HOPE that operations correctly performed the rollback and merge operations on the QA branch in order to get my "hot fix" into the QA environment.   3. Many of my projects have multiple outputs (e.g. a web-application and a windows service). Often I may want to only deploy one or the other. But if I upgrade one to a new version, I no longer have a PROD branch which represents the one I didn't upgrade.   4. Operations team has already demonstrated that merge operations are not being performed correctly: Following a recent merge from Development to Trunk I performed a compare on the two branches and they were different.   5. Because code is recompiled for each environment we cannot use automated versioning, or make use of the "build quality" features of TFS. Essentially what it comes down to is the Operations Team has attached themselves to using MS Build for deployments and as such have adopted a rediculous Source Control branching and merging strategy to support using MS Build for managing deployments. (I see no benefit in having a QA and PROD branch other than to support MS Build based deployments). What I am trying to do is convince the powers that be and the operations team that what we're doing is a bad practice, and also give them an alternative deployment strategy. What I need for this is a Deployment tool that integrates with TFS (e.g. it will show a list of Builds that have a specified "build quality" level (depending upon the environment being deployed into) as a "deployment source" and allow then to maintain a list of "deployment targets" so that at deployment time, they simply pick the build (source) and the target and click the "GO!" button. A proper deployment tool will hopefully eliminate their dependence upon MS Build, allow them to remove access to QA and Production servers from the MS Build process, follow a more sane approach to branching and merging (e.g adopt a "branch per release" best practices strategy) and restore to the developers the TFS permissions which were revoked to support this rediculous process.


Why did Google develop a cross-compiler from Java to JavaScript?

Google developed a cross-compiler from Java to JavaScript. Why did they do this? Does this mean that JavaScript is not good enought for developing advanced web apps?


Micro finance in the programming industry

I've read quite a bit about the positive effects of micro finance in developing countries. Organizations exist that solicit capital from donations and then make micro loans to people for the purpose of setting up some kind of business. The loans are usually quite small, with little to no interest and are well under ten thousand US Dollars, typically reaching only hundreds of dollars. The pay back rate is also excellent. The programs that exist seem to focus on retail and agricultural endeavours, I have yet to see an organization with a focus on technology sectors like software development. Do you know of any established / credible micro finance organizations that supply micro loans to individuals in order to set up software related businesses? Have the loans been paid back as well as other sectors, such as agriculture and retail? I'm looking globally, so organizations in any country would be appreciated.


Why do companies want you to register with their program?

I've always wondered why some companies want you to register when you install their programs. Personally, I just find it annoying and decline, but what do companies have to gain by having their users get registred? They claim that you get "the latest updates" and stuff, but often you get that anyway without having to register. So what's the deal with this registering? I just don't see that point.


How to queue work orders by date and priority?

In my organization I work on orders based on date, so earliest work orders first. We also have an option for order to be marked "priority" in which case those orders are done first but not always. I've asked my boss some questions and I couldn't get answer that made sense...   1. If one order has today's date, and another order has tomorrows date but is marked priority, which order should I work on first? He said the order marked "priority".   2. If one order has today's date, and another order is dated 14 days from today and is marked priority, which order should I work on first? He said the one that has today's date. So the problem is properly placing the order in queue, but it's not something they have an exact formula for. If I was to make a class that only has two properties...               public class WorkOrder     {         public DateTime dueDate;         public bool isPriority;     }      What would be the most straightforward way to put them in queue?


Is it acceptable to use C11 generic macros in Objective-C to box numbers?

I was getting tired of repeating types when writing things like this:               NSDictionary* d = @{@"so": [NSNumber numberWithInt:index]),                         @"much": [NSNumber numberWithBool:accepted]),                         @"repeat": [NSNumber numberWithDouble:height]};      So I defined a generic macro (a new feature in C11):               #define box(X) _Generic((X), \     char: boxChar, \     unsigned char: boxUnsignedChar, \     short: boxShort, \     unsigned short: boxUnsignedShort, \     int: boxInt, \     unsigned int: boxUnsignedInt, \     long: boxLong, \     unsigned long: boxUnsignedLong, \     long long: boxLongLong, \     unsigned long long: boxUnsignedLongLong, \     float: boxFloat, \     double: boxDouble, \     BOOL: boxBool \     )(X)          ... implement type-specific box methods as well ...      So that I could write things like this:               NSDictionary* d = @{@"so": box(index),                         @"much": box(accepted),                         @"shorter": box(height)};      Is this a good idea? Can I expect others to be able to build the code? Will they hate it for not being standard?


I made improvements to free code I found online and notified the author. Was this the right thing to do?

I recently used a library from http://www.braemoor.co.uk/software/index.shtml (the EU VAT No validation library at http://www.braemoor.co.uk/software/vat.shtml) in a project at work. It mentions as the license (or something that looks like one): > All software is provided as freeware for personal or commercial use without > obligation by either party. The author will not accept responsibility for > any problems that may be incurred by use of this software, although any > errors reported will be corrected as soon as possible. Re-distribution of > this software is NOT permitted without explicit permission. I checked the code and found (and applied) a few ways to improve the code so it's more easily maintainable and more readable (you can find one of them on CodeReview.SE). After applying these changes, I considered that others might benefit from them as well and sent them as feedback to the author on his contact address. A few hours later, the author sent a reply thanking me for my suggestions, and that he would go over my changes and keep me informed. My main concern is that while the website mentioned that it was freeware, I'm not sure how far I am allowed to go in altering his software without knowing the license. I assume it's license-free, but it's not specifically mentioned as open source, and I'm slightly worried that I might have overstepped my bounds and took too much liberty with the whole thing. Did I do the right thing?


Shoud I directly return a string message or rather a i18n key when dealing with JSON api?

Suppose a rest api returning this json:               {         "status" : "fail",         "data" : { "title" : "A title is required" }     }      Since the client application would always adapt the error message, would it be better to return an explicit i18n key that the client would have mapped rather than "A title is required"? :               {         "status" : "fail",         "data" : { "title" : "error.creation.title.required" }     }      Indeed, the point is to expect the request consumer (web application for instance) to easily translate the message regarding its localization.