charp OOps
Thursday, 6 June 2024
Abstraction
Real Meaning of abstract :-
abstract is summary of you entire implementation & methods.
abstract is short info of you lengthy code and features.
user can understand by seeing abstract rather than see the entire implementation and lengthy lines.
Abstract helps users to remember key point of entire implementation.
Abstraction in OOP is about managing complexity by exposing only the necessary details to the client and hiding the implementation details. While it is not primarily about security, it does contribute to a more secure and robust system by encapsulating the internal workings and reducing the risk of unintended interactions.
Abstraction is all about showing what is necessary
Abstraction is more about design and not participate in implementation
Intension of abstraction is
Abstraction you can see what it can do , but you can't see how it is doing
in C# we have Partial Abstraction and full abstraction features
interface is best example for full abstraction.
abstract class is partial abstraction as it have abstract and concrete members.
abstraction define contracts that one or more class can implement, without dictating how should implement them.
Key Intentions of Abstraction in OOP
Highlighting Essential Features:
Abstraction allows the developer to expose only the relevant attributes and methods of an object that are necessary for the client (user of the object). This makes it easier for the client to interact with the object without being overwhelmed by unnecessary details.
Hiding Implementation Details:
By hiding the complex implementation details and exposing only what is necessary, abstraction simplifies the interaction with the object. This helps in managing complexity and makes the system easier to understand and use.
Reducing Complexity:
Abstraction helps in breaking down complex systems into simpler, high-level components. This makes it easier to manage and maintain the system.
Improving Modularity:
By defining clear and simple interfaces, abstraction promotes modular design. Each module or component can be developed, tested, and understood independently.
Enhancing Maintainability:
With abstraction, changes in the implementation of an object do not affect the code that interacts with it, as long as the interface remains consistent. This improves maintainability and allows for easier updates and modifications.
Encouraging Reusability:
Encouraging Reusability:
Abstract classes and interfaces define common behaviors that can be reused across different parts of the application or even in different projects. This reduces duplication and promotes code reuse.
9133662111
Inheritance
Inheritance in C#/Java/python is a fundamental concept of Object-Oriented Programming (OOP).
It allows one class to inherit the properties and methods of another class.
Inheritance provides code re-usability. In place of writing the same code, again and again, we can simply inherit the properties of one class into the other.
Code reuse can reduce time and errors
The members defined in one class can be consumed by another class by establishing a parent/child relationship between the classes.
Main features of inheritance :
Code Reusablility :- when existing functionality is required in your new class(new version of exiting object), then inherit it instead of writing duplicate code.
Extensibility :-
Maintainability
Notes :
Base classes are automatically instantiated before derived classes.
Parent Class constructor executes before child class constructor.
C# supports only single class inheritance.
Multiple Inheritance not possible with normal class, can be achieve through interface.
child class is a specialization of base class.
Inheritance in C#/Java/python is a fundamental concept of Object-Oriented Programming (OOP).
It allows one class to inherit the properties and methods of another class.
The key to understanding Inheritance is that it provides code re-usability. In place of writing the same code, again and again, we can simply inherit the properties of one class into the other.
Inheritance is a technique of modelling real-world relationships,OOP is all about real-world objects.
one class inherits from another
features :
Code Reusablility :-The Child/derived/sub class inherits the fields and methods of the Parent/base/super class. This helps with the code reusability in C#.
extensibility
maintainability :- Code Organization and Maintenance
An "is-a" link between classes is established by inheritance, where a subclass is a customized version of its superclass.
Disadvantages of Inheritance
Inherited functions work slower than normal function as there is indirection.
Improper use of inheritance may lead to wrong solutions.
Often, data members in the base class are left unused which may lead to memory wastage.
Inheritance increases the coupling between base class and derived class. A change in base class will affect all the child classes.
OOP supports six different types of inheritance as given below:
Single Inheritance
Multi-level Inheritance
Multiple Inheritance
Multipath Inheritance
Hierarchical Inheritance
Hybrid Inheritance
Terms Used in inheritance
Class: A class is a collection of objects with similar attributes. It's a blueprint or template from which items are made.
Sub Class/Child Class: Subclass is a class which inherits the other class. It is also called a derived class, extended class, or child class.
Super Class/Parent Class: The features of a subclass are inherited from the superclass. It's also known as a parent class or a base class.
Reusability: Reusability, as the name implies, is a feature that allows you to reuse the fields and methods of an existing class while creating a new one. The fields and methods defined in the preceding class can be reused.
Inheritance is one of the fundamental attributes of object-oriented programming. It allows you to define a child class that reuses (inherits), extends, or modifies the behavior of a parent class. The class whose members are inherited is called the base class. The class that inherits the members of the base class is called the derived class.
https://learn.microsoft.com/en-us/dotnet/csharp/fundamentals/tutorials/inheritance
https://www.programiz.com/csharp-programming/inheritance#google_vignette
Split string
In C#, the Split() function is used to split a string into substrings based on a specified delimiters Like Char,string array of char and string and returns an array of substrings.
Split string method always returns string array
String value can Split by single char, Char Array, Char params
Split(char separator)
Split(params char[] separator)
Split(char[] separator)
String value can Split by single Word and by collection of words
Split(string separator)
Split(string[] separator)
Split String into Maximum no of substrings
StringSplitOptions is Enum is help to remove empty entries and trim space of each substring
Split(char[] separator, int count, StringSplitOptions options)
Split(string[] separator, int count, StringSplitOptions options)
Subscribe to:
Posts (Atom)
Abstraction
Real Meaning of abstract :- abstract is summary of you entire implementation & methods. abstract is short info of you lengthy code and ...