Skip to content

Instantly share code, notes, and snippets.

@TylerRockwell
Last active September 29, 2015 13:42
Show Gist options
  • Select an option

  • Save TylerRockwell/b6e7b5e19772331f18ed to your computer and use it in GitHub Desktop.

Select an option

Save TylerRockwell/b6e7b5e19772331f18ed to your computer and use it in GitHub Desktop.
In Class Challenge - 9-29-15
Detailed Ruby Questions
When would you use a hash instead of an array?
An array would be used to store multiple values in an ordered list. A hash should be used when you
need to store key value pairs. For example, if you were to store a person's information, putting it in
an array would require that you remember the order that the information is stored in, and this could change
as the information is changed or updated. Using a hash, however would allow you to store information by named keys.
So, to access a person's phone number you could use person[:phone_number] instead of person[3].
When would you use a symbol instead of a string?
A symbol is used in places where something needs a name, but does not need to have all the methods of a string. Symbols use less memory
and are faster to access, so they are often used, for example as hash keys/values or when setting attr methods.
When would you use modules instead of inheritance?
Inheritance is used in a is-a sense. That is, an electric car is a car, so ElectricCar should inherit from Vehicle. The parent class should contain
properties and methods that all children clases would have in common. Modules are more used in a has-a sense. These contain properties and methods
that may be common to certain types of classes, but not necessarily all of them. Using the example above, a DumpTruck class should inherit from Vehicle
because it shares common traits with other vehicles, but a module should be used for its special functions, such as haul or unload, that other vehicles
would not be capable of.
Big Picture Questions
Is it better to make a single large application, or to make many smaller applications? If you do ever take the second approach, how do you make them talk to each other?
I think it depends on the scope of the project. I believe that all programs should be modular, so in a sense, even large projects would essentially
be composed of many smaller applications. Smaller programs can be included in one another to make the classes/objects and everything that comes along with them
available to one another.
Do you think that there are any downsides to Object-Oriented Programming? If so, what are they?
I think Object-Oriented Programming thus far has had great design, and has allowed us to accomplish many otherwise
impossible tasks. That being said, I think it includes many concepts that people struggle to wrap their minds around.
The levels of abstraction, the way tasks are completed, and how different languages handle memory can be difficult. The fact that
it takes years of practice to learn an understand shows that there are still some complexities that can likely be resolved.
HTTP Questions
What is HTTP?
HTTP stands for Hyper-Text Transfer Protocol
What is an IP address?
An IP address is a unique address for every device on the internet
What are all of the HTTP Verbs?
GET POST PATCH DELETE
Which HTTP Verbs imply that their actions are idempotent?
GET
Which file types can be returned over HTTP?
All of them. Primarily text, though.
What is the difference between HTTP and HTTPS?
HTTPS is secured HTTP. It uses end-to-end data encryption to protect the information being transferred.
What are the port numbers for HTTP and HTTPS?
80, 473
What are HTTP Status Codes? Describe three of them.
They allow the server to tell the client information about their request.
200: Everything is okay
404: Not Found, the resource you requested could not be found
403: Forbidden, you do not have permission to access
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment