1

I wanted to build a custom management system with Php & I had coded some projects with this programming language in the past but I know nothing about OOP! However I have heard a lot that Object Oriented Programming is very necessary to learn & also useful but it's TOO DIFFICULT especially for beginners ! So I decided to code manual like before & after that convert it to object oriented otherwise it will take lots of time to code in Oop from the start. But my question is ,is that possible to convert normal Php code into Oop or not ... And also , is this a good way to start off Object Oriented Programming or else what I should do then ? Thanks in advance

  • 1
    You mean convert automatically, or convert by manual work? Anyway, the answers are respectively "no" and "yes". – rghome Dec 03 '15 at 13:24
  • Also - it is a good way to start, to take something that you understand and to try to refactor it in a OO way. – rghome Dec 03 '15 at 13:25
  • Yes I do want to convert them by manual work –  Dec 03 '15 at 13:26
  • There will certainly be a lot of posts on procedural to oop already on this site. Maybe start here: http://stackoverflow.com/questions/1530868/simple-explanation-php-oop-vs-procedural?rq=1 – rghome Dec 03 '15 at 13:29

1 Answers1

1

It is always possible to convert procedural code to OOP if the language supports OOP.

In fact, doing it this way is often easier for beginners as procedural code is sometimes more natural to write, if you are not used to OOP. Furthmore, you don't have to worry about the creating new functionality, since you have done all that already and (hopefully) got it working.

However, once you have written your procedural code you may begin to see patterns that indicate an class should be used. For example, you have data items that seem to belong together and seem to be always operated on by the same sets of functions. In this case, it might indicate that the data and functions belong together in a class.

rghome
  • 8,529
  • 8
  • 43
  • 62