what the oop | SoloLearn: Learn to code for FREE!


what the oop

WHY use OOP in lanuage


12/5/2019 1:11:45 PM

farah faissal hassan

5 Answers

New Answer


To protect data from the rest of the code and tie it to related functionality.


I'ts basically object oriented programming. by this i mean it's the concept of using a real life objects in a code. OOP is devided into several parts in each programming language. In C++ , C# and Python we have OOP,. Below is a basic program in C# of how classes and objects works, this example doesn't include inheritance and other concepts. //you may run it on vs code, it works //Description: Introduction to OOP, "Classes and objects" using System; namespace Intro_Classes { class student { //Private Attributes private string name; private string sname; private int age; private int grade; //Public Attributes public student()//Default constructor { name = "Ghost"; sname = "Ghost_S"; grade = 0; age =0; } public student(string name,string sname,int age,int grade) { this.name=name; this.sname=sname; this.age=age; this.grade=grade; } public void Set_student(string name,string sname,int age,int grade) { this.name=name; this.sname=sname; this.age=age; this.grade=grade; } public string getname(){ return name; } public string gets_name(){ return sname; } public int getage(){ return age; } public int getgrade(){ return grade; } public string to_string() { return ("Hi my name is "+this.getname()+" and My surname is "+this.gets_name()+". I'm "+this.getage()+ "years old and i'm on grade "+this.getgrade()); } }//end of Student's class class Program { static void prompt() { Console.WriteLine("enter the name please\n"); var name = Console.ReadLine();


I would say it is a concept of using real life objects in a code.


OOP(Object Oriented Programming) languages allows computer programmers to implement an object-oriented design as a working system.. Just as everything around us are seen as objects(either animate or inanimate), so does OOP languages.. For instance, in Java, classes are instantiated as objects.


OOP is awesome. Might be hard at beginning but you will see how powerfull it is and how usefull can be. It can simplify your code using templates and create generic functionality. This is also a crucial thing for security (encapsulation). In c# you can do dependency injection using Interfaces that inlements a class and have acces anywhere in your application where you choose to inject it and can easily write unit tests based on your interfaces