1 / 17

CTEC2902 Advanced Programming in Visual Studio

CTEC2902 Advanced Programming in Visual Studio. CTEC2902 Advanced Programming. The story so far… You have Had the introductory session and lab Started revising / remembering ASP + VB fundamentals. Let’s carry on. Introducing Objects What is an “object”?. Oxford English Dictionary says

Download Presentation

CTEC2902 Advanced Programming in Visual Studio

An Image/Link below is provided (as is) to download presentation Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author. Content is provided to you AS IS for your information and personal use only. Download presentation by click this link. While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server. During download, if you can't get a presentation, the file might be deleted by the publisher.

E N D

Presentation Transcript


  1. CTEC2902Advanced Programming in Visual Studio Introducing Objects

  2. CTEC2902Advanced Programming The story so far… You have Had the introductory session and lab Started revising / remembering ASP + VB fundamentals Let’s carry on Introducing Objects

  3. Introducing Objects What is an “object”? Oxford English Dictionary says Any thing you can see or touch Examples? Any problem with this definition? Introducing Objects

  4. Introducing Objects What is an “object”? UML says Any thing you can define and interact with in your program Examples? How to recognize objects? Introducing Objects

  5. Introducing Objects How to Recognize Objects • Analyse problem specification/definition • Pick out the nouns (they are potential objects) • Not all nouns in spec become objects; some may become properties of other objects • You may need objects not mentioned in spec How to define objects? Introducing Objects

  6. Introducing Objects Defining Objects Step 1 – Identify an object An object must have a unique name Step 2 – How would you describe your object? An object may have zero or more defining characteristics (or properties) Step 3 – What can your object do? An object may have zero or more abilities or capabilities (or methods) Introducing Objects

  7. Introducing Commonality Commonality of Characteristics & Operations My Car Mum’s Car Neighbour's Car • Properties • Year • Engine Size • Colour • etc. • Methods • Move (Direction, Speed) • Turn (Direction, Degree) • Blow horn • etc. Introducing Objects

  8. Introducing Commonality Commonality of Characteristics & Operations My Sister My Neighbour My Uncle • Properties • DoB • Hair Colour • Height • etc. • Methods • Smile • Say (Something) • Wave (Hand) • etc. Introducing Objects

  9. Introducing Commonality Commonality of Characteristics & Operations Similar objects share common characteristics and perform common operations => class Introducing Objects

  10. Introducing Classes What is a class? • Generic definition of similar objects, specifying their • Shared characteristics (or properties) • Common operations (or methods) A template, from which any number of individual (unique) objects may be created Introducing Objects

  11. Introducing Classes Class-Object Relationship A class is where you define … the properties and capabilities that objects can have An object is what you create and use in your solution, as a specific instance of a class e.g. Class – Car Object – My Mum’s car Object – Neighbour’s car • e.g. Class - Computer • Object - My computer at home • Object – The computer in the lab • Object – My laptop Introducing Objects

  12. Introducing Classes E.g., a class & its instance, to represent this university • Class – University • Instance – DMU • Instance – Leicester University E.g., a VB control (class) & two typical instances of it • Class – List box • Object – lstSurnames • Object - lstBooks How do we specify/design classes? Introducing Objects

  13. Introducing Classes E.g., Specifying a class Unique name, indicating purpose & functionality clsCar e.g. Step 1 Registration Make Model Colour Properties (like variables) Data types & validation Read-Write or Read-Only e.g. Step 2 Start Engine Stop Engine Blow Horn Turn Right (Degree) Put In Gear (Number) Methods As Subs or Functions (with/without parameters) e.g. Step 3 Introducing Objects

  14. Each instance has • same properties but with (some or all) different property values • same methods Creating Objects Creating a Car Object - An Instance of Class “Car” Object created with a unique name Specific values assigned to properties A class may have many instances; MumsCar, DadsCar, PoliceCar, etc. MyCar Registration – FN 02 XTC Make - Volkswagen Model - Polo Colour - Silver • Each instance must be • individually created • uniquely named Start Engine Stop Engine Blow Horn Turn Right (12) Put In Gear (3) Introducing Objects

  15. Introducing Classes • Exercise: • Define a class to represent people (or persons) • Class name is “Person” Class Name Person • Properties Name • Surname • Date of Birth • Height • Weight • Hair Colour • Can Swim • etc. • Methods Walk (Speed) • Run (Speed) • Sit • Stand • Say (What) • etc. Introducing Objects

  16. Introducing Classes • Exercise: • Define a class to represent rooms • Class name is “Room” Class Name Room • Properties ID • Seating Capacity • Occupancy • OHP • Internet access • Layout • Air conditioner • etc. Methods SetAirCon(State) Enter(Who) Leave(Who) Other methods? Introducing Objects

  17. Introducing Classes Keep up the good work Introducing Objects

More Related