- What are some advantages of using object-oriented programming (OOP) in JavaScript, and how does it differ from other programming paradigms?
- What are some common design patterns used in object-oriented programming, and how can they help to solve recurring software development problems?
- Can you explain the difference between classical inheritance and prototypal inheritance in JavaScript, and provide some examples of each?
- How do you define a class in JavaScript, and what are some best practices for creating and using classes effectively?
- What is the role of constructors and prototypes in OOP in JavaScript, and how do they relate to each other?
-
-
Save Kishimoto96/2a4a8c96630887e4a8f9940db41240e4 to your computer and use it in GitHub Desktop.
team: fatima , harith riyadh, ahmed rashed, hande nur demirbay
1-allows for code reusability, as code can be written in a modular manner and can be reused in other parts of the application.
2-Singleton Pattern , Factory Pattern, Observer Pattern, Adapter Pattern,Decorator Pattern
3-Classical Inheritance:a subclass can inherit properties and methods from a superclass.
protptypal : objects are created first, and then other objects are created by cloning or inheriting from them.
4- a class is defined using the class keyword.allows for code reusability, as code can be written in a modular manner and can be reused in other parts of the application.
5-constructors and prototypes work together to create and define the properties and behaviors of objects in JavaScript. Constructors are used to create new objects, while prototypes are used to define their properties and methods.
- there are a lot of them some of them are singleton, Factory, Observer, Decorator, and Adapter patterns, we use them to solve recurring software development problems. some of them provide a proven solution to common problems and make code more flexible, maintainable, and extensible also these patterns can help developers save time and effort, improve code quality, and create more robust and scalable software applications.
- In classical inheritance, classes are defined using a blueprint or template, and objects are created from these classes using the new keyword, n prototypal inheritance, objects inherit properties and methods directly from other objects. There are no classes, and objects are created using constructor functions or object literals.
- In JS, classes can be defined using the class keyword, it can help you organize and structure your code in a more object-oriented way
- The prototype is the base class, the constructor your current class. In OOP the above would be class Foo extends Function You can also start inheritance with this entire setup of prototype and constructor making more complex objects as you go whilst sharing functionality.
Team members: @houzifahabbo ,@nour Eddin Hamouda ,@MOHAMMAD-ALMOHAMMAD ,@atakan Serbes
1- It gives us the ability to inherit classes and encapsulates them, it prevents redundancy in code and allows you to not repeat the code you write, and it is more secure.
2- there are a lot of patterns like :
3- In classical inheritance models inheritance occurs when an object instance inherits from a class and a subclass can inherit from a parent class, Prototypal inheritance, on the other hand, supports an object inheriting from any other object rather than from classes.
4- we can make a new class by either using the "new" keyword or setting its prototype to the class prototype, as for best practices, its better to inherit from a parent class instead of repeating the code
such as if we have an Animal class, instead of making classes for all types of animals we can have those classes inherit from the parent animal class.
5- Constructors and prototypes work together to implement inheritance and method sharing in JavaScript. A constructor is used to create and initialize objects, while a prototype is used to share properties and methods among all instances of a constructor function.