Title: C
1C
2C lectures
Aims features of the series
- Give insight into how C works.
- Give insight into .Net.
- Show differences with Java/C where they are
important. - Teach C from the basics upwards
- How its running
- Language constructs
- Design Architectural patterns language
support for these - Hello Kitty! program
- Object Orientation Customer-Order-OrderLines
using TDD - TDD Test Driven Development
3Todays lecture
Lots to do!
- What is C?
- What is it built on top of and around?
- The CLR (and future DLR) lt-gt JVM
- MSIL lt-gt Bytecode (with meta-data)
- Assemblies lt-gt Packages (augmented)
- ASP.Net/WebForms MS MVC.Net MonoRail
- Hello Kitty!-example
- Console Application
- Class Library / Assembly
- Language constructs
- Customer-Order-OrderLine example in C vs. Java
4What is C?
null
- Object oriented, robust, imperative programming
language running on the Common Language Routine
(CLR) - Designed for ease-of-use
- Garbage Collection
- Managed Memory
- Unified type system (everything is an object)
- A large general purpose language created for
.Net, later standardized through ECMA ISO - Architect Anders Hejlsberg
- Similar to languages like C, Java,
Delphi/Pascal - Is compiled into CIL (Common Intermediate
Language) - A lot more!
Referencehttp//www.ecma-international.org/public
ations/standards/Ecma-334.htm
http//www.iso.org/iso/iso_catalogue/catalogue_tc
/catalogue_detail.htm?csnumber36768
5The .Net Framework
Boo Nemerle IronRuby IronPython PHP/Phalanger
Common Language Infrastructure FCL Languages
Just a specification!
Implementations in the class library.
Image fromhttp//www.codeguru.com/csharp/.net/net
_general/netframeworkclasses/article.php/c8245/
6What is the CLR (CLI)?
Common Language Routine / Infrastructure
- The Common Language Routine is the Virtual
Machine which takes CIL/MSIL and executes it. - Because of complete language both at compile time
and at runtime, complete code transformations are
available at runtime. - JIT Just In Time compilation improves
performance of CIL - Compiles blocks of CIL into machine code at time
of execution - Complete reflection system
- Can instantiate any object at runtime depending
on state or input and can emit these into
assembly memory streams. - (i.e. that includes reflection over generic
types) - Memory management
- Thread Management
- Exception Handling Security
- Garbage Collection
Referenceabc
7??????!
Support for internationalization
- The CLR handles UTF-8 by default.
- Creating a ??????! program.
using System namespace LectureOne class
??????ConsoleApp public static void
Main(string args) Console.WriteLine("Hall
å katten!") // yes, latin... string s
"??????" if (s1 '?') Console.WriteLin
e("Yep, we can work with Japanese.") else
Console.WriteLine("No, no UTF-8
support.") Console.ReadKey()
Referenceabc
8Creating Customer
Creating Customer
- Designing how to interact with the object.
TestFixture public class CustomerAndOrderTestFix
ture Address addr Customer cust SetUp
// 1 public void BeforeTest() addr new
Address("Potatisåkern", "211 66",
"Malmö") Test // 2 public void
CanCreateCustomer() cust new
Customer("Karl", "Lindström", addr) Assert.Are
Equal(null, cust.Address.CO) Assert.AreEqual("P
otatisåkern", cust.Address.StreetName) Assert.
AreEqual("Karl", cust.FirstName) Assert.AreEqua
l(Guid.Empty, cust.ID) Assert.AreEqual("Lindstr
öm", cust.LastName)
9Creating Customer-Order-OrderLines
Creating Customer
- Designing how to add order lines to the
customers Order.
Test("Tests the total property of Order") //
attribute public void TotalCost_NoItems() Or
der order new Order(cust, "SEK") order.Create
OrderLine("Grunka", 1, 0) // cheap
grunka. Assert.AreEqual(0, order.Total) orde
r.CreateOrderLine("Ferrarri", 2, 1000000) // a
million each Assert.AreEqual(2000000,
order.Total) Assert.AreEqual(2,
order.OrderLines.Count)
10The code
See dev. Env.
- Have a look at the code now.
Referenceabc
11Next lecture
See dev. Env.
- More about Customer-Order-OrderLine
- Enums
- Foreach
- Structs
- Etc.
- See you then!
Referenceabc