Welcome to the Treehouse Community

Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community! While you're at it, check out some resources Treehouse students have shared here.

Looking to learn something new?

Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.

Start your free trial

PHP Object-Oriented PHP Basics Building the Recipe Separating Methods

mahdi askari
mahdi askari
15,174 Points

I don't understand why we should make two classes. Recipe and Render? Why can't we use one class?

I don't understand why we should make two classes. Recipe and Render? Why can't we use one class? In Object Oriented PHP

1 Answer

Q: Why we should make two classes. Recipe and Render? Answer: Class is a way to group together common functionalities. The use of recipe class is to create a recipe and the use of render class is to show the recipe on to the browser.

Q: Why can't we use one class? Answer: In real world projects as the code base increases it would be hard to maintain if we do not separate functions like this.