Presentation is loading. Please wait.

Presentation is loading. Please wait.

Building Blocks: Initialize() Jump Start

Similar presentations


Presentation on theme: "Building Blocks: Initialize() Jump Start"— Presentation transcript:

1 Building Blocks: Initialize() Jump Start
Jeremy Foster Microsoft Technical Evangelist Christopher Harrison Microsoft Certified Trainer/GeekTrainer Inc.

2 Meet Jeremy Foster | @codefoster
Microsoft Technical Evangelist As a Developer Evangelist, Jeremy Foster's role is to inform and inspire developers about Microsoft's tools and platforms. Jeremy was educated in computer engineering and mathematics, and he gathered disparate industry experience in education, aerospace manufacturing, and insurance. With just enough and not nearly enough education and experience, he joined Microsoft. Jeremy aims to help and inspire other software developers to write code and to write it right.

3 Meet Christopher Harrison | @geektrainer
Microsoft Certified Trainer/GeekTrainer Inc. Christopher Harrison is a Microsoft Certified Trainer, focusing on SharePoint and SQL Server. He's the owner and Head Geek at GeekTrainer, Inc. He's been training for more than 12 years, with a couple of breaks in the middle to take on full-time developer jobs. These days, he focuses on training, presenting at conferences, and consulting.

4 Building Blocks Jump Start
Day 1 | Initialize() Day 2 | Construct() Day 3 | Extend()

5 Day 1 Initialize() Overview
essentials of C# and JavaScript two great languages side by side not a deep dive or thorough coverage into either platform agnostic

6 Setting Expectations Target Audience
Anyone with a building enthusiasm surrounding the inevitable overload of information that comes out of //build next week. Beginner to intermediate developers "Young" developers grasping for a handle on concepts Web developers looking to learn XAML/C# (or vice versa) Suggested Prerequisites/Supporting Material none

7 Join the MVA Community! Microsoft Virtual Academy
Free online learning tailored for IT Pros and Developers Over 1M registered users Up-to-date, relevant training on variety of Microsoft products “Earn while you learn!” Get 50 MVA Points for this event! Visit Enter this code: BldgBlks1 (expires 4/26/2014)

8 Day 1 Initialize() Target Agenda
Module 1: Basic Syntax Module 2: Lists Module 3: Asynchrony and Concurrency Module 4: Data Storage Module 5: Services and OData Module 6: Libraries

9 Building Blocks Initialize()
Module 1: Basic Syntax

10 Topics Module 1: Basic Syntax references variables conditionals loops
functions classes and inheritance

11 Module 1: Basic Syntax References

12 References (JavaScript)
JavaScript engine gets all script by inclusion executed in order included in the HTML (not in the JavaScript) frameworks like require.js for better control

13 script1.js script2.js page.html script3.js

14 References (JavaScript)
<head> <title>My Page</title> <script src="/js/script1.js" /> <script src="/js/script2.js" /> <script src="/js/script3.js" /> <script src=" /> <script> // script </script> </head> <body> <div/> <script> // script </script> </body>

15 Using a script loader such as requirejs
require(["scripts/myscript"], function(myscript) { // myscript.doSomething(); });

16 References (C#) Code is compiled into assemblies Options
Executables (exe) Libraries (dll) Options Add references to dlls Add NuGet packages

17 Referencing Classes Every class is referenced by its full name
Namespace Logical grouping of classes Class

18 Referencing Classes using System.Text; using System.Web; namespace Demos { public class Message { // produces the same compiled code StringBuilder body = new StringBuilder(); System.Text.StringBuilder body = new System.Text.StringBuilder(); } }

19 Topics Module 1: Basic Syntax references variables conditionals loops
functions classes and inheritance

20 Module 1: Basic Syntax Variables

21 Variables (C#) C# is strongly typed Primitives (value types)
Integers, Booleans, Enumerations Objects (reference types) Strings, Arrays, Classes

22 Variable Declaration and Scope
public void DisplayBody() { var output = body.ToString(); if (output.Length > 0) { Int32 length = output.Length; Console.WriteLine(output); } // length out of scope } // output out of scope

23 Instantiating Objects
StringBuilder body = new StringBuilder(); Int32[] scores = { 42, 206, 100 }; Member member = new Member() { FirstName = "Christopher", LastName = "Harrison" }; var member = new { FirstName = "Christopher", LastName = "Harrison" };

24 variables in C#

25 Variables (JavaScript)
Primitives: undefined, null, Boolean, number, string Objects Arrays Functions

26 Variables (JavaScript)
// declaration and instantiation var a = 1; var b = "lorem ipsum"; var c = { firstName: "Steve", lastName: "Jacobs" }; var d = [0,1,2,3,4,5]; var e = ["apple","orange","banana"]; var f = [ { firstName: "Sally", lastName: "Mae" }, { firstName: "Billy", lastName: "Joe" }, { firstName: "Fred", lastName: "Whaze" } ];

27

28 codepen.io variables in javascript

29 Topics Module 1: Basic Syntax references variables conditionals loops
functions classes and inheritance

30 Module 1: Basic Syntax Conditionals

31 Conditionals (JavaScript)
// if if(a > 5) { // do something } // if-else if(a > 5) { // do something } else { // do something else } // if-else-if(else-if,else-if) if(a > 100) { // do something } else if(a > 50) { // do something else } else if(a > 20) { // do something else } else if(a > 10) { // do something else }

32 codepen.io conditionals in javascript

33 Conditionals (C#) // single line if(output.Length == 0) Console.WriteLine("No message"); // multiple line if (output.Length > 0) { Console.WriteLine("This string has {0} letters", output.Length); Console.WriteLine(output); } else { Console.WriteLine("No message"); } // else if if (output.Length > 100) { Console.WriteLine("Output is too long to display"); } else if (output.Length > 0) { Console.WriteLine(output); } else { Console.WriteLine("No message"); }

34 conditionals in C#

35 Topics Module 1: Basic Syntax references variables conditionals loops
functions classes and inheritance

36 Module 1: Basic Syntax Loops

37 Loops (C#) // while Int32 index = 0;
while (index < scores.Length) { Console.WriteLine(scores[index]); index++; } // do do { } while (index < scores.Length); // for for (Int32 index = 0; index < scores.Length; index++) { Int32 score = scores[index]; Console.WriteLine(score); // foreach foreach (Int32 score in scores) {

38 Loops in C#

39 Loops (JavaScript) // for loop for (var i = 0; i < 10; i++) { // do something } // do loop do { // do something } while (x < 100) // while loop while (x < 100) { // do something }

40 codepen.io Loops in javascript

41 Topics Module 1: Basic Syntax references variables conditionals loops
functions classes and inheritance

42 Module 1: Basic Syntax Functions

43 Functions (JavaScript)
// standard function function sum(a,b) { return a+b; } var s = sum(1,2); var f = sum; // functions are objects! f(1,2) // -> 3 var sum = function(a,b) { return a+b; }; // anonymous fct

44 codepen.io Functions in javascript

45 Functions (C#) Perform Action Syntax Accessibility Modifiers
Return type Name Parameters public static String GetOutput(String input) { return input.Length.ToString(); }

46 Properties Access values like fields Syntax Accessibility Modifiers
Data type Name

47 Properties Customer customer = new Customer();
// property public class Customer { private String ; public String get { return ; } set { = value; // automatic property public class Customer { public String { get; set; } } Customer customer = new Customer(); customer. =

48 Functions in C#

49 Topics Module 1: Basic Syntax references variables conditionals loops
functions classes and inheritance

50 Classes and Inheritance
Module 1: Basic Syntax Classes and Inheritance

51 Classes and Inheritance (C#)
Classes model data Think blueprints Inheritance allows for specialization Creates an “Is A” relationship

52 Syntax (C#) Access modifier Options Class name Colon for inheritance
public class Customer { public String { get; set; } public Decimal Balance { get; set; } } public class CorporateCustomer : Customer public String Contact { get; set; }

53 Interfaces Creates a contract
Must implement all methods and properties public interface IWorker { void DoWork(); } public class Worker : IWorker

54 Classes and Inheritance in C#

55 Classes and inheritance (JavaScript)
First of all, there aren't any and there isn't any! WinJS helps us out TypeScript offers them too ECMAScript 6 will bring them

56 Objects and prototyping (JavaScript)
// create a new Widget 'class' var Widget = function() { // here's the constructor }; var w = new Widget(); w.someProperty = "value"; w.prototype.someProperty = "value";

57 WinJS Classes and Inheritance (WinJS)
// create a new Widget 'class' var Robot = WinJS.Class.define( function(name) { this.name = name; }, { modelName: "", on: function() { /* turn robot on */ }, off: function() { /* turn robot off */ } }, { harmsHumans: false } ); var r = new Robot(); r.modelName = "Johnny 5"; r.on(); // var Johnny5 = WinJS.Class.derive(Robot,{},{},{});

58 codepen.io Classes and Inheritance in javascript

59 Topics Module 1: Basic Syntax references variables conditionals loops
functions classes and inheritance

60 Day 1 Initialize() Target Agenda
Module 1: Basic Syntax Module 2: Lists Module 3: Asynchrony and Concurrency Module 4: Data Storage Module 5: Services and OData Module 6: Libraries

61


Download ppt "Building Blocks: Initialize() Jump Start"

Similar presentations


Ads by Google