Karmen Blake
Agile Developer and Instructor
Categories
- Courses (15)
Archives
- June 2008 (2)
- May 2008 (10)
- April 2008 (16)
- March 2008 (8)
- February 2008 (10)
- January 2008 (14)
- December 2007 (4)
- November 2007 (7)
- October 2007 (25)
Tags
- 206 (10)
- 234 (7)
- 282 (10)
- 283 (29)
- 284 (29)
- agile (1)
- announcements (10)
- articles (2)
- assignments (10)
- contest (1)
- employment (1)
- humor (5)
- linux (5)
- location (1)
- microsoft (1)
- office (1)
- preregistration (1)
- rails (4)
- ruby (14)
- scc (2)
- scripting (4)
- syllabi (3)
- syllabus (1)
- tips (1)
- unix (2)
- video (1)
- videos (7)
- web (2)
- windows (3)
Welcome!
You'll find my course content and collaborative discussion about technology.
I teach as an adjunct faculty in the Computer Information Systems department at Spokane Community College
Presentations/Interviews
RubyLearning.com interviewCourse Technology - Ruby on Rails Presentation
Modules - basic syntax
January 27th, 2008 |
In this screencast I introduce modules and syntax. I demonstrate the use of include and extend and when you would use them. In the next screencast I will use modules in a practical example.Code
Modules
January 24th, 2008 |
What can you do if you notice the same functionality being duplicated by your classes? You know it feels yucky inside when you copy some methods from one class and paste them to another, but what do you do?!!? Use a module!!
A module or mixin are practically synonymous. A module is a collection of methods and constants that is external to a Ruby program. It is commonly used to provide features “mixed” into a class.
You may mixin as many modules as you want into a class.
Two ways to mixin instance methods:
class MyClass
include MyModule #this will be mixed into all instances
end
or
my_object = Myclass.new
my_object.extend(MyModule) #this will mixed into only this object
To mixin class methods:
class MyClass
extend MyModule
end
Code Documentation
January 23rd, 2008 |
There are two ways to communicate what your code does: the code itself and using comments.Self Documenting Code
Source code should be understandable not because it has comments but because of its elegance and clarity – correct use of variable names, good use of whitespace, good separation of logic, and concise readability. Code will be read hundreds of times and written only a few times. So invest quality time into spelling out names such as fn into firstname. Fight the urge to use cryptic variable names.Code Comments
Code should have comments however an abundance of comments can be just as bad as too few. Comments should explain why something is done. The code itself already shows what it is done. So commenting on what is done is redundant. Do not use commenting as a substitute for good code. Another way to say that is that if you need to comment code due to its unclarity then maybe you need to rewrite the code to be more clear and remove the comment.
Update: I found this article which is about using natural language in your code to make it more readable. Read it.
Rubyisms
January 23rd, 2008 |
I’ve mentioned most of these in past quarters but I know how easy it is to forget. Many of these will make your life easier if you follow them. Please read through.
Read Rubyisms
Ruby Naming Conventions
January 21st, 2008 |
I was lenient on naming conventions when grading the review assignment. Here is a review of the naming conventions that you will be accountable for from here on out. Online examples:
- http://www.softiesonrails.com/2007/10/18/ruby-101-naming-conventions
- http://beginningrails.com/2007/10/19/ruby-naming-conventions
- http://itsignals.cascadia.com.au/?p=7
Apply to all naming conventions
spell out names (no abbreviations)
File Names
all lower case, separate words with underscore Example: my_homework.rb
Classes
camel case Examples: CompanyA, YourPet, MyOldCar
Variables
all lower case, separate words with underscore Examples: age, first_name, company_one, address
Methods
all lower case, separate words with underscore
methods that return boolean end with ?
Examples: jump, jump_high, old_enough?
puts object prints to_s by default. no need to call to_s unless necessary
CIS 283 - Class Variables and Class methods Assignment
January 21st, 2008 |
Class Variables and Class Methods Example
January 16th, 2008 |
CodeVideo File
Class Methods
January 14th, 2008 |
Class variables - First attempt at screencast
January 13th, 2008 |
Don’t expect too much here. But at least I’m trying. I cannot lecture in person but at least I can screencast. :) Hopefully I’ll get better with these.
I need feedback on video quality – dimension size, sound quality, etc. I have a lot of flexibility as far video settings.
Warning: A couple of times in the screencast I mentioned ‘class method’ when meant to say ‘class variable’.
Code
Video
Class variables, class methods, and modules
January 10th, 2008 |
Primer: Topics to study for this up and coming week
- Class variables
- A shared variable among all instances of a class, so only one copy of a class variable exists for a given class. They are prefixed with two
signs as opposed to onefor an instance variable.
- A shared variable among all instances of a class, so only one copy of a class variable exists for a given class. They are prefixed with two
- Class methods (pages 140-142 in your book)
- A class method is a method that is associated with a class but not an instance of a class. You can call class methods by using the name of the class dot method name (ClassName.method_name). Class methods may also be called static methods. You send a message (method) to a class instead of an instance of an object. You create a class method when it does not make sense for an instance to have such a method. Class methods are usually generic not specific to an instance. For example, “new” is generic and called from the class itself – SomeClass.new
- Modules (pages 155-163 in your book)
- A module is like a class but it cannot be instantiated like a class. Huh? That’s not cool. We can include (mixin) methods and constants from a module into other classes to make them more feature rich. You’ll see the more complex our class structures get we can alleviate that by designing flexibly with modules. We can also use modules to namespace our classes or other modules but we won’t use those as much here.
CIS 283 - OOP Example (Playing with Dice)
January 7th, 2008 |
I know some of you want to see a solution to last quarter’s final. Here is one I hacked up tonight. Enjoy!
Check it out >>
CIS 283 - Review Assignment
January 6th, 2008 |
Please read attached assignment specifications. If you have questions, please comment here on this blog first. Secondly, you may email me at kblake.scc@gmail.com.
Review Assignment
CIS 283 - Syllabus
January 3rd, 2008 |
Here you go! I’ll be getting a review assignment out early next week. Until then I’d review the plethora of code examples found on the P: drive from CIS 282.
Syllabus