6 Replies - 839 Views - Last Post: 04 September 2012 - 12:04 AM

My Site Isn't Well Programmed. Should I Redo it?

Posted 02 September 2012 - 11:35 PM

So I just started PHP like a week ago and I've used other languages like C++ and C# etc. and I really didn't know PHP was object oriented. I've been able to think of algorithms to solve a lot of my problems with PHP MYSQL for displaying things dynamically etc. but a lot of this is done in all the php pages that I use POST or GET in. The code works but somehow I'm not as impressed with myself because I feel like I should be using objects fields and functions etc. within those objects like I have with other languages.

Replies To: My Site Isn't Well Programmed. Should I Redo it?

Re: My Site Isn't Well Programmed. Should I Redo it?

Posted 03 September 2012 - 12:50 AM

I'm assuming (because you're just beginning) that your site isn't one actually getting much traffic - which makes starting over a lot easier. However, I tend to advise against working and reworking the same project, because it doesn't expose you to as many different concepts as you'll get by working on different types of projects.

My suggestion is as follows:
Do not try to keep a site that you are programming as your main blog/site/portfolio until you are capable of writing a secure, maintainable piece of software. I instead recommend using a CMS or blog system such as WordPress for a site like this, or to stick to a site such as Tumblr.

Work on different projects as you learn -- as I said earlier, developing one monolithic project, such as a blog, will not expose you to as many situations as developing several smaller projects. When you get to a point where you either declare a project complete (less likely as a beginner, more likely as a more experienced programmer), or to where you've determined that you've learned enough to realize that your current work isn't up to par, leave the project and get started on a new one. As important as it is for you to be able to complete projects, at the beginner level it is far more important for you to expose yourself to as much information and practice as possible -- completed projects mean nothing if they're a mess, or incredibly simplistic.

Focus on building bigger and bigger projects, but start over from the beginning as often as you can. It'll help solidify your knowledge of what you've already learned to implement, and it will help to prevent you from feeling too overwhelmed when you start getting into the more complex parts of the new project.

Re: My Site Isn't Well Programmed. Should I Redo it?

Posted 03 September 2012 - 08:12 AM

Alternatively you can look to start over using a framework, like CodeIgniter, CakePHP, Yii, and any of a number of others. These use the best practice of a Model-View-Controller architecture. In using these you will design the database up-front, then build the Model (models the data; these classes will interact with the database), the Controller (this uses the data from the Model), and the View (presents the data set by the Controller in a format as desired by the client).

Re: My Site Isn't Well Programmed. Should I Redo it?

Posted 03 September 2012 - 08:37 PM

I really appreciate your guy's help. I feel I am doing a great deal better though since I started using good old Objects in this language Object Oriented like normal and my code is a lot better. In this case I will try to redo this project it's worth it to me. Since I've had a decent amount of other programming experience this is becoming more breezy like my questions answers functions for security questions

I don't know. Since I've only been PHPing for the past week and a half I feel like this is at least ok? I will look at CakePHP more? I looked at their site though; I'm confused what exactly does this do does it code for people now? lol

Re: My Site Isn't Well Programmed. Should I Redo it?

You might also note that PHP is not the only language on the Web front. There's Python (Django) and Ruby (Rails) [...and several other frameworks] that are just as well to look into.

I prefer rails myself, PHP just never really did it for me. I liked the simplicity, elegance, and power that Ruby had to offer and I just stuck with it.

I would avoid reworking something if at all possible. That's what planning and analysis are for. You should spend at least 3 times as much time in preliminary planning and design than you do actually writing the program. This assumes the program is of a large nature and requires this, instead of hack job sysadmin one shot scripts.

Re: My Site Isn't Well Programmed. Should I Redo it?

You might also note that PHP is not the only language on the Web front. There's Python (Django) and Ruby (Rails) [...and several other frameworks] that are just as well to look into.

I prefer rails myself, PHP just never really did it for me. I liked the simplicity, elegance, and power that Ruby had to offer and I just stuck with it.

I would avoid reworking something if at all possible. That's what planning and analysis are for. You should spend at least 3 times as much time in preliminary planning and design than you do actually writing the program. This assumes the program is of a large nature and requires this, instead of hack job sysadmin one shot scripts.

I agree. I also notice when I start thinking of namspaces and importantly classes holding methods etc. I start programming way smarter even for PHP. The thing is and I know this sounds embarrassing but since I started PHP literally a little over a week ago I didn't even know classes and objects existed for PHP until like 3 days ago. That's embarrassing but true.