Mark Dixon 1 22 – Object Oriented Programming. Mark Dixon 2 Questions: Databases How many primary keys? How many foreign keys? 3 2.

Slides:



Advertisements
Similar presentations
Lilian Blot Announcements Teaching Evaluation Form week 9 practical session Formative Assessment week 10 during usual practical sessions group 1 Friday.
Advertisements

Excel and Visual Basic. Outline Data exchange between Excel and Visual Basic. Programming VB in Excel.
The Librarian Web Page Carol Wolf CS396X. Create new controller  To create a new controller that can manage more than just books, type ruby script/generate.
Mark Dixon Page 1 23 – Object Oriented Programming in PhP.
Mark Dixon, SoCCE SOFT 131Page 1 15 – Object Oriented Analysis, Design, and Programming.
Mark Dixon, SoCCE SOFT 131Page 1 22 – Object Oriented Analysis, Design, and Programming.
Chapter 10 THINKING IN OBJECTS 1 Object Oriented programming Instructor: Dr. Essam H. Houssein.
Mark Dixon Page 1 16 – Passing Data between pages: Forms, Sessions, & Query Strings.
Mark Dixon Page 1 05 – Database Design: Sub-forms.
Mark Dixon Page 1 04 – Database Design: Forms. Mark Dixon Page 2 Session Aims & Objectives Aims –To allow easier data entry using forms Objectives, by.
Mark Dixon Page 1 22 – Object Oriented Programming in ASP.
Object Oriented Design An object combines data and operations on that data (object is an instance of class) data: class variables operations: methods Three.
Mark Dixon Page 1 17 – Persistent data storage: relational databases and ADO.
Mark Dixon, SoCCE SOFT 131Page 1 13 – Object Oriented Analysis, Design, and Programming.
PHP (2) – Functions, Arrays, Databases, and sessions.
Mark Dixon Page 1 21 – Object Oriented Programming in ASP.
Creating Object Oriented Programs Object oriented (OO) terminology Class vs. object Instantiate an object in a project Understand Class_Initialize / Terminate.
Mark Dixon, SoCCE SOFT 131Page 1 10 – Variable Scope, and Arrays of Structures.
1 Prototyping for HCI Spring 2004 (Week 8) Jorge A. Toro.
Mark Dixon Page 1 02 – Queries: Query by Example.
Mark Dixon Page 1 20 – Modular Design in ASP. Mark Dixon Page 2 Session Aims & Objectives Aims –Highlight modular design techniques in ASP Objectives,
Mark Dixon Page 1 13 – Object Oriented Programming.
Mark Dixon Page 1 20 – Web applications: Writing data to Databases using ASP.
Mark Dixon, SoCCE SOFT 131Page 1 20 – Web applications: Writing data to Databases using ASP.
C++ fundamentals.
Database Systems Lecture 5 Natasha Alechina
Games and Simulations O-O Programming in Java The Walker School
DAY 21: MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Akhila Kondai October 30, 2013.
Object Oriented Software Development
Mark Dixon Page 1 10 – Iterative Execution. Mark Dixon Page 2 Questions: Variables Write a line of code to declare a variable called h Write a line of.
Mark Dixon 1 20 – Persistent data storage: relational databases and ADO.
Mark Dixon Page 1 19 – Passing Data between pages: Forms, Sessions, & Query Strings.
Object Orientation An Object oriented approach views systems and programs as a collection of interacting objects. An object is a thing in a computer system.
Mark Dixon Page 1 23 – Web applications: Writing data to Databases using PhP.
Mark Dixon Page 1 24 – Object Oriented Programming in ASP.
Mark Dixon 1 22 – Web applications: Writing data to Databases using ASP.Net.
Mark Dixon Page 1 23 – Web applications: Writing data to Databases using ASP.
Mark Dixon 1 09 – Java Servlets. Mark Dixon 2 Session Aims & Objectives Aims –To cover a range of web-application design techniques Objectives, by end.
Mark Dixon Page 1 Web-Application Development Workshop.
Mark Dixon Page 1 21 – Web applications: Writing data to Databases using ASP.
Mark Dixon, SoCCE SOFT 131Page 1 24 – Datatypes and Object Association.
Mark Dixon 1 21 – Databases: Multiple Tables and Writing Data.
Mark Dixon 1 19 – Passing Data between pages: Forms, Sessions, & Query Strings.
1 CS 3870/CS 5870: Note05 Prog3 Web Application with Database.
Introduction to c++ programming - object oriented programming concepts - Structured Vs OOP. Classes and objects - class definition - Objects - class scope.
Mark Dixon SOFT 131Page 1 12 – Object Oriented Analysis, Design, and Programming.
Mark Dixon Page 1 15 – Structured Programming. Mark Dixon Page 2 Admin: Coursework 3 – Test In class test –9 Feb 2010 –2 Feb 2010: revision (technique)
CPS120: Introduction to Computer Science Lecture 16 Data Structures, OOP & Advanced Strings.
ADO.NET Objects Data Adapters Dr. Ron Eaglin. Agenda Builds on Information in Part I Should have working knowledge of creating a database connection Continuation.
Mark Dixon 1 15 – Structured Programming. Mark Dixon 2 Admin: Test 2 In class test –11 Feb 2014 –4 Feb 2014: revision (technique) session 50 mins short.
Using a Database Access97 Please use speaker notes for additional information!
Mark Dixon 1 13 – Parameters. Mark Dixon 2 Question: Arrays How many array variables are in the following code: Dim x Dim y Dim f(4) x = 12 y = 6 f(2)
Mark Dixon, SoCCE SOFT 131Page 1 25 – Soft 131 Examination Revision.
Mark Dixon 1 Soft051 Examination Sample Questions.
MICROSOFT ACCESS – CHAPTER 5 MICROSOFT ACCESS – CHAPTER 6 MICROSOFT ACCESS – CHAPTER 7 Sravanthi Lakkimsety Mar 14,2016.
Software Design and Development Languages and Environments Computing Science.
CS 440 Database Management Systems Stored procedures & OR mapping 1.
Mark Dixon Page 1 09 – Iterative Execution. Mark Dixon Page 2 Questions: Variables Write a line of VBScript code to declare a variable called h Write.
© Stefano Grazioli - Ask for permission for using/quoting: Source: Excel VBA Programming by John Walkenbach.
CPS120: Introduction to Computer Science Lecture 16A Object-Oriented Concepts.
CE-105 Spring 2007 By: Engr. Faisal ur Rehman
15 – Structured Programming
12 – Object Oriented Programming
23 – Object Oriented Programming in ASP
17 – Modular Design in ASP.
Microsoft Access Illustrated
17 – Persistent data storage: relational databases and ADO
19 – Databases: Multiple Tables
Chapter 8 - Functions and Functionality
Presentation transcript:

Mark Dixon 1 22 – Object Oriented Programming

Mark Dixon 2 Questions: Databases How many primary keys? How many foreign keys? 3 2

Mark Dixon 3 Questions: HTML in VB Are these correct (assume variables and fields exist)? s = s + + r("Model") s = s r("Length") h = " " + h + " "  

Mark Dixon 4 Questions: SQL in VB Are these correct (assume variables and fields exist)? id = 4 sql = SELECT * FROM Customer sql = sql " WHERE [CustID] = " + id + ";" cmd = New OldDbCommand(sql, cn)  

Mark Dixon 5 Questions: Writing to Databases What SQL command is used to add a new record to a database table. What SQL command is used to remove a record from a database table. Write an SQL command to put "Hello" into the Description field of all records in the Message table. INSERT DELETE UPDATE Message SET Description = ‘Hello’;

Mark Dixon 6 Session Aims & Objectives Aims –To highlight that the object oriented techniques covered earlier can be used in ASP Objectives, by end of this week’s sessions, you should be able to: –create a class definition in server-side code –create an instance of a class –create a class definition from a class diagram

Mark Dixon 7 Object-Oriented Paradigm A program is made up of a number of objects that communicate with each other by passing messages Each object contains –attributes/properties that represent its state, and –operations/methods that represent its behaviour Objects often mirror the real world –Customers –Students –Patients

Mark Dixon 8 Classes and Instances Object Classes –general descriptions of types of objects, e.g. student, product, customer, lecturer, and room. Object Instances –specific items of a given class, e.g. each of you could be an instance of the student class Room 214 could be an instance of the room class I could be an instance of the lecturer class Bolt could be an instance of the part class

Mark Dixon 9 Object Concepts - Implementation Properties – implemented as –data structures (variables and arrays) Methods – implemented as either –a procedure (to perform some processing), or –a function (to return a value). Object oriented paradigm builds on (rather than replaces) the structured paradigm

Mark Dixon 10 Example: Animals

Mark Dixon 11 Example: Student

Mark Dixon 12 Public and Private Control access to properties and methods Class a Public x As Single Private y As Single Public Sub ResetY() y = 0 End Sub End Class Dim b As New a b.x = 5 b.ResetY() b.y = 10 this works (x is public) this works (ResetY is public)  this will fail (y is private)

Mark Dixon 13 Benefits of OOP in code Procedures and Functions are part of object –encapsulation Related Data and Operations together Private keyword – restrict access to data Clearer code Less prone to error

Mark Dixon 14 Example: Counter (html) Counter

Mark Dixon 15 Example: Counter (code) Dim c As Counter Sub Page_Load() If Session("c") Is Nothing Then Session("c") = New Counter End If c = Session("c") End Sub Sub btnReset_Click(s As Object, e As EventArgs) Handles btnReset.ServerClick c.Reset() End Sub Sub btnUp_Click(s As Object, e As EventArgs) Handles btnUp.ServerClick c.Up() End Sub Sub Page_LoadComplete(s As Object, e As EventArgs) parMsg.innerText = c.GetCount() End Sub Public Class Counter Private mCount As Long Public Function GetCount() As Long GetCount = mCount End Function Public Sub Reset() mCount = 0 End Sub Public Sub Up() mCount = mCount + 1 End Sub Public Sub Down() mCount = mCount - 1 End Sub End Class Counter.vb Class file must be in App_Code folder

Mark Dixon 16.NET Folders Right click project –App_Code – used for classes (put all classes here) –App_Data – used for databases

Mark Dixon 17 Questions: OOP How many –classes –properties –methods –functions –procedures Public Class Counter Private mCount As Long Public Function GetCount() As Long GetCount = mCount End Function Public Sub Reset() mCount = 0 End Sub Public Sub Up() mCount = mCount + 1 End Sub Public Sub Down() mCount = mCount - 1 End Sub End Class Function Twice(x As Long) As Long Return x * 2 End Function

Mark Dixon 18 Class Diagrams Used to describe structure of object classes: Module Code: string Title: string GetTitle(): string SetTitle(t: string) Count(): integer Class Attributes/Properties Class Operations/Methods Class Name

Mark Dixon 19 Class Module Public Code As String Public Title As String Public Function GetTitle() As String Public Sub SetTitle(t As String) Public Function Count() As Integer End Class Implementing Class Diagrams Module Code: String Title: String GetTitle(): string SetTitle(t: string) Count(): integer

Mark Dixon 20 Tutorial Exercise: Counter Task 1: Get the Counter example from the lecture working. Task 2: Modify your code – so that the value cannot go below 0 or above 10. hint: you can't actually stop it going outside the range, but you can detect if it does and then change it.