Saturday, March 21, 2020

Learning Pronouns - Beginner Level ESL Lesson Plan

Learning Pronouns - Beginner Level ESL Lesson Plan The use of pronouns often seeps into the lessons in a number of different aspects: Subject pronouns are discussed when forming and conjugating sentences in the various tenses, object pronouns are introduced through questions words such as who or by a discussion of transitive and intransitive verbs, possessive pronouns and adjectives also get thrown into the mix by discussing the question word whose, or when pointing out how the possessive adjective modifies the noun. I find it helpful to to wrap all these together in a single lesson, as well as the demonstrative pronouns this, that, these and those to help students understand the relationship between the various forms. The lesson comes in two parts: First, students review, identify and create a pronoun chart. Next, students begin to use the pronouns to refer to objects that they have placed on a table. Finally, once students have become relatively comfortable with using personal pronouns, they can add demonstrative pronouns to the mix. Here is an outline of the lesson. This lesson can be used as a means of review, or, as an introduction to the various uses of pronouns (and the possessive adjective) for exceptionally motivated classes. Aim: Develop a deeper understanding of personal and demonstrative pronouns Activity: Chart fill-in, personal object questioning Level: Beginning to lower-intermediate Outline: Reviewing the Forms with a Chart Write four sentences on the board each containing a different type of pronoun (or possessive adjective), preferably using the same person. For example:He has an interesting book.Give him that interesting book.Thats his interesting book.That interesting book is his.Point out the grammatical differences in form between each of these forms. If students have never studied these forms before in an overview, print out this pronoun chart or write on the board.Using the same sentence with minor variations, go through each pronoun and possessive form for various subjects. Ask students to provide the correct change for each sentence as a class.Once students have become comfortable with these changes, ask them to fill out the first chart providing the correct pronoun or adjective form. Understanding Demonstrative Pronouns Now that the explicit learning has been accomplished, its time for some fun. Place a table at the front or in the middle of the classroom.Ask each student to provide an object or objects on the table.Begin asking questions using the objects. At this point it is also a good idea to introduce the idea of demonstrative pronouns. First model the questions and answers: For example:Teacher: Whose is this backpack here? - That is Marcos backpack there.Is this Annas pencil? - No, that isnt Annas pencil.etc.Explain that this and that are used with single objects, these and those are used in the plural. Point out that this and these are used with objects that are here (or close by), and that and those are used objects there (or far away). Phrases such as this - here / that - there are helpful.Continue asking questions with this and these eliciting students responses of these and those. Real World Task to Tie it All Together Ask students to come forward and choose an item which does not belong to them. Each student should create four sentences about the object(s) they choose. For example:This is Annas pencil.She has a pencil.It is her pencil.The pencil is hers.I give her the pencil.(student walks over and hands the item back)Feel free to model this a few times until the students understand what is expected.Repeat with different personal objects. The activity of getting up and retrieving items while using the various forms will help students acquire the grammar through real world application. Pronoun Chart Subject Pronoun Object Pronoun Possessive Adjective Possessive Pronoun I you his hers its none we your theirs

Thursday, March 5, 2020

Global Variables in Ruby

Global Variables in Ruby Global Variables are variables that may be accessed from anywhere in the program regardless of scope. Theyre denoted by beginning with a $ (dollar sign) character. However, the use of global variables is often considered un-Ruby, and you will rarely see them. Defining Global Variables Global variables are defined and used like any other variable. To define them, simply assign a value to them and begin using them. But, as their name suggests, assigning to global variables from any point in the program has global implications. The following program demonstrates this. The method will modify a global variable, and that will affect how the second method runs. $speed 10 def accelerate $speed 100 end def pass_speed_trap if $speed 65 # Give the program a speeding ticket end end accelerate pass_speed_trap Unpopular So why is this un-Ruby and why dont you see global variables very often? Put simply, it breaks encapsulation. If any one class or method can modify the state of the global variables at will with no interface layer, any other classes or methods that rely on that global variable may behave in an unexpected and undesirable manner. Further, such interactions can be very difficult to debug. What modified that global variable and when? Youll be looking through quite a lot of code to find what did it, and that could have been avoided by not breaking the rules of encapsulation. But thats not to say that global variables are never used in Ruby. There are a number of special global variables with single-character names (a-la Perl) that can be used throughout your program. They represent the state of the program itself, and do things like modify the record and field separators for all gets methods. Global Variables $0 - This variable, denoted by $0 (thats a zero), holds the name of the top-level script being executed. In other words, the script file that was run from the command line, not the script file that holds the currently executing code. So, if script1.rb was run from the command line, it would hold script1.rb. If this script requires script2.rb, $0 in that script file would also be script1.rb. The name $0 mirrors the naming convention used in UNIX shell scripting for the same purpose.$* - The command-line arguments in an array denoted by $* (dollar sign and asterisk). For example, if you were to run ./script.rb arg1 arg2, then $* would be equivalent to %w{ arg1 arg2 }. This is equivalent to the special ARGV array and has a less descriptive name, so it is rarely used.$$ - The interpreters process ID, denoted by $$ (two dollar signs). Knowing ones own process ID is often useful in daemon programs (which run in the background, unattached from any terminal) or system services. However, this gets a bit more complicated when threads are involved, so be wary of using it blindly. $/ and $\ - These are the input and output record separators. When you read objects using gets and print them using puts, it uses these to know when a complete record has been read, or what to print between multiple records. By default, these should be the newline character. But since these affect the behavior of all IO objects, theyre rarely used, if at all. You may see them in smaller scripts where breaking the encapsulation rules is not an issue.$? - The exit status of the last child process executed. Of all the variables listed here, this is probably the most useful. The reason for this is simple: you cant get the exit status of child processes by their return value from the system method, only true or false. If you must know the actual return value of the child process, you need to use this special global variable. Again, the name of this variable is taken from the UNIX shells.$_ - The last string read by gets. This variable may be a point of confusion for those coming to Ruby f rom Perl. In Perl, the $_ variable means something similar, but totally different. In Perl, $_ holds the value of the last statement and in Ruby it holds the string returned by the previous gets invocation. Their usage is similar, but what they really hold is very different. You dont often see this variable either (come to think of it, you rarely see any of these variables), but you may see them in very short Ruby programs that process text. In short, youll rarely see global variables. Theyre often bad form (and un-Ruby) and only really useful in very small scripts, where the full implication of their use can be fully appreciated. There are a few special global variables that can be used, but for the most part, they arent used. You dont really need to know all that much about global variables to understand most Ruby programs, but you should at least know that theyre there.