OOP Class1

Jump to: navigation, search

Contents

Intro to Lab

  • Create student accounts

About Class

Technologies

Introduction to Programming languages

Compliled vs Interpreted Languages
Interpreted Languages

Interpreted is not more human readable. It can be just as abstract ad complied code. The difference is how the machine reads and executes the code.

Interpreted langauges read and parse the source input every time a they are executed. After each line is parsed it is converted to machine language and it is executed. Interperted languages are often referd to as scripting languages and are often good for small projects that need to be deployed quickly.

Interperated Scripting Languages are often used on the web

Common Interpreted Languages are Perl,PHP, Python and Ruby

Compiled Languages
Compiled languages use a complier to read and parse the input source code and convert it into machine language. The output binary file is then excuted. If the source changes the program needs to be recompiled. Complied prorams often execute faster and add extra layer of security becuase the source is not always readily available and executable. Complied code also tends to take up less memory and system resources.
Common Client Side


Common Server Side Languages


HelloWorld in several common programming languages Hello World Languages

Why .NET?

  • Discussion

.Net is a platform from Microsoft. It consists of several components. The base of the new platform is the [1] .NET framework. The .NET framework sits on top of the windows(or other operating systems like mono). The .net framework consists of the Common Language Runtime(CLR) and the Framework Class Library(FCL).


The CLR is a platform for compiling, debugging and executing .NET applications. Like java the CLR a virtual machine that can better control runtime security, memory management, and threading.

Here are some examples of the classes available in the .NET framework

*System	Contains fundamental classes and base classes that define commonly used value and reference data types, events and event handlers, interfaces, attributes, and processing exceptions.
*System.Data	Consists mostly of the classes that constitute the ADO.NET architecture. The ADO.NET architecture enables you to build components that efficiently manage data from multiple data sources. In a disconnected scenario (such as the Internet), ADO.NET provides the tools to request, update, and reconcile data in multiple tier systems. The ADO.NET architecture is also implemented in client applications, such as Windows Forms, or HTML pages created by ASP.NET.
*System.Data.Common	Contains classes shared by the .NET Framework data providers. A .NET Framework data provider describes a collection of classes used to access a data source, such as a database, in the managed space.
*System.Data.SqlClient	Encapsulates the .NET Framework Data Provider for SQL Server. The .NET Framework Data Provider for SQL Server describes a collection of classes used to access a SQL Server database in the managed space.
*System.Drawing	Provides access to GDI+ basic graphics functionality. More advanced functionality is provided in the
*System.Drawing.Drawing2D	Provides advanced 2-dimensional and vector graphics functionality. This namespace includes the gradient brushes, the Matrix class (used to define geometric transforms), and the GraphicsPath class.
*System.Drawing.Imaging	Provides advanced GDI+ imaging functionality. Basic graphics functionality is provided by the System.Drawing namespace.
*System.Web	Supplies classes and interfaces that enable browser-server communication.
*System.Web.UI	Provides classes and interfaces that allow you to create controls and pages that will appear in your Web applications as user interface on a Web page.

System.Web.UI.HtmlControls Consists of a collection of classes that allow you to create HTML server controls on a Web Forms page. HTML server controls run on the server and map directly to standard HTML tags supported by most browsers. This allows you to programmatically control the HTML elements on a Web Forms page.

*System.Web.UI.WebControls	Contains classes that allow you to create Web server controls on a Web page. Web server controls run on the server and include form controls such as buttons and text boxes. They also include special purpose controls such as a calendar. Because Web server controls run on the server, you can programmatically control these elements. Web server controls are more abstract than HTML server controls. Their object model does not necessarily reflect HTML syntax.
*System.Windows.Forms	Contains classes that support design-time configuration and behavior for Windows Forms components.

Full List with descriptions http://msdn.microsoft.com/en-us/library/ms229335.aspx

Unlike Java the Microsoft CLR supports multiple languages.

Sun and Microsoft have different programing philosophies. Java write once (in java) run anywhere. CLR write in any CLR language and run on .NET The CLR from Microsoft supports several languages.

  • C# - java like language pronounced C Sharp (the language we will use for this course)
  • VB.NET - Visual Basic .NET
  • JScript
  • J# - Microsoft's Java-language
  • third party languages (cobol,eiffel,pascal,perl) Programming Language Partners

The CLR compiles the .NET languages into MS Intermediate Language (MSIL) which is similar to java's object code. It is an intermediary step between programming language and machine code. The MSIL allows .NET to support multiple programming languages. MSIL code is further compiled by the CLR at run time into machine code. This is known as JIT compilation or Just In Time.

.NET Applications

Hello world in C# for console really simple

using System;
namespace HelloClass
{
    class HelloWorld
    {
        //All Console Apps start with Main Method
        public static void Main()
        {
                Console.WriteLine("Hello World!");
 
        }
    }
}

Hello Console

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace HelloWorldConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            Console.WriteLine("Hello World!");      //Write Hello World! to the console standard out
        }
    }
}
}


http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class1/HelloWorldConsole/HelloWorldConsole/Program.cs

MSIL

.method public hidebysig static void  Main() cil managed
{
  .entrypoint
  // Code size       11 (0xb)
  .maxstack  1
  IL_0000:  ldstr      "Hello World!"
  IL_0005:  call       void [mscorlib]System.Console::WriteLine(string)
  IL_000a:  ret
} // end of method HelloWorldConsole::Main
 

Fully Disassembled hello.cs

Hello WinForms

form1.cs

 
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
 
namespace HelloWorldWindowsForms
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }
 
        private void Form1_Load(object sender, EventArgs e)
        {
            this.Text = "Hello World App";  //Change the title of the form
                                            //yeah i know i could have done it in the designer
 
            label1.Text = "Hello World!";   //Say Hello in a Label
        }
    }
}
 

http://iam.colum.edu/oop/gbrowser.php?file=/classsource/class1/HelloWorldWindowsForms/HelloWorldWindowsForms/Form1.cs

Helloworld! WPF

Window1.xaml.cs

 
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Data;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Imaging;
using System.Windows.Navigation;
using System.Windows.Shapes;
 
namespace HelloWorldWpfApplication
{
    /// <summary>
    /// Interaction logic for Window1.xaml
    /// </summary>
    public partial class Window1 : Window
    {
        public Window1()
        {
            InitializeComponent();
        }
 
        private void Canvas_Loaded(object sender, RoutedEventArgs e)
        {
            this.Title = "Hello WPF app";
            tbHello.Text = "Hello World!";      //Say hello to wpd TexBloc
        }
    }
}
 

window1.xaml

 
<Window x:Class="HelloWorldWpfApplication.Window1"
    xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
    xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
    Title="Window1" Height="300" Width="300">
    <Grid>
        <Canvas Loaded="Canvas_Loaded">
            <TextBlock x:Name="tbHello" Canvas.Left="100" Canvas.Top="100"></TextBlock>
        </Canvas>
 
    </Grid>
</Window>
 
 

Other Links

ECMA C# and Common Language Infrastructure Standards
Mono - Ximian Linux .NET Copy
GotDotNet - Microsoft Site to bridge the gap between .NET team and .NET developers/students


Homework

  1. Get VS2013 and install on your computer or use it in the lab
  2. write and compile Helloworld in csharp as a c# console application bonus make hello world in something besides the console and make it interactive
  3. Upload a zip of hello world to moodle
  4. Read Learning c# Chapters 1-5 pg 0-46
  5. http://www.microsoftvirtualacademy.com/training-courses/c-fundamentals-for-absolute-beginners
    1. 01 Series Introduction 5 Mins
    2. 02 Installing VS 2013 7 mins
    3. 03 Creating Your First C# Program 13 Mins
    4. 04 Dissecting Your First c# Progrman 31 Mins

[[OOP Class1]

Video

This text will be replaced