background preloader

Bestpractices

Facebook Twitter

Errorhandling

Exceptions. How to Write an Equality Method in Java. How to Write an Equality Method in Javaby Martin Odersky, Lex Spoon, and Bill VennersJune 1, 2009 Summary This article describes a technique for overriding the equals method that preserves the contract of equals even when subclassses of concrete classes add new fields. In Item 8 of Effective Java1, Josh Bloch describes the difficulty of preserving the equals contract when subclassing as a “fundamental problem of equivalence relations in object-oriented languages.” Bloch writes: There is no way to extend an instantiable class and add a value component while preserving the equals contract, unless you are willing to forgo the benefits of object-oriented abstraction.

Chapter 28 of Programming in Scala shows an approach that allows subclasses to extend an instantiable class, add a value component, and nevertheless preserve the equals contract. Although in the technique is described in the book in the context of defining Scala classes, it is also applicable to classes defined in Java. 1. 2. 3. Exception Handling in Java (2007) 6 Advanced JavaScript Techniques You Should Know. By Louis Lazaris There have been a number of articles published over the years that discuss best practices techniques for JavaScript. I thought I would go a little bit beyond the scope of those articles and outline a number of advanced techniques and practices that I have personally used or read about that could be invaluable in certain circumstances. This article doesn’t necessarily cover every detail of the methods I’m describing, but provides an overview, along with code examples, of some practical JavaScript coding techniques. 1.

Closures in JavaScript are a fairly straightforward concept, and have been discussed online in a number of in-depth articles. Simply put, closures allow variable scope to be extended past the common scope restrictions of functions. "Think of closures as a kind of regional scope: broader than local but not as broad as global. " To create a closure, you nest a function inside of a function. Further Reading 2. The function above can take up to 6 arguments. 3. 4. 97 Things Every Programmer Should Know. From Programmer 97-things Welcome to the home page for the 97 Things Every Programmer Should Know project, pearls of wisdom for programmers collected from leading practitioners. You can read through the Contributions Appearing in the Book plus the Other Edited Contributions, browse Contributions in Progress, view the list of Contributors, and also learn How to Become a Contributor.

If you would simply like to comment on a contribution, please also read How to Become a Contributor as some of it applies to you. There is no overarching narrative: The collection is intended simply to contain multiple and varied perspectives on what it is that contributors to the project feel programmers should know. This can be anything from code-focused advice to culture, from algorithm usage to agile thinking, from implementation know-how to professionalism, from style to substance, etc. Click here to see the list of contributions selected for the book and here to see other contributions. jQuery and JavaScript Coding: Examples and Best Practices | Smas. Advertisement When used correctly, jQuery can help you make your website more interactive, interesting and exciting. This article will share some best practices and examples for using the popular Javascript framework to create unobtrusive, accessible DOM scripting effects.

The article will explore what constitutes best practices with regard to Javascript and, furthermore, why jQuery is a good choice of a framework to implement best practices. 1. Why jQuery? jQuery is ideal because it can create impressive animations and interactions. jQuery is simple to understand and easy to use, which means the learning curve is small, while the possibilities are (almost) infinite. Javascript and Best Practices Javascript has long been the subject of many heated debates about whether it is possible to use it while still adhering to best practices regarding accessibility and standards compliance.

Obviously there are cases where a Javascript solution is not the best option. Unobtrusive DOM Scripting 2. ... Javascript best practices? Java Practices -> Home. Alexander Klimetschek's Blog : Weblog. Best practices for service interface design in SOA, Part 1: Expl. Effective Java Exceptions.