Programming For Non-Programmers

Forum
Last Post
Threads / Messages

HIddenPanda

Premium Member
Premium Member
Joined
Jul 15, 2010
Messages
61
Points
8
Mysidian Dollar
3,655
Hi. If you're here I'm going to assume that you have never in your life opened/looked at a file of code before discovering Mysidia. Even if you have, maybe I'll have some tips/tricks that you find useful.

Integrated Development Environment
An IDE or Integrated Development Environment is the biggest scariest word for a text editor. IDEs, however, are specifically designed to make programming easier for everyone from beginner to expert. If you're trying to edit and navigate code in just Notepad, you might find that a lot of the text blends together and just looks like a checkerboard of symbols. Compare the two editors in the image below and how easy one is to read compared to the other.
1673977145292.png

I would recommend VS Code personally as it has loads of features and plugins, however you could also use something with an older look like Notepad++. Both are 100% free with portable versions available if that's your thing. Both editors include multiple themes so if light/dark mode isn't your thing they have the other one and probably some more.

VS Code Download
Notepad++ Download

Comments
Comment. Comment. Comment. Let's take a moment to think about a situation. You're going through files and changing bits of code here and there to tweak some mechanics or aesthetics of your site. Now fast forward and you've spent 3 months working on writing events and making assets, but you open up those files of code again and immediately go "what did I do here?" Past you could've/should've done you a favor and left a comment. But it doesn't stop there, you can add comments anywhere and everywhere, so if you don't understand something, leave a comment in the code that reminds you what it does when you learn.
1673979438508.png

Loops and Loops and Loops
Learn your loops! You will inevitably, at some point, want to deal with more than one object at a time. Say you want to write a custom script to give a group of users an item, loops will be your tool. PHP has 4 different loop functions. While, Do While, For, and Foreach.

while (condition is true) {
code to be executed;
}

As long as the condition remains true, the interior code will be executed repeatedly. This can very easily lead to infinite loops if you don't check to make sure that the target of the conditional statement is updated inside the loop. You probably won't need to use "while" much while working with Mysidia, but it never hurts to familiarize yourself.

do {
code to be executed;
} while (condition is true);

Do while is the same concept as the while loop, but instead of checking the conditional statement before executing the interior code, "do while" will always execute once before checking the conditional statement.

for (init counter; test counter; increment counter) {
code to be executed for each iteration;
}

For loops look more intimidating than they are. There are 3 lines of code where we would normally put a conditional statement inside the parentheses. Breaking those down, all you're doing is making a counter, which is only called at the beginning of the loop. Then is our conditional statement, which should compare against the counter and is called before every iteration. Finally, is the incrementation of our counter which is called at the end of every iteration of the loop to update the counter.

foreach ($array as $value) {
code to be executed;
}

Not picking favorites, but foreach is probably the most useful and straightforward loop. For each thing in my list of things, do some stuff. This is also the only loop that is relatively hard to accidentally end up in an infinite loop.

W3Schools
W3Schools is the best resource out there for referencing the basics of all of the major Web programming languages. They have details on all of the basics for HTML, CSS, SQL, PHP, and Javascript. If you want to lookup what a certain function, html tag, or css property does/is, this is the place. The PHP Manual is also great for getting more in-depth detail on PHP or looking up how certain functions work.

Call Stack, Errors, & StackOverflow/Google
"I loaded my page and just got this error." PHP will usually spit out at least two things when an exception causes the page to error, an Error message, and a Call Stack (often referred to as a Stack Trace). Generally, the Error message will indicate what went wrong, and the Call Stack will tell you where the issue occurred by listing the line(s) of code that were being executed and what file they were in. Usually the issue will be in one of those lines. Sometimes, the fastest way to decipher a weird error is to just copy and paste it into Google/Bing/DuckDuckGo/WhateverSearchEngineYouUseIn2023. This will almost always bring up links to StackOverflow posts from people with maybe not the same issue, but similar enough that could explain the issue/provide a solution. The internet is big and not as new anymore, there's bound to be a handful of people who run into the same problems.

TL;DR;
Don't use notepad. Study how loops work. Use W3Schools. Use Google

I hope this provides some help and maybe direction to newer programmers looking to get into this framework. It's one thing to learn programming from a "traditional" course, but Web programming is a beast where you're trying to tackle at least 3 and up to 5 programming languages that are all very different in formatting and function from each other.


Questions, Comments, Suggestions for additional information/tutorials are welcome on this thread, in my PMs, and I'm always lurking on discord. Bonus points if you can remember what Mysidia was called before Mysida :p
 

Similar threads

Users who are viewing this thread

  • Forum Contains New Posts
  • Forum Contains No New Posts

Forum statistics

Threads
4,274
Messages
33,113
Members
1,602
Latest member
BerrieMilk
BETA

Latest Threads

Latest Posts

Top