Angelo weather project and “Self” Explained by itself!

Angelomilienjoseph
4 min readDec 18, 2020

It is a moment of joy to see myself here after a long studying journey, all my confidence is thanks to Flatiron School that give Itself the great task of placing at its student disposition, the best of the actual and updated knowledge capable to instantiate, create or build great software engineers for the future. On that I want to present my weather project witch itself is compound of 3 domain models; Weather, Api, and Cli.

It gives itself the current weather information depending on if the user itself enter a state or a zip code location in the US.The weather project starts with a Cli object that itself greets the user by calling the call method to start the flow of the program.It asks for input that has to be a valid zip code or a valid state name.

With that information the Cli object according to good Class designing principles has the single responsibility to only and only deals with the weather class to ask it to find or create a weather instance whose properties or attributes like “description”, “location”, “temperature”, “feels like”, and some more that the user is interested to know. In the next step of the flow if the the weather class itself had not already instantiated a new cli instance and saved it to it ‘s so called database “@aal variable”to send to the cli class when requested by the user; then it interacts with the api class that way to create a new weather instance. The api itself is only responsible to get the data for the weather to be created.

And that is basically what the the program itself does! please feel yourself welcome to checkout the video for a live presentation of the program or also the codes on git hub in the links below.

Self

I don’t know you but as a lazy developer in a good way I feel like I use the word “self” too many times in my explanation above, and the only way to find out why let’s let self (yes self!) to introduce itself.

hello it might be a little bit weird but I am self, in someway I must be familiar to you, you usually use me in sentence like “I will do it myself” or maybe in this “you know what! do it yourself” or in this “my sister made herself the breakfast”, the common word of those 3 example it’s me “Self”.

In your learning path or your coding journey I might be a little bit scary and confusing to you. And today I want to make you feel comfortable to use me in your next coding project.

The key to use me it’s you must be aware of the context within I am being used , let’s look at the next example below.

“It gives itself the current weather information depending on if the user itself enter a state or a zip code location in the US”

the example above come from the second paragraph and it’s clearly that you can say that the first self is used in the context of the the program I mean it represents the program right? and the second self it’s clearly that it represents the user. Self always represents someone, something or object. In the case of an instance witch can represents anything in the real world when use in the context or in the scope of a class or a method it’s represents that class or the instances that method is being called on. And if you want to know in the scope of who you are just output self in your program. That’s it! Now you must feel comfortable to use “self” in your codes, let me show you an example.

class Dog

def initialize(name, is_hungry)
@name = name
@is_hungry = is_hungry
end

def bark
if @is_hungry == "yes"
self.say_i_am_hungry
else
"barking"
end
end
def say_i_am_hungry
"I am hungry mhmhmhmhm!!"
self.move_tail
end

def move_tail
"moving tail"
end

def sing
move_tail
end
end

“In the bark method if the dog is hungry it says that in the expression “self.say_i_am_hungry” ,it’s the same thing to tell the dog if you are hungry say that yourself!, and then move your tail. it will move its tail with “self.move_tail” statement. We can see that self it’s being used in the context of a dog instances.With this example you must have a strong grasp of how to use “Self” in your code, go ahead and use it!!”

Note that self can be used into an implicit way or manner by example “I will do it myself “ it is the same saying “I will do it” in coding like in the sing method up there “move_tail” is being used there with the implicit “self” its there but we can’t see it and it represents any Dog instances.

Link to git hub: https://github.com/angelomilien/weather
Video Link: https://youtu.be/VpqLc_fvcVI

--

--