Presentation is loading. Please wait.

Presentation is loading. Please wait.

Software development. Chapter 8 – Advanced Topics.

Similar presentations

Presentation on theme: "Software development. Chapter 8 – Advanced Topics."— Presentation transcript:

1 Software development

2 Chapter 8 – Advanced Topics

3 Contents ❸ Efficient use of C# – Asynchronous programming – LINQ Visual Studio 2013 and Blend 2013 Source control in cloud XAML tips – Margins and contracts – Localizing applications Assignments Questions and answers

4 Efficient use of C# C# is a powerful and versatile programming language Several modern features – Such as generic data types, support for asynchronous programming and parallelism, integrated query language etc. We will now explore some useful features of C#

5 Asynchronous programming Asynchronousness in programming means that two or more functionalities are executed parallel to each other (simultaneously) – Not in a queue as traditionally done Asynchronousness can be used to resolve a situation where an application seems to freeze – for example when downloading a large file from the Internet

6 C# and asynchronousness C# makes asynchronous programming easy with the new async and await keywords It makes extensive use of the Task class which is a part of Windows 8 class libraries

7 Sample code private async void StartButton_Click( object sender, RoutedEventArgs e) { try { Task intTask = ExampleMethodAsync(); ResultsTextBox.Text += "Doing something else " + "while the method is processed"; int intResult = await intTask; ResultsTextBox.Text += String.Format( "Length: {0}\n\n", intResult); } catch (Exception) { //... } }

8 LINQ Short for Language Integrated Query LINQ is a query language integrated into C#. It can be used to make fetching data from different sources easier Syntax resembles SQL – If you already know SQL, LINQ is easy to learn

9 Sample LINQ query int[] luvut = {5,3,9,7,1,6,10,4,2}; var lajiteltuna = from l in luvut where l > 5 orderby l select l; foreach (int luku in lajiteltuna) { // display number on screen... }

10 LINQ-supported data sources The last example demonstrated a LINQ query that fetches number from an array In addition to arrays and application-internal objects, LINQ can fetch data from SQL databases – Other supported sources include XML files and web sources

11 Second example NorthwindEntities entities = new NorthwindEntities(); var FinnishClients = from c in entities.Customers where c.Country == "Finland" orderby c.CompanyName select c; foreach (var client in FinnishClients) { int ordercount = client.Orders.Count; // change processing... }

12 Visual Studio 2013 and Blend Visual Studio and Blend are sister tools. You will need both to develop Windows 8 applications – Both have been designed to ensure effortless cooperation between the two applications Once you have opened your project in Visual Studio, you can easily switch to Blend to edit any XAML file – Fastest way to switch is clicking the "Open in Blend" command from Solution Explorer's quick menu

13 Launching Blend

14 Source control Source control is an intrinsic part of any software project Source control makes it possible for several developers to keep track of and organize simultaneous changes – Changed or removed code can be retrieved if needed Every developer should know the basics of source control systems

15 Microsoft's solution Visual Studio works well together with Microsoft's own source control system Team Foundation Service, or TFS for short A cloud service used directly from Visual Studio or with web browser

16 Team Foundation Service

17 Using TFS through Visual Studio During registration you can pick a name for your service – This name will be used to create a URL address for your project, which will be entered to VS Connection created in Visual Studio Team Explorer – Once connected, you can continue to use source control without additional definitions

18 TFS server's properties

19 CodePlex CodePlex is an open web service for communal development of open source solutions CodePlex includes a lite version of a TFS-based source control system CodePlex has tens of thousands of active users and many interesting projects

20 XAML tips Windows 8 interface are defined in the XAML language Being familiar with XAML's features helps your develop better applications faster Here are three tips for better XAML programming

21 Component margins In many cases the size and positions of used interface components is defined with the Margin value Margin values are relative and dependent on whether your selected component is inside another component

22 Example The Margin value will look like this in XAML code: The Margin value consists of four values, which each represent the distance of the component's each edge to the edges of the mother element – The values are ordered as: left, top, right, bottom

23 Margin setting in Visual Studio

24 Contracts Windows 8 application can use contracts to connect to the operating system's features With contracts, the operating system and applications can exchange data – Certain basic processes don't need to be executed separately in each application

25 Search contract An example of such a connection is the Windows search function Search contract adds your application's data into the results when the user uses the operating system's search feature – The content may be text, images, videos etc.

26 Windows search function

27 Localizing applications If your application or game is intended to be distributed outside Finland, you should consider whether it is necessary to translate it to different languages Windows 8 applications can be translated to several languages with little effort

28 Two facets of translation There are two different facets to translation, called localization and globalization Localization – translating and fitting the application to the target culture (e.g. colors and icons, word play in games, etc.) Globalization – An application available only in Finnish or English is set to support different date, currency, and number separators without translating the interface

29 Finding used languages The user's regional and language settings can be found out with right code strings Library classes – Windows.Globalization.Language – System.Globalization.CultureInfo

30 Example string keyboard = Windows. Globalization.Language. CurrentInputMethodLanguageTag; string operating system = System. Globalization.CultureInfo. CurrentCulture.Name;

31 Translatings the interface To translate your interface to different languages, you should use resource files – Resource files function so that instead of inputting the text displayed by TextBlocks and Buttons into your XAML code, the text is written into a resource file for each language. Resource files can be recognized in Visual Studio Solution Explorer from the.resw file format

32 Resource file location Resource files are saved in your project's Strings sub-folder – You may need to create this folder manually More sub-folders are created into this folder for each language code – Language codes are titled as ”xx-XX” – For example, the subfolder for Finnish would be called ”fi-FI”

33 Resource file location

34 Editing resource files Resource files are edited in Visual Studio in Excel-like table, with a key on the left and value on the right – You can copy-paste the values into Excel and send this file to a translations service provider The key consists of two parts: first, a unique name (for example the component's name), and the property name separated with a period. This latter name will be localized. – For example, ”Button.Content”

35 Visual Studio editing view

36 Localized XAML definitions In order for localized resource files to work, each interface component needs an Uid attribute Note that the original definition can be left in the XAML code, such as a button's displayed text – When the application is run, Windows' application libraries can load the resource files corresponding with the user's regional settings and display the interface based on these values

37 Example

Download ppt "Software development. Chapter 8 – Advanced Topics."

Similar presentations

Ads by Google