Skip to content

Instantly share code, notes, and snippets.

@RedSoxFan22
Created June 1, 2015 13:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save RedSoxFan22/41ca5b6229049db2f867 to your computer and use it in GitHub Desktop.
Save RedSoxFan22/41ca5b6229049db2f867 to your computer and use it in GitHub Desktop.
An array and a hash are both collections of data. While an array is written with brackets [], a ahsh is written with curly braces {}. In an array, each piece of data is in a particular place, or index, withn the array. The indexes begin at 0. To get an particualr item from an array, one calls the name of the array and the index on the item like this: array[index_number]. Hashes are often referred to as dictionaries because each spot in a has contains two things, one (the key) refers to the other (the value). To get a particular item from a hash, one calls the name of the hash and uses the key to retrieve the item. There are also different methods available to arrays and hashes. Array methods incluede .each, .map, .select., .join, etc.
A string can be an type of text that is encolsed within quotes. A symbol is the key element in a hash. A symbol is a more powerful tool because it can be used as an attr_accessor within a program, or as a parameter in an initiliazed method. Thus is can be passed around within code.
Modules are preferable to inheritance because inheritance requires that one go back to the original class to determine what is and is not in the class. Inheritance can cause unintended beahviors in programs because classes are so closely linked/related. Modeules are cleaner code because they are self-contained. They give the program the flexibility of inheritance without the interconnectedness that can cause side effects.
It is better to make many smaller applications. In creating applications, we must take several things into consideration. First we must deliver a prodcut to the client that is - if possible - free of any bugs. Also, we must deliever a product that is precicly what the client wants. In order to accomplish these two goals, it is better to build many smaller applications that can be throughly tested along the way, anad that are small enough that they offer the flexiblity needed to quikcly alter them to the client's changing needs. To make the smaller applications communicate with each other, we can require one file in another.
Do you think that there are any downsides to Object-Oriented Programming? If so, what are they?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment