Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Unusual C# - OOP


Published on

session @ ITzo0M4 2010

Published in: Technology
  • Be the first to comment

Unusual C# - OOP

  1. 1. Unusual C#OOP Gate<br />Prepared & Presented by:<br />Eng. : Medhat Dawoud<br />
  2. 2. Relax your self<br />
  3. 3. Let your imaginations<br />
  4. 4. I want you to know that we are learning :<br />
  5. 5. Actually it’s <br />Usual C#<br /><br />
  6. 6. General Overview<br />What is OOP ?<br />What is class?<br />Difference between class and object.<br />The life cycle of an object:<br />Construction <br />Destruction<br />The accessibility.<br />Static Vs Instance.<br />Reference type Vs. Value type.<br />OOP techniques.<br />
  7. 7. What is OOP ?<br /><ul><li>The difference between :</li></ul>Object Oriented Programming and<br />Procedure Oriented Programming.<br /><ul><li>Object Oriented Programming, why?
  8. 8. A real example : car manufacturing. </li></li></ul><li>
  9. 9. What is OOP ?<br /><ul><li>The difference between :</li></ul>Object Oriented Programming and<br />Procedure Oriented Programming.<br /><ul><li>Object Oriented Programming, why?
  10. 10. A real example : car manufacturing. </li></li></ul><li>What is class?<br />Class is a great container .<br />Has some members like : (constructor, properties, fields, Methods, Variables, statements, …).<br />It has some features which are given to its instances.<br />Class like : Department<br />
  11. 11. Difference between class and object:<br />What is an object ?<br />object is a building block of an OOP application, this building block encapsulates part of the application.<br />Objects are created from types, these types of an object is known by classes.<br />The object is an instance of a class.<br />We treat with classes through objects.<br />“every thing is object”<br />
  12. 12. The life cycle of an object:<br />The object has three cases:<br />Construction.<br />Default constructor is often public.<br />What if it become private? <br />Being in use.<br />Destruction.<br />
  13. 13. The accessibility<br />Determine which code can access these members that is whether they are available to all code ( public ) or only to code within the class ( private ).<br />The modifier ( protected ).<br />We can make fields privates and provide access to them via public properties.(the encapsulation)<br />
  14. 14. Static Vs Instance<br />Static members are shared between instances of the class.<br />When using static members you needn’t to instantiate an object.<br />To use Instance members you must instantiate an object from the class.<br />
  15. 15. Reference type Vs Value type<br />
  16. 16. OOP techniques<br />Encapsulation.<br />Abstract.<br />Interface.<br />Inheritance.<br />Polymorphism.<br />
  17. 17. Encapsulation<br />Making fields privates and provide access to them via public properties.<br />Classes Idea is encapsulation.<br />Why encapsulation ?<br />
  18. 18. Abstract<br />Abstract class is a class that may or may not contain abstract methods.<br />Abstract class can’t be instantiated.<br />An abstract method is a method that is declared without an implementation.<br />If a class includes abstract methods, the class itself must be declared abstract.<br />
  19. 19. Interface<br /> If an abstract class contains only abstract method declarations, it should be declared as an interface instead.<br />Interface can’t be instantiated.<br />You can implement interface in an inherited class.<br />Imagine the interface as a contract between interface creator and class consumers.<br />
  20. 20. Inheritance<br />Child class inherited from (derived from) parent class (base class).<br />In C#, you may derive only from a single base class directly.<br />You can override a member in child class that is virtual in the parent class.<br />A class may be sealed.<br />C# provide a common base class for all objects called object.<br />
  21. 21. Polymorphism<br />It is very useful for performing tasks with a minimum of code on different objects from a single class.<br />Overriding & Overloading.<br />Polymorphism means that :<br /> you can use the same instruction with different return value into screen.<br />
  22. 22. Practice <br />
  23. 23. Any Questions ?<br />I have some questions !!<br />
  24. 24. Can you allow class to be inherited, but prevent the method from being over-ridden?<br />Yes, just leave the class public and make the method sealed.<br />
  25. 25. Can you override private virtual methods?<br />No, you cannot access private methods in inherited classes.<br />
  26. 26. Can you declare the override method static while the original method is non-static?<br />No, you can't, the signature of the virtual method must remain the same, only the keyword virtual is changed to keyword override<br />
  27. 27. The last question..<br />Is it true or false , and why ?<br />False , Because its constructor is private <br />
  28. 28. Contact me for any inquiry<br />MedhatDawoud[at] ..E-mail me..<br /> ..follow me..<br /> ..Current Blog..<br /><br />..Coming soon.. <br />
  29. 29. Thanks for listening<br />