ORM Haters Don’t Get It

I’ve seen tons of articles and comments (especially comments) that tell us how bad, crappy and wrong is the concept of ORM (object-relational mapping). Here are the usual claims, and my comments to them: “they are slow” – there is some overhead in mapping, but it is nothing serious. Chances are you will have much slower pieces of code. “they generate bad queries which hurts performance” – first, it generates better queries than the regular developer would write, and second – it generates bad queries if you use bad mappings “they deprive you of control” – you are free to execute native queries “you don’t need them, plain SQL and XDBC is fine” – no, but I’ll discuss this in the next paragraph “they force you to have getters and setters which is bad” – your entities are simple value objects, and having setters/getters is fine there. More on this below database upgrade is hard – there are a lot of tools around the ORMs that make schema transition easy. Many ORMs have these tools built-in But why do you need an ORM in the first place? Assume you decided not to use one. You write your query and get the result back, in the form of a ResultSet (or whatever it looks like in the language you use). There you can access each column by its name. The result is a type unsafe map-like structure. But the rest of your system requires objects – your front-end components take objects, your service methods need objects as parameters, etc. These objects are simple value-objects, and exposing their state via getters...

Javascript-off Unfriendly, And Proud About It

Your site should work even with javascript turned off, they say. I strongly disagree. First, it is a lot of effort to make a function-heavy site work without javascript. You’ve build the thing to work with ajax, cool controls and lots of dialogs. And you should build an entirely new version for those 2 percent that don’t have javascript? The effort just isn’t worth it. Not even for facebook, youtube and twitter – neither of them works without javascript. So, when I develop a web app that fails to work properly without javascript (like welshare), I’m very much aware of that, and it’s done on purpose – to save unnecessary effort, and not to provide a crappy version of the UI. Of course, completely ignoring the fact that javascript may be turned off would be too one-sided. So: make the basic home page and the signup page be workable without javascript. Some users (like me) block scripts with AddOns, for the sake of security. If your homepage is blank when my javascript is off, I’d be hesitant to enable scripts for it. But if I see it’s a trustworthy service, I may go and actually signup. Of course, ajax validation is a must nowadays, but you should have server-side validation anyway, so make your signup form work. display a message “This site requires JavaScript to function properly”. That’s what many sites (including youtube, stackoverflow, and my aforementioned welshare) do. It’s easily handled by the <noscript> tag. content-heavy websites are generally less reliant on javascript. They may use it for paging or comments but it’s not their main functionality, it’s...

Keep As Much Stuff As Possible In The Application Itself

There’s a lot of Ops work to every project. Setting up server machines, and clusters of them, managing the cloud instances, setting up the application servers, HAProxy, load balancers, database clusters, message queues, search engine, DNS, alerts, and whatnot. That’s why the Devops movement is popular – there’s a lot more happening outside the application that is vital to its success. But unix/linux is tedious. I hate it, to be honest. Shell script is ugly and I would rather invent a new language and write a compiler for it, that write a shell script. I know many “hackers” will gasp at this statement, but let’s face it – it should be used only as a really last resort, because it will most likely stay out of the application’s repository, it is not developer friendly, and it’s ugly (yes, you can version it, you can write it with good comments, and still…) But enough for my hate for shell scripting (and command-line executed perl scripts for that matter). That’s not the only thing that should be kept to minimum. (Btw, this is the ‘whining’ paragraph’, you can probably skip it). The “Getting Started” guide of all databases, message queues, search engines, servers, etc. says “easy to install”. Sure, you just apt-get install it, then go to /usr/lib/foo/bar and change a configuration file, then give permissions to a newly-created user that runs it, oh, and you customize the shell-script to do something, and you’re there. Oh, and /usr/lib/foo/bar – that’s different depending on how you install it and who has installed it. I’ve seen tomcat installed in at least 5 different...

Programming Puns

Though not strictly puns, I tried to make them sort-of funny MHR2TUBPG2NP : – What are you doing on this bench with a bank slip and a marker? – Benchmarking our transactions. What’s “on” on Earth? The air conditional. What do communists and functional programmers have in common? They hate classes. “You shall not pass by reference”, said Gandalf to James Gosling. I’ll create a programming language named obl. That way, when using a for-loop, I will be obl-iterating. Why are “i”, “j” and “k” the most used letters for loop variables? Ask Dijkstra. What’s common about basements and maven repositories? They hold jars. I’ve written a movie about insects. Here’s the ant script. – What are you doing with this bucket of paint at the construction site? – Making the build green. Write string concatenation in PHP on the dotted line. A garbage collector joined Men in Black to help them with erasing memory. I asked the Oracle what is my future, and it responded with ORA-27102: out of memory Though not strictly puns, I tried to make them sort-of funny MHR2TUBPG2NP : – What are you doing on this bench with a bank slip and a marker? – Benchmarking our transactions. What’s “on” on Earth? The air conditional. What do communists and functional programmers have in common? They hate classes. “You shall not pass by reference”, said Gandalf to James Gosling. I’ll create a programming language named obl. That way, when using a for-loop, I will be obl-iterating. Why are “i”, “j” and “k” the most used letters for loop variables? Ask Dijkstra. What’s common about basements...

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