Best practices and common mistakes

Facebook Twitter
12 common programming mistakes to avoid | Geek Files Programming is an art and science and like all art and science the only way to learn is from mistakes. I have made many… and I would like to share with you the mistakes that I have made over my journey with development. These are some of the most common programming mistakes made by developers (including me) and how to avoid them (not listed in any specific order) Can you imagine a program without comments. Just imagine how difficult it would be to read someone else’s code without comments. 12 common programming mistakes to avoid | Geek Files
by Miško Hevery Everyone seems to think that they are writing OO after all they are using OO languages such as Java, Python or Ruby. But if you exam the code it is often procedural in nature. Static Methods How to think about OO How to think about OO
Flaw: Brittle Global State & Singletons Accessing global state statically doesn’t clarify those shared dependencies to readers of the constructors and methods that use the Global State. Global State and Singletons make APIs lie about their true dependencies. To really understand the dependencies, developers must read every line of code. It causes Spooky Action at a Distance: when running test suites, global state mutated in one test can cause a subsequent or parallel test to fail unexpectedly. Break the static dependency using manual or Guice dependency injection. NOTE: When we say “Singleton” or “JVM Singleton” in this document, we mean the classic Gang of Four singleton. Flaw: Brittle Global State & Singletons
by Miško Hevery Recently many of you, after reading Guide to Testability, wrote to telling me there is nothing wrong with static methods. After all what can be easier to test than Math.abs()! Static Methods are Death to Testability Static Methods are Death to Testability
Breaking the Law of Demeter is Like Looking for a Needle in the Haystack Breaking the Law of Demeter is Like Looking for a Needle in the Haystack July 18th, 2008 · 20 Comments · by Miško Hevery Every time I see Law of Demeter violation I imagine a haystack where the code is desperately trying to locate the needle. class Mechanic { Engine engine; Mechanic(Context context) { this.engine = context.getEngine(); } }
August 14th, 2008 · 7 Comments · by Miško Hevery Procedural languages allowed us to remove GOTOs in our code. I would like to think that OO languages allow us to remove IFs (conditionals). I know you can’t remove of all the IFs, but it is interesting just how many IFs you can remove in an application. You can’t remove these IFs: Procedural Language Eliminated GOTOs; OO Eliminated IFs Procedural Language Eliminated GOTOs; OO Eliminated IFs
How to think about OO Everyone seems to think that they are writing OO after all they are using OO languages such as Java, Python or Ruby. But if you exam the code it is often procedural in nature. Static Methods Static methods are procedural in nature and they have no place in OO world. How to think about OO
How To Think About OO How To Think About OO We Recommend These Resources Everyone seems to think that they are writing OO after all they are using OO languages such as Java, Python or Ruby. But if you exam the code it is often procedural in nature.
Falsehoods Programmers Believe About Names: MicroISV on a Shoestring Falsehoods Programmers Believe About Names: MicroISV on a Shoestring [This post has been translated into Japanese by one of our readers: 和訳もあります。] John Graham-Cumming wrote an article today complaining about how a computer system he was working with described his last name as having invalid characters. It of course does not, because anything someone tells you is their name is — by definition — an appropriate identifier for them. John was understandably vexed about this situation, and he has every right to be, because names are central to our identities, virtually by definition.
There's an election coming up in Thailand on December 23rd and the streets are lined with election posters. As a bit of an i18n geek, I find it interesting that the posters almost all make the candidates' first names at least twice as big as their last names. If you're also an i18n geek, your reaction might well be: "it must be because Thais write their family name first, followed by their given name". But you would be wrong. Thais have a given name and a family name; the given name is written first, and the family name last. Thai personal names - James Clark's Random Thoughts Thai personal names - James Clark's Random Thoughts
‘Real’ names online, part 2 : defining ‘real’ - A Modern Hypatia Before we get into the more interesting meat of the topic (which will follow next week), I want to go into a digression about the problem of ‘real names’. First problem: What does a ‘real name’ look like? We like to think that we know them when we see them. But really, we don’t.
I’ve been watching the conversations about the new RealID additions on the Blizzard forums with some interest, because they tie into a much larger conversation about online interactions and anonymity and pseudonymity. So, in the next week or so, a few posts about first, some background, and then some specific concerns and considerations around the use of real-world identifying names online. Why does this matter on a librarian’s blog? Well, first, because I use the ‘Net, and I’m fascinated by how other people use it, and about how to help give people tools to make informed choices for their use of it. But also because I think this is one of the major freedom of information issues of at least the next decade: how do we balance a desire for sincere conversation, with meaning and history and in the context of a particular community, with the reality that some people will abuse, harass, intimidate, or otherwise seek to harm others. Background (‘real’ names online : part 1) « A Modern Hypatia
Personal names around the world Background People who create web forms, databases, or ontologies are often unaware how different people’s names can be in other countries. They build their forms or databases in a way that assumes too much on the part of foreign users. This article will first introduce you to some of the different styles used for personal names, and then some of the possible implications for handling those on the Web. This article doesn't provide all the answers – the best answer will vary according to the needs of the application, and in most cases, it may be difficult to find a 'perfect' solution.
Mise à jour de Gordon Fowler Le simple fait de demander un nom et un prénom dans un formulaire web peut paraître trivial. Mais à bien y réfléchir, cela ne l'est pas. C'est en tout cas le point de vue du W3C qui vient de publier une page de conseils. Comment les noms diffèrent à travers le monde ? Le W3C se penche sur les implications pour les formulaires et bases de données Web