Lecture 5: Component-based Programming. 2 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 5-2 Objectives “Components are another term for classes,

Slides:



Advertisements
Similar presentations
What is a Computer Program? For a computer to be able to do anything (multiply, play a song, run a word processor), it must be given the instructions.
Advertisements

INTRODUCTION Chapter 1 1. Java CPSC 1100 University of Tennessee at Chattanooga 2  Difference between Visual Logic & Java  Lots  Visual Logic Flowcharts.
Wrap-up: Where Do You Go From Here? MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET Objectives “.NET is the future of software development.
1 Mobile Computing Mobile First (formerly Worklight) Copyright 2015 by Janson Industries.
1/50 Project Management. 2/50 StumbleUpon 3/50 Overview Customize? Why, what, how?.NET Framework overview & fundamentals Class libraries, namespaces,
Getting Ready for Java. What is Java? Java is a programming language: a language that you can learn to write, and the computer can be made to understand.
CIS 234: Integrated Development Environments Dr. Ralph D. Westfall May, 2007.
.NET’s CLR How does it really work? 7/2/20151Bhavani Sankar Ikkurthi CS 795 Presentation.
2. Developing in.NET and C#. 2 Microsoft Objectives “Microsoft.NET development is based on an underlying framework of tools and classes. These tools and.
15-Jul-15 Getting Ready for Java. What is Java? Java is a programming language: a language that you can learn to write, and the computer can be made to.
Lecture 9: Debugging & Testing. 9-2 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET Objectives “Unfortunately, errors are a part of life. Some.
Introduction to Java.
Creating and Running Your First C# Program Svetlin Nakov Telerik Corporation
Tahir Nawaz Visual Programming C# Week 2. What is C#? C# (pronounced "C sharp") is an object- oriented language that is used to build applications for.
PHY281Introduction to JavaSlide 1 Introduction to Java In this section we will learn how how to use Java and write our first Java Applet:  The Java Development.
CS0007: Introduction to Computer Programming Setting Up Java.
How to make it work? Doncho Minkov Telerik Academy academy.telerik.com Technical Trainer
Object Oriented Software Development 1. Introduction to C# and Visual Studio.
.NET On A Shoe String By: Patrick Brannen Lead Developer iDevCo, Inc.
.NET Framework Introduction Nouman Qureshi
Intro to dot Net Dr. John Abraham UTPA – Fall 09 CSCI 3327.
Lecture 2: An Introduction to J# and.NET. 2 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 2-2 Objectives “Microsoft.NET is based on the.NET.
An Introduction to C# and the .NET Framework
Joe Hummel, PhD Dept of Mathematics and Computer Science Lake Forest College Lecture 8: WebForms — Web-based.
Microsoft Visual Basic 2005 CHAPTER 1 Introduction to Visual Basic 2005 Programming.
Getting Started With Java Downloading and installing software Running your first program Dr. DwyerFall 2012.
1 ENG236: ENG236: C++ Programming Environment (2) Rocky K. C. Chang THE HONG KONG POLYTECHNIC UNIVERSITY.
Introduction 01_intro.ppt
1..NET Architecture Based on slides by Joe Hummel.
ISYS 512 Business Application Design and Development with.Net David Chao.
NOTE: To change the image on this slide, select the picture and delete it. Then click the Pictures icon in the placeholder to insert your own image. WEB.
CSC300 Visual Programming Dr. Craig Reinhart. Objectives Teach the basics of C++ –You won’t be an expert but hopefully a very good novice –GUI development.
1 Program Execution in the 21 st Century Modern Software Development in.NET and C# A webcast series for C++, Java, and VB6 developers – Part 1 of 15: [
Architecture of.NET Framework .NET Framework ٭ Microsoft.NET (pronounced “dot net”) is a software component that runs on the Windows operating.
Session 1 - Introduction and Data Access Layer
11 Getting Started with C# Chapter Objectives You will be able to: 1. Say in general terms how C# differs from C. 2. Create, compile, and run a.
Introduction to .NET Rui Ye.
Lecture Set 1 Part B: Understanding Visual Studio and.NET – Structure and Terminology 1/16/ :04 PM.
Understanding Code Compilation and Deployment Lesson 4.
Creating and Running Your First C# Program Svetlin Nakov Telerik Corporation
Lesley Bross, August 29, 2010 ArcGIS 10 add-in glossary.
Neal Stublen Class Objectives  Develop an understanding of the.NET Framework  Gain proficiency using Visual Studio  Begin learning.
An intro to programming. The purpose of writing a program is to solve a problem or take advantage of an opportunity Consists of multiple steps:  Understanding.
Lecture 7: WinForms & Controls, Part MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET Objectives “Visual Studio.NET ships with a wealth.
Lecture 1 Programming in C# Introducing C# Writing a C# Program.
Component-Based Software Engineering Introduction to.NET Paul Krause.
NOTE: To change the image on this slide, select the picture and delete it. Then click the Pictures icon in the placeholder to insert your own image. WEB.
Java and C# [this is a bonus – it is not a required lesson] ACO101: Introduction to Computer Science.
Introduction to .NET Framework
Preliminaries CS 310: Object-oriented Programming Java API.
Visual Basic.NET BASICS Lesson 1 A First Look at Microsoft Visual Basic.NET.
Microsoft Visual Basic 2005 BASICS Lesson 1 A First Look at Microsoft Visual Basic.
29-Nov-15 Getting Ready for Java. 2 What is Java? Java is a programming language: a language that you can learn to write, and the computer can be made.
JAVA Programming “When you are willing to make sacrifices for a great cause, you will never be alone.” Instructor: รัฐภูมิ เถื่อนถนอม
Lecture 4: J# Execution Model. 2 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 4-2 Objectives “J# programs execute like any other.NET program.
1. The .NET Architecture 1. The .NET Architecture 2003
Getting Started with.NET Getting Started with.NET/Lesson 1/Slide 1 of 31 Objectives In this lesson, you will learn to: *Identify the components of the.NET.
1 Getting Started with C++ Part 1 Windows. 2 Objective You will be able to create, compile, and run a very simple C++ program on Windows, using Microsoft.
Lecture Set 1 Part B: Understanding Visual Studio and.NET – Structure and Terminology 1/16/ :04 PM.
CS 201 Lecture 1 (b) Using an IDE Tarik Booker CS 201: Introduction to Programming California State University, Los Angeles.
Guide To Develop Mobile Apps With Titanium. Agenda Overview Installation of Platform SDKs Pros of Appcelerator Titanium Cons of Appcelerator Titanium.
ClickOnce Deployment (One-click Deployment)
Lecture 1: The .NET Architecture
CSC 222: Object-Oriented Programming
INF230 Basics in C# Programming
Introduction to .NET Framework Ch2 – Deitel’s Book
Lecture 3: The J# Language
The Role of Command Line Compiler (csc.exe)
Review of Previous Lesson
ClickOnce Deployment (One-click Deployment)
Presentation transcript:

Lecture 5: Component-based Programming

2 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 5-2 Objectives “Components are another term for classes, DLLs, and assemblies. Component-based programming is the logical tendency to design our programs as a set of components instead of a large monolithic app. Given the design of.NET and its Framework Class Library, J# programming is inherently component-based programming... ” In 3 Parts: 1.Component-based programming 2.Working with.NET components 3.Creating your own.NET components

3 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 5-3 Part 1 Component-based programming…

4 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 5-4 Component-based programming OO programming is component-based programming –classes are components.NET programming is component-based programming –DLLs are components Other components you'll use: –Supplemental UI Library

5 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 5-5.NET components.NET components must be installed to run a.NET program –in fact, CLR + FxCL must be installed –these are known collectively as the.NET Framework Hardware Operating System Common Language Runtime (CLR).NET program.NET Framework Class Library (FxCL).NET Framework

6 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 5-6 Installing.NET Framework.NET Framework is installed as part of Visual Studio.NET How to install on systems without VS.NET? Pre-installed on Windows 2003 and above Otherwise you must install 2 pieces of software, in this order: 1..NET Framework 1.1 Redistributable :dotnetfx.exe (20MB) 2.Visual J#.NET Version 1.1 Redistributable :vjredist.exe (7MB) Requirements: –Windows 98 or above

7 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 5-7 Installing.NET Framework (cont'd) Installing.NET Framework 1.1 Redistributable : – –also available via Windows Update (IE, Tools menu, recommended) Installing Visual J#.NET Version 1.1 Redistributable : – Other components are installed on an "as-needed" basis Supplemental UI Library: –see

8 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 5-8 Part 2 Working with.NET components…

9 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 5-9 Programming options J# programming can really be done at two levels: 1.using Visual Studio.NET 2.at the command-line, much like Sun's JDK Let's use the command-line tools since it's easier to understand how.NET component work…

10 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 5-10 Command-line development Main tools: –vjc :Visual J# compiler –notepad :simple Windows text editor (any editor will do) How to get started? –open Visual Studio.NET 2003 Command Prompt Start menu, All Programs, Microsoft Visual Studio.NET 2003, Visual Studio.NET Tools, Visual Studio.NET 2003 Command Prompt

11 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 5-11 Example Let's create a simple GUI app using the Java Class Library –in particular, using the SWING classes of the JCL GUIApp : –outputs "ouch!" to the console each time you click the button… C:\GUIApp> guiapp.exe ouch!

12 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 5-12 GUIApp GUIApp is a single source code file "GUIApp.jsl": public class GUIApp { public static void main(String[] args) { javax.swing.JFrame frame = new javax.swing.JFrame(); java.awt.Container c = frame.getContentPane(); javax.swing.JButton button1 = new javax.swing.JButton("Click Me"); frame.setSize(100, 100); frame.setLocation(100, 100); frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); c.add(button1); button1.addActionListener(new ButtonHandler()); frame.show(); } } //class class ButtonHandler implements java.awt.event.ActionListener { public void actionPerformed(java.awt.event.ActionEvent e) { System.out.println("ouch!"); } } //class public class GUIApp { public static void main(String[] args) { javax.swing.JFrame frame = new javax.swing.JFrame(); java.awt.Container c = frame.getContentPane(); javax.swing.JButton button1 = new javax.swing.JButton("Click Me"); frame.setSize(100, 100); frame.setLocation(100, 100); frame.setDefaultCloseOperation(javax.swing.WindowConstants.EXIT_ON_CLOSE); c.add(button1); button1.addActionListener(new ButtonHandler()); frame.show(); } } //class class ButtonHandler implements java.awt.event.ActionListener { public void actionPerformed(java.awt.event.ActionEvent e) { System.out.println("ouch!"); } } //class

13 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 5-13 Compilation Compile using the Visual J# compiler "vjc" –reference Supplemental UI Library to use SWING –compiler switches: /t:build a console-based.EXE /r:reference the specified.NET component (.DLL) C:\GUIApp> dir 04/20/ GUIApp.jsl C:\GUIApp> vjc /t:exe GUIApp.jsl /r:vjssupuilib.dll Microsoft (R) Visual J#.NET Compiler version For Microsoft (R).NET Framework version Copyright... C:\GUIApp> dir 04/20/200420,480GUIApp.exe

14 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 5-14 Run! Run the.EXE from the command-line: C:\GUIApp> guiapp.exe ouch!

15 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 5-15.NET Framework SDK.NET Framework SDK contains the command-line tools –SDK = Software Development Kit –.NET equivalent of Sun's JDK –installed as part of Visual Studio.NET –available separately as a free download (100MB):

16 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 5-16 Issues with using Swing Advantage of using Swing: You can recompile without modification usings Sun’s JDK and run on any Java platform. Disadvantage of using Swing: Swing programming by hand is hard and tedious and does not let you take full advantage of the Visual Studio integrated IDE.

17 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 5-17 Example #2 A better example of SWING –Visual Sorting demo… public VisualSorting() { super("VisualSorting"); URL u = VisualSorting.class.getResource("Random.jpg"); icon= new ImageIcon(u); // create AlgorithmPanels, and the mainControlPanel populateAlgorithmsPane(); mainControlPanel = new MainControlPanel (this); // add the algorithmPanel, and mainControlPanel to the contentPanel getContentPane().setLayout (new GridBagLayout()); GridBagConstraints gConstraints = new GridBagConstraints(); gConstraints.anchor = GridBagConstraints.CENTER; gConstraints.fill = GridBagConstraints.BOTH; gConstraints.gridx = GridBagConstraints.RELATIVE; gConstraints.gridy = GridBagConstraints.RELATIVE; gConstraints.gridwidth = GridBagConstraints.REMAINDER; gConstraints.gridheight = 650;. public VisualSorting() { super("VisualSorting"); URL u = VisualSorting.class.getResource("Random.jpg"); icon= new ImageIcon(u); // create AlgorithmPanels, and the mainControlPanel populateAlgorithmsPane(); mainControlPanel = new MainControlPanel (this); // add the algorithmPanel, and mainControlPanel to the contentPanel getContentPane().setLayout (new GridBagLayout()); GridBagConstraints gConstraints = new GridBagConstraints(); gConstraints.anchor = GridBagConstraints.CENTER; gConstraints.fill = GridBagConstraints.BOTH; gConstraints.gridx = GridBagConstraints.RELATIVE; gConstraints.gridy = GridBagConstraints.RELATIVE; gConstraints.gridwidth = GridBagConstraints.REMAINDER; gConstraints.gridheight = 650;. public static void main(String args[]) { VisualSorting sd = new VisualSorting(); sd.setSize((int) (520 * 1.61), 520); sd.setResizable(false); sd.reset(); sd.show(); } public static void main(String args[]) { VisualSorting sd = new VisualSorting(); sd.setSize((int) (520 * 1.61), 520); sd.setResizable(false); sd.reset(); sd.show(); }

18 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 5-18 Part 3 Creating your own.NET components…

19 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 5-19 Motivation Professionals create their own components for many reasons: –Team programming: each builds their own component and tests separately. –Multi-language programming: components in different languages are built (e.g. VB, J#, C++) and then integrated. –Component reuse –Component updating: Components can be updated independently to fix bugs

20 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 5-20 Example: N-Tier design Business applications commonly follow an N-Tier design –application is logically divided by task areas –physically built as a set of components Business.dll Presentation Tier Data Access Tier e.g. read and write from customer files or database Data Tier e.g. data source, like files or database Business Logic Tier e.g. purchase products or pay employees GUI.exe DataAccess.dll

21 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 5-21 Component-based BankingApp Let's rebuild the BankingApp as a set of components: transactions.txt customers.txt App.jsl Customer.jsl CustomersIO.jsl Transactions.jsl Transactions.dll BankingApp.exe Customers.dll

22 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 5-22 (1) Customers.dll First, build the lower-level data access tier, Customers.dll : –in this case we target (/t:) a library, not an exe –Rather than /t:library we can abbreviate to /t:l C:\BankingApp> dir *.jsl 04/20/20041,039App.jsl 04/20/ Customer.jsl 04/20/20041,603CustomersIO.jsl 04/20/20041,443Transactions.jsl C:\BankingApp> vjc /t:library Customer.jsl CustomersIO.jsl /out:Custo mers.dll Microsoft (R) Visual J#.NET Compiler version For Microsoft (R).NET Framework version Copyright... C:\BankingApp> dir *.dll 04/20/200420,480Customers.dll

23 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 5-23 (2) Transactions.dll Second, build the middle-level business tier, Transactions.dll : –reference Customers.dll to gain access to definition of Customer C:\BankingApp> dir *.jsl 04/20/20041,039App.jsl 04/20/ Customer.jsl 04/20/20041,603CustomersIO.jsl 04/20/20041,443Transactions.jsl C:\BankingApp> vjc /t:library Transactions.jsl /r:Customers.dll /out:Trans actions.dll Microsoft (R) Visual J#.NET Compiler version For Microsoft (R).NET Framework version Copyright... C:\BankingApp> dir *.dll 04/20/200420,480Customers.dll 04/20/ Transactions.dll

24 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 5-24 (3) BankingApp.exe Third, build the presentation tier.EXE, BankingApp.exe : –references both Customers.dll and Transactions.dll C:\BankingApp> dir *.jsl 04/20/20041,039App.jsl 04/20/ Customer.jsl 04/20/20041,603CustomersIO.jsl 04/20/20041,443Transactions.jsl C:\BankingApp> vjc /t:exe App.jsl /r:Customers.dll /r:Transactions.dll /out:Ba nkingApp.exe Microsoft (R) Visual J#.NET Compiler version For Microsoft (R).NET Framework version Copyright... C:\BankingApp> dir *.dll;*.exe 04/20/200420,480Customers.dll 04/20/ Transactions.dll 04/20/200420,480BankingApp.exe

25 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 5-25 Run! BankingApp runs exactly as before…

26 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 5-26 If.NET can't find component? If a referenced.DLL cannot be found, program fails to run… Example: –move Customers.dll out of folder, and try running app… move to desktop…

27 MicrosoftIntroducing CS using.NETJ# in Visual Studio.NET 5-27 Summary.NET is built using component-based programming J# programming is component-based programming Professional programming is component-based programming