Jump to content

Good uses of OOP?


Boo-urns

Recommended Posts

Man, Wrong, wrong, wrong!

 

 

Programming in an OOP Language does NOT equal programming in an OOP Way!

 

OOP is a methodology which requires alot of practice and thought to do correctly and efficiently.

 

Unfortunately I have been misunderstood. I do not mean that programming in an OOP language equals programming in an OOP way. I mean that to program at all with a language like C# or Java, you absolutely WILL use objects even if you do not write a class. For instance, if you want to connect to a database you will be using the System.Data namespace. Then you will be using the data classes to access the database and you must use the properties and methods of this class. In php, you have an option to do functions or object oriented. For instance, http://us.php.net/manual/en/mysqli.query.php you will see that there are 2 methods to connect to the database using the mysqli extensions. The first is a procedural method, the second is an object oriented method. C# and Java does not have this. This is what I meant. Sorry for the confusion.

Link to comment
Share on other sites

My preference is name.cls.php if you have a classes folder.

 

For my own stuff I create a folder called classes and name each class the same as the file name it communicates with on the view layer of the site.  When working on a project it is really easy to know right away where to go when a function needs to be modified.  For ajax sites I create a folder called output and again put files with the same name as those in the view.

 

My file structure would look pretty close to this.

 

index.php

includes/classes/index.php

includes/output/index.php

 

forum.php

includes/classes/forum.php

includes/output/forum.php

 

administrator.php

includes/classes/administrator.php

includes/output/administrator.php

 

I would not call this common practice or a standard of any kind but it is what I do to keep everything straight and has proved to be a very scalable method.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.