Jump to content

OOP why ?


anatak

Recommended Posts

Here is my situation.

I built a website

I used a lot of functions.

started messing with objects

Remembered my OO course (Java)

read the OOP tutorial (learned some new stuff since I learned Java way way back )

 

Now I am confused as how to design a website with OO.

 

I just can't seem to get my head around how to start.

 

I was thinking about making a class called webpage or website

in webpage would be two classes

header and body

header has some functions to get the HTML out

body has three classes left, middle and right

left will become a navigation menu

middle will be the main content

right will be a bar with sponsors, language selector, ...

 

 

And then I realised that this did not look OO to me.

 

I am sorry to make you all read this much but I am totally confused about how to start building a OO website

 

Any hints as to how to start the OO design will be very much appreciated.

 

anatak

 

Link to comment
Share on other sites

Have you tried taking a look at the MVC, model-view-controller, pattern? The controller processes user actions, the model handles the data and the view handles the view/template. You can check it out on Wikipedia and there are a couple of links in the resources topic regarding the MVC pattern. Personally I found that the easiest way to grasp this pattern is by taking a look at frameworks which utilize it. Examples of such could be CakePHP or CodeIgniter.

Link to comment
Share on other sites

  • 2 weeks later...

If you can't wrap your head around the concept of OOP, you probably shouldn't even consider using it.

 

The real question is:

 

Will I benefit from Object Oriented Methodologies?

 

If your answer is "???" or "No" or "I don't know", then don't bother.

 

If your answer is yes.. Definately take a look at CodeIgniter.

Link to comment
Share on other sites

will I benefit from an OO approach

yes I think I will since I found out that  a lot of my code is very similar to each other.

rewriting that into OO will be more efficient since I can extend classes.

 

the way I will go about this is that I will adopt a mixed approach.

 

most of my functions will be rewritten in classes

the reason is that a class is much easier to modify later than a function (IMO)

and that I can extend classes and thus reuse code easily and that the changes (hopefully improvements) made in the parent class propagate into the child classes.

 

If you can't wrap your head around the concept of OOP, you probably shouldn't even consider using it.

 

No I still don t see why it should be fully OO since that is not more efficient.

Yes I can wrap my head around OO it is not that difficult I think. It is just a different way of working / thinking.

I worked on some OO projects and I see the benefits for large programs. I just don t see the benefit of using a class to write say your header of your webpage unless you are making a lot of websites for people and then of course you can have a benefit. (not my situation)

 

thanks for the reactions so far

and I will look at the frameworks soon to get a better idea.

 

anatak

Link to comment
Share on other sites

 

No I still don t see why it should be fully OO since that is not more efficient.

Yes I can wrap my head around OO it is not that difficult I think. It is just a different way of working / thinking.

I worked on some OO projects and I see the benefits for large programs. I just don t see the benefit of using a class to write say your header of your webpage unless you are making a lot of websites for people and then of course you can have a benefit. (not my situation)

 

 

I think you answered your own question right there. One of the reasons for using Object based programming is code reuse ability. Not only in a single program but also in other programs. While Object programming can be helpful in one website / program it really shines when used for a base of several programs. i.e. CakePHP, Code Igniter, ...

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.