140 likes | 249 Views
Exploring Objects with the Debugger. Objects & Programming. Programming is the act of writing instructions that tell a computer how to do something
E N D
Objects & Programming • Programming is the act of writing instructions that tell a computer how to do something • Objects allow us to represent computer technology in our code so that we may send command (methods) & access settings (properties) of the computer technology • Lots of different parts to the computer system so we need lots of different kinds of object
Types of Object • For this module we shall split them into the following categories… • Web Forms and Controls We use these to create the interface in the presentation layer • .NET Library Objects Ready made objects allowing us to do things such a print or send emails • Variables These objects allow us to control the computer’s RAM • Custom Objects You may create your own objects to perform a whole host of tasks
The Send Password Program • We have almost certainly used a program like this before...
Computer Technology Involved • The user… • Enters their email address • Presses the send password button • Technology to control • Keyboard, screen, mouse • The system • Queries the database • Sends an email to the user • Technology to control • Database file, RAM, E Mail Message, E Mail Server
Objects we will use… • Keyboard Control objects • Screen Control objects • Mouse Control objects • Database Custom object(s) • RAM Variables • E Mail Message .NET Library Object • E Mail Server .NET Library Object
System Input-Output Provides tools for file input and output Drawing Provides graphical drawing tools Web Provides tools for Internet interconnectivity Data Provides tools for accessing databases .NET Library • Huge library of ready made classes • Two classes of interest • System.Net.Mail.MailMessage Controls the email message • System.Net.Mail.SmtpClient Controls the email server
Creating an E Mail • Create the following e mail… • Dim myMessage As New System.Net.Mail.MailMessage • (“you@whatever.com”, “johnsmith@nowhere.com”, “Hello John”,”Hi this is a test!”)
Sending the EMail Dim myMessage As New System.Net.Mail.MailMessage (“you@whatever.com”, “johnsmith@nowhere.com”, “Hello John”,”Hi this is a test!”) Dim Server As New System.Net.Mail.SmtpClient("mail.dmu.ac.uk") Server.Send(myMessage) • Note the use of parameters! • Parameters do a similar job to the assignment statement
Encapsulation • Hides the complexity contained inside the object • Variables – RAM • DataConnection – Database • Mail Message Objects - Email • SMTP Client – E Mail Server
Presentation Middle Layer .NET and Custom Objects Data Layer Database I N T E R F A C E Events C O D E Q U E R I E S Parameters T A B L E S Send Password Architecture
Click Event Handler • There is a lot of code to think about so how do we make life simpler?
Break Points • Allow us to stop the program, run it one line at a time and inspect variable. • Press F9 to turn break points on and off