8 Most common mistakes C# developers make

Thanks to: http://blog.goyello.com/2013/01/07/8-most-common-mistakes-c-developers-make/


While working with (young) C# programmers I’ve noticed that some mistakes are being repeated by almost every one of them. These are mostly the mistakes, which once you point them, are quite easy to remember. However, if a developer is not aware of them, they can cause many problems with the efficiency and quality of the developed software. Therefore, I decided to gather the 8 most common mistakes made.

1. String concatenation instead of StringBuilder

String concatenation works in such a way that every time when you add something to a string, a new address in the memory is being allocated. The previous string is copied to a new location with the newly added part. This is inefficient. On the other hand we have StringBuilder which keeps the same position in the memory without performing the copy operation. Thanks to the strings’ appending by means of StringBuilder the process is much more efficient, especially in case of hundreds of append operations.


2. LINQ – ‘Where’ with ‘First’ instead of FirstOrDefault

A lot of programmers find a certain set of elements by means of ‘Where’ and then return the first occurrence. This is inappropriate, because the ‘First’ method can be also applied with the ‘Where’ condition. What’s more, it shouldn’t be taken for granted that the value will always be found. If “First” is used when no value is found, an exception will be thrown. Thus, it’s better to use FirstOrDefault instead. When using FirstOrDefault, if no value has been found, the default value for this type will be returned and no exception will be thrown.



3. Casting by means of ‘(T)’ instead of ‘as (T)’ when possibly not castable

It’s common that software developers use simple ‘(T)’ casting, instead of ‘as (T)’. And usually it doesn’t have any negative influence because casted objects are always castable. Yet, if there is even a very slight probability that an object can be under some circumstances not castable, „as (T)” casting should be used. See Difference Between C# Cast Syntax and the AS Operators for more details.


4. Not using mapping for rewriting properties

There are a lot of ready and very powerful C# mappers (e.g. AutoMapper). If a few lines of code are simply connected with rewriting properties, it’s definitely a place for a mapper. Even if some properties aren’t directly copied but some additional logic is performed, using a mapper is still a good choice (mappers enable defining the rules of rewriting properties to a big extend).

5. Incorrect exceptions re-throwing

C# programmers usually forget that when they throw an exception using „throw ex” they loose the stack trace. It is then considerably harder to debug an application and to achieve appropriate log messages. When simply using „throw” no data is lost and the whole exception together with the stack trace can be easily retrieved.


6. Not using ‘using’ for objects disposal

Many C# software developers don’t even know that ‘using’ keyword is not only used as a directive for adding namespaces, but also for disposing objects. If you know that a certain object should be disposed after performing some operations, always use the ‘using’ statement to make sure that the object will actually be disposed.

7. Using ‘foreach’ instead of ‘for’ for anything else than collections

Remember that if you want to iterate through anything that is not a collection (so through e.g. an array), using the ‘for’ loop is much more efficient than using the ‘foreach’ loop. See Foreach vs For Performance for more details.

8. Retrieving or saving data to DB in more than 1 call

This is a very common mistake, especially among junior developers and especially when using ORMs like Entity Framework or NHibernate. Every DB call consumes some amount of time and therefore it’s crucial to decrease the amount of DB calls as much as possible. There are many ways to do so:

  • Using fetching (Eager Loading)
  • Enclosing DB operations in transactions
  • In case of a really complex logic, just moving it to the DB by building a stored procedure


Best WordPress Multilanguage Plugins


The two main contenders as best multilanguage plugins for WordPress are WPML and QTranslate. If you want a quick answer to which one comes out on top, I would say go for WPML. If you have enough time to give them a test drive, by all means do so and judge for yourself which one works best for your needs.


If you want the most fully featured multilanguage plugin solution for WordPress, your best bet is WPML.

WPML makes it possible to turn WordPress blogs multilingual in a few minutes with no knowledge of PHP or WordPress. Its advanced features allow professional web developers to build full multilingual websites.

  • Turns a single WordPress site into a multilingual site.
  • Powerful translation management, allowing teams of translators to work on multilingual sites.
  • Built-in theme localization without .mo files.
  • Comments translation allows you to moderate and reply to comments in your own language.
  • Integrated professional translation (optional feature for folks who need help translating).
  • Includes CMS navigation elements for drop down menus, breadcrumbs trail and sidebar navigation.
  • Robust links to posts and pages that never break.

WPML is also offering full integration with Gravity Forms, so you can easily translate all the forms on your site as well.

Download WPML

ICanLocalize, the creators of WPML, offer reliable commercial support for WPML. This support provides timely and dependable help directly from the developers. You can also order translations to be done directly from the plugin interface, via the ICanLocalize service.


An alternative to WPML is QTranslate. It is also a valid multilanguage plugin that works a bit differently to WPML.

qTranslate makes creation of multilingual content as easy as working with a single language. Here are some features:

  • qTranslate Services – Professional human and automated machine translation with two clicks
  • One-Click-Switching between the languages – Change the language as easy as switching between Visual and HTML
  • Language customizations without changing the .mo files – Use Quick-Tags instead for easy localization
  • Multilingual dates out of the box – Translates dates and time for you
  • Comes with a lot of languages already builtin! – English, German, Simplified Chinese and a lot of others
  • No more juggling with .mo-files! – qTranslate will download them automatically for you
  • Choose one of 3 Modes to make your URLs pretty and SEO-friendly. – The everywhere compatible ?lang=en, simple and beautiful /en/foo/ or nice and neat en.yoursite.com
  • One language for each URL – Users and SEO will thank you for not mixing multilingual content

qTranslate supports infinite languages, which can be easily added/modified/deleted via the comfortable Configuration Page. All you need to do is activate the plugin and start writing the content.

Download QTranslate

Comparing WPML and QTranslate

qTranslate stores all languages alternatives for each post in the same post, whereas WPML manages multilingual posts in one post per language. Translations in WPML are then linked together, indicating that one page is the translation of another. Each of this plugin has advantages and disadvantages.

Here is a comparison between qTranslate and WPML:

Advantages of WPML:

  1. The database contents for posts remain unmodified (easy install and uninstall).
  2. Everything gets translated by default. If a post includes custom fields, they’re attached to that post, so they are already associated with the language.
  3. Other plugins that analyze contents (like related posts) keep working correctly.
  4. Great support from an established company employing more than 15 people.

Disadvantages of WPML:

  1. More complex architecture. The plugin needs to hook to many WordPress functions and filter them so that only contents that matches the language is returned.
  2. Additional tables are required normally, to hold the translation grouping.

Advantage of qTranslate:

  1. Side by side editing is easily implemented.
  2. Less things to break. There are no additional tables and much fewer things to modify in WordPress.

Disadvantages of qTranslate:

  1. In order to create multilingual contents, the user needs to insert the language tags manually, to everything the plugin doesn’t hook to. Example: Adjust MicroKid Related Posts with qTranslate Plugins
  2. Uninstall can be complicated, as the database needs to be cleaned from multilingual contents.

In SEO terms, the main advantage of WPML over qTranslate is the URL rewriting. With qTranslate, you create a page, name it and every translated version will contain the same URLs elements.
E.g. http://www.islecreative.com/translation-french and http://www.islecreative.com/fr/translation-french
With WPML, every page can have a unique URLs which you can decide
E.g. http://www.islecreative.com/translation-french and http://www.islecreative.com/fr/traduction-francais

Furthermore, I find WPML more user-friendly. All the translated pages are listed on the Page section, and the translated versions remain accessible whenever a page is being edited.

Our recommendation: Get the WPML Multilingual plugin

Have you used any of these two plugins? Have something to add to the above review? Leave a comment below!

Remember that when building a multilanguage website you can also pick a suitable WordPress multilingual theme from our review.

Get the WPML Multilingual plugin


How to make more time in your day

Do you struggle to fit everything into your working day?

Most Project Managers find it hard to get all their tasks done each day, but you can get more out of your working hours by working smartly. Here’s how to do it…

How to make more time in your day

#1: Use templates
Templates are documents or files that you can use time and time again. Don’t create a new Project Charter for every project, for example. Use a template and simply fill in the relevant bits for this project. You’ll save time because you won’t have to set up titles, headers or footers or any other style elements.

You can also use templates for creating schedules, task lists, reports and anything else that you use on your project. Don’t just limit yourself to documents!

#2: Use time sheets
The key to getting more done is understanding what you currently do with your time. Time sheets will show you what you have actually been working on, so you can assess how your time is being spent. You might, for example, find that you spend too long in meetings each week, or working on a particular element of project management like budgeting. Using timesheet software will help you keep track of where your time is going.

Once you have completed time sheets for a couple of weeks you will be able to see where you are wasting time in the day. You can also decide if there is anything you could delegate to another team member as a learning opportunity.

#3: Take breaks
It might seem counter-intuitive, but it really will help you get more done if you schedule some breaks into your day. Breaks help refresh your brain and your body, which means you come back to your desk feeling more motivated and capable of completing your tasks. Go for a walk, talk to a colleague or simply get a cup of coffee. Anything that gives your eyes a rest from the screen and your mind a change of scene will do.

#4: Use dashboards
Dashboards are visual representations of project progress and they are a great way to see the big picture status of your project. You won’t have to review every element of the project to get a status update as you’ll be able to see it all at a glance.

Dashboards are also great to share with your stakeholders. They will save you time producing bespoke reports month after month as instead, your project sponsor and anyone else who is interested can simply log on and see the status for themselves in real-time.

#5: Store your files online
Project managers and their teams spend a great deal of time looking for important project files. You can save time if you set up an online filing system that will structure your files for you and keep them secure. Then you’ll always know where the latest copy of a document is kept, and you won’t waste time hunting for it when you need it. This will also help your project team save time!

Of course, you don’t need to spend your extra hours on project work! Why not use some of it to study for a professional qualification, or to catch up with a good book, or to just get home earlier and spend more time with your family?

Use the professional time sheet features in ProjectManager.com to track your time and work out where you could be spending it differently.

You can also store documents securely online, create tailored dashboards, store templates and produce reports with just a few clicks—all great ways to get a bit of time back during your working day. Give it a free try now.

JavaScript Frameworks/Libraries


JavaScript Frameworks (Libraries)

Advanced JavaScript programming (especially the complex handling of browser differences), can often be very difficult and time-consuming to work with.

To deal with these difficulties, a lot of JavaScript (helper) libraries have been developed.

These JavaScript libraries are often called JavaScript frameworks.

In this tutorial, we will take a look at some of the most popular JavaScript frameworks:

  • jQuery
  • Prototype
  • MooTools

All of these frameworks have functions for common JavaScript tasks like animations, DOM manipulation, and Ajax handling.

In this tutorial we will teach you how start using them, to make JavaScript programming easier, safer, and much more exciting.


jQuery is the most popular JavaScript framework on the Internet today.

It uses CSS selectors to access and manipulate HTML elements (DOM Objects) on a web page.

jQuery also provides a companion UI (user interface) framework and numerous other plug-ins.

Many of the largest companies on the Web use jQuery:

  • Google
  • Microsoft
  • IBM
  • Netflix

You will find an excellent jQuery Tutorial here at W3Schools.


Prototype is a JavaScript library that provides a simple API to perform common web tasks.

API is short for Application Programming Interface. It is a library of properties and methods for manipulating the HTML DOM.

Prototype enhances JavaScript by providing classes and inheritance.


MooTools is also a framework that offers an API to make common JavaScript programming easier.

MooTools also includes some lightweight effects and animation functions.

Other Frameworks

Here are some other frameworks not covered in this short overview:

YUI – The Yahoo! User Interface Framework is a large library that covers a lot of functions, from simple JavaScript utilities to complete internet widgets.

Ext JS – Customizable widgets for building rich Internet applications.

Dojo – A toolkit designed around packages for DOM manipulation, events, widgets, and more.

script.aculo.us – Open-source JavaScript framework for visual effects and interface behaviors.

UIZE – Widgets, AJAX, DOM, templates, and more.

CDN – Content Delivery Networks

You always want your web pages to be as fast as possible. You want to keep the size of your pages as small as possible, and you want the browser to cache as much as possible.

If many different web sites use the same JavaScript framework, it makes sense to host the framework library in a common location for every web page to share.

A CDN (Content Delivery Network) solves this. A CDN is a network of servers containing shared code libraries.

Google provides a free CDN for a number of JavaScript libraries, including:

  • jQuery
  • Prototype
  • MooTools
  • Dojo
  • Yahoo! YUI

To use a JavaScript framework library in your web pages, just include the library in a <script> tag:

Using Frameworks

Before you decide to use a JavaScript framework for your web pages, it might be a good idea to test the framework first.

JavaScript frameworks are very easy to test. You don’t have to install them on your computer, and there are no setup programs.

Normally you just have to reference a library file from your web page.

Six critical questions for any SharePoint developer


Although many organizations that use SharePoint employ internal developers to create custom solutions, every customer organization I’ve encountered in my ten years of SharePoint consulting has used external vendors for at least some development. These vendors include individual contractors, Microsoft Certified Partner firms like non-linear creations, and independent software vendors (ISVs) like Bamboo Solutions or K2.

Whether you use internal employees or third-party vendors, and whether an application is a simple web part or a complex business-process automation, you must not deploy it until you know it can be trusted. A poorly-written application can slow (or bring down) your entire SharePoint farm. It can destroy or corrupt data in your databases, or critical files on your servers. It can also circumvent your security, opening you up to all manner of attacks.

Below are six critical questions that you must ask any SharePoint developer, internal or external.

1. Is this a Sandboxed Solution?

Prior to SharePoint 2010, the only option available to the customer was to deploy every solution as a Farm Solution, where files are deployed to the file system and the code runs in the same execution space as SharePoint itself. If the solution is well written and behaves itself (for example, by NOT hogging all the server memory and crashing the SharePoint site it lives in), this is not a problem. But since the quality of custom SharePoint solutions is fully dependent on the developer/vendor, deploying a Farm Solution calls for a lot of trust on the part of the server administrator/customer

Overcoming the customer’s understandable reluctance to deploy Farm Solutions was the driving force behind the introduction, with the 2010 product release, of Sandboxed Solutions. Sandboxed Solutions are web parts, Lists or other SharePoint features that run isolated from your SharePoint sites. By default, a Sandboxed Solution cannot access or affect anything outside of the local SharePoint site; external databases, web services, and the file system are all off limits. Your server administrators can apply limits and quotas to the Solution, so that if it misbehaves by (for example) hogging server memory, SharePoint 2010 will shut it down.

Your developers/vendor may complain that Sandboxed Solutions are additional work. They may say that they are too neutered and can’t do anything useful. However, for a solution that requires access only to the local sites, lists and libraries, the latter isn’t true. And Sandboxed Solutions can be given additional permissions safely by using something called Full Trust Proxies, which let your vendor’s code request specific rights, while remaining isolated from the SharePoint execution space.

Now that we have Sandboxed Solutions, a SharePoint developer’s first question (and yours) when designing a new feature should always be, “can I write this as a Sandboxed Solution?”.

2. If it’s not Sandboxed, does it run as fully or partially trusted?

Sandboxed Solutions are still quite new, and do require extra work, so they are not yet the industry standard (this will change very soon). And there will always be some solutions that can run only as Farm Solutions. You will still have occasions, then, when it will be acceptable to deploy a Farm Solution. But if your vendor or in-house developer delivers you a Farm Solution, you must know if it partially or fully trusted.With a fully-trusted solution, your developer’s code can access the file system on your SharePoint servers, it can access the Windows Registry — it is pretty much an administrator. From a developer’s viewpoint, this is the fastest and easiest way to develop. But with the availability of Sandboxed Solutions and partially-trusted solutions, there are very few reasons for you to accept a fully-trusted solution.

A partially-trusted solution has no innate rights, and must be explicitly granted permissions (in a special configuration file called a Code Access Security policy) to do anything. The developer must provide this file, which you can inspect.

3. Does it use Elevated Privileges?

If for some reason your vendor must provide you with a fully-trusted solution, you must not deploy it until you understand everything it is going to try to do.

One of the key questions in the vetting process: does it use RunWithElevatedPrivileges? This is a SharePoint feature that is exactly what it sounds like. By default, when your vendor’s code tries to do something like access a SharePoint document, it impersonates the user browsing the page; the code can’t do anything the user can’t do. However, a fully-trusted solution (or a partially-trusted one granted the permission) can use RunWithElevatedPrivileges to temporarily impersonate an account that has Full Control of your SharePoint application. RunWithElevatedPrivileges is a powerful tool that must be used sparingly, because it can circumvent your carefully-planned SharePoint security.

Something else that can circumvent your security is Feature Event Receivers.

4. Does it use Feature Feature Receivers?

A Farm (non-Sandboxed) Solution can include small bits of code that run when your server administrator installs or uninstalls a custom solution. For example, the solution may depend on the existence of an external database; a Feature Event Receiver can confirm that the database exists, and create it if necessary.

Feature Event Receivers enjoy full administrative privileges on your server farm, so it is very important that you fully understand what they are programmed to do.

5. Where does it store configuration settings?

Many applications need a place to store configuration settings (e.g., database connection strings, or a email address for alerts). If your vendor’s solution uses the main configuration file (web.config) for this purpose, you increase your risk because this file may be shared by hundreds of SharePoint sites on your farm, and the slightest typo can bring them all down.

In general, an experienced SharePoint developer will not provide you a solution that requires manual entries to web.config. Instead, a Sandboxed Solution will keep its settings in a local SharePoint list, and a Farm Solution will do the same or include a Feature (or Feature Event Receiver) that adds settings to the web.config file automagically on installation (and removes them on uninstallation).

6. Where does it log messages?

Finally, an experienced vendor will develop a solution with extensive logging. Even if the code has been developed defensively and tested thoroughly (two other things you need to ask about), even the best software goes wrong occasionally. When that happens in a production environment, you need to know exactly what happened so it can be diagnosed and remedied.

An application can log messages to the Windows event log, a database table, the SharePoint Unified Logging Service, or a SharePoint List. Before you deploy the solution, you need to know which of these places it logs to, what kinds of messages it logs (is logging too verbose? Too sparse?), and whether the logging can be configured (is logging off by default? Are there different modes — Errors Only, Verbose, etc.?). If there is no way for you to get enough information when something goes wrong to at least understand what happened, without involving the vendor, this is a sign of a poorly-designed solution.

These questions are only a sampling of the kind of due diligence required of you as the owner of a SharePoint environment. As in any business relationship, the key ingredient is trust.

– See more at: http://blog.nonlinearcreations.com/2011/04/six-critical-questions/#sthash.Xb3gc7OY.dpuf