For those seeking enlightenment, this page describes ancient secrets used by the Hidden Masters to lie and cheat their way into the Final Rubykk Heaven. At the small cost of all your integrity, you, too, can follow this path.
The ocean of code can often be an intimidating place, and every navigator must understand the lay of the waters before they can set course across them. As a master, you have the ability to part this ocean into smaller seas (properly named and labeled of course!) will allow you and any other to more easily travel through your code ocean.
Especially as your application grows larger in scale, a good organization system allows you to navigate through the ocean of code with ease. Use separate files and create folders as necessary to keep both your project and your mind organized. A master should not need memorize their entire file structure to do their work.
Put each distinct class into its own file and name the file after the contained class. Use folders as necessary.
Global variables are not your friends. At best, they are temporary allies with whom you should develop a distaste working with, for, or around.
Accessible everywhere in your project, they are the social truest butterflies of the variable realm, but also the easiest influenced. Being seen everywhere means they can be changed, distorted, altered, manipulated, and otherwise bamboozled at any place in the project.
Imagine you give some important data to a global to hold. Imagine you love this data. Imagine it's vital for your life that this data remain safe. After they traverse the land of your lengthy application, they arrive back to your console with all that beautiful data mangled- why? How? you ask, but they cannot quite remember; since everyone in the land could have done this, knowing where to begin your search for justice is a challenge all on its own. Global variables' ability to traverse the entire breadth of your application is impressive and at times an asset, but their unreliability should relegate their usage to sparing, at most.
Be a true master and remember that globals are best when used practically never.
Think of the splat as a sponge; it's there to sop up any leftover arguments after all of the other arguments have had their chance at the input. Anything that the splat sops up will be input as an array with the name to which the splat is attached.
A master will use the splat to triumph even under unknown circumstances.
It's important to keep any information that the user does not explicitly need hidden or inaccessible outside of your code. This prevents the user from inadvertantly doing something harmful to the properties and methods in your code. This is best accomplished through encapsulation and keeping each object or method limited to one specific purpose.
Divide your tasks into specific objects and methods for the safest organization.
Variables are the vessels for the data in your application, and masters must learn to tame these beasts. The first art of taming is deceptively simple but all can fail without proper variable names.
When calling into the ether and demanding a new variable into existence, you must be sure to give this variable a meaningful name, selected with careful intention. One must not overlook this simple task; when you have thousands of variables inhabiting your future application, unclear names will make a nightmare out of sorting out data flows and scope. Debugging becomes a hellish task, and you will suffer endlessly for your lack of foresight.
A master names all variables with care and intention.
Ruby is magical and sweet, its cloying nature well known to the many masters. Compact and small code is a beautiful feature of the language and the three-part ternary adds a great deal to the landscape of Ruby's elegance.
CONDITION ? true-case : false-case
Above we see the base rendition of the ternary. The CONDITION describes anything that returns a boolean value; place your conditionals here. The following question mark acts as a keyword that leads to our TRUE case- what happens if the condition evaluates as true? Put that code after the question mark. Following the true case is a colon, again acting as a keyword, that leads to our FALSE case.
The ternary is powerful due to its short, compact form, and can help cut down on overly lengthy and unweildy code. However, it is NOT always appropriate and should only be used when the entire statement can fit on a single line. Remember, discretion is the better part of valor.
A master seeks clear, concise code, with the ternary as one of this many tools.
An important approach to testing where the user assumes no knowledge of how the program works, knowing only the type of input it should receive and what output can be expected. This type of testing ensures that the point of view of the user is addressed, rather than the programmer.
A master understands that it is the 'what', not the 'how' that matters.
The way of the Duck teaches the idea that the methods and properties of your class determine how your object should behave, instead of determining it's type through inheritance. If it looks like a duck and sounds like a duck, then it is ostensibly acting in the role of a duck. This system of organization can help lead to cleaner overall design in an application.
A master knows to assign roles and duck types when necessary for best design.