A question about how to proceed with coding a project

30 Replies - 13755 Views - Last Post: 22 March 2011 - 02:21 PM

Project: Framework or code from scratch?

Posted 31 December 2010 - 11:37 PM

POPULAR

Hello fellow PHP developers.

Mostly I have only worked on smaller projects that only served one small and sometime simplified purpose. But lately I have got the urge to begin on something bigger. Now I got the blueprints, and I have the idea. Even started with some code in the CodeIgniter framework, but my problem is this. Is this going to hurt in the long-run?

Specifically what I am wondering about is: When working on a bigger project with a large infrastructure and a lot of content, is it wise to use a framework, or should the code be written by scratch?

If you have any experience with this topic I've would love to hear about it.

Replies To: Project: Framework or code from scratch?

Re: Project: Framework or code from scratch?

Posted 31 December 2010 - 11:50 PM

Moved to PHP Programmers.

In the real world, you will often times be working on large projects where a lot of the code is already written and you will be maintaining or expanding upon it. Essentially, you will be working with other peoples' frameworks.

In regards to 3rd party APIs, there is a saying in the IT world about reinventing the wheel. Using 3rd party APIs can cut down on development time significantly and allow you to focus on the specifics for the project rather than a lot of the backend stuff.

So to answer your question, I think familiarizing yourself with some commonly used 3rd Party APIs is a good idea.

Re: Project: Framework or code from scratch?

Posted 31 December 2010 - 11:59 PM

First off I want to express my gratitude with moving my post to the PHP Programmers thread, thank you!

I guess it is true that you rarely are the first off to code on a large project. But when you are saying 3rd Party APIs, what exactly do you mean? Are you thinking of basic APIs like ones from Google Map? Or are you referring to more complex ones?

If I were to start a project in the PHP framework CodeIgniter, would that set any limitations on including 3rd party APIs?

Re: Project: Framework or code from scratch?

Posted 01 January 2011 - 12:14 AM

Ah, now I fully understand your statement.

Yes, 3rd party APIs can't really limit you in any way. But what I sometimes wonder is this: "Is it healthy to use a 3rd party application or framework?". It speeds up productivity and maybe even optimization by using methods that you were not even familiar with. But I just can't help feeling that in some way or another, it got to be bad practice.

Is there any advantages by writing your code from scratch, besides that you know your application inside out? Which you also can with a framework developed application by actually reading the pre-made functions and methods you use.

Re: Project: Framework or code from scratch?

Posted 01 January 2011 - 12:21 AM

It's more the design of the framework. Certain 3rd Party APIs are just poorly designed, buggy, or cumbersome. This makes them a pain to work with. Always a good idea to research the APIs before choosing them to make sure you are getting what you want.

As for writing everything from scratch, that just doesn't happen anymore. Even APIs like XML Parsing, database connections, etc., are all pre-written. At some level, you will be using someone else's code.

Re: Project: Framework or code from scratch?

Posted 01 January 2011 - 12:34 AM

I completely agree that the tools and APIs that you choose to work with are critically important. None of us would like to wake up one day and see that that API are no longer supported or updated, though this doesn't stop you from using it - but it makes it less attractive. At the same time when choosing a API it'll have to be thorough, we don't want to find our self re-writing your code because that originally chosen API didn't fit you needs suddenly.

But am I the only one that feels that instead of being raw developers, we are simplifying the job heavily that it makes us maybe - less of a developer?

Now it is my believe that if you can explain to your self and others what actually happens in that and that specific line of code, you are a raw programmer. Since you could just have written the original API code your self, because you understand it. Still, I don't find my self browsing trough my APIs and frameworks at first. Maybe I should.

Your thoughts on the matter is gratefully appriciated.

And thanks for posting this thread on the DIC twitter page, very kind of you.

Re: Project: Framework or code from scratch?

Posted 01 January 2011 - 12:41 AM

A lot of newbies have the same thoughts about reinventing the wheel. In the IT industry, there is another saying that goes something like: The novice programmer asks "how can I?", while the experienced developer asks "where has this been done before?".

In real world development, you don't have the luxury of time to reinvent the wheel always. And you/your team will probably be doing something of significance, not just pencil pushing or writing 10 lines of code. It will probably be an involved project. If you want to gain the experience of reinventing the wheel personally, go for it. It can be a good exercise. However, professionally, your boss(es) care about getting the project done on time and that it is functional. They don't care if you are a "raw" programmer or not if the project works as they want it to.

Re: Project: Framework or code from scratch?

Posted 01 January 2011 - 12:54 AM

I enjoyed your novice-expert saying. And I guess it is true as the clients wants their product as fast as possible, naturally. And if the result is the same, more or less, why not go with a framework and APIs that fits your needs.

One day I think I'll try and invent the wheel again, hopefully after that I would feel more comfortable working with the existing frameworks. I guess that the bottom line is that am afraid of writing something that couldn't be mine, and that I have a urge of understanding the skin and bones of my work. But I guess this varies heavily from developer to developer.

Re: Project: Framework or code from scratch?

Posted 01 January 2011 - 08:55 AM

Quote

the experienced developer asks "where has this been done before?"

You've obviously never met my boss Although I must admit he's getting better, but where PHP is sort of the bastard child of our huge project (the meat is in the servers which are running primarily C), the UI is somewhat...unwieldy

Re: Project: Framework or code from scratch?

Posted 01 January 2011 - 12:18 PM

My opinion about frameworks is this: There are many facets to a large framework and each of those pieces have received a lot of attention over time by someone who is an expert, or at least very knowledgeable, on the piece s/he worked on. (at least this is the way it SHOULD be) If you go ahead and make your own framework, if you're not an expert in each area you will probably do something wrong or forget an important piece, which could end up compromising the security or the stability of your projects that use the framework. There is a reason that frameworks are updated often: they missed something. There are tons of updates to every framework that fix security holes because there are tons of ways that apps can be exploited, and if you don't have knowledge about each of those security risks then you could get yourself into a lot of trouble.
I know this post sounds a bit grim, but it's more true than it should be. I'm not saying that you can't make your own framework for your projects, but if it is public, I would put your trust in something that has been tried and tested.

Re: Project: Framework or code from scratch?

Posted 01 January 2011 - 12:42 PM

joezim007, on 01 January 2011 - 02:18 PM, said:

...if you're not an expert in each area you will probably do something wrong or forget an important piece, which could end up compromising the security or the stability of your projects that use the framework. There is a reason that frameworks are updated often: they missed something.

I'm not saying you're wrong, but something to keep in mind is that if you use a framework and they did miss something, your site becomes extremely vulnerable as soon as a hacker compromises another site that uses the same framework. If you wrote your own then your security flaws are yours and yours alone, assuming you've made decent effort at making your site secure. Hacking somebody else's site gives no advantage to the hacker attacking yours. There are pros and cons to everything!

Re: Project: Framework or code from scratch?

Posted 01 January 2011 - 04:34 PM

Sorry if I'm repeating something someone already said. I didn't take time to read all the posts.

I find coding from scratch in PHP better for me. I've learn tons and tons of things having to code the project from the ground up that I wouldn't have had to learn if I went with framework like CodeIgniter. Once you've learned the language sufficiently I'd suggest going with a framework.

Re: Project: Framework or code from scratch?

Posted 01 January 2011 - 05:03 PM

If you program in a high level language then you're already using someone else's code in your project. Take addslashes for example: You can either call the one included in PHP or write your own. It's the same for every method that the language provides.

Maybe you think that using a third party API diminishes the contribution you make to your own code. However, really it's just about how you spend your time. With a third party API you can code faster. This means you have spare time to add more features, test more thoroughly, complete more projects or just more time to spend with your girlfriend.

Re: Project: Framework or code from scratch?

Posted 02 January 2011 - 02:25 AM

CTphpnwb, on 02 January 2011 - 04:42 AM, said:

joezim007, on 01 January 2011 - 02:18 PM, said:

...if you're not an expert in each area you will probably do something wrong or forget an important piece, which could end up compromising the security or the stability of your projects that use the framework. There is a reason that frameworks are updated often: they missed something.

I'm not saying you're wrong, but something to keep in mind is that if you use a framework and they did miss something, your site becomes extremely vulnerable as soon as a hacker compromises another site that uses the same framework. If you wrote your own then your security flaws are yours and yours alone, assuming you've made decent effort at making your site secure. Hacking somebody else's site gives no advantage to the hacker attacking yours. There are pros and cons to everything!

I would have to disagree. If you are building something on even a quarter of the scale of CodeIgniter, you introduce so many different possible security flaws, it's not funny.
Having a framework like that means a) so many security helpers are built in already (e.g. XSS cleaning by default in a few places!), and B) any flaws get fixed quickly, and c) so many people are working on the same project that flaws are mighty few in the first place.
You'd need to be a freakin' expert to avoid ALL of these flaws.

Reinventing the wheel, whilst good experience, needs you to avoid all of the flaws and pitfalls along the way. And in plus, there are very few possible attack vectors that CI sets: most of them, once again, come back to the framework-user's code, so in my not-so-humble opinion, using a framework is a fantastic idea, unless a) it's much bigger than your project needs to be, or B) it forces you to use an overkill design methodology, therefore adding a ton of work.