Presentation is loading. Please wait.

Presentation is loading. Please wait.

Overview Type conversions Advanced types enum struct array Function parameters by value and by reference Layered Applications Business Logic Layer & Testing.

Similar presentations


Presentation on theme: "Overview Type conversions Advanced types enum struct array Function parameters by value and by reference Layered Applications Business Logic Layer & Testing."— Presentation transcript:

1 Overview Type conversions Advanced types enum struct array Function parameters by value and by reference Layered Applications Business Logic Layer & Testing Presentation Layer (Console apps and Windows Forms apps)

2 C# Types – Value types true, false 0 – 255 ‘a’, ‘b’, ‘c’, ‘\t’, etc. 28-29 significant digits, ± 7.9 x 10 28 15-16 significant digits, ± 5.0 x 10 324 to ±1.7 x 10 308 List of constants of same type - byte, sbyte, short, ushort, int, uint, long, or ulong 7 significant digits, ± 3.4 x 10 38 -2,147,483,648 to 2,147,483,647 –9,223,372,036,854,775,808 to 9,223,372,036,854,775,807 -128 to 127 -32,768 to 32,767 Group of related value types 0 to 4,294,967,295 0 to 18,446,744,073,709,551,615 0 to 65,535

3 Type conversions Types with smaller range can be implicitly converted to types with larger range Other types MAY be explicitly converted target_type outvar = (target_type) variableName

4 Advanced types – enum To constrain the possible values for a variable Declared at same level as class Plain text names associated with number

5 Advanced types – struct A custom, multi-valued, type that can have functions Declared at same level as class Can contain value types (int, long, double, etc) and strings

6 Advanced types – Array Making it easier to create/access groups of values of the same type

7 Functions – Define and call Syntax: [scope][static] type name ([params]) { statements [return [value];] } Define : Call :

8 Params by ref and by value

9 Visual Studio Solutions … Projects (.csproj) * Visual Studio Solution (.sln)

10 Presentation Layer Layered Applications Business Logic Layer Data Data Access Layer BLL Business objects & logic DAL Read/Write data from/to a database

11 Steps to building a layered application 1. Get requirements for application feature(s) 2. Decide on a presentation layer and sketch it out (no code) 3. Create the … Data access layer and tests, debug Business logic layer and tests, debug Presentation layer and connect to business layer, debug 4. Test the application 5. Create installer 6. Deploy application to users 7. Repeat until all application features are complete

12 Creating a Business Layer Add Class Library Project to Solution Suffix name with BLL (e.g. IssueTrackerBLL) Add classes to represent the business objects Add properties and methods to these classes to represent the business data and processes respectively

13 Testing a Business Layer Create a Test Project Common to have one Test Project per application Project Suffix Test Project name with “Tests”

14 Adding a Test

15 Editing the TestMethod

16 Running the test – no debugging With cursor in test method … Or right-click and use TestDriven.NET

17 Running the test – with debugging With cursor in test method … Or right-click and use TestDriven.NET Need Breakpoint (F9 to toggle)

18 Test results Test with MS Test Test with TestDriven.NET

19 Building a Presentation Layer (UI) Add UI Application Project that satisfies the requirements Windows Console Application Windows Forms Application WPF Application Web ASP.NET Web Application ASP.NET MVC Application Silverlight Application This is the StartUp Project Suffix Project name with UI (Optional)

20 Command-line args for Console applications

21 C# Compiler & command-line args

22 Windows Forms Application A Form is a container for UI controls Common for starting form to have name MainForm Drag & Drop from Toolbox

23 Naming child controls Give child control names prefixes btn = Button txt = TextBox lbl = Label lst = ListBox cbo = ComboBox rdo = RadioButton etc. Adding code to controls … Double-click control or code by hand

24 “Connecting” the UI and BLL Add Reference in UI to BLL Project Add using to UI code (MainForm.cs in this example)

25 Example: Accessing BLL from UI


Download ppt "Overview Type conversions Advanced types enum struct array Function parameters by value and by reference Layered Applications Business Logic Layer & Testing."

Similar presentations


Ads by Google