resting — 2009-09-24T12:44:14-04:00 — #1
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.
kayarc — 2009-09-24T13:20:09-04:00 — #2
PHP's manual has a bit on OOP:
If you do not insist on writing code from scratch, use an OOP framework like CodeIgniter, Symfony, or CakePHP
dimis283 — 2009-09-24T17:17:22-04:00 — #3
My experience says too that OOP is very good.
I like the style of book .
If you want to use a framework I thing that it is obvious to practice first and then to use it at a production evironment.
Look also at yiiframework.com
kayarc — 2009-09-24T18:04:41-04:00 — #4
What are people's thoughts on Yii Framework?
danman — 2009-09-25T03:17:44-04:00 — #5
To design classes that could be used in other projects, you should, for example, not have dependencies inside your class, instead add those dependencies after object creation
$model = New Model();
dimis283 — 2009-09-25T04:52:29-04:00 — #6
I use Yii and my opinion is that is a good framework.
It use OOP and MVC patern, you may as example extend a base class of the framework or use and extend other classes or just create your own.
You may look here
resting — 2009-09-25T09:40:43-04:00 — #7
thats a very nice book you recommended dimis283
Yii is something new to me. how does it compare to those popular ones like zend, cakephp, codeigniter?
i guess to design a software, we should start with a UML diagram? any recommended open source solution for that? like i'm using mysql workbench for doing ERD diagrams.
dimis283 — 2009-09-25T11:26:05-04:00 — #8
Yii is relative new but has its base at prado, I used CI and I thing Yii is a better choice.
As I notice have many simiralities with cake as they are from Ruby on Rails as they saying.
Netbeans.org has support of uml and php.
czaries — 2009-09-25T12:08:50-04:00 — #9
I tend to model my data first. Recently, I just start with an ORM immediately. Data access and updating is something that happens all throughout your app, so its important to centralize all the functionality in a single place right off the bat. Otherwise, you end up with queries in a bunch of places they shouldn't be and code responsibilities can end up mixed pretty badly. OOP itself doesn't solve these design issues or prevent you from doing things you shouldn't.
sg707 — 2009-09-25T13:19:05-04:00 — #10
These day and age, developers don't do OO design as much as before. It's not like we're building from scratch. I'd say savy developers are more like "Open Source Architect". They would add the ingredients needed to make the developers to code faster! So, most of the time you just need build few classes that extend their framework. I hardly call Data model as OO design but if you do then this is where majority of OO design would fit in.
If you ever do java then these 3 are the hot tech to learn
JSF + Spring + Hibernate
By learning these, you'll automatically understand OOP.
jream — 2009-09-25T14:18:00-04:00 — #11
Ive been struggling to understand OOP for a while, and after messing around so long I'm slowly beginning to catch on. Be patient with learning it, it's kind of tricky.
I think the first thing you should try doing is making a MySQL Class, so that inserting and selecting is really easy, then you use 1 object of the mysql class through your entire aplplication.
pcspectra — 2009-09-25T19:53:42-04:00 — #12
OOP alone won't make your code better, you can write non-cohesive and highly coupled code in OO languages, just as you can break OO best practices while using OOP.
Brush up on OOD principles: http://ootips.org/ood-principles.html
Decomposing an object isn't easy, nor can be it be easily explained, each problem is different. What good OOP will facilitate is easier refactoring, so further decomposition of an object API becomes much easier.
Just remember DRY KISS...keep everything extremely simple...no method greater than 25 SLOC lines or whatever your comfortable with...
jake_arkinstall — 2009-09-25T20:02:50-04:00 — #13
Maybe so, but I'd definitely say that the learning process does. It adds another dimension to the way you think about programming. If you write a program procedurally, then learn OOP to a decent level, write the program in OOP then write it again procedurally, it's safe to say that all 3 versions will be very different.
Generally the 3rd (Procedural, after learning OOP concepts) will be neater and more structured than the 1st (Procedural, before learning OOP concepts), and the 2nd (OOP) and 3rd (Procedural Post-OOP) could be similar in some ways.
kayarc — 2009-09-26T03:09:42-04:00 — #14
OOP seems to be a different way of organizing and orchestrating your applications flow. When I first started, I wrote functions for everything and they ended up everywhere. At that point I hated it. I've been sticking with it and, although I'm still noob I suppose, really like it. For me it is far superior to procedural in many circumstances. Of course, there are times procedural makes more sense than OOP but generally only when you are writing something on a smaller scale.
renownedmedia — 2009-09-27T17:46:20-04:00 — #15
CodeIgniter is your friend, it forced me to use OOP and I haven't looked back. I no longer re-write code as all my classes are very modular.
CI uses the MVC approach for development, very useful for finding a good starting point with your application development.
treacle0996 — 2009-09-29T04:49:15-04:00 — #16
I am just getting to grips with oop. I am rewriting an ecommerce site to use it, and there are some cases when i don't know whether to use a class or just keep calling a function/include.
For example, inserting the google analytics code. To insert a chunk of code like that (something that will never change, and will never be inherited from) is a class the best
option, or an include, or a function?. Which takes the least processing?
Another example - i have a function, checkSession which returns the value of a session var or false. Presumably a quick lookup like that should remain a stand-alone function?
danman — 2009-09-29T07:19:10-04:00 — #17
Something like google analytics code would maybe be not be a candidate for a class, however I think the issue is also how you structure your site, do you want to mix php includes with classes for example? Therefore it could be wise to make a statistics class just to keep thing organised.
"checkSession" function seems to belong to a specific class, maybe a session or user class depending on your class structure...so avoid a stand alone function for this
feketegy — 2009-09-29T07:34:55-04:00 — #18
It's absolutely BAD choice using a PHP framework before knowing even basic OOP concepts, it's will mess you up...
First, learn the OOP principles, then try to make simple applications using OOP, only after this try a PHP framework...
Try reading a book on OOP, because it will give you a more systematic learning, than on blogs.
I recommend these books:
Object-Oriented Programming with PHP5
PHP 5 Objects, Patterns, and Practice
The Object-Oriented Thought Process
treacle0996 — 2009-09-29T10:10:39-04:00 — #19
danman, re the checksession example. I use that everywhere.
if user is logged, don't show login tab, show account instead.
if basket is not empty, show checkout option
check if user tried to access the checkout page without logging in first (so it knows to redirect after login)
for the id of the basket to add lines to
do you suggest i add it as a function to all sorts of classes?
danman — 2009-09-29T10:46:09-04:00 — #20
No not really..
A good approach could be to put the session handling in a class to be able to change that implementation if needed later on
public function __construct()
public function get($name)
And then the user class or basket class or something has specific methods
for example a "IsLoggedIn" method that uses the Session class...
if($user->IsLoggedIn())// do something
next page →