SlideShare a Scribd company logo
1 of 58
Principles of Object Oriented Programming David GiardMCTS, MCSE, MCDBA, MCSD DavidGiard.com
nPlus1.org nPlus1.org is a site dedicated to helping Architects, aspiring Architects and Lead Developers learn, connect and contribute. http://nplus1.org
Agenda The Challenge The Basics Bringing Order To Chaos Guiding Principles
The Challenge
The Complexity of software derives from 4 elements: Complexity of the problem domain Difficulty to manage the development process Flexibility possible through software Software problems often model discrete systems
? How do you write great software every time?
Good question… lots of answers! The customer–friendly programmer says: “Great software always does what the customer wants it to. So even if the customer thinks of new ways to use the software, it doesn’t break or give them unexpected results.”
Good question… lots of answers! The design–guru programmer says: “Great software is when you use tried-and-true design patterns and principles. You’ve kept your objects loosely coupled, and your code opens for extension but closed for modification. That also helps keep the code more usable, so you don’t have to rework everything to use parts of your application over and over again.”
Good question… lots of answers! The object-oriented programmer says: “Great software is code that is object-oriented. So there's not a bunch of duplicate code, and each object pretty much controls its own behavior. It’s also easy to extend because your design is really solid and flexible.”
Answer: Simplify Complexity Answer: Eschew Obfuscation
The Basics
The Basics Objects Classes Members Properties Methods Events Constructors Instances Message Passing
Defining Classes class Name:BaseType{    // Members } class MyType{    public String SomeString;    public Int32 x;    public Int32 y;   public void DoSomething()	{	…	} }
Class Members Fields The state of an object Properties Also maintain state Methods Constructors Functions Properties (smart fields) Members come in two basic forms Instance Static
Fields Maintain state of an object Accessing a field class Point{ public Int32 X;   public Int32 Y;    private In32 _x; }  Point p = new Point(); p.X = 100; p.Y = 200; Console.WriteLine(p.X);
Properties Methods that look like fields (smart fields) Can have read-only or write-only properties class Point{    Int32 _x;    Int32 _y; public Int32 X   {       get{return _x;}       set{_x = value;} }    public Int32 Y   {       get{return _y;}       set{_y = value;} } }
Methods class MyType{    public Int32 SomeMethod()   {      Int32 z = 0;       // Code omitted… return z;    }    public static void StaticMethod()   {       // Do something    } } MyType t = new MyType(); t.SomeMethod();
Method Parameters class MyType{    public Int32 AddNumbers(Int32 x, Int32 y)   {       Int32 z = x + y; return z;    } } MyType t = new MyType(); t.AddNumbers(1,2);
Types and Instances
Instantiating an Object public class MyType {   public string MyStringField; public void InstanceMethod()   {       // Do something    } } MyType o = new MyType(); o.MyStringField = “Hello”; String x = o.MyStringField; o.InstanceMethod();
Static Types public static class MyType{ 	public static void StaticMethod() { 		// Do something 	} } MyType.StaticMethod();
Constructors Constructors are used to initialize fields class Point { private Int32 _x; private Int32 _y;    public Point()   {	// Setup code   }    public Point(Int32 xCoordinate, Int32 yCoordinate)   {      _x = xCoordinate; _y = yCoordinate;    } }
Referencing an object Objects are reference types Pointer to memory MyType obj1 = new MyType(); obj2 = obj1; obj2.Color = “Red”; Console.WriteLine(obj1.Color)
Event Handling C# and VB have built in support for events Great for dealing with objects in an event-driven operating system More than one type can register interest in a single event A single type can register interest in any number of events
Event Handling class MyForm:Form{ MyForm(){       Button button = new Button(); button.Text = "Button"; button.Click += new EventHandler(HandleClick); Controls.Add(button);    }    void HandleClick(Object sender, EventArgs e){ MessageBox.Show("The Click event fired!");    }    public static void Main(){ Application.Run(new MyForm());    }   }
Designing Types: Accessibilities public – Accessible to all private – Accessible to containing class protected – Accessible to containing or derived classes internal – Accessible to code in same assembly
Demo
Bringing Order to the ChaosObject Oriented Programming
Bringing Order to the ChaosConcepts of Object Orientation Encapsulation Abstraction Inheritance Polymorphism Decoupling
Bringing Order to the Chaos Encapsulation and Abstraction
Bringing Order to the ChaosThe Role of Encapsulation Car Transmission Engine Stop() Start() Axel Axel Drive() Wheel Wheel Wheel Wheel
Bringing Order to the ChaosThe Role of Abstraction
Demo
Bringing Order to the ChaosThe Role of Inheritance
Inheritance Vehicle Plane +Start() +Stop() +Steer() +Fly() +Start() +Stop() +Steer() Train +Start() +Stop() +Steer() +BlowHorn() Automobile +Start() +Stop() +Steer() +Honk()
Polymorphism
Designing Types: Polymorphism Use the virtual keyword to make a method virtual In derived class, override method is marked with the override keyword Example ToString() method in Object class Example derived class overriding ToString() public virtual string ToString();  class SomeClass:Object{    public override String ToString(){       return “Some String Representing State”;    } }
Demo
Interfaces Define public members No Implementation Your types can implement interfaces Must implement all methods in the interface interface IName{    // Members } Class ClassName: IName{ }
Interfaces using System;   class SomeType{};   class SortType:SomeType, IComparable{    Int32 val;    public SortType(Int32 val){       this.val = val;    }    public Int32 CompareTo(Object obj){       return this.val - ((SortType)obj).val;    }      public override string ToString(){       return val.ToString();    } }   class App{    public static void Main(){ SomeType[] objs = new SomeType[]{          new SortType(3), new SortType(1), new SortType(2)};   Array.Sort(objs); foreach(SomeType o in objs){ Console.WriteLine(o.ToString());       }     } }
Bringing Order to the ChaosThe Role of Decoupling
Demo
Airplane  speed: int getSpeed(): int setSpeed(int) UML and Class Diagrams Class Diagram Name Member Variables   name:type Methods  name(parameters the method uses): return type
Visual Studio Class Designer
Demo
Guiding Principles
SOLIDPrinciples Single responsibility Open Close Liskov Substitution. Interface Segregation  Dependency Injection
Liskovsubstitution public class Rectangle{  public virtual int Height { get; set; }  public virtual int Width { get; set; }  public int Area()  {    return Height * Width;  }}
Liskovsubstitution rectangle.Height = 4;rectangle.Width = 5;int expectedArea = 20;int actualArea = rectangle.Area();Debug.Assert(expectedArea == actualArea);
Liskovsubstitution public class Square : Rectangle {    public override int Height {    get { return base.Height; }    set { base.Height = value;          base.Width = value;    }  }  public override int Width {    get { return base.Width; }    set { base.Width = value;          base.Height = value;    }  }}
Liskovsubstitution Rectangle square = new Square();square.Width = 4;square.Height = 5;int expectedArea = 20;int actualArea = rectangle.Area();Debug.Assert(expectedArea == actualArea);
Interfacesegregationprinciple interface IWorker {	public void work();	public void eat();}
Interfacesegregationprinciple public class Customer  {  private IFoo _foo;  public Customer(IFoo foo)   { this._foo= foo;     } }

More Related Content

What's hot (16)

Data oriented design
Data oriented designData oriented design
Data oriented design
 
A well-typed program never goes wrong
A well-typed program never goes wrongA well-typed program never goes wrong
A well-typed program never goes wrong
 
C++ Constructor destructor
C++ Constructor destructorC++ Constructor destructor
C++ Constructor destructor
 
Concept of constructors
Concept of constructorsConcept of constructors
Concept of constructors
 
Constructor and destructor
Constructor and destructorConstructor and destructor
Constructor and destructor
 
Writing Node.js Bindings - General Principles - Gabriel Schulhof
Writing Node.js Bindings - General Principles - Gabriel SchulhofWriting Node.js Bindings - General Principles - Gabriel Schulhof
Writing Node.js Bindings - General Principles - Gabriel Schulhof
 
Constructor & Destructor
Constructor & DestructorConstructor & Destructor
Constructor & Destructor
 
04. constructor & destructor
04. constructor & destructor04. constructor & destructor
04. constructor & destructor
 
Structure in c
Structure in cStructure in c
Structure in c
 
C++lecture9
C++lecture9C++lecture9
C++lecture9
 
Intake 38 5 1
Intake 38 5 1Intake 38 5 1
Intake 38 5 1
 
Dotnet unit 4
Dotnet unit 4Dotnet unit 4
Dotnet unit 4
 
Op ps
Op psOp ps
Op ps
 
Java Concepts
Java ConceptsJava Concepts
Java Concepts
 
Chapter 2
Chapter 2Chapter 2
Chapter 2
 
C#ppt
C#pptC#ppt
C#ppt
 

Viewers also liked

Le Startup Innovative, Opportunità per il Territorio. Licata (AG), 17 Ottobre...
Le Startup Innovative, Opportunità per il Territorio. Licata (AG), 17 Ottobre...Le Startup Innovative, Opportunità per il Territorio. Licata (AG), 17 Ottobre...
Le Startup Innovative, Opportunità per il Territorio. Licata (AG), 17 Ottobre...Eugenio Agnello
 
Transforming HR in an Uncertain Economy: Priorities and Processes That Delive...
Transforming HR in an Uncertain Economy: Priorities and Processes That Delive...Transforming HR in an Uncertain Economy: Priorities and Processes That Delive...
Transforming HR in an Uncertain Economy: Priorities and Processes That Delive...welshms
 
Caching and Microsoft Distributed Cache (aka "Velocity")
Caching and Microsoft Distributed Cache (aka "Velocity")Caching and Microsoft Distributed Cache (aka "Velocity")
Caching and Microsoft Distributed Cache (aka "Velocity")David Giard
 
GrouperEye Product Plan
GrouperEye Product PlanGrouperEye Product Plan
GrouperEye Product Planwilliamstj
 
Verifica Di Resistenza Al Fuoco. Nuove Norme Tecniche 2008
Verifica Di Resistenza Al Fuoco. Nuove Norme Tecniche 2008Verifica Di Resistenza Al Fuoco. Nuove Norme Tecniche 2008
Verifica Di Resistenza Al Fuoco. Nuove Norme Tecniche 2008Eugenio Agnello
 
2009 03 31 Healthstory Webinar Presentation
2009 03 31 Healthstory Webinar Presentation2009 03 31 Healthstory Webinar Presentation
2009 03 31 Healthstory Webinar PresentationNick van Terheyden
 
Reaching More Customers in 2015 With a Responsive Mobile Website Design
Reaching More Customers in 2015 With a Responsive Mobile Website DesignReaching More Customers in 2015 With a Responsive Mobile Website Design
Reaching More Customers in 2015 With a Responsive Mobile Website DesignRichard Sink
 
Impianti Fotovoltaici Principi Basilari Ingg Conti Scuto Ott.'08
Impianti Fotovoltaici Principi Basilari Ingg Conti Scuto Ott.'08Impianti Fotovoltaici Principi Basilari Ingg Conti Scuto Ott.'08
Impianti Fotovoltaici Principi Basilari Ingg Conti Scuto Ott.'08Eugenio Agnello
 
Towers Perrin's Health Care 360 Performance Study - Value for Your Organization
Towers Perrin's Health Care 360 Performance Study - Value for Your OrganizationTowers Perrin's Health Care 360 Performance Study - Value for Your Organization
Towers Perrin's Health Care 360 Performance Study - Value for Your Organizationwelshms
 
Sistemi di Gestione Ambientale. La Filiera delle Responsabilità nel Settore d...
Sistemi di Gestione Ambientale. La Filiera delle Responsabilità nel Settore d...Sistemi di Gestione Ambientale. La Filiera delle Responsabilità nel Settore d...
Sistemi di Gestione Ambientale. La Filiera delle Responsabilità nel Settore d...Eugenio Agnello
 
Colorado Climate
Colorado ClimateColorado Climate
Colorado Climatextina44
 
Greenwich IATA Presentation 7 Oct 2008 Final Website
Greenwich IATA Presentation 7 Oct 2008 Final WebsiteGreenwich IATA Presentation 7 Oct 2008 Final Website
Greenwich IATA Presentation 7 Oct 2008 Final Websitercsmuk
 
The Business of Mobile Apps
The Business of Mobile AppsThe Business of Mobile Apps
The Business of Mobile AppsNorman Liang
 

Viewers also liked (20)

Le Startup Innovative, Opportunità per il Territorio. Licata (AG), 17 Ottobre...
Le Startup Innovative, Opportunità per il Territorio. Licata (AG), 17 Ottobre...Le Startup Innovative, Opportunità per il Territorio. Licata (AG), 17 Ottobre...
Le Startup Innovative, Opportunità per il Territorio. Licata (AG), 17 Ottobre...
 
test
testtest
test
 
Transforming HR in an Uncertain Economy: Priorities and Processes That Delive...
Transforming HR in an Uncertain Economy: Priorities and Processes That Delive...Transforming HR in an Uncertain Economy: Priorities and Processes That Delive...
Transforming HR in an Uncertain Economy: Priorities and Processes That Delive...
 
Caching and Microsoft Distributed Cache (aka "Velocity")
Caching and Microsoft Distributed Cache (aka "Velocity")Caching and Microsoft Distributed Cache (aka "Velocity")
Caching and Microsoft Distributed Cache (aka "Velocity")
 
GrouperEye Product Plan
GrouperEye Product PlanGrouperEye Product Plan
GrouperEye Product Plan
 
Verifica Di Resistenza Al Fuoco. Nuove Norme Tecniche 2008
Verifica Di Resistenza Al Fuoco. Nuove Norme Tecniche 2008Verifica Di Resistenza Al Fuoco. Nuove Norme Tecniche 2008
Verifica Di Resistenza Al Fuoco. Nuove Norme Tecniche 2008
 
2009 03 31 Healthstory Webinar Presentation
2009 03 31 Healthstory Webinar Presentation2009 03 31 Healthstory Webinar Presentation
2009 03 31 Healthstory Webinar Presentation
 
Reaching More Customers in 2015 With a Responsive Mobile Website Design
Reaching More Customers in 2015 With a Responsive Mobile Website DesignReaching More Customers in 2015 With a Responsive Mobile Website Design
Reaching More Customers in 2015 With a Responsive Mobile Website Design
 
Impianti Fotovoltaici Principi Basilari Ingg Conti Scuto Ott.'08
Impianti Fotovoltaici Principi Basilari Ingg Conti Scuto Ott.'08Impianti Fotovoltaici Principi Basilari Ingg Conti Scuto Ott.'08
Impianti Fotovoltaici Principi Basilari Ingg Conti Scuto Ott.'08
 
Venus
VenusVenus
Venus
 
Towers Perrin's Health Care 360 Performance Study - Value for Your Organization
Towers Perrin's Health Care 360 Performance Study - Value for Your OrganizationTowers Perrin's Health Care 360 Performance Study - Value for Your Organization
Towers Perrin's Health Care 360 Performance Study - Value for Your Organization
 
Sistemi di Gestione Ambientale. La Filiera delle Responsabilità nel Settore d...
Sistemi di Gestione Ambientale. La Filiera delle Responsabilità nel Settore d...Sistemi di Gestione Ambientale. La Filiera delle Responsabilità nel Settore d...
Sistemi di Gestione Ambientale. La Filiera delle Responsabilità nel Settore d...
 
the great eight
the great eightthe great eight
the great eight
 
Social awareness
Social awarenessSocial awareness
Social awareness
 
J query
J queryJ query
J query
 
Colorado Climate
Colorado ClimateColorado Climate
Colorado Climate
 
Greenwich IATA Presentation 7 Oct 2008 Final Website
Greenwich IATA Presentation 7 Oct 2008 Final WebsiteGreenwich IATA Presentation 7 Oct 2008 Final Website
Greenwich IATA Presentation 7 Oct 2008 Final Website
 
μάθηση
μάθησημάθηση
μάθηση
 
Brand Establisher
Brand EstablisherBrand Establisher
Brand Establisher
 
The Business of Mobile Apps
The Business of Mobile AppsThe Business of Mobile Apps
The Business of Mobile Apps
 

Similar to Intro to object oriented programming

Getting Started - Console Program and Problem Solving
Getting Started - Console Program and Problem SolvingGetting Started - Console Program and Problem Solving
Getting Started - Console Program and Problem SolvingHock Leng PUAH
 
SPF Getting Started - Console Program
SPF Getting Started - Console ProgramSPF Getting Started - Console Program
SPF Getting Started - Console ProgramHock Leng PUAH
 
Cleaner Code: How Clean Code is Functional Code
Cleaner Code: How Clean Code is Functional CodeCleaner Code: How Clean Code is Functional Code
Cleaner Code: How Clean Code is Functional CodeDave Fancher
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharpvoegtu
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharpvoegtu
 
C# Summer course - Lecture 3
C# Summer course - Lecture 3C# Summer course - Lecture 3
C# Summer course - Lecture 3mohamedsamyali
 
JSLounge - TypeScript 소개
JSLounge - TypeScript 소개JSLounge - TypeScript 소개
JSLounge - TypeScript 소개Reagan Hwang
 
classes object fgfhdfgfdgfgfgfgfdoop.pptx
classes object  fgfhdfgfdgfgfgfgfdoop.pptxclasses object  fgfhdfgfdgfgfgfgfdoop.pptx
classes object fgfhdfgfdgfgfgfgfdoop.pptxarjun431527
 
Introduction to c#
Introduction to c#Introduction to c#
Introduction to c#singhadarsh
 
.Net december 2017 updates - Tamir Dresher
.Net december 2017 updates - Tamir Dresher.Net december 2017 updates - Tamir Dresher
.Net december 2017 updates - Tamir DresherTamir Dresher
 
Microsoft dynamics ax 2012 development introduction part 2/3
Microsoft dynamics ax 2012 development introduction part 2/3Microsoft dynamics ax 2012 development introduction part 2/3
Microsoft dynamics ax 2012 development introduction part 2/3Ali Raza Zaidi
 
Implementation of interface9 cm604.30
Implementation of interface9 cm604.30Implementation of interface9 cm604.30
Implementation of interface9 cm604.30myrajendra
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programmingRenas Rekany
 

Similar to Intro to object oriented programming (20)

Getting Started - Console Program and Problem Solving
Getting Started - Console Program and Problem SolvingGetting Started - Console Program and Problem Solving
Getting Started - Console Program and Problem Solving
 
SPF Getting Started - Console Program
SPF Getting Started - Console ProgramSPF Getting Started - Console Program
SPF Getting Started - Console Program
 
Cleaner Code: How Clean Code is Functional Code
Cleaner Code: How Clean Code is Functional CodeCleaner Code: How Clean Code is Functional Code
Cleaner Code: How Clean Code is Functional Code
 
Object-oriented Basics
Object-oriented BasicsObject-oriented Basics
Object-oriented Basics
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharp
 
Introduction to csharp
Introduction to csharpIntroduction to csharp
Introduction to csharp
 
C# Summer course - Lecture 3
C# Summer course - Lecture 3C# Summer course - Lecture 3
C# Summer course - Lecture 3
 
Clean code
Clean codeClean code
Clean code
 
JSLounge - TypeScript 소개
JSLounge - TypeScript 소개JSLounge - TypeScript 소개
JSLounge - TypeScript 소개
 
classes object fgfhdfgfdgfgfgfgfdoop.pptx
classes object  fgfhdfgfdgfgfgfgfdoop.pptxclasses object  fgfhdfgfdgfgfgfgfdoop.pptx
classes object fgfhdfgfdgfgfgfgfdoop.pptx
 
Introduction to c#
Introduction to c#Introduction to c#
Introduction to c#
 
Classes1
Classes1Classes1
Classes1
 
Java 2
Java   2Java   2
Java 2
 
.Net december 2017 updates - Tamir Dresher
.Net december 2017 updates - Tamir Dresher.Net december 2017 updates - Tamir Dresher
.Net december 2017 updates - Tamir Dresher
 
1204csharp
1204csharp1204csharp
1204csharp
 
Microsoft dynamics ax 2012 development introduction part 2/3
Microsoft dynamics ax 2012 development introduction part 2/3Microsoft dynamics ax 2012 development introduction part 2/3
Microsoft dynamics ax 2012 development introduction part 2/3
 
Oops concept
Oops conceptOops concept
Oops concept
 
Implementation of interface9 cm604.30
Implementation of interface9 cm604.30Implementation of interface9 cm604.30
Implementation of interface9 cm604.30
 
Object oriented programming
Object oriented programmingObject oriented programming
Object oriented programming
 
X++ 1.pptx
X++ 1.pptxX++ 1.pptx
X++ 1.pptx
 

More from David Giard

Data Visualization - CodeMash 2022
Data Visualization - CodeMash 2022Data Visualization - CodeMash 2022
Data Visualization - CodeMash 2022David Giard
 
Azure data factory
Azure data factoryAzure data factory
Azure data factoryDavid Giard
 
University of Texas lecture: Data Science Tools in Microsoft Azure
University of Texas lecture: Data Science Tools in Microsoft AzureUniversity of Texas lecture: Data Science Tools in Microsoft Azure
University of Texas lecture: Data Science Tools in Microsoft AzureDavid Giard
 
University of Texas, Data Science, March 29, 2018
University of Texas, Data Science, March 29, 2018University of Texas, Data Science, March 29, 2018
University of Texas, Data Science, March 29, 2018David Giard
 
Intro to cloud and azure
Intro to cloud and azureIntro to cloud and azure
Intro to cloud and azureDavid Giard
 
Azure and deep learning
Azure and deep learningAzure and deep learning
Azure and deep learningDavid Giard
 
Azure and Deep Learning
Azure and Deep LearningAzure and Deep Learning
Azure and Deep LearningDavid Giard
 
Cloud and azure and rock and roll
Cloud and azure and rock and rollCloud and azure and rock and roll
Cloud and azure and rock and rollDavid Giard
 
Own your own career advice from a veteran consultant
Own your own career   advice from a veteran consultantOwn your own career   advice from a veteran consultant
Own your own career advice from a veteran consultantDavid Giard
 
You and Your Tech Community
You and Your Tech CommunityYou and Your Tech Community
You and Your Tech CommunityDavid Giard
 
Microsoft Azure IoT overview
Microsoft Azure IoT overviewMicrosoft Azure IoT overview
Microsoft Azure IoT overviewDavid Giard
 
Cloud and azure and rock and roll
Cloud and azure and rock and rollCloud and azure and rock and roll
Cloud and azure and rock and rollDavid Giard
 
Big Data on azure
Big Data on azureBig Data on azure
Big Data on azureDavid Giard
 
Microsoft azure without microsoft
Microsoft azure without microsoftMicrosoft azure without microsoft
Microsoft azure without microsoftDavid Giard
 
Azure mobile apps
Azure mobile appsAzure mobile apps
Azure mobile appsDavid Giard
 
Building a TV show with Angular, Bootstrap, and Web Services
Building a TV show with Angular, Bootstrap, and Web ServicesBuilding a TV show with Angular, Bootstrap, and Web Services
Building a TV show with Angular, Bootstrap, and Web ServicesDavid Giard
 
Effective Data Visualization
Effective Data VisualizationEffective Data Visualization
Effective Data VisualizationDavid Giard
 
Angular2 and TypeScript
Angular2 and TypeScriptAngular2 and TypeScript
Angular2 and TypeScriptDavid Giard
 

More from David Giard (20)

Data Visualization - CodeMash 2022
Data Visualization - CodeMash 2022Data Visualization - CodeMash 2022
Data Visualization - CodeMash 2022
 
Azure data factory
Azure data factoryAzure data factory
Azure data factory
 
Azure functions
Azure functionsAzure functions
Azure functions
 
University of Texas lecture: Data Science Tools in Microsoft Azure
University of Texas lecture: Data Science Tools in Microsoft AzureUniversity of Texas lecture: Data Science Tools in Microsoft Azure
University of Texas lecture: Data Science Tools in Microsoft Azure
 
University of Texas, Data Science, March 29, 2018
University of Texas, Data Science, March 29, 2018University of Texas, Data Science, March 29, 2018
University of Texas, Data Science, March 29, 2018
 
Intro to cloud and azure
Intro to cloud and azureIntro to cloud and azure
Intro to cloud and azure
 
Azure and deep learning
Azure and deep learningAzure and deep learning
Azure and deep learning
 
Azure and Deep Learning
Azure and Deep LearningAzure and Deep Learning
Azure and Deep Learning
 
Custom vision
Custom visionCustom vision
Custom vision
 
Cloud and azure and rock and roll
Cloud and azure and rock and rollCloud and azure and rock and roll
Cloud and azure and rock and roll
 
Own your own career advice from a veteran consultant
Own your own career   advice from a veteran consultantOwn your own career   advice from a veteran consultant
Own your own career advice from a veteran consultant
 
You and Your Tech Community
You and Your Tech CommunityYou and Your Tech Community
You and Your Tech Community
 
Microsoft Azure IoT overview
Microsoft Azure IoT overviewMicrosoft Azure IoT overview
Microsoft Azure IoT overview
 
Cloud and azure and rock and roll
Cloud and azure and rock and rollCloud and azure and rock and roll
Cloud and azure and rock and roll
 
Big Data on azure
Big Data on azureBig Data on azure
Big Data on azure
 
Microsoft azure without microsoft
Microsoft azure without microsoftMicrosoft azure without microsoft
Microsoft azure without microsoft
 
Azure mobile apps
Azure mobile appsAzure mobile apps
Azure mobile apps
 
Building a TV show with Angular, Bootstrap, and Web Services
Building a TV show with Angular, Bootstrap, and Web ServicesBuilding a TV show with Angular, Bootstrap, and Web Services
Building a TV show with Angular, Bootstrap, and Web Services
 
Effective Data Visualization
Effective Data VisualizationEffective Data Visualization
Effective Data Visualization
 
Angular2 and TypeScript
Angular2 and TypeScriptAngular2 and TypeScript
Angular2 and TypeScript
 

Recently uploaded

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Scott Keck-Warren
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Mark Simos
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfAlex Barbosa Coqueiro
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024BookNet Canada
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsMiki Katsuragi
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupFlorian Wilhelm
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfRankYa
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embeddingZilliz
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Manik S Magar
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii SoldatenkoFwdays
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024Stephanie Beckett
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Enterprise Knowledge
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationSlibray Presentation
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationSafe Software
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsSergiu Bodiu
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubKalema Edgar
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Mattias Andersson
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsRizwan Syed
 

Recently uploaded (20)

Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024Advanced Test Driven-Development @ php[tek] 2024
Advanced Test Driven-Development @ php[tek] 2024
 
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
Tampa BSides - Chef's Tour of Microsoft Security Adoption Framework (SAF)
 
Unraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdfUnraveling Multimodality with Large Language Models.pdf
Unraveling Multimodality with Large Language Models.pdf
 
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
New from BookNet Canada for 2024: BNC CataList - Tech Forum 2024
 
Vertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering TipsVertex AI Gemini Prompt Engineering Tips
Vertex AI Gemini Prompt Engineering Tips
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Streamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project SetupStreamlining Python Development: A Guide to a Modern Project Setup
Streamlining Python Development: A Guide to a Modern Project Setup
 
Search Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdfSearch Engine Optimization SEO PDF for 2024.pdf
Search Engine Optimization SEO PDF for 2024.pdf
 
Training state-of-the-art general text embedding
Training state-of-the-art general text embeddingTraining state-of-the-art general text embedding
Training state-of-the-art general text embedding
 
Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!Anypoint Exchange: It’s Not Just a Repo!
Anypoint Exchange: It’s Not Just a Repo!
 
"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko"Debugging python applications inside k8s environment", Andrii Soldatenko
"Debugging python applications inside k8s environment", Andrii Soldatenko
 
What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024What's New in Teams Calling, Meetings and Devices March 2024
What's New in Teams Calling, Meetings and Devices March 2024
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024Designing IA for AI - Information Architecture Conference 2024
Designing IA for AI - Information Architecture Conference 2024
 
Connect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck PresentationConnect Wave/ connectwave Pitch Deck Presentation
Connect Wave/ connectwave Pitch Deck Presentation
 
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry InnovationBeyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
Beyond Boundaries: Leveraging No-Code Solutions for Industry Innovation
 
DevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platformsDevEX - reference for building teams, processes, and platforms
DevEX - reference for building teams, processes, and platforms
 
Unleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding ClubUnleash Your Potential - Namagunga Girls Coding Club
Unleash Your Potential - Namagunga Girls Coding Club
 
Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?Are Multi-Cloud and Serverless Good or Bad?
Are Multi-Cloud and Serverless Good or Bad?
 
Scanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL CertsScanning the Internet for External Cloud Exposures via SSL Certs
Scanning the Internet for External Cloud Exposures via SSL Certs
 

Intro to object oriented programming

Editor's Notes

  1. Photo by meganpru(Creative Commons License)http://www.flickr.com/photos/meganpru/57943941/
  2. Complexity of the problem domainThe problems we try to solve in software often involve elements of inescapable complexity, in which we find a myriad of competing, perhaps even contradictory, requirementsDifficulty to manage the development processThe fundamental task of the software development team is to engineer the illusion of simplicity – to shield users from this vast and often arbitrary external complexityFlexibility possible through softwareSoftware offers the ultimate flexibility, so it is possible for a developer to express almost any kinf of abstractionCharacterizing the behavior of discrete systemsA lot of software is designed to model discrete systems. Discrete systems are not easily modeled in procedural code.
  3. Photo by All Glass Photo's photostream(Creative Commons License)http://www.flickr.com/photos/jim_rafferty_uk/2203549363/
  4. Sample Dialog:In C# like any other object oriented language, the members in a type are basically either fields or methods. However, C# has a rich selection of field and method options.Fields are the data or state of an object or type, and methods are the functionality.Members come in two basic forms, instance and static. Instance members are the most common, and there will be one per instance or object. Static members are shared amongst instances and are one per type.Instance methods require an instance to be called, but static methods can be called directly just using the name of the type. The automatic “this” parameter is passed to instance methods, but not static methods.In .NET or managed code it is a common design pattern to create a class that cannot be instantiated, with nothing but static methods. This is a way of creating methods that are sort-of global, but are still logically grouped with other related methods. The System.Console class is an example of this design pattern.Speaker Instructions:You don’t have to say the stuff in that last paragraph, but concrete examples like these do help to nail down the ideas for the listeners.
  5. As an object oriented programmer you will first and foremost create instances of types. This means that you will use a definition for a type, which has a name such as String or ArrayList, to create an actual object in memory. This object is structured based on the details described in the type’s definition.After you have created an object, you can use it by calling methods and/or referencing fields on the object. When you are finished with the object it must be cleaned up. Is some environments you do this explicitly; in others, such as C# or Java, cleanup is done for you by the system.Creating instances is a nice introduction to OO programming, but eventually you will have to define your own type. By doing so you create a new classification for a kind of object that can be created. You give the type a name, and you create members of the type such as methods and fields.It is important to distinguish between types and instances, so I will make an analogy. Think of the type as a descriptive tool (like a cookie cutter), while an instance is an object created from that description (in the same way that a cookie is created from a cookie cutter).
  6. Static typesare most often used when you need to call a method repeatedly.It doesn’t make sense to waste the overhead of instantiating an object just to call a method.When using a static type, only one instance of the class is created.
  7. Sample Dialog:C# supports constructor syntax much like C++. However, unlike C++ it is invalid to call a constructor method directly, so if you wish to implement a constructor in terms of another constructor you must use the special colon-this notation you see here.In this example, the simpler Point() constructor automatically calls the more complex constructor with the default x and y values of 0.You can indicate which base constructor to callUse the base keywordYou can implement simpler constructors in terms of more complex ones with the this keyword (suggested)Speaker Instructions:FYI, it is recommended that you have only one constructor for a type, and that the rest of the constructors be implemented in terms of this one. However, this is not always possible and must be handled on a type-by-type bases.
  8. An object is a reference type.This means that variables that refer to an object are simply pointing to that object. Multiple variables can be pointing to the same object, which can cause confusion. Accessing any of these variables will access or modify the object.From the computer’s point of view, objects are data. They are the culmination of their fields and enough information to indicate their type. Often this data is complex and sizeable, and it is stored in the memory heap of the program that created the instance.Because objects so often live in the heap-memory of a program, the most common way of dealing with an instance is through a reference variable. The reference variable can be a global or local variable, or it can be a field in another object. Either way, there are some rules of reference variables.Reference variables have a type associated with them. For every object-type defined in an object oriented system, there is a matching reference variable type that is used to refer to instances of the type.Reference variables can refer to an instance or object, or they can refer to null (in most OO languages anyway). A null reference simply indicates that this variable does not refer to any object, but could have an object reference assigned to it.Reference variables do not always refer to objects of the exact sametype as the reference variable. This can be confusing, but in fact the rules are simple. A reference variable must refer to an object of matching type or it must refer to an object that is ultimately derived from the matching type.Looking back to the relationship between Automobile and Machine, a reference variable of type Automobile can only refer to an instance of Automobile; however a reference variable of type Machine can refer to an instance of Machine or an instance of Automobile. You can look at this as being possible, because Automobile is a Machine through the affect of derivation.Reference variables are your means of access to an object or instance. There are two related rules of reference variables.Regardless of what type of instance your reference variable refers to, it is the type of the variable that constrains how you can touch or affect the instance. Regardless of what type of reference variable you are using to refer to an object, the type of the object never changes for the life of the object.
  9. Sample Dialog:C# has built in support for event notification and handling, which is great for dealing with OSs that are becoming increasingly event driven.Events in C# are very flexible compared to the virtual-function method of responding to system events.Speaker Instructions:We have several slides on this, so you don’t have to say everything on this slide.
  10. Sample Dialog:The source code on this slide shows a simple class derived from Form. The interesting part, however, is how the class registers its interest in the Click event defined by an instance of the Button class. The MyForm class indicates which of its methods (in this case the HandleClick method) should be called when the event is fired.
  11. Sample Dialog:Like C++ and Java, C# supports member and class accessibility. The default accessibility is private, and you must decorate members with an accessibility modifier to set a different accessibility.The most common accessibilities are public, private, and protected. However, C# introduces the idea of an internal accessibility which allows access by any class in the same binary assembly file. This is similar to, but more flexible than the C++ friend class.Speaker Instructions:You could spend forever talking about accessibility. If you like you can edge into the direction of design by saying that fields should be private, and methods can be public, etc. But be careful, because you could sink ten minutes on this slide alone.
  12. Encapsulation and Abstraction are related concepts
  13. Encapsulation is the hiding of the internal mechanisms and data structures of a software component behind a defined interface.We don’t need to understand the details of how the component works internally in order to use that component.Increases integrity by preventing external users from setting internal state of a component to an invalid state.
  14. Abstraction is simplifying complex reality by modeling classes appropriate to the problem, and working at the most appropriate level of inheritance for a given aspect of the problem.
  15. The object structure is important because it illustrates how different objects collaborate with one another through patterns of interaction.
  16. A type defines a number of fields and methods. A derived type inherits the base type’s fields and methods, and adds more of its own, to become a new type (extending from the exisiting one).
  17. Polymorphism is closely related to type-derivation and reference variables. But it is an advanced topic, and can be difficult to describe. The goal is to allow a generic piece of code to work with objects or instances generically; meanwhile we want the objects themselves to do the right thing based on their respective types.
  18. Sample Dialog:To create a virtual function in C# you must attribute your method with the virtual keyword. Virtual methods can be public, protected, or protected internal.To override a virtual method in a derived class you must explicitly indicate your intent using the override keyword. Your derived method must also match the base method signature exactly.Speaker Instructions:The override keyword is actually part of the versioning story in the .NET Framework. But this is probably a bit too much to explain in the discussion. However, for your own study you may want to look up the “override” and “new” keywords in the documentation, as this is an example of a feature that is much more well thought out than the equivalent feature in Java.Another Example:using System; class App{ public static void Main(String[] args){ Object[] objects = new Object[]{ new Lemon(), new Grapefruit(), new Truck(), new Lemon(), new Lime() };foreach(Object o in objects){Console.WriteLine(o.ToString()); } }} class Citrus{ public override String ToString(){ return "I am a "+this.GetType().ToString(); }} class Lime:Citrus{} class Lemon:Citrus{} class Grapefruit:Citrus{} class Truck{ public override String ToString(){ return "Truck here"; }}
  19. Sample Dialog:Interfaces are an excellent way for a type to take on a role without being derived from a type that defines this role. For example, two totally unrelated types can be sortable and therefore take on the well-defined ability to be sorted, even though they are not derived in the same derivation hierarchy. This is possible through interfaces.In C# you cannot have multiple base classes, but a type can implement any number of interfaces.You will find that you implement pre-existing interfaces often, but from time to time you will have to define your own interface. Interfaces can include only methods, properties, and events. It is not valid for an interface to include a field. Interfaces are defined using the interface keyword as shown here.
  20. Interfaces are a great feature of object oriented programming. Some languages such as C++ support a concept called multiple derivation. The .NET Framework does not allow for multiple inheritance, and as a result neither does C#. Sometimes, it is nice, however, for a type to be able to take on several roles. This is where Interfaces come in.
  21. When Designing a complex software project, it is essential to decompose it into smaller and smaller parts, each of which we may then refine independently.
  22. Poster by Derrick Bailey
  23. Poster by Derrick Bailey
  24. Poster by Derrick Bailey
  25. Code sample from Chander Dahl’s presentation, based on writings of Robert Martin
  26. Poster by Derrick Bailey
  27. Poster by Derrick Bailey