Functional (FP) vs Object Oriented (OOP)

University System Example (FP)

  • AddStudent
  • UpdateStudent
  • DeleteStudent
  • CalculateAverage
  • AddCourse
  • UpdateCourse
  • DeleteCouse
  • EnrollStudentInCourse
  • UnEnrollStudentFromCoruse
  • HowManyStudentsInCourse
  • Doctor (Add, Edit, Delete)
  • AssignCourseToDoctor
  • SendEmailToStudent
  • SendTextMessageToStudent
  • SendEmailToDoctor
  • SendTextMessageToDoctor
  • CallStudent
  • CallDoctor
  • AddEmployee
  • UpdateEmployee
  • DeleteEmployee
  • CalculateSalary
  • PaySalary
  • ………… Simply You can have thousands of functions in your System!!!!

The problem is not with number of functions at all The problem is with organizing them and the way you look at them

To make it simple for you What it you have thousands of contacts and phone numbers and all these contacts and numbers are not organized! You will have a nightmare

Functional (FP) vs Object Oriented (OOP)

University System Example (OOP)

  • Student
  • Doctor
  • Department
  • Course
  • Major
  • Others
  • Employee
  • Collage

أنت بتتعامل مع أشياء وليس مع ميثود ولا فرايبلز

Simply Group Members and Functions Inside Related Objects

StudentObject:

Student1.Name Student1.Email Student1.GetEnrolledCourses() Student1.CalcuateAverage() Student1.SendEmail(Subject, Body) Student1.EnrollInCourse(10) Student1.PayFees Student1.UnEnrolFromCourse(10)

You can do whatever you want with a certain student through its object

بتخليك تتعامل مع الكود من فوق لتحت وتسهل حياتك more securty