Podcast
Questions and Answers
Which of the following is a core principle of Object-Oriented Programming (OOP)?
Which of the following is a core principle of Object-Oriented Programming (OOP)?
- Functional composition
- Modular programming
- Encapsulation (correct)
- Procedural decomposition
In object-oriented design, what is the primary purpose of abstraction?
In object-oriented design, what is the primary purpose of abstraction?
- To reduce the amount of code written
- To directly access and manipulate internal data of objects
- To increase the complexity of the system
- To hide complex implementation details and expose only essential information (correct)
Which concept allows a class to inherit properties and methods from another class?
Which concept allows a class to inherit properties and methods from another class?
- Polymorphism
- Abstraction
- Inheritance (correct)
- Encapsulation
What is the term for the ability of different classes to respond to the same method call in their own way?
What is the term for the ability of different classes to respond to the same method call in their own way?
Which languages support operator overloading?
Which languages support operator overloading?
In languages that support it, what is the primary reason to avoid excessive operator overloading?
In languages that support it, what is the primary reason to avoid excessive operator overloading?
Which of the following access modifiers provides the most restrictive access?
Which of the following access modifiers provides the most restrictive access?
If a class member is declared as 'protected', where can it be accessed?
If a class member is declared as 'protected', where can it be accessed?
What does the sealed
keyword prevent in C#?
What does the sealed
keyword prevent in C#?
What is the significance of the virtual
keyword in C#?
What is the significance of the virtual
keyword in C#?
In the context of class methods, what is method overriding?
In the context of class methods, what is method overriding?
What condition must be met for method overloading to occur?
What condition must be met for method overloading to occur?
Which of the following statements best describes an interface in object-oriented programming?
Which of the following statements best describes an interface in object-oriented programming?
How does an interface differ from an abstract class?
How does an interface differ from an abstract class?
Why are interfaces considered more flexible compared to inheritance in some scenarios?
Why are interfaces considered more flexible compared to inheritance in some scenarios?
What is the primary purpose of generic classes?
What is the primary purpose of generic classes?
In Java, what is the role of angle brackets <>
when using ArrayList
?
In Java, what is the role of angle brackets <>
when using ArrayList
?
Which of the following is a key concern of Object-Oriented Design (OOD)?
Which of the following is a key concern of Object-Oriented Design (OOD)?
What is the purpose of constructors in object-oriented programming?
What is the purpose of constructors in object-oriented programming?
In C#, what are destructors also known as?
In C#, what are destructors also known as?
When is a destructor typically called?
When is a destructor typically called?
If memory is no longer needed during runtime, where is it cleared from?
If memory is no longer needed during runtime, where is it cleared from?
Which component is responsible for automatically freeing up memory that is no longer being used by a program?
Which component is responsible for automatically freeing up memory that is no longer being used by a program?
Why is it important to free memory that is no longer being used by a program?
Why is it important to free memory that is no longer being used by a program?
What is the correct format to define a destructor for ClassName?
What is the correct format to define a destructor for ClassName?
What is a 'getter' primarily used for in the context of object properties?
What is a 'getter' primarily used for in the context of object properties?
What happens when a class implements an interface?
What happens when a class implements an interface?
Which of the following is true about 'internal' access modifier?
Which of the following is true about 'internal' access modifier?
What happens if a derived class does not override a virtual method in a base class?
What happens if a derived class does not override a virtual method in a base class?
Which memory location are local variables stored?
Which memory location are local variables stored?
Which memory location are dynamic variables stored?
Which memory location are dynamic variables stored?
What is a base class also known as?
What is a base class also known as?
What is a derived class also known as?
What is a derived class also known as?
What term describes containing information in an object, exposing selected information?
What term describes containing information in an object, exposing selected information?
What technique can be used to construct complex systems with primitive objects and primitive data?
What technique can be used to construct complex systems with primitive objects and primitive data?
What can higher order functions be used for with Object oriented design?
What can higher order functions be used for with Object oriented design?
Which of the following is an Object Oriented language?
Which of the following is an Object Oriented language?
Which of the following can be overloaded in C#?
Which of the following can be overloaded in C#?
What is the closest mechanism to operator overloading in Java?
What is the closest mechanism to operator overloading in Java?
What are the downsides of using operator overloading?
What are the downsides of using operator overloading?
Flashcards
Object-Oriented Design
Object-Oriented Design
A design paradigm centered around 'objects' which contain data and code to manipulate that data.
Github
Github
A place to store and manage your code
Encapsulation
Encapsulation
Containing information within an object and exposing only selected information.
Abstraction
Abstraction
Signup and view all the flashcards
Inheritance
Inheritance
Signup and view all the flashcards
Polymorphism
Polymorphism
Signup and view all the flashcards
Computer Science
Computer Science
Signup and view all the flashcards
Operator Overloading
Operator Overloading
Signup and view all the flashcards
Operator Overloading
Operator Overloading
Signup and view all the flashcards
'operator' keyword
'operator' keyword
Signup and view all the flashcards
Operator Overloading in Java
Operator Overloading in Java
Signup and view all the flashcards
Drawback of Operator Overloading
Drawback of Operator Overloading
Signup and view all the flashcards
Inheritance
Inheritance
Signup and view all the flashcards
Static Members
Static Members
Signup and view all the flashcards
Instance Members
Instance Members
Signup and view all the flashcards
Access Modifiers
Access Modifiers
Signup and view all the flashcards
Public
Public
Signup and view all the flashcards
Private
Private
Signup and view all the flashcards
Protected
Protected
Signup and view all the flashcards
Sealed
Sealed
Signup and view all the flashcards
Internal
Internal
Signup and view all the flashcards
Virtual
Virtual
Signup and view all the flashcards
Base/Parent
Base/Parent
Signup and view all the flashcards
Derived/Child
Derived/Child
Signup and view all the flashcards
Overriding
Overriding
Signup and view all the flashcards
Overloading
Overloading
Signup and view all the flashcards
Interface
Interface
Signup and view all the flashcards
Abstract Class
Abstract Class
Signup and view all the flashcards
Interfaces
Interfaces
Signup and view all the flashcards
Abstract Class
Abstract Class
Signup and view all the flashcards
Interfaces
Interfaces
Signup and view all the flashcards
Generic Classes
Generic Classes
Signup and view all the flashcards
Generic Classes
Generic Classes
Signup and view all the flashcards
OOD Concerns
OOD Concerns
Signup and view all the flashcards
Properties
Properties
Signup and view all the flashcards
Properties
Properties
Signup and view all the flashcards
Getters
Getters
Signup and view all the flashcards
Setters
Setters
Signup and view all the flashcards
Constructors
Constructors
Signup and view all the flashcards
Destructors
Destructors
Signup and view all the flashcards
Stack
Stack
Signup and view all the flashcards
Heap
Heap
Signup and view all the flashcards
Garbage Collector
Garbage Collector
Signup and view all the flashcards
Study Notes
Object Oriented Design
- Creating a GitHub account is typically the first step when working with a team in this design paradigm.
- Check your email for invites to the correct organization and make sure everyone on the team gets added.
- Permissions are handled in GitHub teams.
Techniques for Managing Complexity
- Black box abstraction, primitive objects, procedures, and primitive data are used to manage complexity.
- Combining procedures and data types serves as a means of organizing code.
- Abstraction encapsulates procedure definitions and implements data structures.
- Common patterns are captured using higher-order functions and treating data as procedures, and procedures as data.
Object Oriented Programming (OOP)
- The four pillars of OOP are encapsulation abstraction, inheritance, and polymorphism.
- Encapsulation contains information in an object, exposing only selected information.
- Abstraction exposes high-level public methods for accessing an object.
- Inheritance allows child classes to inherit both data and behaviors from the parent class.
- Polymorphism allows many methods to perform the same task.
Building Abstractions in Computer Science
- Computer Science is a discipline that builds abstractions to manage complexity.
- The goal is to write correct and high-performing code.
Gameplan: OOP Languages and Design Patterns
- Object Oriented Languages
- C#, C++, Java, TypeScript/JavaScript, Python, and Rust are object-oriented languages.
- Operator Overloading
- Operator overloading is present in languages like C++, C#, and Python.
- Some languages, like Java and JavaScript/TypeScript, do not support operator overloading.
- C# Operator Overloading
- Details on C# operator overloading can be found at this link: https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/operators/operator-overloading
- C# uses the 'operator' keyword and allows overloading of operators like +, -, *, /, &, and |.
- Java: toString Method
- The toString method in Java can be remotely linked to operator overloading.
- Python Methods
- Python uses _str() and _add() methods for operator overloading.
- Drawbacks of Operator Overloading
- Using it can make code harder to read and maintain, as it might obscure functionality compared to explicit functions.
Inheritance
- Before delving deep into inheritance there are some concepts that should be fully understood
- These are:
- Static versus Instance
- Why inherit
- Access Modifiers
- Access Modifiers
- Public access modifiers
- Private access modifiers
- Protected access modifiers
- Abstract access modifiers
- C# modifiers
- Sealed Modifiers
- Internal Modifiers
- Virtual Modifiers
- Terminology
- Base == Parent
- Derived == Child
- Morale of the story
- People will kill end themselves if given too many choices
Interfaces: What They Are and How They Differ from Abstract Classes
- An interface contains definitions for a group of related functionalities that a non-abstract class or struct must implement.
- Interfaces may define static methods with mandatory implementations and default implementations for members.
- They cannot declare instance data like fields or auto-implemented properties.
- An in-depth reference can be found at: https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/types/interfaces
- Abstract Class vs Interface:
- Abstract Classes can have variables and can only inherit one class, but can have virtual functions.
- Interfaces can implement multiple interfaces but can only have abstract-like members.
- Examples
- interface IImage { void Save(); void Load(); }
- interface IEquitable<T> { bool Equals(T obj); }
- public interface IComparable { int CompareTo(object obj); }
Generic Classes: Flexibility Compared to Inheritance
- OOD(Object-Oriented Design) aims to reuse as much code as possible and limits redundancies.
- Techniques seen include:
- Using functions
- Defining variables and constants
- Generic classes encapsulate operations that are not specific to a particular data type.
- The most common use for generic classes is with collections like linked lists, hash tables, stacks, queues, and trees.
- Java uses ArrayList<> to store variable types
- Let's Boil Down the List
- Add / Concat
- Remove
- Index
- Size
- Head/Tail
- Sort: a way to compare
- Search: a way to compare
- Any other?
Dependency Injection
- Dependency Injection, a case for interfaces: https://www.youtube.com/watch?v=J1f5b4vcxCQ
Other Notes
- Properties
- Properties differ from variables
- Usually public access
- Customize access with getters and setters
- Getters and Setters
- Functions for properties
- Accessors have getters and setters
- Can also be customized or use default
- Constructors
- Needed to create objects
- Can be overloaded with multiple methods
- Always public
- Instance variables
- Destructors
- C# calls them Finalizers
- Called when the object is destroyed by the garbage collector
- Format: "~ClassName()"
Low Level Memory Management
- Memory and data are kept in one of 2 locations
- Stack
- Local Variables
- Graphics look like Pancakes
- Heap
- Dynamic
- Graphics look like trees
- Why Free Memory?
- Only limited amounts of space are available in OS
- The OS defines limited zone of operation
- Garbage Collection
- Garbage Collectors clean up old data
- They are Done automatically by most modern languages to clear memory
- Clears items from the heap that no longer have anything else pointing to them
Studying That Suits You
Use AI to generate personalized quizzes and flashcards to suit your learning preferences.