Tuesday, July 24, 2012

10 useful typography tips to improve your website readability

Published on July 16th, 2012 by Jean-Baptiste Jung.

Typography is often neglected on websites. This is a shame, because by improving your typography, you'll improve both your website design and readability. In this article, I have compiled 10 extremely useful typography tips that will help you to make your website looks better.

Correct line height

One of the most common web typography mistake is definitely an incorrect line height. Line height define the height of a line of text, so it have to be set according on the font size.

As a rule of thumb, I always add 7px to the font size when setting line height on texts (with 12 to 15 pixels font size)

body{      font-size:14px;      line-height:21px; /* 14px + 7px */  }  

Correct title margins

Another common mistake is an incorrect margin around titles. A title is related to a paragraph, it is not a separator between two paragraphs. This is why a title should have a wider margin on top than on its bottom.

Don't use too many different fonts

In order to keep your website readable and professional, you shouldn't use more than 3 different fonts. Using too many fonts can be confusing for the reader and will make your website look cluttered.
On the other hand, using fewer fonts keeps your website clean and readable. You can use one font for headings, one for the text, and eventually another one for the logo or the subtitles.

Use monospaced fonts to display code snippets

If you're a developer (like most persons reading this blog) you probably want to display some code snippets on your blog. If yes, please use a monospaced font to do so. So, what's a monospaced font? It's a font whose letters and characters each occupy the same amount of horizontal space.

So, which fonts should you use to display code snippets on a website? Courier is by far the most popular, but what about giving a try to most recent fonts such as Consolas or Monaco? And if you want even more choice, you should definitely have a look there.

Care about contrast

Even if your website have a great typography, another point to consider is contrast. If your page background is grey (#999999), then do not use a dark grey text (#333333) otherwise your content may be hard to read, especially for older people or people with visual disabilities.

Generally, excepted if your site is about hacking, black hat seo or gothic rock, you should use a light background and a dark font to keep a bright contrast and increase your site readability.

Keep underlined text for links

Since I've started using the internet twelve years ago, the default style applied to links by browsers is a blue text with an underline. Althought the blue is often changed to another color, the underline has been since recognized as the generic style for links. This is why you should never use underlined text for other things than links. Otherwise, this can be very confusing for your readers.

Create a library of styles

A simple and effective way to make your website visually stunning is create specific styles for specific usages. For example, what about creating a .warning CSS class to display warnings to your readers?

Hierarchize titles and text

In order to improve readability, creating a hierarchy consisting of titles, intro paragraphs and regular text is important because they allow your readers to visualize your articles and quickly access to the part that they're interested in.

Don't be afraid of white space

One of the best typography tip I've received is "Don't be afraid of white space". White space is not blank space nor unused space, it make your design clutter-free and professional. Many people love Apple's website for that reason: It's sophisticated but simple, and have lots of white space.

Use the right symbols

An important point to consider if you're looking to improve your typography is the use of the rights symbols. For example, double prime symbols are often used instead of quote symbols.
Note the difference betwen the double prime verison:

He said "Hello".

And the same text, using quote symbols:

He said "Hello".

Better, isn't it? If you're a WordPress user, you'll probably be happy to know that your favorite blogging platform automatically transform double primes into smart quotes. Otherwise, you should use HTML entities as shown below:

He said &s;ldquo;Hello”.

Thursday, July 19, 2012

10 reasons why SQL Server 2008 is going to rock

Just like its predecessor, SQL Server 2008 is taking its sweet time to actually ship.  However, unlike its predecessor, it won't just be a "worthwhile upgrade".  It will kick ass.

Here are the top 10 reasons why.

10.  Plug-in model for SSMS.   SSMS 2005 also had a plug-in model, but it was not published, so the few developers that braved that environment were flying blind.  Apparently for 2008, the plug-in model will be published and a thousand add-ins will bloom. 

9.  Inline variable assignment.  I often wondered why, as a language, SQL languishes behind the times.  I mean, it has barely any modern syntactic sugar.  Well, in this version, they are at least scratching the the tip of the iceberg. 

Instead of:

DECLARE @myVar int   SET @myVar = 5


you can do it in one line:

DECLARE @myVar int = 5


Sweet.

8.  C like math syntaxSET @i += 5.  Enough said.  They finally let a C# developer on the SQL team. 

7.  Auditing.  It's a 10 dollar word for storing changes to your data for later review, debugging or in response to regulatory laws.  It's a thankless and a mundane task and no one is ever excited by the prospect of writing triggers to handle it.  SQL Server 2008 introduces automatic auditing, so we can now check one thing off our to do list.

6.  Compression.  You may think that this feature is a waste of time, but it's not what it sounds like.  The release will offer row-level and page-level compression.  The compression mostly takes place on the metadata.  For instance, page compression will store common data for affected rows in a single place. 

The metadata storage for variable length fields is going to be completely crazy: they are pushing things into bits (instead of bytes).  For instance, length of the varchar will be stored in 3 bits. 

Anyway, I don't really care about space savings - storage is cheap.  What I do care about is that the feature promised (key word here "promises") to reduce I/O and RAM utilization, while increasing CPU utilization.  Every single performance problem I ever dealt with had to do with I/O overloading.  Will see how this plays out.  I am skeptical until I see some real world production benchmarks.

5.  Filtered Indexes.  This is another feature that sounds great - will have to see how it plays out.  Anyway, it allows you to create an index while specifying what rows are not to be in the index.  For example, index all rows where Status != null.  Theoretically, it'll get rid of all the dead weight in the index, allowing for faster queries. 

4.  Resource governor.  All I can say is FINALLY.  Sybase has had it since version 12 (that's last millennium, people).  Basically it allows the DBA to specify how much resources (e.g. CPU/RAM) each user is entitled to.  At the very least, it'll prevent people, with sparse SQL knowledge from shooting off a query with a Cartesian product and bringing down the box.

Actually Sybase is still ahead of MS on this feature.  Its ASE server allows you to prioritize one user over another - a feature that I found immensely useful.

3.  Plan freezing.  This is a solution to my personal pet peeve. Sometimes SQL Server decides to change its plan on you (in response to data changes, etc...).  If you've achieved your optimal query plan, now you can stick with it.  Yeah, I know, hints are evil, but there are situations when you want to take a hammer to SQL Server - well, this is the chill pill.

2.  Processing of delimited strings.   This is awesome and I could have used this feature...well, always.  Currently, we pass in delimited strings in the following manner:

exec sp_MySproc 'murphy,35;galen,31;samuels,27;colton,42'


Then the stored proc needs to parse the string into a usable form - a mindless task.

In 2008, Microsoft introduced Table Value Parameters (TVP). 

CREATE TYPE PeepsType AS TABLE (Name varchar(20), Age int)   DECLARE @myPeeps PeepsType   INSERT @myPeeps SELECT 'murphy', 35   INSERT @myPeeps SELECT 'galen', 31   INSERT @myPeeps SELECT 'samuels', 27   INSERT @myPeeps SELECT 'colton', 42    exec sp_MySproc2 @myPeeps 


And the sproc would look like this:

CREATE PROCEDURE sp_MySproc2(@myPeeps PeepsType READONLY) ...


The advantage here is that you can treat the Table Type as a regular table, use it in joins, etc.  Say goodbye to all those string parsing routines.

1. Intellisense in the SQL Server Management Studio (SSMS).  This has been previously possible in SQL Server 2000 and 2005 with Intellisense use of 3rd party add-ins like SQL Prompt ($195).  But these tools are a horrible hack at best (e.g. they hook into the editor window and try to interpret what the application is doing). 

Built-in intellisense is huge - it means new people can easily learn the database schema as they go.

There are a ton of other great features - most of them small, but hugely useful.  There is a lot of polishing all over the place, like server resource monitoring right in SSMS, a la Vista. 


Ref.:http://angryhacker.com/blog/archive/2008/06/20/10-reasons-why-sql-server-2008-is-going-to-rock.aspx

 

How To Write An Interview Winning Resume

By John Sansom, 2012/07/19

Writing a resume that rocks is not an art. It just requires some planning and an understanding of what you want it to achieve for you.

Of course therein also lies the problem because many people are not exactly sure what they want their resume to do for them. This is why you will often see resumes that have listed every single technology feature a candidate has ever encountered, or why the hiring manager is reading a resume that is eight pages long and wondering when the pain of this monstrosity will all be over. The truth is the hiring manager never even reads the entire resume and instead simply moves immediately on to the next one without giving it a further thought.

Do you want your resume to be one that gets overlooked? Of course not!

I'm going to share with you exactly what you need to do in order to create an interview winning resume for a Database Administrator (DBA), Data Professional or any other darn profession you can think of for that matter. What prompted such an awesome display of generosity you ask? Well there is a story behind it (alluded to here) that you can ask me about next time we meet, but for now let's just pretend it's because I'm a super nice chap.

Regular readers will know that I'm a big fan of KISS. Not the awesome rock band but rather the principle of Keep ISimple Stupid! So for your reading pleasure I have compressed a wealth of winning resume writing knowledge into 4 simple rules. I know, impressive right.

In order to ensure that your resume gives you the best possible chance of securing your next interview it MUST be:

  1. Readable
  2. Relevant
  3. Accurate
  4. Valuable

Let's take a look at each rule in a little more detail to find out exactly what is required.

1. Readable

Your resume should be a pleasure to read. It should be an effortless experience for the reader, enabling them to immediately zone in on precisely the information they seek. The language you use should be concise and to the point. You've got a limited amount of space to use in order to sell yourself and you want to do so within two pages. That's right, your resume should be two pages maximum. Anything more and you are not being concise or relevant enough.

In summary some of the points you will want to consider are:

  • Scannable – Is your resume easy on the eye? Can the reader easily locate information?
  • Concise – Stay on point. Be specific and don't waffle.
  • Incorporate bulleted lists – These will improve the structure of your content, making it scannable and easier to consume.
  • Consider font choice - Keep it clear and professional. Stay away from creative fonts and color palettes.
  • Two page limit - Don't squash your content. Be ruthless with what you include.

2. Relevant

Include only what is relevant to the "specific" role you are targeting your resume for. It can be tempting to list each and every skill that you may have, you might be putting your resume forward for a number of different opportunities but if the skills are not relevant then they won't demonstrate value(see 4.Value below) to the reader. The irony of a catch all resume is that it will actually get you nothing. It's demonstrably lazy. Don't do it!

In summary some of the points you will want to consider are:

  • Be specific – Include ONLY the information pertinent to the role.
  • Don't include references – You'll be asked for them if and when needed. Use the space for "valuable" content.
  • Exclude personal interests – Your personality will come across/be promoted during the interview.

3. Accurate

The invention of the Spellchecker was a wonderful thing folks, so there really is no excuse for spelling mistakes or poor grammar. All good Data Professionals have excellent attention to detail, fail to get this one right and you're pretty much just demonstrating that you don't have what it takes.

In summary some of the points you will want to consider are:

  • Spelling and Grammar – Check it, double check it, get someone else to proof read.
  • Accuracy of facts and information – Use of correct product/technology names and versions.

4. Valuable

Why should I hire you? You know SQL Server clustering, so what? Why is that of use to me as a business owner? Demonstrate the business value you have delivered because of what you know or have done. Simply listing technology and skills is boring. Take your resume to the next level by clearly showing the reader how you delivered value using what you know. Be factual in your delivery and mind you don't take it to the other extreme or you'll end up coming across as boastful. The emphasis required on demonstrable financial value for a Sales Director is going to be a lot more than is needed for BI Developer. You need to find the right balance for your market.

In summary some of the points you will want to consider are:

  • Expertise – Demonstrate your value through the results of your actions that were enabled by your skills.
  • Key Achievements – Make a point of highlighting your big wins and achievements. Deployed an entire DR solution protecting assets worth £x million? Tell the reader.
  • Demonstrable value – Revenue, costs savings, business awareness. What makes you an asset to have on staff?
  • Passion – Show your love of technology(or chosen field) and for learning.

Keep It Simple

There you have it, four simple rules you should make sure your resume follows to give you the best possible chance of winning that next interview spot.

What do you think is important to creating an interview winning resume?

Best of luck with your job search!

Monday, July 16, 2012

10 ways to speed up Windows 7

Takeaway: You don't have to live with a Windows 7 machine that's becoming unbearably slow. Here are 10 basic steps that will optimize system performance.

With Windows 7, Microsoft did a really good job making the system perform well. However, over time, Windows 7 systems can slow down and need some care and feeding to regain their former glory. Further, some Windows 7 features can be leveraged to improve overall system performance. In this article, I will outline 10 steps you can take to boost the performance of your Windows 7 systems.

1: Disable unnecessary services

Not every system service that is running on a stock Windows 7 machine is necessary. A number of services can either be disabled or modified to run only when needed. Once you make these changes, the service no longer has to consume system resources and the system no longer has to spend time starting the service. Earlier this year, I wrote an article here at TechRepublic titled 10+ Windows 7 services you may not need.

2: Reduce the number of startup items

Windows 7 systems eventually begin to suffer under the weight of software that is installed in the normal course of business. Many software titles install more than is necessary and include helper applications designed solely to make the software start up more quickly or facilitate other communication (e.g., iTunes helper). And new software installations might add a permanent presence to the system tray, even if it's not absolutely necessary for the system to function (Steam games, for example).

You could go through your system tool by tool and remove the offending software, but you might want to keep the underlying tool around and just prevent the helper from loading. This and more can be accomplished through the use of MSconfig, a tool that has long been a part of Windows. MSconfig allows you to selectively disable startup items and take other steps toward improving overall system performance.

To use MSconfig, go to Start and in the search box, type MSconfig. From the Startup tab (Figure A), you can disable items. Just be careful about what you choose.

Figure A

Disable items to improve overall system performance.

3: Remove the bloatware installed by vendors

I've long felt that Microsoft's OEMs sometimes actively work against the Redmond behemoth and sully the company's name. Nowhere is this more evident than in the case of what has become known as "bloatware." In the never-ending race to the bottom of the PC market, lower cost PCs have had their profit margins bolstered by OEMs through the inclusion of mostly junk software - short-term trials and the like — that does nothing but add a few dollars of profit while bringing performance to a crawl. Frankly, this is one of the reasons that I believe that Microsoft's Surface announcement, in which Microsoft noted that it would make its own device, is brilliant. The company needs to start with a clean slate in some ways (no pun intended).

If your PC shipped with a bunch of stuff you'll never use, get rid of that software. Generally, you can go to Start | Control Panel | Programs And Features (Figure B) and remove software you no longer plan to use. If the software adds items to the startup process, getting rid of it will make the PC start faster and, ultimately, perform better overall.

Figure B

Use Programs And Features to remove unwanted software.

4: Keep viruses and spyware off your system

If you're running Windows, you need to be running an anti-malware program to keep viruses and spyware off your system. Nothing will ruin good performance like a boatload of spyware. My personal favorite (and free!) tool for combating malware is Microsoft Security Essentials. In my experience, it's been successful in catching bad stuff while not significantly degrading system performance itself.

5: Check your memory

How much RAM do you have? Is your system consuming all or most of your RAM? Does the system page out to disk? If so, you're suffering a massive performance hit, which can be solved by adding more memory to your PC. Greg Shultz explains how to do this by using Resource Monitor.

6: Go solid state

Solid state is all the rage these days, and with good reason. It's fast! More and more laptops and even desktops are moving to the technology because of the performance benefits. Solid state disks use memory cells from which data can be read very quickly, as opposed to the relatively plodding nature of rotational storage. By moving to SSD, you can give your Windows 7 system renewed life — and give yourself a whole new user experience.

But SSDs can be expensive, so you need to be smart about how to use them in the most cost-effective way. See ZDnet's Windows 7 and SSDs: Trimming the fat from your system drive for tips on manking good decisions about how to implement SSD.

7: Ensure that power settings favor performance

This one is easy! When you're plugged in, configure Windows 7's power plans to favor performance over power savings. When you choose to use Windows 7′ high performance power plan, you might increase the computer's performance in some (but not all) circumstances. It really depends on the kind of work you're doing and how often you allow the computer to sit idle.

To change power plans, go to Start | Control Panel | Power Options and choose your power plan settings (Figure C). For more about how these plans operate, see Evaluate the efficiency of Windows 7 power plan settings.

Figure C

Go to Power Options to choose Windows 7 power plan settings.

8: Keep your system defragmented (unless you've followed item 6)

If you're using a traditional spinning disk in your Windows 7 system, you can keep your system operating at peak efficiency by periodically defragmenting the hard drive. If, however, you've opted to go with SSD-based storage, don't do this. First, you won't get any performance benefit and second, you'll significantly reduce the life of that expensive SSD.

Disk defragmentation is scheduled to take place once per week, but you can change this by going to Start | Accessories | System Tools | Disk Defragmenter (Figure D). In addition to changing the schedule, you can run an on-demand defrag from here. You can also run a defrag from the command line instead of from a GUI. Bill Detwiler's video explains how.

Figure D

You can schedule a defrag in the Disk Defragmenter dialog box.

9: Disable or tune search indexing

Windows 7's search is good, but it can also affect system performance. If you really need to run a tool at full tilt, you can disable indexing altogether. Or you can tune the indexer to meet your specific needs, possibly reducing its overall impact on system performance.

10: Use ReadyBoost

Perhaps you don't want to jump into the solid-state game right away but would like some of the benefit that can be had from flash-based storage. Using nothing more than a USB stick, you can do so through a Windows 7 feature known as ReadyBoost. (Note that if you're already using an SSD as your system drive, ReadyBoost won't be available, since there would be no performance gain.)

ReadyBoost allows the system to make use of one of these speedy storage devices as a cache, improving overall performance of the system. The flash storage device that you choose to use for ReadyBoost should meet the following specifications set by Microsoft:

  • Capacity of at least 256 MB, with at least 64 kilobytes (KB) of free space
  • At least a 2.5 MB/sec throughput for 4-KB random reads
  • At least a 1.75 MB/sec throughput for 1MB random writes

Here's another nice feature: If Windows doesn't think ReadyBoost will provide a performance gain, it will tell you and won't let you enable it. In Figure E, you can see that I've opened the properties for a portable USB stick, which I've added to my Windows 7 system. However, Windows knows that the system disk is already fast enough, so ReadyBoost isn't available as an option. If you want to learn more about how to enable and configure ReadyBoost in your system, see Take a closer look at ReadyBoost features in Windows 7.

Figure E

ReadyBoost isn't needed for this system.

Sunday, July 8, 2012

10 Reasons Why Visual Basic is Better Than C#


07 March 2012

After having converted a whole lot of training materials based on VB.NET into C#, Andy 'Wise Owl' Brown decided to write a tongue-in-cheek rant whilst he could still remember the pain-points. 'Convert to VB.NET! You have nothing to lose but your semi-colons! '

Visual Basic is a better programming language than Visual C#. Who says so? This article! Here are 10 reasons why you should always choose VB over C#.

1 – "Rose is a rose is a rose is a rose"

This is a quotation from Gertrude Stein's 1922 play Geography and Plays. However, the poetry wouldn't work in C#, because – unforgivably – it's a cASe-SeNSitIvE language. This is madness!

Before I start ranting, let me just acknowledge that case-sensitivity confers one (and only one) advantage – it makes it easier to name private and public properties:

Writing properties like this means that you can refer to the public Name property, and it's obvious what the private equivalent will be called (name).

// private version of variable
private string name = null;
public string Name
{
    get
    {
        
return txtName.Text;
    
}
    set
    {
        name 
= txtName.Text;
    
}
}

So now we've got that out of the way: case-sensitive programming languages make everything else harder. Why, you ask?

  • You keep having to switch between upper and lower case when typing, causing RSI in your poor little fingers as you reach for the inconsiderately located Shift key.
  • You are much more likely to make mistakes - are you sure you meant to type DateOfBirth, or should it have been dateofbirth?
  • When you accidentally leave Caps lock on, it really matters.

The only possible benefit is that you can use more combinations of variable names, that is, you can use more of one of the few infinite resources in this universe…

It doesn't matter if you disagree with everything else in this article: case-sensitivity alone is sufficient reason to ditch C#!

2 – The Switch clause

Both VB and C# contain a way of testing mutually exclusive possibilities, the Select Case and Switch clauses respectively. Only one of them works properly.

A Visual Basic Select Case clause, returning a description of how old someone is. The age range for a young person is a tad generous, reflecting the age of the author of this article.

A Visual Basic Select Case clause, returning a description of how old someone is. The age range for a young person is a tad generous, reflecting the age of the author of this article.

Select Case AgeEntered

    
Case Is < 18
        txtVerdict.Text 
= "child"
    
Case Is < 50
        txtVerdict.Text 
= "young person"
    
Case Is < 65
        txtVerdict.Text 
= "middle-aged"
    
Case Else
        
txtVerdict.Text = "elderly"

End Select

You can't do this using Switch in C#, as - astonishingly - it can't handle relational operators. You have to use an If/ Else If clause instead. But even if you could, you'd still have to type in lots of unnecessary Break statements:

switch (AgeThreshold) {
    
case 18 : 
        
txtVerdict.Text = "child";
        
break;
    
case 50 :
        
txtVerdict.Text = "young person";
        
break;
    
case 65 :
        
txtVerdict.Text = "middle-aged";
        
break;
    
default:
        txtVerdict.Text 
= "elderly";
        
break;
}
 

It's easy to forget to type in each of these Break statements!

3 – Event-Handling code

This is specific to Visual Studio (I'm using 2010, the latest version). Suppose I want to attach code to anything but the default Click event of a typical button:

Selecting the button

Let's suppose that I want to attach code to the MouseHover event of this button.

I can do this in Visual Basic without leaving the code window:

a) First choose the object from the drop list.

Attaching the Mousehover code
Choosing the event to code

b)Then choose the event you want to code.

In C# you can't do this – you have to return to the button's properties window and choose to show its events:

Selecting the event in C#

You can double-click to attach code to this event for the selected button – but that's the only simple way to create it for C#.

But it's even worse than that. If you then rename a control (in this case btnApply) you have to re-associate the event-handler with the renamed control in the properties window (or in the initialisation code, if you can find it). In Visual Basic, of course, you can do all of this in code:

    Private Sub btnApply_Click(ByVal sender AsSystem.Object,

        ByVal e As System.EventArgs) Handles btnApply.Click

 

        MessageBox.Show("Hello")

 

    End Sub

Globally change btnApply to the new button's name in code, and everything will work as before.

4 –Stupid symbols

C# was written by academics. It shows. Consider this table of C# symbols and their VB equivalents:

What you're trying to doC# SymbolVB Equivalent
Test if two conditions are both true&&and
Test if one or other condition is true||or
Test if a condition is not true!not
Concatenate two strings of text+&
Test if a condition is true within an if statement===

Which column looks like it was designed by a real person?

5 – Autocorrection in Visual Basic actually works

IntelliSense works much better for Visual Basic than for Visual C#. Take just one example – creating a write-only property. Let's start with Visual Basic:

When you press return at the line end…

    WriteOnly Property PersonName As String

        Set(value As String)

 

        End Set

    End Property

… You get this fully-completed clause.

For C#, the same thing doesn't happen:

When you press return here, nothing happens (other than a blank line appearing).

This is just one example. I've just spent ages transcribing our VB courses into C#, and believe me, there are many, many more!

6 – Lack of supported functions

Here are a couple of functions I use from time to time in VB:

FunctionWhat it does
IsNumericTests if a value can be converted to a number
PMTCalculates the annual mortgage payment for a loan

Great functions, but they don't exist in C#.

7 – That wretched semi-colon

Why do I have to end every line in C# with a semi-colon? The argument used to be that it avoided the need to use continuation characters in Visual Basic:

MessageBox.Show( _
    text:
="This article is a bit opinionated", _
    caption:
="Message")

You used to have to use an underscore as a continuation character to show incomplete lines of code in VB.

However, as of Visual Basic 2010 you rarely need to do this anymore. Come on, C#: Visual Basic has ditched its line-ending character; why can't you?(;)

Someone commented on my original (much shorter) blog about this:

    "In a short amount of time you'll type those semi-colons without thinking about it (I even type them when programming in visual basic)." 

That's like saying that you'll soon get used to not having any matches to light your fire, and you'll even start rubbing sticks together to start a fire when you finally manage to buy a box!

8 – Arguments and variables

The order of words in a C# variable declaration is wrong. When you introduce someone, you wouldn't say, "This is my friend who's a solicitor; he's called Bob". So why do you say:

string PersonName = "Bob";

To me:

Dim PersonName As String = "Bob"

…is much more logical. I also find the C# method of having to prefix arguments with the word out confusing, particularly as you have to do it both in the called and calling routine.

9 – Strictness

C# is a much fussier language than Visual Basic (even if you turn Option Strict on in Visual Basic, this is still true). "And a good thing, too!", I hear you cry. Well, maybe. Consider this Visual Basic code:

Enum AgeBand
   Child 
= 18
   Young 
= 30
   MiddleAged 
= 60
   SeniorCitizen 
= 90
End 
Enum



Select Case 
Age
    
Case Is < AgeBand.Child
        
MessageBox.Show("Child")
    
Case Else
        
MessageBox.Show("Adult")
End Select

With Option Strict turned on this shouldn't really work, as it's comparing an integer with an enumeration – but VB has the common sense to realise what you want to do.

The equivalent in Visual C# doesn't work:

A less forgiving language…

What this means is that you end up having to fill your code with messy type conversions:

The simplest way of converting an enumeration to an integer; but why should you have to?

// find out the age entered
int Age = Convert.ToInt32(txtAge.Text);

if (Age < (int) AgeBand.Child) {
    MessageBox.Show("Child");
} else {
    MessageBox.Show
("Adult");
}

10 – Redimensioning arrays

If you want to dynamically change the length of an array in Visual Basic, you can use Redim Preserve. To do the same thing in Visual C#, you have to copy the array, add a value and then copy it back:

The vile, clunky C# method of extending an array.

string[] PartyGuests = new string[2];

PartyGuests[0] = "Sarah Palin";
PartyGuests[1] = "Richard Dawkins";

// whoops! forgot to invite Mitt

// create a new extended array
string[] tempGuests = new string[PartyGuests.Length + 1];

// copy all of the elements from the old array into new one
Array.Copy(PartyGuests,tempGuests,PartyGuests.Length);

// add Mitt as last element
tempGuests[PartyGuests.Length] = "Mitt Romney";

// restore full list into original array
PartyGuests = tempGuests;

// check works
foreach (string Guest in PartyGuests) {
    System.Diagnostics.Debug.Write
(Guest);
}
 

This epitomises Visual C# for me. Critics will tell me that:

  • Behind the scenes, the Redim Preserve command does exactly the same thing as the C# code above; and
  • I should be using lists and not arrays anyway.

That's hardly the point! The point is that - as so often - Visual Basic makes something easier to code than C# does.

Conclusion

So those are my 10 reasons to code in Visual Basic. What are you waiting for, all you C# code-monkeys? Convert all of your code to VB – you have nothing to lose but your semi-colons!

ITWORLD
If you have any question then you put your question as comments.

Put your suggestions as comments