This developer's chronicles

Web development using Scrum, C#, AngularJS and the like

Tag: Javascript

Typescript: Making Javascript strongly typed

For the lovers of strongly typed languages Javascript has always been a double-edge sword. It offers a great deal of flexibility as it is a dynamic language but that flexibility comes at a high cost, you get no compile time checking so you only find out about potential errors while you are on the browser.

Fortunately (for the strongly-typed language fans out there) there are a range of languages that are a superset of Javascript which can be used to extend Javascript’s functionality making it strongly-typed.

One of such languages is Typescript; Microsoft’s free and open-source input into the world of Javascript superset languages. One of the interesting facts about it is its high adoption from the open source community as it can be incorporated into many different IDEs (such as Eclipse, Webstorm and Visual Studio).

Some of the great features that Typescript provides are:

  1. Compile time checking: Find potential errors on your code before your customer does.
  2. Strongly-typed objects: By specifying the type of objects your functions expect you can reduce the risk of unexpected results.
  3. Classes and inheritance: Typescript provides you with the syntax to declare and use Classes, Inheritance and Modules so you can write more robust code.
  4. Write consistent code: Thanks to TsLint you can create rules for your organization which will ensure your team writes consistent code across projects.
  5. Intellisense: Type faster by letting your IDE provide you with attribute names, functions, etc, something you don’t fully get with dynamic languages.
  6. Javascript is valid Typescript: Do you have any existing Javascript code? no problems !, any valid Javascript code is valid Typescript code.

Below is an example of how a function in Typescript would look like (note how it can be specified what type of object you function expects and what type of object it will return):

[sourcecode language=”javascript”]
export function parseJsonDate(jsonDateString: string): string {

return jsonDateString ? new Date(parseInt(jsonDateString.replace(“/Date(“, “”), 10)).toDateString() : “”;
};
[/sourcecode]

 

Fore more information or to play around with Typescript be sure to visit the TypeScript website

 

Have you had any experience with TypeScript? Do you think it provides any other benefits apart from what was outlined above?

Tips on how to pass Microsoft exam 70-480: Programming in HTML5 with JavaScript and CSS3

Microsoft exam 70-480 is one of the first exams a .NET web developer faces in their career and hopefully with this blog post I’ll make it a bit easier for you to pass it on your first attempt if you haven’t sat it or to finally take the bull by the horns.

Tip 1: Know the topics covered in the exam

If you start with this one you can pat yourself on the back now!. By doing your research and knowing what skills you need to master before you start studying for the exam you will be able to have a better planning and a better outcome.

The topics for the 70-480 exam can be found here, make sure you have a thorough read and don’t worry if you don’t understand some of its content. it will start to make sense once you spend some time studying and practicing

Tip 2: Make your game plan

Now that you know what topics may be asked during the exam you can start planning which ones you’re going to study first and how long you honestly think it’s going to take you to review/study the theory plus the amount of time you will spend practicing it.

Tip 3: Get this Microsoft training guide

Why this training guide? Firstly because it covers most topics of the exam and secondly because it is laid in a way that makes learning easier, you start with the easy stuff and progress towards more complicated things (I followed it chapter by chapter and as I was doing ALL the exercises in the book and finishing the chapters I could simply cross-out those items/topics from the ‘to be studied’ list).

Tip 4: Watch videos on your way to work / school / Uni

Rather than spending your valuable time checking your facebook on your daily commute, download a few videos from Youtube (or Microsoft Virtual Academy, Pluralsight, Udemy etc etc) about the new HTML5 APIs, or CSS3, or Javascript etc. Make sure you watch the same videos a couple of times and once you have access to your computer put all that into practice. You will be amazed how fast you learn / grasp knowledge by watching and then doing.

Tip 5: Create a small project

This is the best part for me because you get to choose a fun project to work on and you can practice the really cool things you have been learning so far (you can manipulate the DOM and make objects fade in/fade out or get a user’s position by using the HTML5 Geolocation API, etc, etc), think about it, the sky is the limit!

6. Do a couple of practice tests

You have a few options to know if you are almost ready to sit this exam, one is to pay around $200 (AUD) for the real exam and give it a go (there are always deals to have a second shot free or charge), alternatively you can buy a practice exam for about half that price (or you can always ask Google for a cheaper option !).

Regardless of your choice make sure you do at least one practice test so you get the feeling of what the test is like, the timing involved and whether you need to go back and review some items.

Do you know any other topics that can help devs sitting this or any other exam? I’d love to hear them and add them to this list !.