Today's Posts Follow Us On Twitter! TFL Members on Twitter  
Forum search: Advanced Search  
Navigation
Marketplace
  Members Login:
Lost password?
  Forum Statistics:
Forum Members: 24,254
Total Threads: 80,792
Total Posts: 566,472
There are 1670 users currently browsing (tf).
 
  Our Partners:
 
  TalkFreelance     Design and Development     Programming     PHP and MySQL :

Object Oriented Programming

Thread title: Object Oriented Programming
Closed Thread  
Page 1 of 2 1 2 >
    Thread tools Search this thread Display Modes  
11-21-2006, 06:34 PM
#1
Spawny is offline Spawny
Spawny's Avatar
Status: Request a custom title
Join date: Aug 2005
Location: Great Yarmouth, England
Expertise:
Software:
 
Posts: 1,321
iTrader: 2 / 100%
 

Spawny is on a distinguished road

Send a message via AIM to Spawny Send a message via MSN to Spawny

  Old  Object Oriented Programming

I've seen a lot of talk about OOP, but i've never actually understood what all the fuss is about, so I was just wondering if anyone could explain the following to me:
  • What are the advantages of OOP?
  • How is OOP actually used?
  • Why is there such a big fuss over it?

Thanks.

11-24-2006, 05:17 PM
#2
fernand is offline fernand
Status: I'm new around here
Join date: Nov 2006
Location:
Expertise:
Software:
 
Posts: 18
iTrader: 0 / 0%
 

fernand is on a distinguished road

  Old

maybe the wiki will shed a light:
http://en.wikipedia.org/wiki/Object-...ed_programming

12-12-2006, 11:29 PM
#3
monit0r is offline monit0r
Status: Junior Member
Join date: Dec 2006
Location: London
Expertise:
Software:
 
Posts: 71
iTrader: 0 / 0%
 

monit0r is on a distinguished road

  Old

It may be a little high spec, but have a very brief look at UML
http://en.wikipedia.org/wiki/Unified_Modeling_Language

12-13-2006, 01:17 AM
#4
Andrew R is offline Andrew R
Status: Request a custom title
Join date: Dec 2005
Location: Arizona
Expertise:
Software:
 
Posts: 5,200
iTrader: 17 / 95%
 

Andrew R is on a distinguished road

  Old

http://www.sitepoint.com/forums/showthread.php?t=59898

Entire discussion on SitePoint.

Simply put, OOP just makes the code much cleaner with less syntax needed for bigger PHP projects.

12-13-2006, 10:30 AM
#5
paaaaaaaaaa is offline paaaaaaaaaa
Status: I'm new around here
Join date: Dec 2006
Location:
Expertise:
Software:
 
Posts: 2
iTrader: 0 / 0%
 

paaaaaaaaaa is on a distinguished road

  Old

Just because PHP 5 now has great support for OOP people are feeling the need to code using OOP. I still have not got into OOP yet. I have used it a bit but still find that function orientated code and arrays fit all my needs.

I think I have a quite unique way of coding. I find the use of global arrays great for big applications and often don’t see other programmers using them that much. I tend to plan what my script will need to do in steps and then sort them into functions. I manage to keep my code very clean and easy to understand.

Great sitepoint thread, I'm reading through that now.

12-13-2006, 11:17 AM
#6
sparckyz is offline sparckyz
sparckyz's Avatar
Status: Member
Join date: Nov 2006
Location: Nowhere
Expertise:
Software:
 
Posts: 192
iTrader: 0 / 0%
 

sparckyz is on a distinguished road

  Old

As i understand it a big advantage, but not the only, to OOP is code re-useability. Also some languages can only be written using OOP (i think lol), thats pretty much all i know .

12-13-2006, 02:01 PM
#7
paaaaaaaaaa is offline paaaaaaaaaa
Status: I'm new around here
Join date: Dec 2006
Location:
Expertise:
Software:
 
Posts: 2
iTrader: 0 / 0%
 

paaaaaaaaaa is on a distinguished road

  Old

Yeah re-useability is what I always hear but isnt that the same case for functions?

Also I hear OOP helps organise your code better but I dont like it when a file has something like 6 long functions in it and you have to struggle scrolling through the file to find something which can be the case with classes.

Isn't having a class effectivly like having a function that will run through some sub functions and then finally return an array.

12-13-2006, 03:08 PM
#8
Andrew R is offline Andrew R
Status: Request a custom title
Join date: Dec 2005
Location: Arizona
Expertise:
Software:
 
Posts: 5,200
iTrader: 17 / 95%
 

Andrew R is on a distinguished road

  Old

Originally Posted by paaaaaaaaaa
Yeah re-useability is what I always hear but isnt that the same case for functions?

Also I hear OOP helps organise your code better but I dont like it when a file has something like 6 long functions in it and you have to struggle scrolling through the file to find something which can be the case with classes.

Isn't having a class effectivly like having a function that will run through some sub functions and then finally return an array.
Classes can do more than just group functions together. You can use them together with less lines of code and also manipulate the vars used within the class/functions.

12-13-2006, 03:19 PM
#9
derek lapp is offline derek lapp
Status: design rockstar
Join date: Jan 2005
Location: guelph, ontario
Expertise:
Software:
 
Posts: 2,246
iTrader: 0 / 0%
 

derek lapp is on a distinguished road

  Old

in regards to php the logic behind oop is very simlar to just having a file full of functions, but they're not the same. if you know how, oop can be used far more effectively and effeciently.

i am not one of these people so i can't tell you how. none the less, i use classes to drive most of my scripts.

in a wierd way of thinking, think of php classes like css clases. look at it this way: you have a people class, which has a method that returns personal data (name, address, phone, email etc). compared to a strict file full of functions nothing's different. but now you're writing an employees class that returns personal + employee data (personal + employee num, position, etc). with inheritance you don't have to re-write anything, you can just extend and add on as you need it.

just like in a css file:
Code:
.chartHeading, .calendar-month {
	background: #4C4C4C;
	font-weight: bold;
	font-size: 1.1em;
	color: #FFFFFF;
}
	.calendar-month {
		padding: 5px;
	}
.calendar-month inherists everything from .chartHeading and saves me from re-writing it. the formatting is obviously different, but the logic is still there, and i'm sure it's an example that you'll get.

12-13-2006, 03:24 PM
#10
Andrew R is offline Andrew R
Status: Request a custom title
Join date: Dec 2005
Location: Arizona
Expertise:
Software:
 
Posts: 5,200
iTrader: 17 / 95%
 

Andrew R is on a distinguished road

  Old

Also, with PHP OOP, you have inheritance, polymorphism, you can extend classes with other classes, etc. It's much more than a class with functions in it.

Closed Thread  
Page 1 of 2 1 2 >


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 

  Posting Rules  
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump:
 
  Contains New Posts Forum Contains New Posts   Contains No New Posts Forum Contains No New Posts   A Closed Forum Forum is Closed