Do you do OOP?

Take a look at Zend Framework, I’ve been using it for months now and it has increased my productivity dramatically :wink:

It’s all about throwing balls.

When you throw a ball a lot of things happen. Nerves fire. Muscles flex: brachialis anticus, deltoid, biceps, pectoralis major, coracobrachialis - all the many muscles of the arm. And not just the arm. Millions of years of evolution have hard-wired Newton’s laws of motion into our command and control systems. When you throw a ball, you don’t fall over with that every-action-has-an-opposite-reaction thing. Almost every muscle in your body has a part to play in throwing the ball, maintaining balance and just generally looking well-buffed in case anyone is watching.

There’s a lot going on, when you stop to think about it, too much for us to actually comprehend in real-time. We’d be overwhelmed with data. Luckily we don’t have to. We just think “throw the ball” and moments later, there it is, flying through the air.

That’s OOP.

A class presents a simple interface to all the fiddly details. We don’t really care what they are (at least not at the point of use). We just want to throw the ball, as quickly and simply as possible. We’ve got lots of other things to do as well and there’s a limit to what we can hold in our heads at one time. A nice simple interface to a complex set of actions helps us to understand what’s going on.

What should be encapsulated? Good classes tend to do just one thing. They round up a bunch of related data and behaviour in one place rather than spreading it around all over the app. That is the key skill: figuring out how to cut the logic cake to make good, coherent components. Sometimes there isn’t only one answer just a series of choices and consequences.

For me i use OOP framework like CodeIgniter, Symfony, or CakePHP since i do not write code from scratch…its more easy and effective…

Thanks for that danman.

So, you are suggesting that the isLoggedIn method would create a new Session instance ?
Or would I create an instance at the start of each page and pass that through to User? - and any other classes that needed it

This is the part i’m finding hard to get my head around - when to create new instances and when to pass things through. It seems wrong to create an instance every time i just need to get a single value. Isn’t there a big overhead to that?

Yes “isLoggedIn” method could create a new Session instance. I dont think it will cause any problems.
Do not create an instance at the start of each page, it seems unnesesarry since you dont know if it will be needed…in my opinion …

Consider a singleton approach on the session class since session_start(); for example should not be called more then one time …

I dont think you have to worry about overhead for this…
Anyway the question about creating an instance or not or call static functions is debated back and forth and i think it it hard to answer in generel terms…

Really? Whenever I try the ZF for anything more than a simple project my productivity plummets dramatically :lol:

zend framework is how you should not program OOP.

Its just a bunch a static classes that cause spaghetti code.

I just love the smell of FUD in the morning.

Exactly how many “static classes” have you found in the framework? Zend_Debug is one. Is one too many for you?

Try to look for “static function” … there you’ll find entirely different count.

How many? And what percentage of the total methods are static? And hows does that percentage compare with other popular frameworks? Hard data please.

The original design from several years ago did indeed rely too much on static classes and methods. Most of those have since been re-factored. There are still a few but not many.

There are some things wrong with the framework (which is true for all frame works) but overuse of static’s is not one of them.

During the early builds and beta releases, that was true. However, that is certainly not the case anymore, and hasn’t been since about beta 0.8. Zend Framework is now at 1.9.

I suggest you take another look at Zend Framework before spreading rumors like that.

I don’t need to look at it again. It has 1,000’s of people working on it and no proper direction.

Its the too many cooks proverb.

I don’t even think many of the people who have been working on the zend framework have even been to college. They seem to be all self taught and have never worked with any other type of OOP language before.

I’m sure that if the zend framework did not have the zend name on it then it would not be mentioned so much.

I seem to remember the original creator of PHP Rasmus Lerdorf not being happy with zend framework.

When people argue for using ZF its hard to tell what experiance they have, if they are just into the hype or which other frameworks they have used.

Seriously what can ZF do that code igniter can not?

There are almost certainly a lot of static of methods in ZF, but to be fair, they are there to implement tried, tested and well researched architectural design patterns.

I don’t use Zend, much to my disadvantage I might add, but lets understand why those static methods are there before attempting to slate them…

tried, tested and well researched architectural design patterns

So does every other OOP framework.

patterns should only be used when there is a problem the pattern can solve. zend seems to use patterns when they are not needed. same with a lot of people on this forum. they don’t use KISS. they just use patterns for the sake of using them.

so what are you saying code igniter does not use design patterns? or any of the other frameworks.

It seems to me that you are digressing a bit. Once again, how many static classes are there in the framework and how does that compare to other frameworks? Let’s be specific here otherwise the impression is given that maybe the code has not actually been looked at since it was released.

hold on I just downloaded the latest version opened a random library file. all session methods are static and the same goes for the cache. first 2 files I open.

that is not how you setup a session class or a cache class. how the hell are you soposed to draw a diagram showing where the cache or session is being used. Its completly stupied. they might aswell just use functions.

Let me start by saying that it is very encouraging that you are willing to actually look at the code. It would have been nice if you had learned something about it before proclaiming it to be useless but I know how unreasonable that would be.

Now you might want to take a peak at the documentation

Before getting all worked up. You see, Zend_Session_Namespace is the usual session object. Zend_Session is merely used to setup some parameters.

Zend_Cache is similar.

Once you start coding non-trivial apps you might start to understand how some thing work.

last version i used was ZendFramework-1.5.1

Look I’ll show you how bad ZF is.

No. Of Files

Mail
ZF: 29
Code Ignter: 1

Cache
ZF: 16
Code Ignter: 1

Request
ZF: 1
Code Ignter: 1

Log
ZF: 14
Code Ignter: 1

Config
ZF: 4
Code Ignter: 1

Controller
ZF: 40
Code Ignter: 1

View
ZF: 43
Code Ignter: 1

Ever heard that its harder to keep programming simple than it is writing complex code?

This is because people with with years of experience such as myself know how to code efficiently with the minimum amount of code.

I don’t need ZF cache class I can code my own in 5 minutes with just the right number of needed methods and without the bloat of having to load more than 1 class.

I just don’t understand how you can argue when I show you these types of figures.

One person just argued that ZF uses design patterns.
So do all the other frameworks.

What are you going to say next? that ZF is light weight?
It clearly is not.

That it uses MVC?
So do a lot of the other frameworks and they do it the right way with a lot less classes.

Are you going to say that ZF is easier to use?
How can it be easier to use when it has such a large API? Its like learning smarty to create a web site instead of learning PHP.

Its the fastest!
I seem to remember ZF benchmarked against other frameworks and it got the lowset score. So its not a fast framework.

Remember Zend the company did not create PHP they just piggy backed on it so they could sell their warez. They have about 6 contributors to PHP out of 1,000 people who are working on each release.

Do you or anyone else have another argument why ZF is the best framework to use?

Zend could maybe be taken to another topic? The OP:

Do you?

If you do, what are the steps you take from design to actual production?

I’m a lonely programmer and I keep repeating codes. Haven’t realized the power of OOP yet cause I don’t know how to start. Don’t know what are the classes I need. Don’t know how to design classes that could be used in other projects.

I think it’s helpful to discuss what makes a good or bad class without getting too bogged down with Zend.