News:

Please note these forums are mostly a testing ground for my SMF work and I don't really use them otherwise.

Main Menu

Where does a script come from

Started by SleePy, Jun 27, 2008, 09:08 PM

Previous topic - Next topic

0 Members and 2 Guests are viewing this topic.

SleePy

Well, this is easier to explain to anyone of all ages (unlike explaining where other things come from).

For me, a script just doesn't appear nor do I just open something up and start coding right away. I don't know about most people but I do know I like to think about what I am going to do and think about the best possible way to accomplish it.

For the most part, I start off with just thinking about it. It may take days to do this. I usually find it best to go do something like play video games or work really hard at work. I don't know why, but once I have my mind off coding I am able to think very clearly on how to create something. It is usually during something else I spawn the good idea and then start working out the details in my head.
I go over what I think I will need such as functions, loops, arrays, variables, etc. It makes it fun when you have other things such as SMF going to be involved in the script as then I start to add in, doesn't SMF do this already? Then go about thinking how I can accomplish it without doing to much work and using my already available resources.
This is why I like working on very new versions of PHP. If I where to use PHP 4, I couldn't use the scandir function and would need to use the opendir function and set it into a handler, then loop through it in a while and get all the files/directories in that directory into an array and then close it. Thats a lot more work than just calling a simple function.

If I am going to be working with a database it depends on what I do next. If I am using SMF such as making a mod, I will manipulate things in the database to see if I can't use already available tables and columns). If I am using my own database or not using SMF, I usually hold off on this for a bit.

The next part is actually working with the script. If I am not using SMF but my own script, I usually save time and just hard code things that will sooner or later be arrays or variables that where received from a database query. My main focus at the point is to just get it going. During this process I usually don't remove hard coded text strings or anything like that. It makes it easy for if I have a new sparked idea on how to do something I can change it without going to to many files. As well I usually hard code right in there at the end of it the template part so I can easily split it out and debug any issues from that.

Once that is done, if I did hard code queries, I go back in and make them work as they should and start manipulating the database. Sometimes I am not messing with a database but instead a file or something, no mater what I am doing, I usually leave the dynamics such as files or queries until I got the initial idea down of how I wanted the script done.

After I got it working more dynamic, I start by removing hard coded text strings and using sprintf function as needed to make it so translation into other languages work properly. As well during this stage I will also move it correctly to its template and make the calls in source files as needed so it knows what template file we are looking for.

Finally I have the script going, its dynamic, its using language strings, it has a template, but I am not done yet. At this stage I am usually doing bug checking to ensure it should still work. I check my theories and functions to make sure they are logical. As well if I didn't already I make sure I am using proper coding and comments (where needed).

Hopefully after all of this the script is ready. I then do some more final touches to it. Add some spices and maybe some Easter eggs. Who knows, its all working and ready to go, I can add some fun stuff if I wanted to :P

That is how I usually come up with a script, Most people don't realize that a script just doesn't always appears. By doing things in this order it does help out with your script development. For others it is sometimes easier to just start coding, find issues and continue through this process of guess and check and possibly tons of rewrites to just get where they wanted to in the first place.
No siggy! :D