Code Reviews Do Not Guarantee A Good Product

If you have a decent development process, you most probably have code reviews. But it appears many people (especially management) believe that code reviews make sure the end product is good, and bug-free. This has nothing to do with reality, as you can probably guess. The purpose of code reviews is to: make sure coding style is consistent throughout the application basic things are done properly. For example – don’t use Strings for numbers, don’t synchronize access to singletons, use StringBuilder inside loops, etc. no code duplication exists layer boundaries are preserved – no database access in the view layer, no UI code in the service layer, etc. By doing that, code reviews try to minimize the possibility of generating a lot of technical debt. That debt in turn may lead to problematic development of new features and maintenance. But preventing this does not guarantee the product will be good. It certainly does not mean that it will be as if the code was written by the reviewer. The code review cannot (and should not) catch problems with the business logic and the program flow. Exceptions flying all over is something not easily detectable by the reviewer. Depending on the structure this should be caught by QA, the developers themselves or in most cases – both. So, when management asks you “how come the product is crap if we had code reviews?”, you can say “how come my car breaks all the time if all parts were inspected when built?”. If you have a decent development process, you most probably have code reviews. But it appears many people (especially...

My Problem With Your Interviews

This article comes right after Facebook rejected me after 3 phone interviews, but it is not going to be a hate-post. In fact, I’ve been planning to write it for a couple of months. But now onto the topic: tech companies (Google, Facebook, VMWare, at least, but certainly many more) are all trying to find the best technical talent. (So they contacted me and asked if I’m interested in “exploring opportunities” with them). But how do they do that? The typical interview (be it a phone screen, or an onsite interview) consists of solving a problem. Some call these problems “puzzles”. They are usually non-real world problems that aim to verify your algorithmic skills and your computer science knowledge. The simple ones include recursion, binary search, basic data structures (linked list, hasthable, trees). The more complex ones require red-black trees, Dijkstra, knowledge of NP-completeness, etc. If you are on the phone, you write the code in a shared document. If onsite – you write it on a whiteboard. So, these puzzles should verify your computer science and algorithm skills. But let’s step back a little and see the picture from another angle. what you do on these interviews is something you never, ever do in real life: you write code without using any compiler or debugger. You do that in a limited time, with people watching you / waiting for you on the line. But let’s put that aside for now. Let’s assume that writing code without being able to run it is fine for interview purposes. the skills that these puzzles are testing are skills that the majority...

Is Moving All Jars To a Shared lib Folder Beneficial?

We will be running more than one web application on the same tomcat (7.0.22), so we wondered whether there will be a benefit in moving all jars to tomcat/lib instead of having them in each application’s WEB-INF/lib (since our applications have almost identical dependencies). What this gives as benefit for sure, without even testing, is that the classes are loaded by the parent classloader, and are loaded only once, rather than by each app’s classloader. Here are the results on my machine, with 2 applications: Startup times (4 runs): WEB-INF/lib INFO: Server startup in 77554 ms INFO: Server startup in 62391 ms INFO: Server startup in 62598 ms INFO: Server startup in 61002 ms tomcat/lib INFO: Server startup in 72321 ms INFO: Server startup in 71151 ms INFO: Server startup in 69841 ms INFO: Server startup in 71047 ms Memory (2 runs): WEB-INF/lib PermGen: size=278, Used=198 Heap: size=1,029, Used=465 PermGen: Size=276, Used=198 Heap: Size=1,049, USed=501 tomcat/lib PermGen: Size=199, Used=151 Heap: size=1,043, Used=412 PermGen: Size=195, Used=151 Heap: size=1,035, Used=418 The only difference is in the used PermGen size, which differs with ~50 MB per app (size differs with ~80). (Used Heap goes up and down, hence the difference). This is without working wit the app, which would add a bit more difference, but most of our classes are loaded eagerly by the spring context. So this is not enough benefit for the deployment complications it introduces – you can no longer package your application directly from maven/ant – you have to post-process it to clear the jars, and also make sure your environments have up-to-date tomcat/lib folders. We will be...

Is Reddit Handling Trailing Slashes Incorrectly?

Looking at my blog analytics yesterday, I got half of my reddit views from reddit.com/r/programming, and the other half – from reddit.com/r/programming/ – only one trailing slash difference. The general principle is (my post about it) that you should choose only one version, and redirect the other with 301, because search engines treat the two URLs as completely different resources (what this means internally for search engines – I don’t know) But reddit doesn’t redirect anything – is it a mistake on their side, or is it something done on purpose, and if so – why? Looking at my blog analytics yesterday, I got half of my reddit views from reddit.com/r/programming, and the other half – from reddit.com/r/programming/ – only one trailing slash difference. The general principle is (my post about it) that you should choose only one version, and redirect the other with 301, because search engines treat the two URLs as completely different resources (what this means internally for search engines – I don’t know) But reddit doesn’t redirect anything – is it a mistake on their side, or is it something done on purpose, and if so –...

State Does Not Belong In The Code

What is “state” in your web application? It’s the data that gets stored (regardless of the destination – memory, database, file-system). The application itself must not store any state in the code. This means your classes should only have fields with objects that are also stateless. In other words – you should not store anything in your services, DAOs or controllers during the program flow. This is a complete “must” for your service layer. Why? Your application needs to be scalable. This means it needs to be run in a cluster, and state is the hardest thing to distribute. If you minimize the places where state is stored, you minimize the complexity of clustering. But state should exist, and here is where it is fine to have it: the database – be it SQL, NoSQL or even a search engine, it’s the main thing that stores state. It is the thing that is supposed to support clustering, or a huge dedicated machine that handles requests from multiple other “code” servers. The code communicates with the database, but the code itself does not store anything for more than one client request; cache – caching is relatively easy to distribute (it’s basically key-value). There are many ready-to-use solutions like EhCache and memcached. So instead of computing a result, or getting it from the DB on each request, you can configure caching and store the result in memory. But again – code does not store anything – it just populates and queries the cache; HTTP session – in web components (controllers, managed beans, whatever you call it). It is very similar to...