Page 2 of 4

Posted: Tue Jun 06, 2006 12:23 pm
by MrPotatoes
once i learned how to use the MVC design pattern everything opened up for me.

arrays are the absolutel best but i still code them like in C/C++ because it's easier for me to see how it works otherwise.

the autoloader class i finished not too long ago made me go 'whoa'

Posted: Tue Jun 06, 2006 12:38 pm
by Christopher
MrPotatoes wrote:once i learned how to use the MVC design pattern everything opened up for me.
I'll second that -- especially a controller architecture. I have found that a good clean controller implementation makes everything else fall neatly into place. For me, Models and View are just busy-work.

Posted: Tue Jun 06, 2006 12:49 pm
by MrPotatoes
ew really? you code everything into your Controller?

i've been doing pusedo MVC's for awhile now. i just didn't know there was a real pattern that was already definded and used and documented. so it came pretty easilly to me. and man is my coding so much cleaner and nicer. i've done basically a front controller and a whol bunch of models and such. now i've got everything so split up it's sexy.

but i still put everything into the model and the controller really is justa switch statement that checks for user input in the views

honestly tho, my code is really clean and really nice. this is the best code i've writen in the longes time and i'm anal retentive about good clean code. ask my friends, i'm known for it lmao!

Posted: Tue Jun 06, 2006 12:56 pm
by Luke
my friends don't even know I know how to code... not that I hide it from them... they just wouldn't be interested. LOL

Posted: Tue Jun 06, 2006 1:37 pm
by jayshields
I don't have any friend in real life that code either. I'm really trying to get my mate into PHP so he can help me with my project. I gave him some URL's (inc. this forum - he's qwasqaws) and I've just leant him my PHP/MySQL book :)

Posted: Tue Jun 06, 2006 3:11 pm
by Buddha443556
Well no one else mentioned it ... so I'll throw in PHP + Ajax. I'm finding more and more way to use these together.

Posted: Tue Jun 06, 2006 3:18 pm
by Chris Corbyn
Hang on a minute. MVC? AJAX? These things aren't really PHP that made you go WHOA, these are more general fields that apply to other languages ;) Thinking of things just in PHP that make you go WHOA is pretty tough actually. I sadly can't think of anything much more than what's already been said :(

Posted: Tue Jun 06, 2006 4:16 pm
by MrPotatoes
d11wtq wrote:Hang on a minute. MVC? AJAX? These things aren't really PHP that made you go WHOA, these are more general fields that apply to other languages ;) Thinking of things just in PHP that make you go WHOA is pretty tough actually. I sadly can't think of anything much more than what's already been said :(
a pattern is something that is applicatble. if it has been started somewhere else fine but it doesn't mean that it's not PHP because of that.

and no, it didn't really make me go WHOA like my loader class did but it did make me thing how awesome it is to have a name and more guidelines for something that i've been doing quite literally for years :D :D :D

Posted: Tue Jun 06, 2006 4:21 pm
by Luke
well that's fine... I was looking for more programming concepts, so I guess the title should have been programming concepts that make you go "whoa!"

Posted: Tue Jun 06, 2006 4:32 pm
by Maugrim_The_Reaper
Thinking about where I came from, C++/Java, saying goodbye to int,long,double,float,byte,char,etc was actually kind of neat... I did miss type hinting and access control though - seemed a bit lazy at the time.

Posted: Tue Jun 06, 2006 4:43 pm
by MrPotatoes
Maugrim_The_Reaper wrote:Thinking about where I came from, C++/Java, saying goodbye to int,long,double,float,byte,char,etc was actually kind of neat... I did miss type hinting and access control though - seemed a bit lazy at the time.
i miss it and i don't miss it.

i love thier string stuff. but i wish we had pointers and control over loading. w/o having to actually change the way that it's put onto the server. well, pointers if you want them but don't need them kind of option. that would be awesome. cuz PHP is fast as hell as it is and with pointers it would only add to it but you don't actually need them if you don't want them :D.

that would be my perfect web language :D :D :D

Posted: Tue Jun 06, 2006 5:35 pm
by Chris Corbyn
MrPotatoes wrote:but i wish we had pointers and control over loading. w/o having to actually change the way that it's put onto the server. well, pointers if you want them but don't need them kind of option.
I doubt PHP will ever include pointers. I'm not sure there's even a need for it :)

Namespaces I would like. Especially for creating libraries which need to be integrated into any other code namespaces give you a nice clean separation.

Posted: Tue Jun 06, 2006 10:06 pm
by alex.barylski
Seems everyone missed the boat... :P

I thought this was PHP functionality only...?

Anyways...PHP has tons of quirks which have made me go whoa or &@#^&@$(*&

PHP4:

1) Objects instances are not unique
If you compare (using == or ===) two objects of the same class with the same data they are always the same...this is because PHP doesn't support instances perse in PHP4 - this is corrected in PHP5 :)

I encountered this problem while working on a DOM implementaiton...as it is possible to have a Node object initialized with the same data...

2) Class names are not preserved *exactly* as written but converted to lowercase for whatever reason.

If your framework code relies on your written convention...this can bite you in the a$$

Variable variables caught me by surprise when I first started as I typo-ed a variable wrong and couldn't figure out WTF was going wrong...

PHP Heredoc interesting...albeit hardly useful...at least once I got comfortable to using template engines anyways :)

Value and Value and Type Comparisons Using === or == was confusing when I started...until I got use to using a loosely typed language...

The ease of use of PHP was frustrating...it introduced a whole new set of problems that a compiler would typically catch...

Mostly...the paradigm shift of desktop application developement to web application development is what was most difficult for me...

Most Windows desktop applications don't require user login, etc...at least not on Win16/32...because of the lack of networks, distributed environments, etc on older Windows desktops...I also never paid much attention to security...filtering data, etc...

Later on, when I started with COM I began to pay attention to things like buffer overflows, etc...

SQL was probably the biggest hurdle for me...as I always start from the bottom and work up when I learn something...I couldn't figure out for the life of me how the hell SQL worked...

Understood it's concept...but needed to understand the underlying engine before I accepted it's use... :P

Were tables files or were tables stored inside a single database file...were some quqestions I had to ask...until I switched to PHP I wrote all data access by hand :oops:

That was an embarissing moment :P

Using PHP CLI is interesting if you require some advanced file search and filter...

Last but not least...PHP extensions are a real joy...especially those pointed out to me by Feyd...

The runkit extension lets me emulate Windows hooks...which are very powerful :)

If you can capture when a function, etc is called, you can do many cool things, such as:

1) Automatically profile your functions without having to enter start and stop code...
2) Generate a call graph of executed functions/methods
3) Disable functions, etc...

http://pecl.php.net/package/runkit

There are many little caveats of PHP which throw me off when I try something that C++ did nicely...but thats a whole different story :)

Cheers :)

Posted: Tue Jun 06, 2006 10:59 pm
by bdlang
Hockey wrote:PHP Heredoc interesting...albeit hardly useful...at least once I got comfortable to using template engines anyways
:o

I always use HEREDOC syntax, especially for SQL statements. Look at the difference:

Code: Select all

$sql= 'SELECT b.prodID, b.catID, b.title, b.market_price, b.sale_price, c.category, c.page  FROM books AS b INNER JOIN categories AS c USING (catID) WHERE b.ISBN = \'' .$ISBN. '\'';
compared to

Code: Select all

$sql= <<< END
SELECT
 b.prodID
, b.catID
, b.title
, b.market_price
, b.sale_price
, c.category
, c.page
FROM books AS b
INNER JOIN categories AS c
 USING (catID)
WHERE b.ISBN = '{$ISBN}'
END;
The ability to add / remove elements of the statement, enhanced readability is so much better; although you could use the concatenation operator to spread it across multiple lines, this way is alot easier and less code.

When I first saw this, it definitely made a 'whoa' impression.

Posted: Tue Jun 06, 2006 11:16 pm
by RobertGonzalez
bdlang wrote:
Hockey wrote:PHP Heredoc interesting...albeit hardly useful...at least once I got comfortable to using template engines anyways
:o

I always use HEREDOC syntax, especially for SQL statements. Look at the difference:

Code: Select all

$sql= 'SELECT b.prodID, b.catID, b.title, b.market_price, b.sale_price, c.category, c.page  FROM books AS b INNER JOIN categories AS c USING (catID) WHERE b.ISBN = \'' .$ISBN. '\'';
compared to

Code: Select all

$sql= <<< END
SELECT
 b.prodID
, b.catID
, b.title
, b.market_price
, b.sale_price
, c.category
, c.page
FROM books AS b
INNER JOIN categories AS c
 USING (catID)
WHERE b.ISBN = '{$ISBN}'
END;
The ability to add / remove elements of the statement, enhanced readability is so much better; although you could use the concatenation operator to spread it across multiple lines, this way is alot easier and less code.

When I first saw this, it definitely made a 'whoa' impression.
Funny thing, when I learned that you can span lines inside of strings (without concatenating) I found that SQL queries became a lot easier to read.

Code: Select all

<?php
$sql="SELECT b.prodID, b.catID, b.title, b.market_price, b.sale_price, c.category, c.page
        FROM books AS b 
        INNER JOIN categories AS c 
        USING (catID) 
        WHERE b.ISBN = '{$ISBN}'";
?>