Newbie - What is a framework?

Ye' old general discussion board. Basically, for everything that isn't covered elsewhere. Come here to shoot the breeze, shoot your mouth off, or whatever suits your fancy.
This forum is not for asking programming related questions.

Moderator: General Moderators

Post Reply
nyzwerewolf
Forum Newbie
Posts: 2
Joined: Thu Nov 12, 2009 11:06 pm
Location: New York

Newbie - What is a framework?

Post by nyzwerewolf »

hello guys,

greetings to all.

my question here is probably very stupid. I'd like to know what a framework is. I recently started learning PHP, and I came across Zend Framework. I did some research and I found out that there are numerous PHP Frameworks available to use.

As of now, I only know how to write basic php and I use Coda, Dreamweaver, phpDesigner to write in.

So, What is a framework? What is it used for? if you can advise and help a newbie to get his feet wet, that will be great. Thanks a lot.

Lowell
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: Newbie - What is a framework?

Post by superdezign »

A framework in software is like having all of the necessary tools to build a house provided for you. Some frameworks are like having the materials and assembling them yourself, and other frameworks are like having a whole house built and just adding in the furniture. A framework is basically a foundation for starting your programming and, depending on the framework, it can speed up the development process. Any good framework will help with organization, but a few will actually improve your programming speed after you surpass the learning curve.

Zend is an example of a do-it-yourself framework, where you are provided the tools and it is up to you to assemble your system.

When it comes to using a framework, it's better to avoid them at the start of your programming and learn the basics first. Otherwise, you will likely not understand the implications of your code.
nyzwerewolf
Forum Newbie
Posts: 2
Joined: Thu Nov 12, 2009 11:06 pm
Location: New York

Re: Newbie - What is a framework?

Post by nyzwerewolf »

Thanks a lot for clearing up this for me! I really appreciate it.
I am going to stay away from frameworks until I have learned the PHP language & it's integration with databases completely.
I hope to learn from you experts in the future.
Thanks again,
Low
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Newbie - What is a framework?

Post by josh »

Technically speaking, I think a framework is anything that "inverts control". That might not make sense, but think of this

Code: Select all

 
abstract class My_Framework
{
 function doHardWork()
{
// bunch of code
$this->doEasyStepA();
// bunch more complex code
$this->doEasyStepB();
// more code
}
abstract function doEasyStepA();
abstract function doEasyStepB();
}
 
Then the user of this framework would extend this abstract class, overriding certain methods. I like to make a mental picture of this big machine with mechanical arms, that hold buckets. And you the programmer, put things in certain buckets, when you turn this machine on it's big mechanical arms come to life moving in all sorts of fancy patterns and movements, that interact with the "stuff" you put in each bucket.

Kind of an abstract way to look at it, but thats how I think about it.

For instance Zend has a Form framework, it helps you write web forms. Sometimes though, you need to write your own code, like validation logic. It has "buckets" (classes) where you can put your validation logic, while letting the forms library do all the heavy lifting, your little validation class just gets called when it needs to validate data, and just returns true or false, your little validation class is a "plug in" to this framework. This framework "machine" knows when it needs to validate a field, to call the code you put in it's "buckets".

So basically like superdesigns explanation, I would consider the pre-fab house that you put furniture into, a framework. If you were just given the building materials then id call it a library.
Wolf_22
Forum Contributor
Posts: 159
Joined: Fri Dec 26, 2008 9:43 pm

Re: Newbie - What is a framework?

Post by Wolf_22 »

Does / Would this mean that Wordpress uses a framework? If so, what is it?
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Newbie - What is a framework?

Post by josh »

Wordpress is a poor example of the proper way of doing things. For something semi-decent see Joomla. Joomla uses a framework
Wolf_22
Forum Contributor
Posts: 159
Joined: Fri Dec 26, 2008 9:43 pm

Re: Newbie - What is a framework?

Post by Wolf_22 »

josh wrote:Wordpress is a poor example of the proper way of doing things. For something semi-decent see Joomla. Joomla uses a framework
Ouch! I use Wordpress thank you very much! :D

Seriously, I'll take Wordpress any day over using Joomla. It may have a better framework, but it will never be as easy to use or as easily configurable (in my mind, at least--my little, tiny, minuscule mind...). :drunk:
User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Re: Newbie - What is a framework?

Post by superdezign »

Wolf_22 wrote:
josh wrote:Wordpress is a poor example of the proper way of doing things. For something semi-decent see Joomla. Joomla uses a framework
Ouch! I use Wordpress thank you very much! :D

Seriously, I'll take Wordpress any day over using Joomla. It may have a better framework, but it will never be as easy to use or as easily configurable (in my mind, at least--my little, tiny, minuscule mind...). :drunk:
I think josh is referring to the programming style. I don't use Wordpress, but I believe it does not make use of OOP. Though OOP is admittedly slower, especially in interpreted languages, it is still considered best practice in terms of producing maintainable and readable code.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Newbie - What is a framework?

Post by josh »

I use wordpress for blogging too, but not programming
Wolf_22
Forum Contributor
Posts: 159
Joined: Fri Dec 26, 2008 9:43 pm

Re: Newbie - What is a framework?

Post by Wolf_22 »

To each their own, I suppose. Wordpress does, however, make use of OOP--whether it's good use, though, is another discussion. All I know (what little I know) is that I've always had better productivity with Wordpress in terms of any aspect of website design. I'm currently working on a Joomla project where a subscription facility is being implemented and the Joomla package itself doesn't even yet support PHP 5.3 (unless you use an experimental patch or else if I'm mistaken). I've just never had a lot of luck with Joomla. :(
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Re: Newbie - What is a framework?

Post by josh »

I just thought I'd add that the benefits of frameworks extend beyond helping you get work done faster, they help you adhere to more consistent code styles that adhere to proven techniques. In fact one may find it will take longer to build something with a framework, initially, but later on features can be added continually, whereas without the framework the programmer may fall victim to a bad architecture and become riddled in bugs :banghead:

Theres lots of properties of a framework, for instance extensibility. You should be able to add features (which includes changing existing features) without hard coding anything that would prevent you from taking advantage of future versions of that framework. In this way just because you skinned a blogging software doesn't mean you used a framework (not that thats inherently bad)
Post Reply