Presentation for Women Who Code Austin on May 5, 2014. Now with notes included for SlideShare. Recorded livestream here: baer.ly/1us79Za. Want to learn Android Dev? Take the Udemy course! https://www.udemy.com/become-an-android-developer-from-scratch/?couponCode=MOLLYBLOG
3. Speaker todaysSpeaker = Molly Rand;
Notes:
Become an Android Developer From Scratch is the Udemy course created by
the guys who trained me. You can find it online here:
https://www.udemy.com/become-an-android-developer-from-scratch/, and if you
don’t want to pay full price there’s a promo code on my blog at
codemolly.tumblr.com. Please feel free to tweet at me or hit me up on my blog if
you want to connect/ have questions about Android programming from a noob’s
perspective.
6. Hallmarks of Java
• Object Oriented
• Static typing
• Libraries
• Mature Platform
Notes:
This is a great article my mentor shared on one coder’s
opinions about why he likes Java:
http://stevewedig.com/2014/02/17/why-and-how-i-write-
java/
8. Code
Components
File
Class
Attributes
Methods
Notes:
Your file name should match your class name (it’s convention, and a really
good one). The package at the top of the file lets you know what files are
grouped together in a single project.
Attributes are like the nouns/adjectives. They tell you what your class has
and describe it.
Methods are like your verbs – they tell you what objects of that class can do
and how they do it.
10. Clues in the Case
• PascalCase
• Used for class names
• Found in class signature and variable declarations (data type)
• camelCase
• Variables and method names
• snake_case
• Mainly seen in built-in static variables (constants)
• Also XML in Android programming
11.
12. Notes:
Curly braces are your biggest indicator when deciphering Java
code. If you can separate the code into blocks you reduce your
cognitive load and can deal with the file one small piece at a
time.
Semicolons come at the end of every java statement – important
to note because sometimes one statement will take up multiple
lines, or less often you may have multiple statements on a single
line
Parentheses in a method signature (next slide) tell you what that
method needs as input in order to run. When a method is called,
those input parameters go in the parentheses of the method call.
Brackets are used when denoting that you are creating an array,
and when accessing individual elements of an array.
Operators are used in mathematical expressions and logic
comparisons.
13.
14. Notes:
This is a Java method signature – where a method (action an object of a class can
take) is defined.
The accessibility keyword denotes who can call this method. Public methods can be
called by objects wherever they’re created. Private methods can only be called
internally within the class. Protected methods are more complicated, but worth some
research if you really want to get into Java.
The return type is the data type you will get back when the method is run. A return
type of void simply means that the code within the method will run, but you won’t
have any kind of object returned to you (maybe variables within the object change,
maybe something happens on your screen). If the return type is not void, there must
be a statement within the method’s code block (between the curly braces) that
returns a variable of that type.
Parameters have a declared type and variable name. The type is because Java is a
statically typed language, and the variable name is so that we can use the
parameter within this method without having to know what it’s called anywhere else
in the code. This is super handy for making modular, reusable code. Methods can
have 0, 1, or many parameters of any number of data types.
15. Any method that has a signature like this can then be called on objects of its
class. A method call looks like variableName.methodName(parameter);
Passing in the wrong number or type of parameters will result in a compile-time
error. If a method signature has a return type other than void, you’ll typically
want to assign that method call to a variable of the corresponding type. For
example: if my method is public boolean isTrue(){ } then simply calling
variable.isTrue(); won’t do anything. I need to say boolean truth =
variable.isTrue(); and then I can use truth in logic tests in later code statements.
17. Method Signature
Block of code
Parameter is an object of
the NoteSlide class
(Defined in the same project)
Method name is
slideTime
Returns a String
19. Declaring variables
of type int
Calling method valueOf which takes
a single int as a parameter and
returns a String
Notas do Editor
Become an Android Developer From Scratch is the Udemy course created by the guys who trained me. You can find it online here: https://www.udemy.com/become-an-android-developer-from-scratch/, and if you don’t want to pay full price there’s a promo code on my blog at codemolly.tumblr.com. Please feel free to tweet at me or hit me up on my blog if you want to connect/ have questions about Android programming from a noob’s perspective.
Become an Android Developer From Scratch is the Udemy course created by the guys who trained me. You can find it online here: https://www.udemy.com/become-an-android-developer-from-scratch/, and if you don’t want to pay full price there’s a promo code on my blog at codemolly.tumblr.com. Please feel free to tweet at me or hit me up on my blog if you want to connect/ have questions about Android programming from a noob’s perspective.
This is a great article my mentor shared on one coder’s opinions about why he likes Java: http://stevewedig.com/2014/02/17/why-and-how-i-write-java/
This is a great article my mentor shared on one coder’s opinions about why he likes Java: http://stevewedig.com/2014/02/17/why-and-how-i-write-java/
Your file name should match your class name (it’s convention, and a really good one). The package at the top of the file lets you know what files are grouped together in a single project.Attributes are like the nouns/adjectives. They tell you what your class has and describe it.Methods are like your verbs – they tell you what objects of that class can do and how they do it.
Your file name should match your class name (it’s convention, and a really good one). The package at the top of the file lets you know what files are grouped together in a single project.Attributes are like the nouns/adjectives. They tell you what your class has and describe it.Methods are like your verbs – they tell you what objects of that class can do and how they do it.
PascalCase is used for class names. If you see a word in PascalCase, it’s either going to be in a class signature or it’s going to denote a variable’s class (i.e. its data type)camelCase is used for variables and method names.snake_case is mainly seen in built-in static variables (constants). And in XML in Android programming.
Curly braces are your biggest indicator when deciphering Java code. If you can separate the code into blocks you reduce your cognitive load and can deal with the file one small piece at a time.Semicolons come at the end of every java statement – important to note because sometimes one statement will take up multiple lines, or less often you may have multiple statements on a single lineParentheses in a method signature (next slide) tell you what that method needs as input in order to run. When a method is called, those input parameters go in the parentheses of the method call.Brackets are used when denoting that you are creating an array, and when accessing individual elements of an array.Operators are used in mathematical expressions and logic comparisons.
Curly braces are your biggest indicator when deciphering Java code. If you can separate the code into blocks you reduce your cognitive load and can deal with the file one small piece at a time.Semicolons come at the end of every java statement – important to note because sometimes one statement will take up multiple lines, or less often you may have multiple statements on a single lineParentheses in a method signature (next slide) tell you what that method needs as input in order to run. When a method is called, those input parameters go in the parentheses of the method call.Brackets are used when denoting that you are creating an array, and when accessing individual elements of an array.Operators are used in mathematical expressions and logic comparisons.
This is a Java method signature – where a method (action an object of a class can take) is defined. The accessibility keyword denotes who can call this method. Public methods can be called by objects wherever they’re created. Private methods can only be called internally within the class. Protected methods are more complicated, but worth some research if you really want to get into Java.The return type is the data type you will get back when the method is run. A return type of void simply means that the code within the method will run, but you won’t have any kind of object returned to you (maybe variables within the object change, maybe something happens on your screen). If the return type is not void, there must be a statement within the method’s code block (between the curly braces) that returns a variable of that type.Parameters have a declared type and variable name. The type is because Java is a statically typed language, and the variable name is so that we can use the parameter within this method without having to know what it’s called anywhere else in the code. This is super handy for making modular, reusable code. Methods can have 0, 1, or many parameters of any number of data types.Any method that has a signature like this can then be called on objects of its class. A method call looks like variableName.methodName(parameter); Passing in the wrong number or type of parameters will result in a compile-time error. If a method signature has a return type other than void, you’ll typically want to assign that method call to a variable of the corresponding type. For example: if my method is public booleanisTrue(){ } then simply calling variable.isTrue(); won’t do anything. I need to say boolean truth = variable.isTrue(); and then I can use truth in logic tests in later code statements.
This is a Java method signature – where a method (action an object of a class can take) is defined. The accessibility keyword denotes who can call this method. Public methods can be called by objects wherever they’re created. Private methods can only be called internally within the class. Protected methods are more complicated, but worth some research if you really want to get into Java.The return type is the data type you will get back when the method is run. A return type of void simply means that the code within the method will run, but you won’t have any kind of object returned to you (maybe variables within the object change, maybe something happens on your screen). If the return type is not void, there must be a statement within the method’s code block (between the curly braces) that returns a variable of that type.Parameters have a declared type and variable name. The type is because Java is a statically typed language, and the variable name is so that we can use the parameter within this method without having to know what it’s called anywhere else in the code. This is super handy for making modular, reusable code. Methods can have 0, 1, or many parameters of any number of data types.Any method that has a signature like this can then be called on objects of its class. A method call looks like variableName.methodName(parameter); Passing in the wrong number or type of parameters will result in a compile-time error. If a method signature has a return type other than void, you’ll typically want to assign that method call to a variable of the corresponding type. For example: if my method is public booleanisTrue(){ } then simply calling variable.isTrue(); won’t do anything. I need to say boolean truth = variable.isTrue(); and then I can use truth in logic tests in later code statements.
This is a Java method signature – where a method (action an object of a class can take) is defined. The accessibility keyword denotes who can call this method. Public methods can be called by objects wherever they’re created. Private methods can only be called internally within the class. Protected methods are more complicated, but worth some research if you really want to get into Java.The return type is the data type you will get back when the method is run. A return type of void simply means that the code within the method will run, but you won’t have any kind of object returned to you (maybe variables within the object change, maybe something happens on your screen). If the return type is not void, there must be a statement within the method’s code block (between the curly braces) that returns a variable of that type.Parameters have a declared type and variable name. The type is because Java is a statically typed language, and the variable name is so that we can use the parameter within this method without having to know what it’s called anywhere else in the code. This is super handy for making modular, reusable code. Methods can have 0, 1, or many parameters of any number of data types.Any method that has a signature like this can then be called on objects of its class. A method call looks like variableName.methodName(parameter); Passing in the wrong number or type of parameters will result in a compile-time error. If a method signature has a return type other than void, you’ll typically want to assign that method call to a variable of the corresponding type. For example: if my method is public booleanisTrue(){ } then simply calling variable.isTrue(); won’t do anything. I need to say boolean truth = variable.isTrue(); and then I can use truth in logic tests in later code statements.