This document discusses object-oriented programming concepts in .NET and C#, including designing classes, inheritance, interfaces, and garbage collection. It provides examples of creating classes with fields, properties, indexers, and methods. Inheritance allows code and design reuse when one class inherits from another. Interfaces represent contracts that classes can implement to interact with each other. .NET relies on garbage collection rather than explicit object destruction.
In this chapter we will understand how to define custom classes and their elements. We will learn to declare fields, constructors and properties for the classes. We will revise what a method is and we will broaden our knowledge about access modifiers and methods. We will observe the characteristics of the constructors and we will set out how the program objects coexist in the dynamic memory and how their fields are initialized. Finally, we will explain what the static elements of a class are – fields (including constants), properties and methods and how to use them properly. In this chapter we will also introduce generic types (generics), enumerated types (enumerations) and nested classes.
In this chapter we will understand how to define custom classes and their elements. We will learn to declare fields, constructors and properties for the classes. We will revise what a method is and we will broaden our knowledge about access modifiers and methods. We will observe the characteristics of the constructors and we will set out how the program objects coexist in the dynamic memory and how their fields are initialized. Finally, we will explain what the static elements of a class are – fields (including constants), properties and methods and how to use them properly. In this chapter we will also introduce generic types (generics), enumerated types (enumerations) and nested classes.
Dev Concepts: Object-Oriented ProgrammingSvetlin Nakov
What Is Object-Oriented Programming?
Watch the video lesson from Svetlin Nakov and learn more at:
https://softuni.org/dev-concepts/what-is-object-oriented-programming
Be among the first to learn about how Acend Corporate Learning unlocks the benefits of .NET. Learn how .NET-connected solutions enable your business to integrate systems more rapidly and in a more agile manner and help you realize the promise of information anytime, anywhere, on any device.
Dev Concepts: Object-Oriented ProgrammingSvetlin Nakov
What Is Object-Oriented Programming?
Watch the video lesson from Svetlin Nakov and learn more at:
https://softuni.org/dev-concepts/what-is-object-oriented-programming
Be among the first to learn about how Acend Corporate Learning unlocks the benefits of .NET. Learn how .NET-connected solutions enable your business to integrate systems more rapidly and in a more agile manner and help you realize the promise of information anytime, anywhere, on any device.
The French Revolution, which began in 1789, was a period of radical social and political upheaval in France. It marked the decline of absolute monarchies, the rise of secular and democratic republics, and the eventual rise of Napoleon Bonaparte. This revolutionary period is crucial in understanding the transition from feudalism to modernity in Europe.
For more information, visit-www.vavaclasses.com
Instructions for Submissions thorugh G- Classroom.pptxJheel Barad
This presentation provides a briefing on how to upload submissions and documents in Google Classroom. It was prepared as part of an orientation for new Sainik School in-service teacher trainees. As a training officer, my goal is to ensure that you are comfortable and proficient with this essential tool for managing assignments and fostering student engagement.
Palestine last event orientationfvgnh .pptxRaedMohamed3
An EFL lesson about the current events in Palestine. It is intended to be for intermediate students who wish to increase their listening skills through a short lesson in power point.
How to Make a Field invisible in Odoo 17Celine George
It is possible to hide or invisible some fields in odoo. Commonly using “invisible” attribute in the field definition to invisible the fields. This slide will show how to make a field invisible in odoo 17.
2024.06.01 Introducing a competency framework for languag learning materials ...Sandy Millin
http://sandymillin.wordpress.com/iateflwebinar2024
Published classroom materials form the basis of syllabuses, drive teacher professional development, and have a potentially huge influence on learners, teachers and education systems. All teachers also create their own materials, whether a few sentences on a blackboard, a highly-structured fully-realised online course, or anything in between. Despite this, the knowledge and skills needed to create effective language learning materials are rarely part of teacher training, and are mostly learnt by trial and error.
Knowledge and skills frameworks, generally called competency frameworks, for ELT teachers, trainers and managers have existed for a few years now. However, until I created one for my MA dissertation, there wasn’t one drawing together what we need to know and do to be able to effectively produce language learning materials.
This webinar will introduce you to my framework, highlighting the key competencies I identified from my research. It will also show how anybody involved in language teaching (any language, not just English!), teacher training, managing schools or developing language learning materials can benefit from using the framework.
Honest Reviews of Tim Han LMA Course Program.pptxtimhan337
Personal development courses are widely available today, with each one promising life-changing outcomes. Tim Han’s Life Mastery Achievers (LMA) Course has drawn a lot of interest. In addition to offering my frank assessment of Success Insider’s LMA Course, this piece examines the course’s effects via a variety of Tim Han LMA course reviews and Success Insider comments.
Francesca Gottschalk - How can education support child empowerment.pptxEduSkills OECD
Francesca Gottschalk from the OECD’s Centre for Educational Research and Innovation presents at the Ask an Expert Webinar: How can education support child empowerment?
Operation “Blue Star” is the only event in the history of Independent India where the state went into war with its own people. Even after about 40 years it is not clear if it was culmination of states anger over people of the region, a political game of power or start of dictatorial chapter in the democratic setup.
The people of Punjab felt alienated from main stream due to denial of their just demands during a long democratic struggle since independence. As it happen all over the word, it led to militant struggle with great loss of lives of military, police and civilian personnel. Killing of Indira Gandhi and massacre of innocent Sikhs in Delhi and other India cities was also associated with this movement.
A Strategic Approach: GenAI in EducationPeter Windle
Artificial Intelligence (AI) technologies such as Generative AI, Image Generators and Large Language Models have had a dramatic impact on teaching, learning and assessment over the past 18 months. The most immediate threat AI posed was to Academic Integrity with Higher Education Institutes (HEIs) focusing their efforts on combating the use of GenAI in assessment. Guidelines were developed for staff and students, policies put in place too. Innovative educators have forged paths in the use of Generative AI for teaching, learning and assessments leading to pockets of transformation springing up across HEIs, often with little or no top-down guidance, support or direction.
This Gasta posits a strategic approach to integrating AI into HEIs to prepare staff, students and the curriculum for an evolving world and workplace. We will highlight the advantages of working with these technologies beyond the realm of teaching, learning and assessment by considering prompt engineering skills, industry impact, curriculum changes, and the need for staff upskilling. In contrast, not engaging strategically with Generative AI poses risks, including falling behind peers, missed opportunities and failing to ensure our graduates remain employable. The rapid evolution of AI technologies necessitates a proactive and strategic approach if we are to remain relevant.
Model Attribute Check Company Auto PropertyCeline George
In Odoo, the multi-company feature allows you to manage multiple companies within a single Odoo database instance. Each company can have its own configurations while still sharing common resources such as products, customers, and suppliers.
2. 2
Microsoft
Objectives
“Classes, objects and object-oriented programming (OOP) play a fundamental role in .NET. C# features full support for the object- oriented programming paradigm…”
•Designing your own classes
•Destroying objects and garbage collection
•Inheritance
•Interfaces
4. 4
Microsoft
Motivation
•.NET contains thousands of prebuilt classes in the FCL
•So why design your own?
–to model entities unique to your application domain…
•Examples:
–employees
–customers
–products
–orders
–documents
–business units
–etc.
5. 5
Microsoft
Simple class members
•C# supports standard fields, methods and constructors
–with standard access control: public, private, protected
public class Person { public string Name; // fields public int Age; public Person() // default constructor { this.Name = "?"; this.Age = -1; } public Person(string name, int age) // parameterized ctor { this.Name = name; this.Age = age; } public override string ToString() // method { return this.Name; } }//class
6. 6
Microsoft
Basic design rules
•Provide constructor(s)
•Omit default constructor for parameterized initialization
•Override ToString, Equals and GetHashCode
•Data hiding: "hide as many details as you can"
–enable access when necessary via accessors and mutators
–.NET provides a cleaner mechanism via properties…
7. 7
Microsoft
Properties
•Goal:
–to allow our class users to safely write code like this:
–provides field-like access with method-like semantics…
–… enabling access control, validation, data persistence, screen updating, etc.
Person p; p = new Person("joe hummel", 40); p.Age = p.Age + 1;
8. 8
Microsoft
Observation
•Read of value ("Get") vs. Write of value ("Set")
Person p; p = new Person("joe hummel", 40); p.Age = p.Age + 1;
Get age
Set age
9. 9
Microsoft
Property implementation
•Implementation options:
–read-only
–write-only
–read-write
public class Person { private string m_Name; private int m_Age; . . . public string Name { get { ... } } public int Age { get { ... } set { ... } } }
read-only
read-write
10. 10
Microsoft
Example
•Simplest implementation just reads / writes private field:
public class Person { private string m_Name; private int m_Age; . . . public string Name // Name property { get { return this.m_Name; } } public int Age // Age property { get { return this.m_Age; } set { this.m_Age = value; } } }
11. 11
Microsoft
Indexers
•Enable array-like access with method-like semantics
–great for data structure classes, collections, etc.
People p; // collection of Person objects p = new People(); p[0] = new Person("joe hummel", 40); . . . age = p[0].Age;
Set
Get
12. 12
Microsoft
Example
•Implemented like properties, with Get and Set methods:
public class People { private Person[] m_people; // underlying array . . . public Person this[int i] // int indexer { get { return this.m_people[i]; } set { this.m_people[i] = value; } } public Person this[string name] // string indexer { get { return ...; } } }
read-only
read-write
14. 14
Microsoft
Object creation and destruction
•Objects are explicitly created via new
•Objects are never explicitly destroyed!
–.NET relies upon garbage collection to destroy objects
–garbage collector runs unpredictably…
15. 15
Microsoft
Finalization
•Objects can be notified when they are garbage collected
•Garbage collector (GC) will call object's finalizer
public class Person
{
.
.
.
~Person() // finalizer
{
...
}
16. 16
Microsoft
Should you rely upon finalization?
•No!
–it's unpredictable
–it's expensive (.NET tracks object on special queue, etc.)
•Alternatives?
–design classes so that timely finalization is unnecessary
–provide Close / Dispose method for class users to call
** Warning ** As a .NET programmer, you are responsible for calling Dispose / Close. Rule of thumb: if you call Open, you need to call Close / Dispose for correct execution. Common examples are file I/O, database I/O, and XML processing.
18. 18
Microsoft
Inheritance
•Use in the small, when a derived class "is-a" base class
–enables code reuse
–enables design reuse & polymorphic programming
•Example:
–a Student is-a Person
Undergraduate
Person
Student
Employee
Graduate
Staff
Faculty
19. 19
Microsoft
Implementation
•C# supports single inheritance
–public inheritance only (C++ parlance)
–base keyword gives you access to base class's members
public class Student : Person { private int m_ID; public Student(string name, int age, int id) // constructor :base(name, age) { this.m_ID = id; } }
Student
Person
20. 20
Microsoft
Binding
•C# supports both static and dynamic binding
–determined by absence or presence of virtual keyword
–derived class must acknowledge with new or override
public class Person { . . . // statically-bound public string HomeAddress() { … } // dynamically-bound public virtual decimal Salary() { … } }
public class Student : Person { . . . public new string HomeAddress() { … } public override decimal Salary() { … } }
21. 21
Microsoft
All classes inherit from System.Object
StringArrayValueTypeExceptionDelegateClass1MulticastDelegateClass2Class3ObjectEnum1Structure1EnumPrimitive typesBooleanByteInt16Int32Int64CharSingleDoubleDecimalDateTimeSystem-defined typesUser-defined typesDelegate1TimeSpanGuid
23. 23
Microsoft
Interfaces
•An interface represents a design
•Example:
–the design of an object for iterating across a data structure
–interface = method signatures only, no implementation details!
–this is how foreach loop works…
public interface IEnumerator { void Reset(); // reset iterator to beginning bool MoveNext(); // advance to next element object Current { get; } // retrieve current element }
24. 24
Microsoft
Why use interfaces?
•Formalize system design before implementation
–especially helpful for PITL (programming in the large)
•Design by contract
–interface represents contract between client and object
•Decoupling
–interface specifies interaction between class A and B
–by decoupling A from B, A can easily interact with C, D, …
25. 25
Microsoft
.NET is heavily influenced by interfaces
•IComparable
•ICloneable
•IDisposable
•IEnumerable & IEnumerator
•IList
•ISerializable
•IDBConnection, IDBCommand, IDataReader
•etc.
26. 26
Microsoft
Example
•Sorting
–FCL contains methods that sort for you
–sort any kind of object
–object must implement IComparable
object[] students; students = new object[n]; students[0] = new Student(…); students[1] = new Student(…); . . . Array.Sort(students);
public interface IComparable { int CompareTo(object obj); }
27. 27
Microsoft
To be a sortable object…
•Sortable objects must implement IComparable
•Example:
–Student objects sort by id
public class Student : Person, IComparable { private int m_ID; . . . int IComparable.CompareTo(Object obj) { Student other; other = (Student) obj; return this.m_ID – other.m_ID; } }
base class
interface
Student
Person
28. 28
Microsoft
Summary
•Object-oriented programming is *the* paradigm of .NET
•C# is a fully object-oriented programming language
–fields, properties, indexers, methods, constructors
–garbage collection
–single inheritance
–interfaces
•Inheritance?
–consider when class A "is-a" class B
–but you only get single-inheritance, so make it count
•Interfaces?
–consider when class C interacts with classes D, E, F, …
–a class can implement any number of interfaces
29. 29
Microsoft
References
•Books:
–I. Pohl, "C# by Dissection"
–S. Lippman, "C# Primer"
–J. Mayo, "C# Unleashed"