Cover image for Introducing Typescript: Language features

Introducing Typescript: Language features

samueleresca profile image Samuele Resca ・2 min read

Originally posted on https://samueleresca.net

The following post describes a parking lot using Typescript and OOP pattern, the scope of the demo is shows some Typescript language features.

Introducing Typescript and setup project

I have written this post about typescript, Let's follow it to setup the project using a simple editor and GruntJs.

The problem

Design an OO parking lot using typescript language features

The solution

Model overview

We're going to implement a generic parking lot ticketing system, using the following classes and interfaces:


Ticket class UML The Ticket class is used by Vehicle class: it describes the associations between the parked Vehicle and the entering ticket. It defines an id, entry and exit Date. The id is calculated using the combination between current time and license plate of car.

Lang features: Basic types, Classes, Getter/Setter

Source code https://gist.github.com/589b0f440e1a84d0ba66


Vehicle class UML The Vehicle class contains some attributes about Vehicle dimensions, and brand and the license plate. It also contains the methods to park/exit the Vehicles from Parking lot. The Car extends Vehicle class, and it adds additional information: car insurance. The Vehicle class can be eventually extended to add other vehicle types.

Lang features: Basic types, Classes, Getter/Setter;, Inheritance

Source code https://gist.github.com/3f48c0317ee86589e6d8

Parking Lot

Parking Lot class UML The Parking lot is described using a combination between an interface and a class: the interface contains functions signatures, and the concrete class contains an array that is used as a Vehicles container. ParkingLot uses *custom find method * that can find objects inside arrays.

Lang features:Basic types, Classes, Inheritance, Generics

Source code https://gist.github.com/cfb74ed2ca148154c0b0
The sources are available on github

Posted on by:

samueleresca profile

Samuele Resca


Samuele Resca is an Microsoft MVP Visual Studio and Development Technologies, Software Engineer, specializing mainly on ASP.NET MVC and in general about everything that revolves around the web. Samuele was born in 1994, and works as a software developer @ YOOX NET-A-PORTER Group He loves the MVC frameworks, ASP.NET MVC, Javascript, Node.js and Typescript.


markdown guide