creating your own framework

  • (2 Pages)
  • +
  • 1
  • 2

20 Replies - 18806 Views - Last Post: 05 June 2012 - 06:36 PM

#16 shadowstep0705  Icon User is offline

  • New D.I.C Head
  • member icon

Reputation: 6
  • View blog
  • Posts: 48
  • Joined: 26-May 10

Re: creating your own framework

Posted 01 October 2011 - 07:43 AM

You guys think that creating your own framework is a good practice? Should you have much experience to build it? Or can a medium php scripter do it?
Was This Post Helpful? 0
  • +
  • -

#17 eZACKe  Icon User is offline

  • Garbage Collector

Reputation: 120
  • View blog
  • Posts: 1,278
  • Joined: 01-June 09

Re: creating your own framework

Posted 04 October 2011 - 11:24 AM

View Postshadowstep0705, on 01 October 2011 - 10:43 AM, said:

You guys think that creating your own framework is a good practice? Should you have much experience to build it? Or can a medium php scripter do it?


I have to side with RudiVisser on this one. I think you build your "framework" through work that you have just done (perhaps multiple times). So who can make a framework? I'd say just about anyone. Your framework will just grow with your abilities.

This post has been edited by eZACKe: 04 October 2011 - 11:25 AM

Was This Post Helpful? 0
  • +
  • -

#18 husseycoding  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 52
  • View blog
  • Posts: 174
  • Joined: 23-June 10

Re: creating your own framework

Posted 05 October 2011 - 03:26 AM

Personally, I just don't think that creating your own framework from scratch makes sense. I use Zend on a regular basis, and the vast majority of the work I undertake to pay the bills is developing Magento (itself built on Zend). Here are a few of my thoughts on the subject:

- Aside from the functionality it offers, a big plus in using Zend is the standardisation of code and moving away from the 'roll your own approach'.
- This immediately makes your work hugely more portable. Imagine if you wrote an application roll your own vs with Zend, then you find you need to bring in a new developer on the project - a Zend developer would be up to speed hugely faster.
- Compared to the development that has gone into Zend, one person is hugely limited on what they can realistically do. Why reinvent the wheel when there is software out there that does exactly what you need if you just spend a little time learning?
- Documentation for Zend is good, there is very little you will want to do that you will struggle to find an answer for.
- Zend is loosely coupled meaning that each component operates largely independently of the others - you can even pull out components and use them in your own project if you so wish.
- Although there is a lot of capability there, Zend is not bloated - you define the resources to be included in the project so only what is required is loaded.
- As your projects scale up, or perhaps you expand an existing project you'll only need to be constantly adding components to your roll your own framework that are most likely already there in Zend. Imagine creating something like Magento roll your own - no thank you!
- Zend is extremely scalable, you can use it for all kinds of projects from ones that only need one component to ones that need nearly all of them.
- Yes Zend takes time to learn, but put in the effort and you have an extremely powerful tool you would never be able to build on your own.

A few thoughts on Atli's 'rant':

One of the ideas behind the using an MVC framework is so that you don't have to worry about the intricacies of building your own SQL statements. On simple projects, yes it can be easy enough to write your own SQL statements, but with anything past a certain size, the queries can become pretty complex and pretty long - I know I wouldn't want to be writing some of the massive queries that Magento requires!

I know you can't 'see' the query you have generated directly with Zend, but if you spend a bit of time learning how to write statements the Zend way, you can write very complex queries quickly and easily without fear of any syntax errors. Also you can pull and display the raw database query as a way of checking exactly what the request is you are making should you need to.

As for the class names - they are actually all very logical. Simply, they just refer to the Zend component and various classes within each component. Also with the class name, you know exactly where the class can be found on the filesystem, so for instance the class Zend_Application_Exception is located at Zend/Application/Exception.php in the library. Pretty straightforward really.


So for me, rolling your own just doesn't make sense when you consider the capability and scalability of the solutions that are already out there...
Was This Post Helpful? 1
  • +
  • -

#19 Atli  Icon User is offline

  • D.I.C Lover
  • member icon

Reputation: 3715
  • View blog
  • Posts: 5,972
  • Joined: 08-June 10

Re: creating your own framework

Posted 05 October 2011 - 06:36 AM

View Posthusseycoding, on 05 October 2011 - 10:26 AM, said:

- This immediately makes your work hugely more portable. Imagine if you wrote an application roll your own vs with Zend, then you find you need to bring in a new developer on the project - a Zend developer would be up to speed hugely faster.

This is a good point. It's actually what prompted me to try and learn Zend in the first place. Wouldn't hurt to be able to put "Zend capable" on the resume :)

I just can't bring myself to go through with it though. Not until I need it, at least.


View Posthusseycoding, on 05 October 2011 - 10:26 AM, said:

One of the ideas behind the using an MVC framework is so that you don't have to worry about the intricacies of building your own SQL statements.

Not really. Well at least not for the "MVC" part. The "framework" part, perhaps.

The idea behind the MVC pattern is simply to separate the application into easily manageable layers. The model, being responsible for the application state and logic, is what handles the data, but the actual method used to access the data is not defined. Whether you use some sort of DAL or plain old fashion SQL queries, both are valid.

I, for instance, have been using the MVC pattern for all my projects for ages but I have never abstracted the way I access the databases (much); it's always things like raw SQL queries, or at the very most some simple view-to-class CRUD mapping for simple designs. That does not mean I'm using the pattern incorrectly, or not using it at all. It's a very open ended pattern, by design.

View Posthusseycoding, on 05 October 2011 - 10:26 AM, said:

On simple projects, yes it can be easy enough to write your own SQL statements, but with anything past a certain size, the queries can become pretty complex and pretty long - I know I wouldn't want to be writing some of the massive queries that Magento requires!

Personally I would rather spend ages building the queries myself, and know exactly what they are doing, than have them written for me by a query builder. I would never trust an abstractation layer to build a long and complex query without losing some of the optimization I could do manually. - But then, I tend to put a great deal of effort into my databases. More, even, than I do into my application design.

Hell, if the queries are really that long and complex you'd probably be better of separating them into a few views and/or functions. Tends to be better not to put to much of the database work onto the application code itself.

View Posthusseycoding, on 05 October 2011 - 10:26 AM, said:

As for the class names - they are actually all very logical. ...

True, but that's not what was bugging me. They tend to be very long and make the code unnecessarily verbose. I don't need the absolute path to every class I use listed right there in the code. I'd rather just deal with that in the header, using includes or namespaces if available, and then just call the classes by their "name" part in the code.
Was This Post Helpful? 0
  • +
  • -

#20 husseycoding  Icon User is offline

  • D.I.C Head
  • member icon

Reputation: 52
  • View blog
  • Posts: 174
  • Joined: 23-June 10

Re: creating your own framework

Posted 05 October 2011 - 07:40 AM

Hi Atli,

Thanks for the reply, a couple more thoughts:

'One of the ideas behind the using an MVC framework...' - to be honest I stand by what I said previously. I understand the MVC architecture, but I have never come across a developed off the shelf framework using MVC architecture that requires you to write raw SQL statements as the only way of querying a database. Not much of the 'M' left in that case.

As you point out however, yes it is perfectly valid to write raw SQL queries yourself (as you can also do in Zend should the need arise), but for me I understand what the SQL queries are doing and how they get built so laboring the point by creating them from scratch every time doesn't make sense. Also of course time means money to my clients so spending hours on SQL statements is just not a realistic or sensible option...

In terms of the way that the queries are built, they are actually very customisable and I would think you wouldn't be disappointed with the versatility you have in writing them. Some of the queries Magento generates are indeed very long, but then the application is very extensive as is the database, so short queries are only realistic in a few cases. There is also a huge amount of interplay between data in various tables - just because there is a lot of it and it's needed in a lot of different places.

Class names in Zend - well there are a lot of classes (have a look at the API documentation), so it's a logical way of doing things I think. I constantly use it in tracking down the various files in a Magento install - saves an absolute age. But you are of course free to use as short a class name as you like when building your own application.

I think that all these kinds of discussions pretty much boil down to each persons preference, experience and current project requirements, so as long as someone is happy doing it a certain way and it works for them then there is no real reason to change (as long as they are always willing to learn new things!).
Was This Post Helpful? 0
  • +
  • -

#21 cpumatt  Icon User is offline

  • New D.I.C Head

Reputation: 0
  • View blog
  • Posts: 24
  • Joined: 05-June 12

Re: creating your own framework

Posted 05 June 2012 - 06:36 PM

I've made a mini-framework for the things I always used in programs and it worked out very well. Though, if I just learned something, I'll keep typing it so I'll learn it and keep it in my head.
Was This Post Helpful? 0
  • +
  • -

  • (2 Pages)
  • +
  • 1
  • 2