270 likes | 425 Views
Object Oriented Programming Course Introduction. Dr. Mike Spann m.spann@bham.ac.uk. Course Introduction. This course introduces you to object oriented programming using C# and the .NET programming environment
E N D
Object Oriented ProgrammingCourseIntroduction Dr. Mike Spann m.spann@bham.ac.uk
Course Introduction This course introduces you to object oriented programming using C# and the .NET programming environment It also teaches you a few more advanced techniques such as graphics/multimedia programming and web form programming You will be introduced to object oriented design techniques using UML notation
Course Introduction The course will consist of lectures, tutorials and an un-assessed programming exercise It is assessed by a major programming assignment only (no exam!)
Recommended Textbook • There are already dozens of textbooks on C# • You need to choose one which suits you and your budget • The course recommended book is: • Visual C# 2010. How to Program. 3rd Edition. H.M. Deitel, P.J. Deitel • Published by Pearson • ISBN 0-13-701183-0 • It has everything there but is rather long and glosses over some important detail at times • Amazon Link
Course resources Course web site Visual studio home page Visual C# developer centre Visual C# basics
Course contents (Week 1) Course Introduction Introduction to C# Classes and Objects Inheritance and Polymorphism Interfaces, Callbacks, Delegates and Events Graphical User Interfaces Graphics and Multimedia Multi-threading Files and Streams Windows Forms and ASP.NET
Visual Studio • Visual Studio 2012 is now installed on the School network and it is recommended that you use that for your assignment • Do not use the express version! • You can install VS2012 on your laptop for free using the University MSDN agreement • Go to https://www.epsit.bham.ac.uk/software/msdn-aa/ • As far as I know, VS 2013 not installed on the school network but you are welcome to install it • I have it on my office machine
Object Oriented Programming (OOP) Introduction • OOP: Now the dominant way to program, yet it is over 40 years old! (Simula '67 and Smalltalk '72 were the first OOPLs) • Dr. Alan Kay received ACM’s Turing Award, the “Nobel Prize of Computing,” in 2003 for Smalltalk, the first complete dynamic OOPL • It was slow to catch on, but since the mid-90’s everybody’s been doing it! • OOP emphasizes objects, which often reflect real-life objects • have both properties and capabilities • i.e., they can perform tasks: “they know how to...”
OOP Introduction • A simple way to think about designing and implementing a system using OOP is to ask the following 3 questions about your proposed system: • What are the system’s objects? • What do those objects know how to do? • What properties do those objects have?
Examples A B Digital watch
Examples (Digital watch) • What are the objects? • watch display, buttons A (set mode), B(adjust time), timer • Capabilities: What do those objects know how to do? • watch display: • be created • display the time or hours/minutes digits individually • button A: • sets/resets display mode • button B: • sends message to watch display to increment/decrement hours/minutes digits
Examples (Digital watch) • What properties do those objects have? • watch display: • size • background colour • text fonts • flash on/off • display mode • button A, button B: • size • colour
Examples Traffic light controller
Examples (Traffic light controller) • What are the objects? • lamp controller, sequencer, traffic sensor, priority scheduler • Capabilities: What do those objects know how to do? • lamp controller: • be created • turns red, amber, green lamps on and off • sequencer: • be created • sends on/off signal to lamp controllers in correct sequence and at correct times
Examples (Traffic light controller) • Capabilities: What do those objects know how to do? (cont) • traffic sensor: • be created • determines mean vehicle count per unit time • priority scheduler: • be created • sends on/off signal to lamp controllers in correct sequence and at correct times
Examples (Traffic light controller) • What properties do those objects have? • lamp controller: • sequencer: • sequence intervals • traffic sensor: • averaging window size • priority scheduler: • traffic through-put requirements
Examples Tetris
Examples (Tetris) • What are the objects? • piece, board • Capabilities: What do those objects know how to do? • piece: • be created • fall • rotate • stop at collision • board: • be created • remove rows • check for end of game
Examples (Tetris) • What properties do those objects have? • piece: • orientation • position • shape • color • board: • size • rows
So what is object oriented? • In OOP, objects are considered anthropomorphic • the object has both storage and behaviour to operate on its current state • eg bed can make itself, door can open itself, menu can let selections be picked • but, each must be told when to perform actions by another object — so objects must cooperate to accomplish task • Each object represents an abstraction • a “black box” - hides details you do not care about • allows you as the programmer to control program’s complexity — only think about salient features
So what is object oriented? • So, OOP involves writing programs by modeling the problem as set of collaborating components • you determine what the building blocks are • think about the object, their behaviour and their properties • put them together so they cooperate properly • think about how they interact with other objects • A simple analogy is like building with smart Legos, some of which are pre-defined, some of which you design!
What exactly is OOP? • 3 components: • Data abstraction • implementation, interface • Encapsulation • ‘packaged’ objects • controlled interaction with other objects • Polymorphism (‘many forms’) • objects can assume ‘many forms’ through same interface
Why OOP? • Allows the management of complexity. • How? • Controlled object behaviour and interactions as defined by the object state. • Allows for extendibility and re-usability. • How? • Classes are packaged with well defined interfaces and hidden implementations.
OOP Applications • What is OOP good for? • Modelling asynchronously interacting objects. Eg: • GUIs • Event simulation • Ray tracing visualisation • CAD simulation • Real-time control/embedded systems • Robotics • Image/Video processing • Client/Server systems
OOP Applications • What is OOP not good for? • Mathematical programming (use MATLAB or MATHCAD!) • Data processing
youtube Intro to OOP http://www.youtube.com/watch?v=OQjPcS1tkDQ