Categories
Programming

How Writing Helps Your Learning

I’m used to understanding HTML and CSS, so learning how functions make buttons work, and how classes store objects that you can create to run methods is pretty advanced for me. So this is how I’m digesting all this new information, through blog posts I share with other beginners.

It’s true, some cats are allergic to you.

I’ve been learning how to program with Google Flutter, learning their Dart programming language, which is an Object Oriented Programming language, which practically means its code is built with objects. I haven’t been studying long, but it is still a lot to unpack coming from a background in web design. I’m used to understanding HTML and CSS, so learning how functions make buttons work, and how classes store objects that you can create to run methods is pretty advanced for me. So this is how I’m digesting all this new information, through blog posts I share with other beginners. 

Since my last post, Programming Until You Get Headaches, I’ve covered so much new information that I need to unpack into this post that I’m afraid I might skip something. I’m still studying under Angela Yu on Udemy and we started on the Quizzlr app she created for us to follow along with and it’s all new information about Lists, If and Else statements or rather, Conditionals, and finally Classes and Objects. All of this information is a lot to consume at once so I’m taking my time, but by writing how this makes sense to me helps me digest all the new information a little better.

Testing Memory of Lists

This is how a list looks in a class.

I’m going to try to explain how a list works. You start with the syntax List and follow it with data type in these carats <>, so for instance, List<String> represents a List of Strings, following that you can title the List. 

List<String> favoriteWords = [ ‘Triple’, ‘Flinch’, ‘Flounder’]; 

This creates a list of strings called favoriteWords that are Triple, Flinch and Flounder (These are the first words that come to mind). You can refer to this list in your app by just calling on it with a positional number in the list starting from 0. I’m pretty sure I’d have to create a variable to call on it. 

int wordNumber = 0

Now if I wanted to print a word from the List I’d have to call on it like so:

print(favoriteWords[0]); — this is calling on the index of my list in the 0th position, which is the first in the list, which is Triple. 

Damn, I’m just getting started with this, because in the Quizzlr app I’m building, it gets so much more complex by inputting a List like this into a Class. I’m not sure if I can unpack all of this, but I’ll try. 

if, else, else if and whatever else

Listen I’m not a pro, and if you’re here to learn from a pro then go to stackoverflow.com, you’re in the wrong place, but if you want to try to make sense of programming like I am, through the eyes of a beginner, you’re right on track. This is an example of an if else statement in this app:

if (correctAnswer == false){

print(‘user is right’);

} else {

print(‘user is wrong’);

}

This statement pretty much just passes a print statement to the console if the condition is true or false, here is a bit about Conditionals

Conditionals

Button pressed conditional statement in Quizzlr app

The == translates as ‘is to’, while the = translates as make left hand = right hand, eg. Kyle = boy. Double equals, == is for conditional statements. 

== is the condition and inside {go();} is the instruction:

if (track == ‘clear’){

go();

}

Some more syntax that can work:

!=   Is not equal to

>   Is greater than

<   Is less than

>=   Is greater than or equal to

<=   Is lesser than or equal to

Combine with comparators

&& AND

|| or

! Not

As I learn more about conditionals I’ll give you some practical uses, but this here is just an overview.

Classes & Objects

A Class is a blueprint. A class has properties like color; numberOfSeats; etc & it has methods like, drive(); break();

With Classes, variables are now properties, and functions are now methods.

class Car {

int numberOfDoors = 5;  — property

  void drive() {   — method

print(‘Wheels turning’);

}

}

Object of this class:

Car myCar = Car();

OOP – Object Oriented Programming

Abstraction – functionality with different components, more complex systems with smaller pieces with more defined roles

Looks like you can create classes that hold lists, and classes to construct the list. Kinda mind boggling. 

I’m in the middle of this module, so there is still more to unpack.