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

#1 adn258  Icon User is offline

  • D.I.C Addict

Reputation: 11
  • View blog
  • Posts: 762
  • Joined: 31-August 11

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.

Should I go back and fix it? I'm having troubles in my head.

Is This A Good Question/Topic? 0
  • +

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

#2 Mina-no-Hime  Icon User is offline

  • D.I.C Head

Reputation: 98
  • View blog
  • Posts: 176
  • Joined: 23-August 12

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.
Was This Post Helpful? 2
  • +
  • -

#3 JackOfAllTrades  Icon User is offline

  • Saucy!
  • member icon

Reputation: 6062
  • View blog
  • Posts: 23,513
  • Joined: 23-August 08

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).
Was This Post Helpful? 2
  • +
  • -

#4 adn258  Icon User is offline

  • D.I.C Addict

Reputation: 11
  • View blog
  • Posts: 762
  • Joined: 31-August 11

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

<?php
class SecurityQuestions
{
private $q = array("What is 3 plus 3?"=>"6", "The Opposite Of Happy Starts With An S And Is 3 Letters?"=>"sad","Opposite Gender Of A Female?"=>"male");

  public function GetRandomQuestion()
  {
	 return (array_rand($this->q));
  }

  public function bCorrectQuestionAnswer($question, $answer)
  {
	  return ($this->q[$question] == $answer);
  }
	
}
?>



This is just an example but I've been using this and when a user types and answer I use GET to send the question and post for the answer like so with the above function

Then In Using This for using GET with the action so that can be used
<form name="register" action="RegisterScript.php?Question=<?php echo $question; ?>" method="post">




$question = $_GET['Question'];
$answer = $_POST['SecurityQuestion'];
$q = new SecurityQuestions();

if (!$q->bCorrectQuestionAnswer($question,$answer))
{
  	RegisterError("Incorrect Answer To Security Question.  Try Again");
}




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
Was This Post Helpful? 0
  • +
  • -

#5 adelinebosanquet  Icon User is offline

  • New D.I.C Head

Reputation: -3
  • View blog
  • Posts: 1
  • Joined: 03-September 12

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

Posted 03 September 2012 - 10:33 PM

If you want to changes form the server side of your website, definately you should have to solve the huge errors of your website.
Was This Post Helpful? -3
  • +
  • -

#6 Lemur  Icon User is offline

  • Pragmatism over Dogma
  • member icon


Reputation: 1360
  • View blog
  • Posts: 3,433
  • Joined: 28-November 09

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

Posted 03 September 2012 - 10:45 PM

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.
Was This Post Helpful? 1
  • +
  • -

#7 adn258  Icon User is offline

  • D.I.C Addict

Reputation: 11
  • View blog
  • Posts: 762
  • Joined: 31-August 11

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

Posted 04 September 2012 - 12:04 AM

View PostLemur, on 03 September 2012 - 10:45 PM, said:

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.
Was This Post Helpful? 0
  • +
  • -

Page 1 of 1