by Bozho | Apr 30, 2012 | Aggregated, Opinions
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...
by Bozho | Apr 26, 2012 | Aggregated, Developer tips
This should really be a simple distinction, but I’ve been answering a slew of similar questions on Stackoverflow, and often people misunderstand the matter. So, what is a classpath? A set of all the classes (and jars with classes) that are required by your application. But there are two, or actually three distinct classpaths: compile-time classpath. Contains the classes that you’ve added in your IDE (assuming you use an IDE) in order to compile your code. In other words, this is the classpath passed to “javac” (though you may be using another compiler). runtime classpath. Contains the classes that are used when your application is running. That’s the classpath passed to the “java” executable. In the case of web apps this is your /lib folder, plus any other jars provided by the application server/servlet container test classpath – this is also a sort of runtime classpath, but it is used when you run tests. Tests do not run inside your application server/servlet container, so their classpath is a bit different Maven defines dependency scopes that are really useful for explaining the differences between the different types of classpaths. Read the short description of each scope. Many people assume that if they successfully compiled the application with a given jar file present, it means that the application will run fine. But it doesn’t – you need the same jars that you used to compile your application to be present on your runtime classpath as well. Well, not necessarily all of them, and not necessarily only them. A few examples: you compile the code with a given library on the compile-time...
by Bozho | Apr 22, 2012 | Aggregated, Opinions
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...
by Bozho | Apr 17, 2012 | Aggregated, Developer tips
You may be using JSON to transfer data (we were using it in our message queue). While this is good, it has the only benefit of being human-readable. If you don’t care about readability, you’d probably want to use a more efficient serialization mechanism. Multiple options exist: protobuf, MessagePack, protostuff, java serialization. The easiest of them to use is java serialization, but it is less efficient (with both memory and time) than the other solutions. There are some benchmarks that will help you choose the most efficient solution, but if you want it to be easy and almost drop-in replacement to your JSON solution, MessagePack might be the best option. I made a simple test to compare the JSON output to the MessagePack output in terms of size: 2300 vs 150 bytes for a simple message. Pretty good reduction, and if the messages are a lot, it’s a must to optimize. However, you need to register all classes in the message pack. There are two options: use @Message on all the objects in the serialized graph. This is a bit tedious, especially if you already have a lot of classes that are transferred. You have to go through the whole graph you can manually register all classes with the mesagpack. Again tedious, because you also have to register all classes that the message class contains as a field (recursively) That’s why I wrote the following code to loop all our message classes, and register them with the message pack on startup. It partly relies on spring classes, but if you are not using spring, you can replace them: private...
by Bozho | Apr 5, 2012 | Aggregated, Opinions
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...
Recent Comments