Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Earth - Kal (re-submitted) #51

Open
wants to merge 9 commits into
base: master
Choose a base branch
from
Open

Conversation

kashenafi
Copy link

@kashenafi kashenafi commented Sep 26, 2020

Assignment Submission: Solar System

Congratulations! You're submitting your assignment. Please reflect on the assignment with these questions.

Reflection

Question Answer
When does the initialize method run? What does it do? The method runs at the very start of the creation of the class instance. It's useful when we want to initialize some class variables at the time of object creation.
Why do you imagine we made our instance variables readable but not writable? We want to make sure the user cannot alter the data inside the object. Just access it to be read/seen.
How would your program be different if each planet was stored as a Hash instead of an instance of a class? How the data was added (to the hash) would change. Maybe each planet name would be the keys and the attributes stored respectively in an array (the value). So, the 'add_planet' method in solar_system.rb functionality would change to add to a hash instead of an array.
How would your program be different if your SolarSystem class used a Hash instead of an Array to store the list of planets? I probably wouldn't need the 'Planet' class. I would just add the 'summary' method to the SolarSystem class and have the method pull info from the hash already present in that class. The method would probably have to take one parameter (planet name) and check if the planet is in the hash or return ArgumentError otherwise.
There is a software design principle called the SRP. The Single Responsibility Principle (SRP) says that each class should be responsible for exactly one thing. Do your classes follow SRP? What responsibilities do they have? Not necessarily... I'd say only Planet is close to having one responsibility--which is creating the class instance and having a method that outputs a summary statement. SolarSystem, on the other hand, has a few more responsibilities. (I'm understanding 'responsibilities' as including methods). They are: to initialize instance of a SolarSystem, to add a planet, to list the planets, and to return the planet information according to inputted name (still working on getting distance from sun and distances between planets).
How did you organize your require statements? Which files needed requires, and which did not? What is the pattern? I installed the 'Pry' gem (that was the last 'require' statement in main.rb). Main.rb has 'require_relative' statements for both solar_system.rb and planet.rb because it references objects found in both files. Solar-system.rb has only one 'require_relative' statement because it only needs to reference the object/code(?) found in planet.rb. Planet.rb does not have any because it's functionality does not require accessing another file.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant