I just did some awesome optimizations for AgroGo. One of them was related to a strange behavior in Spring Security. By default, anything that's protected by Spring Security is sent to the browser with the "Cache-Control: no-cache, no-store, max-age=0" header parameter causing the browser to reload all files on every request. This is bad for various reasons … Continue reading Spring Security caching issue
Tag: Tips
Single-responsibility Principle
This principle states that: A class should have one and only one reason to change, meaning that a class should have only one job. A classic example is the one with the shapes. Let's see it: In the code above we have a problem with the getArea() method. The problem is that it handles the … Continue reading Single-responsibility Principle
Operations automation with Python
When I have recurrent operations I usually try to find a way to automate them. One of the best tool for this is Python. With Python you can easily create a cross platform script that can do almost anything you want with minimal effort. Let me give you one example: Believe it or not this … Continue reading Operations automation with Python
SOLID principles can go wrong
Many developers try to improve their programming practices by learning the SOLID principles. No harm here, this is a very good thing, the only problem is that without some experience (I mean a lot of it), you can easily make your code utterly complicated using the same principles that were designed to make your code … Continue reading SOLID principles can go wrong
Ten Programming Commandments
1. Thou shalt write correct and maintainable code. When writing code your priority should be to write correct and maintainable code. If your code is not according to the specifications it is useless. Also, your code must be easily understandable by other programmers, must follow coding conventions. Code must be structured in such a manner that … Continue reading Ten Programming Commandments
C++: Using Smart Pointers with Arrays
The modern C++ standard libraries, includes smart pointers, which are used to help ensure that programs are free of memory and resource leaks and are exception-safe. All good and sweet, but these structures have a dark little secret. You may ask yourself how do smart pointers choose between delete and delete[] when deleting the managed … Continue reading C++: Using Smart Pointers with Arrays
Thoughts about Micro Optimization
Some people say that you should not micro optimize your code, but if what you love is micro optimization that's what you should do! But you must make sure your algorithm is good before start micro optimizing. Some might say that speed is not important but this is false. Speed is not as important as … Continue reading Thoughts about Micro Optimization
JavaScript: Deal with cached async calls
If you are doing asynchronous calls to a server (AJAX or something else) you must know that some browsers will cache the result for a specific request. The problem with that is that if you want to pull data from the server using repeated asynchronous requests then you are out of luck, the cache operation … Continue reading JavaScript: Deal with cached async calls
Programming Tips: Avoid NULL values
One way to make your code simpler and avoid potential bugs is by avoiding NULL values when possible. Usually you won't have a significant performance overhead doing this. By not returning null values you eliminate null pointer exceptions and also you simplify your code by eliminating the null checks. Example 1 Simplify your code by … Continue reading Programming Tips: Avoid NULL values
The Self-Documenting Code Myth
In my opinion, the idea of true self-documenting code is a myth. I agree that the code itself is always going to be the most up-to-date explanation of what your code does, but I thing that it's very hard for it to explain intent, which is the most vital aspect of comments. If it's written … Continue reading The Self-Documenting Code Myth