In Software engineering we always struggle with
- Repeating code
- Tight coupling
- Hard to change system
and in order to solve this we use these FIVE features:
- INTERFACE :
We use this for flexibility
For example ,When we write code tied to one implementation and later we can't change it and in this case we use an interface so our code depends on a contract not a concrete class.
Think it Like : We don't care how it works ,just make sure it works.
- ABSTRACT :
We use this when we don’t want to repeat code.
Problem:
Multiple classes share same logic → duplication everywhere.
Solution:
Use an abstract class to put common logic in one place
Think it Like : Some things are SAME, some are DIFFERENT.
Example:
- STATIC :
We use this when we don't need an object for this .
Problem:
When we create objects just to run simple logic.
Solution
Use static for utility/helper logic
Think it like :This doesn’t belong to an object ,it’s just a function.
Example:
- DELEGATE :
This simply means a function pointer.
Problem
Hardcoding logic → no flexibility at runtime
Solution
We use delegate to pass functions as data.
Think it like :Let the user decide what happens.
Example:
- GENERICS :
We use this when we don't want duplicate code for types.
Problem:
Same logic repeated for int, string, object…
Solution:
Use generics to write once, use everywhere
Think it like: Type doesn’t matter — logic is same or Generics = one code, many types.