Tuesday, August 31, 2010

Extraordinary Standard MBeans

Standard MBeans are commonly used for several reasons. They are easy to use, the interfaces can be applied to client-side proxies, and the interfaces allow for easy Javadoc-based documentation of the management interface on the Standard MBean. MXBeans share these advantages and add a few of their own such as looser required naming and package! conventions and greater interoperability support via Open MBean Types.

However, as discussed in my blog entry The JMX Model MBean, there are some disadvantages of Standard MBeans (and MXBeans) that Model MBeans can address. The most significant reason for using the Model MBean (to wrap existing non-JMX resources such as employed in the Spring Framework) is not possible with Standard or MXBeans due to their static nature. However, the advantage of being able to provide information on operations, parameters, constructors, attributes, and notifications is not a sole advantage of Model MBeans or even of the class of dynamic MBeans. I will demonstrate in this blog entry on! e approach to specifying operation metadata for Standard MBean! s and MX Beans that can be displayed in JConsole and other clients that know how to handle MBeanInfo.

The key to providing additional metadata above and beyond what is normally associated with a Standard MBean is use of the class javax.management.StandardMBean. The description portion of this class's Javadoc documentation shows two ways to use this class. They are using StandardMBean's public constructors or by having the MBean implementation class extend the StandardMBean class (but still implement the same interface). Using the StandardMBean class allows the naming conventions normally associated with Standard MBeans to be relaxed because arbitrary implementation classes and interf! aces can be associated with this class. However, in this blog entry, I will keep the normal implementation/interface naming conventions and use the class StandardMBean to provide metadata to the Standard MBean and MXBean.

My first code listing shows a class called DustinMBean that extends StandardMBean so that I can override the StandardMBean.cacheMBeanInfo method.

DustinMBean.java

package dustin.jmx;

import javax.management.MBeanInfo;
import javax.management.StandardMBean;

/**
* Child of StandardMBean overridden for customization purposes.
*
* @author Dustin
*/
public class DustinMBean extends StandardMBean
{
/**!
* Single constructor accepting MBean implementation ! class, M Bean interface,
* and whether or not it is an MXBean (Standard MBean if not MXBean). Note
* that my parent, StandardMBean, has more than one constructor, but I'm only
* using one of them.
*
* @param implementation MBean implementation class.
* @param mbeanInterface MBean implementation class's interface.
* @param isMXBean true if MXBean; false if Standard MBean.
*/
public DustinMBean(
T implementation,
Class mbeanInterface,
boolean isMXBean )
{
super(implementation, mbeanInterface, isMXBean);
}

/**
* Specify an MBeanInfo to be used with a StandardMBean-turned-DynamicMBean.
*
* @param mbeanInfo MBeanInfo describing this standard MBean turned into a
* Dynamic MBean.
*/
public void setMBeanInfo(final MBeanInfo mbeanInfo)
{
cacheMBeanInfo(mbeanInfo! );
}
}


The class shown above makes it easy to set a Standard MBean's MBeanInfo instance.

I will be using a Standard MBean and an MXBean in this blog entry. The next two code listings show the interface and implementation class for the Standard MBean.

SimpleCalculatorMBean.java (Standard MBean Interface)

package dustin.jmx;

/**
* Interface for a Standard MBean example using the Simple Calculator.
*
* @author Dustin
*/
public interface SimpleCalculatorMBean
{
/**
* Calculate the sum of the augend and the addend.
*
* @param augend First integer to be added.
* @param addend Second integer to be added.
* @return Sum of augend and addend.
*/
public int add(final int augend, final int addend);
/**
* Calculate the difference between the mi! nuend an d subtrahend.
*
* @param minuend Minuend in subtraction operation.
* @param subtrahend Subtrahend in subtraction operation.
* @return Difference of minuend and subtrahend.
*/
public int subtract(final int minuend, final int subtrahend);

/**
* Calculate the product of the two provided factors.
*
* @param factor1 First integer factor.
* @param factor2 Second integer factor.
* @return Product of provided factors.
*/
public int multiply(final int factor1, final int factor2);

/**
* Calculate the quotient of the dividend divided by the divisor.
*
* @param dividend Integer dividend.
* @param divisor Integer divisor.
* @return Quotient of dividend divided by divisor.
*/
public double divide(final int dividend, final int divisor);

/**
* Provides the type of o! peration last executed against this calculator class.
*
* @return Type of operation last executed against this calculator.
*/
public OperationType whatWasTheLastOperation();
}


SimpleCalculator.java (Standard MBean Implementation)

package dustin.jmx;

/**
* Simple calculator class intended to demonstrate how a class with no knowledge
* of JMX or management can be used as a Standard MBean.
*
* @author Dustin
*/
public class SimpleCalculator implements SimpleCalculatorMBean
{
private OperationType lastOperation = OperationType.NO_OPERATIONS_INVOKED;

/**
* Calculate the sum of the augend and the addend.
*
* @param augend First integer to be added.
* @param addend Second integer to be added.
* @return Su! m of augend and addend.
*/
public int add(fin! al int a ugend, final int addend)
{
lastOperation = OperationType.INTEGER_ADDITION;
return augend + addend;
}

/**
* Calculate the difference between the minuend and subtrahend.
*
* @param minuend Minuend in subtraction operation.
* @param subtrahend Subtrahend in subtraction operation.
* @return Difference of minuend and subtrahend.
*/
public int subtract(final int minuend, final int subtrahend)
{
lastOperation = OperationType.INTEGER_SUBTRACTION;
return minuend - subtrahend;
}

/**
* Calculate the product of the two provided factors.
*
* @param factor1 First integer factor.
* @param factor2 Second integer factor.
* @return Product of provided factors.
*/
public int multiply(final int factor1, final int factor2)
{
lastOperation = OperationTy! pe.INTEGER_MULTIPLICATION;
return factor1 * factor2;
}

/**
* Calculate the quotient of the dividend divided by the divisor.
*
* @param dividend Integer dividend.
* @param divisor Integer divisor.
* @return Quotient of dividend divided by divisor.
*/
public double divide(final int dividend, final int divisor)
{
lastOperation = OperationType.INTEGER_DIVISION;
return dividend / divisor;
}

/**
* Provides the type of operation last executed against this calculator class.
*
* @return Type of operation last executed against this calculator.
*/
public OperationType whatWasTheLastOperation()
{
return this.lastOperation;
}
}


The two code listings immediately above are the interface and implementation for the Standard MBean. The next two lis! tings are for the interface and implementation for a very simi! lar MXBe an. The MXBean is not really any more complicated than the Standard MBean, but I needed to name it something different.

LessSimpleCalculatorMXBean.java (MXBean Interface)

package dustin.jmx;

/**
* Interface for a standard MXBean example using the Simple Calculator.
*
* @author Dustin
*/
public interface LessSimpleCalculatorMXBean
{
/**
* Calculate the sum of the augend and the addend.
*
* @param augend First integer to be added.
* @param addend Second integer to be added.
* @return Sum of augend and addend.
*/
public int add(final int augend, final int addend);

/**
* Calculate the difference between the minuend and subtrahend.
*
* @param minuend Minuend in subtraction operation.
* @param subtrahend Subt! rahend in subtraction operation.
* @return Difference of minuend and subtrahend.
*/
public int subtract(final int minuend, final int subtrahend);

/**
* Calculate the product of the two provided factors.
*
* @param factor1 First integer factor.
* @param factor2 Second integer factor.
* @return Product of provided factors.
*/
public int multiply(final int factor1, final int factor2);

/**
* Calculate the quotient of the dividend divided by the divisor.
*
* @param dividend Integer dividend.
* @param divisor Integer divisor.
* @return Quotient of dividend divided by divisor.
*/
public double divide(final int dividend, final int divisor);

/**
* Provides the type of operation last executed against this calculator class.
*
* @return Type of operation last executed a! gainst this calculator.
*/
public OperationTy! pe whatW asTheLastOperation();
}


LessSimpleCalculator.java (MXBean Implementation)

package dustin.jmx;

/**
* Simple calculator class intended to demonstrate how a class with no knowledge
* of JMX or management can be used as an MXBean.
*
* @author Dustin
*/
public class LessSimpleCalculator implements LessSimpleCalculatorMXBean
{
private OperationType lastOperation = OperationType.NO_OPERATIONS_INVOKED;

/**
* Calculate the sum of the augend and the addend.
*
* @param augend First integer to be added.
* @param addend Second integer to be added.
* @return Sum of augend and addend.
*/
public int add(final int augend, final int addend)
{
lastOperation = OperationType.INTEGER_ADDITION;
return augend + ! addend;
}

/**
* Calculate the difference between the minuend and subtrahend.
*
* @param minuend Minuend in subtraction operation.
* @param subtrahend Subtrahend in subtraction operation.
* @return Difference of minuend and subtrahend.
*/
public int subtract(final int minuend, final int subtrahend)
{
lastOperation = OperationType.INTEGER_SUBTRACTION;
return minuend - subtrahend;
}

/**
* Calculate the product of the two provided factors.
*
* @param factor1 First integer factor.
* @param factor2 Second integer factor.
* @return Product of provided factors.
*/
public int multiply(final int factor1, final int factor2)
{
lastOperation = OperationType.INTEGER_MULTIPLICATION;
return factor1 * factor2;
}

/**
* Calculate the quo! tient of the dividend divided by the divisor.
*
! * @p aram dividend Integer dividend.
* @param divisor Integer divisor.
* @return Quotient of dividend divided by divisor.
*/
public double divide(final int dividend, final int divisor)
{
lastOperation = OperationType.INTEGER_DIVISION;
return dividend / divisor;
}

/**
* Provides the type of operation last executed against this calculator class.
*
* @return Type of operation last executed against this calculator.
*/
public OperationType whatWasTheLastOperation()
{
return this.lastOperation;
}
}


Both the Standard MBean and MXBean code listings above use the OperationType enum. The main reason for adding an enum into the mix is to demonstrate differences between Standard MBean and MXMBean.

OperationType.java

package dustin.jmx;

/**
* Simple enum representing a type of calculator operation.
*
* @author Dustin
*/
public enum OperationType
{
INTEGER_ADDITION,
INTEGER_SUBTRACTION,
INTEGER_MULTIPLICATION,
INTEGER_DIVISION,
NO_OPERATIONS_INVOKED
}


With the Standard MBean, MXBean, enum, and DustinMBean classes all shown above, it is time to look at the class that calls DustinMBean to turn the Standard and MXBeans into dynamic MBeans with metadata descriptions.

StandardMBeanDemonstrator.java

package dustin.jmx;

import java.lang.management.ManagementFactory;
import javax.management.InstanceAlreadyExistsException;
import javax.management.MBeanException;
import javax.management.MBeanInfo;
import j! avax.management.MBeanOperationInfo;
import javax.manageme! nt.MBean ParameterInfo;
import javax.management.MBeanRegistrationException;
import javax.management.MBeanServer;
import javax.management.MalformedObjectNameException;
import javax.management.NotCompliantMBeanException;
import javax.management.ObjectName;
import javax.management.ReflectionException;

/**
* This class is intended to demonstrate a more powerful Standard MBean
* available from overriding the javax.management.StandardMBean class.
*
* @author Dustin
*/
public class StandardMBeanDemonstrator
{
/**
* Pause for the specified number of milliseconds.
*
* @param millisecondsToPause Milliseconds to pause execution.
*/
public static void pause(final int millisecondsToPause)
{
try
{
Thread.sleep(millisecondsToPause);
}
catch (InterruptedException threadAwakened)
{
! System.err.println("Don't wake me up!\n" + threadAwakened.getMessage());
}
}

/**
* Construct the meta information for the SimpleCalculator
* Standard-turned-Dynamic MBeans operations and the operations' parameters.
*
* Note that this method was adapted from a very similar method for
* constructor Model MBean operation info data that was discussed in the
* method buildModelMBeanOperationInfo() in the class
* ModelMBeanDemonstrator in the blog entry "The JMX Model MBean"
* (http://marxsoftware.blogspot.com/2008/07/jmx-model-mbean.html).
*
* @return Metadata about MBean's operations.
*/
private static MBeanOperationInfo[] buildMBeanOperationInfo()
{
//
// Build the PARAMETERS and OPERATIONS meta information for "add".
//

final MBeanParameterInfo augen! dParameter =
new MBeanParameterInfo(
! "a ugend",
Integer.TYPE.toString(),
"The first parameter in the addition (augend)." );
final MBeanParameterInfo addendParameter =
new MBeanParameterInfo(
"addend",
Integer.TYPE.toString(),
"The second parameter in the addition (addend)." );

final MBeanOperationInfo addOperationInfo =
new MBeanOperationInfo(
"add",
"Integer Addition",
new MBeanParameterInfo[] {augendParameter, addendParameter},
Integer.TYPE.toString(),
MBeanOperationInfo.INFO );


//
// Build the PARAMETERS and OPERATIONS meta information for "subtract".
//

final MBeanParameterInfo minuendParameter =
new MBeanParameterInfo(
"minuend",
Integer.TYPE.toString(),
"The fir! st parameter in the substraction (minuend)." );

final MBeanParameterInfo subtrahendParameter =
new MBeanParameterInfo(
"subtrahend",
Integer.TYPE.toString(),
"The second parameter in the subtraction (subtrahend)." );

final MBeanOperationInfo subtractOperationInfo =
new MBeanOperationInfo(
"subtract",
"Integer Subtraction",
new MBeanParameterInfo[] {minuendParameter, subtrahendParameter},
Integer.TYPE.toString(),
MBeanOperationInfo.INFO );

//
// Build the PARAMETERS and OPERATIONS meta information for "multiply".
//

final MBeanParameterInfo factorOneParameter =
new MBeanParameterInfo(
"factor1",
Integer.TYPE.toString(),
"The first factor in the multiplication." ! );

final MBeanParameterInfo factorTwoParamete! r =
new MBeanParameterInfo(
"factor2",
Integer.TYPE.toString(),
"The second factor in the multiplication." );

final MBeanOperationInfo multiplyOperationInfo =
new MBeanOperationInfo(
"multiply",
"Integer Multiplication",
new MBeanParameterInfo[] {factorOneParameter, factorTwoParameter},
Integer.TYPE.toString(),
MBeanOperationInfo.INFO );

//
// Build the PARAMETERS and OPERATIONS meta information for "divide".
//

final MBeanParameterInfo dividendParameter =
new MBeanParameterInfo(
"dividend",
Integer.TYPE.toString(),
"The dividend in the division." );

final MBeanParameterInfo divisorParameter =
new MBeanParameterInfo(
"divisor",
! Integer.TYPE.toString(),
"The divisor in the division." );

final MBeanOperationInfo divideOperationInfo =
new MBeanOperationInfo(
"divide",
"Integer Division",
new MBeanParameterInfo[] {dividendParameter, divisorParameter},
Double.TYPE.toString(),
MBeanOperationInfo.INFO );

//
// Build the PARAMETERS and OPERATIONS meta information for
// "whatWasTheLastOperation" method.
//

final MBeanOperationInfo lastOperationOperationInfo =
new MBeanOperationInfo(
"whatWasTheLastOperation",
"Last Calculator Operation Performed",
null,
"OperationType",
MBeanOperationInfo.INFO );

return new MBeanOperationInfo[]
{ addOperationInfo, subtractOperationInfo,
multiplyOperationInfo, divideOperationInfo,
! lastOperationOperationInfo };

}

/**
* Create a SimpleCalculator-specific MBeanInfo.
*
* @param mbeanClassName Name of MBean class being used.
* @param description Description for MBean display.
* @return Generated MBeanInfo.
*/
private static MBeanInfo createCalculatorMBeanInfo(
final String mbeanClassName,
final String description )
{

final MBeanInfo mbeanInfo =
new MBeanInfo(
mbeanClassName, // underlying class name
description, // description of MBean meant for humans
null, // attributes
null, // constructors
buildMBeanOperationInfo(), // operations
null); // notifications
return mbeanInfo;
}

/**
* ! Register the provided MBean (implementation and interface provided) with
* the provided ObjectName on the provided MBeanServer as a Standard MBean
* if isMXBean is false or as an MXBean if isMXBean is true.
*
* @param mBeanClass MBean implementation class.
* @param interfaceClass MBean interface.
* @param objectNameStr ObjectName under which MBean will be registered.
* @param isMXBean true if this is MXBean; false if Standard MBean.
* @param mbs MBean Server on which to register MBean.
*/
private static void registerStandardMBean(
final Class mBeanClass,
final Class interfaceClass,
final String objectNameStr,
final boolean isMXBean,
final MBeanServer mbs)
{
try
{
final Object objectForMBean = mBeanClass.newInstance();
final ObjectName objectName = new ObjectName(objectNameSt! r);
final DustinMBean standardMBean =
! n ew DustinMBean(
mBeanClass.cast(objectForMBean),
interfaceClass,
isMXBean);
standardMBean.setMBeanInfo(
createCalculatorMBeanInfo(
mBeanClass.getName(),
"Simple Standard MBean-turned Dynamic Example.") );
mbs.registerMBean(standardMBean, objectName);
System.out.println(
"MBean with ObjectName " + objectNameStr + " based on class "
+ mBeanClass.getCanonicalName() + " and interface "
+ interfaceClass.getCanonicalName() + " has been registered.");
}
catch (InstantiationException ex)
{
System.err.println(
"Unable to instantiate provided class or interface.\n"
+ ex.getMessage() );
}
catch (IllegalAccessException ex)
{
System.err.println(
! "Cannot access the provided class for a new instance.\n"
+ ex.getMessage() );
}
catch (MalformedObjectNameException ex)
{
System.err.println(
"Cannot create an ObjectName " + objectNameStr + ":\n"
+ ex.getMessage() );
}
catch (InstanceAlreadyExistsException ex)
{
System.err.println(
"An MBean instance already exists with name " + objectNameStr
+ ":\n" + ex.getMessage() );
}
catch (MBeanRegistrationException ex)
{
System.err.println(
"Failed to register MBean " + objectNameStr + " based on class "
+ mBeanClass.getCanonicalName() + ":\n" + ex.getMessage() );
}
catch (NotCompliantMBeanException ex)
{
System.err.println(
"The class " + mBe! anClass.getCanonicalName() + " is not a "
+ "! complian t MBean: " + ex.getMessage() );
}
}

/**
* Create and register an MBean given the provided MBean's implementation
* class name, the desired Object Name for the MBean, and the MBeanServer
* on which to register the MBean.
*
* @param mBeanClass MBean implementation class.
* @param objectNameStr ObjectName to be used for the MBean instance.
* @param mbs MBean Server that will be hosting the MBean.
*/
private static void createAndRegisterStandardMBean(
final Class mBeanClass,
final String objectNameStr,
final MBeanServer mbs)
{

String standardMBeanClassName = "";
try
{
final ObjectName standardMBeanName = new ObjectName(objectNameStr);
standardMBeanClassName = mBeanClass.getCanonicalName();
mbs.createMBean(standardMBeanClassName, standardMBea! nName);
System.err.println(
"Standard MBean " + standardMBeanName + " created and registered "
+ "using the class " + standardMBeanClassName );
}
catch (ReflectionException ex)
{
System.err.println(
"Problem trying to get name of class for MBean:\n"
+ ex.getMessage() );
}
catch (InstanceAlreadyExistsException ex)
{
System.err.println(
"MBean already exists and is registered with name "
+ objectNameStr + ":\n" + ex.getMessage() );
}
catch (MBeanRegistrationException ex)
{
System.err.println(
"Error trying to register MBean " + objectNameStr + ":\n"
+ ex.getMessage() );
}
catch (NotCompliantMBeanException ex)
{
System.err.println(
! "Class " + standardMBeanClassName + " is not a c! ompliant MBean:\n"
+ ex.getMessage() );
}
catch (MalformedObjectNameException ex)
{
System.err.println( "Bad objectname " + objectNameStr + ":\n"
+ ex.getMessage() );
}
catch (MBeanException ex)
{
System.err.println(
"MBeanException encountered trying to register class "
+ standardMBeanClassName + " as MBean with ObjectName of "
+ objectNameStr + ":\n" + ex.getMessage() );
}
}

/**
* Main executable for running Standard and MXBean examples.
*
* @param arguments The command line arguments.
*/
public static void main(String[] arguments)
{
final MBeanServer mbs = ManagementFactory.getPlatformMBeanServer();

// Create and register a standard MBean the standard way.
create! AndRegisterStandardMBean(
SimpleCalculator.class, // SimpleCalculator is Standard MBean
"standardmbean:type=standard", // ObjectName string
mbs); // MBean server to register on

// Create and register an MXBean the standard way.
createAndRegisterStandardMBean(
LessSimpleCalculator.class,
"standardmbean:type=mxbean",
mbs);

// Register a standard MBean using the StandardMBean-extended class.
registerStandardMBean(
SimpleCalculator.class,
SimpleCalculatorMBean.class,
"dynamicmbean:type=standard",
false,
mbs);

// Register an MXBean using the StandardMBean-extended class.
registerStandardMBean(
LessSimpleCalculator.class,
LessSimpleCalculatorMXBean.class,
"dynamicmbea! n:type=mxbean",
true,
mbs);
pause(100000);
}
}


In the class above, the method that sets up the metadata [buildMBeanOperationInfo()] is extremely similar to the same method used in an earlier blog entry to set up metadata on operations for the Model MBean class.

It is inside the try block in the registerStandardMBean method that most of the action occurs in terms of using the StandardMBean-derived DustinMBean. This method is a little more complicated than it would need to be if was less generic and reflection was not used. The example usage code shown in the Javadoc for StandardMBean shows how easy it can be.

For instance, instead of using reflection like this:


final Object objectForMBean = mBeanClass.newInstance();
final ObjectName objectName = new ObjectName(objectNameStr);
final DustinMBean standardMBean =
new DustinMBean(
mBeanClass.cast(objectForMBean),
interfaceClass,
isMXBean);
standardMBean.setMBeanInfo(
createCalculatorMBeanInfo(
mBeanClass.getName(),
"Simple Standard MBean-turned Dynamic Example.") );
mbs.registerMBean(standardMBean, objectName);


it could be done less generically but much more simply like this


final ObjectName objectName = new ObjectName(objectNameStr);
final DustinMBean standardMBean =
new DustinMBean(
new SimpleCalculator(),
SimpleCalculatorMBean.class,
isMXBean);
standardMBean.setMBeanInfo(
createCalculatorMBeanInfo(
! "dustin.jmx.SimpleCalculator",
"Simple Standa! rd MBean -turned Dynamic Example.") );
mbs.registerMBean(standardMBean, objectName);


In the main() of the StandardMBeanDemonstrator class, the code demonstrates that the Standard MBean and the MXBean are each used twice, once in the standard way and once via the StandardMBean class. The standard approach depends entirely on naming conventions between implementation and interface while the StandardMBean approach allows the implementation and interface to be explicitly associated in code. The latter approach also allows extra metadata to be specified.

I won't show it here, but the whatWasTheLastOperation() operation only works in JConsole for the two uses of MXBean and not for the two uses of Standard MBean for reasons displayed in a previous blog entry.

I'll end this entry with two screen ! snapshots. One shows the MXBean that was created and registered with the MBeanServer in the standard way. It works perfectly well, but lacks descriptive information in JConsole. The second shows the same MXBean registered with the StandardMBean approach. It works as well, but also shows dynamic MBean level of description.

MXBean Registered on MBean Server in Standard Way




MXBean Registered on MBean Server via StandardMBean Class!




In conclusion, use of the Java SE-provided StandardMBean class allows JMX developers to treat Standard and MXBeans more like dynamic MBeans. Because all MBean types support Descriptors as of Java SE 6, the differences between the types of MBeans continue to blur.

difference quotient calculator

Kung Fu Panda!

Mrs.S and I did the Imax thing tonight, to see Kung Fu Panda. Admittedly, the previews for it hooked us in... not to mention that any movie that beats an Adam Sandler movie at the box office opening weekend gets my deep appreciation.

Dreamworks animation - 'nuff said. These folks know their 1's and 0's. Special shout-out to the clever adaptation of the Dreamworks logo at the beginning.

Great story about Po the Panda and the legendary Dragon Warrior. Nice twists to the story, tons o' action, but be warned - the bad guy (snow leopard, actually) in this flick is really really bad. As in, pretty scary. At least, I still have a few nail prints from Mrs.S's reaction to a few scenes.

Wasn't Master Po in Kung Fu (the old TV series) the blind master who called Caine "Grasshopper?" Just curious...

Bottom line, seekers of fun fa! mily flicks, seekers of great animation flicks, or seekers of seeing a panda's bottom take on a snow leopard - this is your movie. We'll be seeing it at least a couple of times more, and you better believe when this puppy comes out on DVD, it'll be ours that day. Even the end credits are beautiful, and worth staying for.

Not to mention that if you haven't read the hype about who the different voices are done by, the credits where they are revealed will have you going, "whoa!"

ENDING ALERT: Yes, there is a little something at the end of the credits. Mrs.S and I were the only souls left in the theater, and thus a whole bunch of folks will never know what we know. Hee hee hee...

Ezzie goes into her signature "rear leg spin and whip tail kick" and serves up the rating:

Ezzie the Wonder Dog gives this one three spinning tails in monkey style. Mr.S adds a b! owl of noodles, complete with special secret ingredient. Want ! to know what that is? Go see the movie - you'll find out. :-D

congreve cube

Using Algebra To Teach Basic Operations.

The basic operations are usually defined as addition, subtraction, multiplication and division. Algebra because it is generic math can get the basic concepts across quickly and easily. Notice I used the term "generic." Much less intimidating than "abstract mathematics".

There are many kinds of base ten blocks that you can purchase, but base ten blocks are not all the same and some are much more useful than others. First off, make sure they are base ten blocks, I have seen block sets where they are base seven and even base three...where seven of the x are same as an x2 or just three y are the same as the y2 while still quite workable doing the larger problems becomes somewhat difficult because it takes too long to count out the units. This is very much akin to getting lost in computation...many students lose track of the problem they are doing because even if they understand the concepts they can't do the math or it takes them a long time to ! do the math and they forget what they were doing in the first place.

Here we see a seven year old student doing simple sums with the blocks handy in case he gets stuck...he didn't get stuck. Note there are a few problems where he has to figure out what x is, and to do so he will have to do some subtraction even though all these problems seem to be "addition."
For 7 + x = 15,

He doesn't try to figure out the answer by counting forward he knows two ways to solve it. One he "subtract! s" 7 from 15 by using addends...seven needs 3 to be ten (taking the seven out of the ten) and 3 + 5 = 8 or "using up" the five, he can take 5 out of 7 which leaves 2, and 2 needs 8 to be ten...so the answer is 8 either way.

Next we build some simple rectangles in algebra. For the the first problem he got out 3x and a nine (the nine block) but that didn't make a rectangle. He looked at me for help and I just smiled. "Make me a rectangle..."

He puzzles over it for a moment and then you can see the light bulb go on. "I need t! hree 3's!" Now counting the sides is EASY 3 across and x + 3 up...the next one looks "hard" so he skips it and does the last one. I think this is because we spent some time playing with nines and he hasn't had much experience with sevens.

You don't see it here but he got out 9x and then got out nine fours and was able to see that the rectangle was 9x + 36 and the sides were 9 across and x + 4 up.

9x + 36 = 9(x + 4)

Then I showed him that he could have used 4 nines and we talked a little about 9 being the "common factor", but mostly this lesson was about division for him...making 36 "fit" on the 9x...if the whole thing is 36 and one side is 9 what does the other side have to be? Four. Which is why he got out fours...



He did the same thing with 7x + 21 (the problem in the middle, solution pictured and built but the answer isn't written yet)...took him several tries before he got out three's...I asked him why he didn't just get out sevens...he thought for a moment and then went, "OH, now I get it...!"


Next he got to build his own problem and we see that bigger is funner.! I had two top trays out, which meant he had 3x2 and 20x to work with so he used all of them. BIGGER IS FUNNER. He spent some time building it and making it so he could use up all the x. Then he fit in the eights and I told him to count it.

"What do you mean?" he said coyly.

"Tell me the whole thing and the sides....he did and then I told him to write it down.
base ten blocks


Remember the child is seven, his writing skills are not well developed, first he wrote it too small then he wrote i! t too big for purposes of the picture but I think he did just ! fine...i t was taking him quite a while to write it and I wanted to move on to the next problem...

The mind wants to work very rapidly, counting out individual units from the various manipulative sets takes too long. Sometimes even counting out tens or x's takes too long. So while sets that have base ten blocks with tens and individual units are quite useful they become tedious if you want to use them to demonstrate many problems in a row or even just a few larger problems. By larger I simply mean problems that will have a lot of pieces to get out. Showing 60% of 80 for example or even a simple problem like (x+6)(x+7) will require getting out 42 units...you already have to get out 13x, counting out 42 units takes a lot of time, and the student can often get lost (and bored) because of it; however, if all you have to do is get out an x-square, 6 sevens (or 7 sixes) and you can grab 7x and 6x, the problem can be built very rapidly.

base 10 manipulativesIn this case he had the rectangle

2x2 + 20x + 42

And he had to find the sides. Later when he knows his multiplication better he will see that the factors of 42 will be a big help in solving this problem quickly, but for now he takes the 20x and makes a rectangle out of that...it took some trial and error to get 6x on top and 14x (two sets of 7x) so that they would fit...that was a lot of counting and adding. Then he still wasn't sure he had it right because he could not tell if 6 times 7 was 42 because he di! dn't know it. You can see him doing computation on the side..! .he has 14 three times and the sevens drawn out...again lots of math going on here to figure out if he has 42 or not. 30 + 4 times 3 or 30 plus 12, and then the long way where he has to add seven plus seven plus seven etc until he gets to 42. If he had to count out individual units this problem would have taken MUCH longer and he may not have finished it at all.

2x2 + 20x + 42 = (x + 7)(2x + 6)

(In the picture the 2x is cut off.) With a few simple pictures, you can actually SEE what it is I'm talking about. You can see that becomes easy to teach counting and addition, and multiplication and division using algebra because the child has to count out and add up the blocks in order to build the rectangles needed to solve the problems. At this point you begin to see why a picture is worth a thousand words, and if a picture is worth a thousand words having your hands on the blocks and then being able to draw them is worth a thousand explanat! ions. Further, this is the way the subconscious mind works, using pictures NOT symbols and we have come to realize over the last 100 years that most learning takes place in the subconscious mind not in the conscious mind.

Students who benefit from base ten blocks most are the kinesthetic learners, because they literally can get their hands on algebra and work with the problems. They can see and touch the problems in a very real sense. They can see that x times x is an x square, they can touch it...they see and touch the distributive theory of multiplication because they can see an x+3 is just a number with two parts (a binomial) and if I have 3(x+3) (spoken three times x plus three), I get 3x+9 and they can see it.

Getting this problem out is still easy even if the blocks you have are all individual units, but it's still easier to get out 3 threes...and by the way we can note than 9 is a square number when we build it this way. As soon as you do a ! problem like 5(x+8) counting out the 40 units is going to slow! things down and actually take away from the lesson and the concept that the 5 multiplies the x and the 8. Manipulative sets that use rods to represent numbers are again quite useful but will have serious drawbacks when attempting to demonstrate algebra or square numbers and square roots because most often 3, 3-rods do not make a square. Simple concepts like x + x = 2x are easy for any student who is just learning to count. Base ten manipulatives or base ten blocks can be used for so much more than just counting or to teach addition. When used properly very young students can lean to count and add WHILE they learn algebra and vis-versa, and counting, adding and subtracting lead to multiplication and division.


"We used to think that if we knew one, we knew two, because one and one are two. We are finding that we must learn a great deal more about 'and'." ~Arthur Stanley Eddington, as quoted in! A Dictionary of Scientific Quotations" (1991) by Alan L. Mackay, p. 79


Lastly for fun he got to build whatever he wanted. Lots of multiplication went on here as I made him count by nines and fives and tens.
Fun Math Activities

The tens are two fives so we counted pretty high by fives, and we counted all those nines (the teal colored one that make up the roof). Using the "trick" "one less and what does it need?" 6 nines is 54, which means 5 is one less than six and six needs four to be ten...for 14 nines it's tw! o less and what does it need? 14 minus 2 is 12 and 4 needs 6 ! to be te n so (14)(9) = 126 We also counted by adding nines...

BTW you can check me out on FACE BOOK now...and get up dates etc...and of course get more at Crewton Ramone's House of Math

algebra made easy to understand

Help!

Here's the deal:  I'm working on curriculum for my school and Algebra 2 is making my eyes cross.  I think the major problem is the state of Virginia is in a transition year between "old" Standards of Learning (SOLs), and "new" ones.  This year is supposed to be the year that we're still teaching and assessing the old SOLs, but we're supposed to teach the new ones, too.  Those of you that teach Algebra 2 already know that there's an enormous amount of information to cover in a short period of time.  To give you context, our school teaches it as a semester-long block course.  There's only so much a brain can handle in one day, though! 

Here's the first draft of my skills list and structure...I'm not sure what to do about the old vs. new SOLs (my skills list is based on the old SOLs because that is what will be assessed).

Note:  Gray items are not included in old or new SOLs but might be necessary for student understanding
          Blue items are being taken out of the SOLs starting next year
          Red items are new to the SOLs starting this year

Unit 1 Algebra 1 Review/Solving Equations


1 Solve multi-step equations and inequalities
2 Matrix +/-
3 Solve compound inequalities
4 Solve absolute value equations
5 Solve absolute value inequalities

Unit 2 Polynomial Review/Add Depth

6 Factor trinomial a = 1
7 Factor trinomial a > 1
8 Factor special cases (sum/diff of cubes, diff of squares, perfect square trinomials)
9 Factor out GCF first (factor completely)
10 Exponent rules
11 +/- polynomials
12 Multiply polynomials
13 Divide polynomials

Unit 3 Rational Expressions

14 Identify undefined values
15 Simplify rational expressions by factoring and canceling out common factors
16 Multiply and divide fractions
17 Multiply and divide rational expressions
18 Add and subtract fractions
19 Add and subtract rational expressions
20 Simplify complex fractions
21 Solve rational equations

Unit 4 Radicals, Radical Equations and Complex Numbers

22 Simplify numbers under radical
23 Simplify monomials under radical
24 Multiply and divide radicals
25 Add and subtract radicals
26 Nth roots to rational exponents and vice versa
27 Simplify expressions with nth roots and rational exponents
28 Solve radical equations
29 Simplify square roots with negative terms inside radical using i
30 Add and subtract complex numbers
31 Powers of i
32 Multiply complex numbers

Unit 5 Functions (intro)

33 Domain and range of relations (from ordered pairs, mapping, graph, table)
34 Identify relations that are functions and one-to-one
35 Given graph and a value k, find f(k)
36 Given graph, find zeros
37 Given graph and a value k, find where f(x)=k

Unit 6 Linear Functions


38 Slope from graph, equation, points
39 Graph from equation
40 Equation from graph
41 x- and y- intercepts
42 Determine whether lines are parallel, perpendicular, or neither from equation or graph
43 Write equations for parallel and perpendicular lines given line and point off the line
44 Graph linear inequalities

Unit 7 Systems


45 Solve systems of equations by graphing
46 Multiply Matrices using a graphing calculator
47 Inverse matrix method of systems
48 Systems of equations word problems
49 Graph systems of linear inequalities
50 Linear programming max/min problems

Unit 8 Functions (reprise)

51 Function math (addition, subtraction, multiplication, division)
52 Function composition, find a value i.e. f(g(3))
53 Function composition, find the function i.e. f(g(x))
54 Find an inverse function by switching variables

Unit 9 Quadratics

55 Graph from vertex form, identify max/min and zeros
56 Solve by factoring
57 Solve by Quadratic Formula (including complex solutions)
58 Determine roots using the discriminant
59 Write equation for quadratic given roots
60 Quadratic systems
61 Polynomials: relating x-intercept, zeroes and factors
62 End behavior for polynomials

Unit 10 Exponential/Logarithmic functions

63 Exponential growth or decay from function
64 Sketch base graph of exponential/log functions
65 Exponential to log and vice versa
66 Data analysis/curve of best fit for linear, quadratic, exponential and log

Unit 11 Transformations and Parent Functions

67 Graph absolute value functions
68 Horizontal and vertical translations of linear, quadratic, cubic, abs value, exponential and log
69 Reflections and stretching of linear, quadratic, cubic, abs value, exponential and log
70 Combinations of transformations on parent functions
71 Identify parent graphs of parent functions
72 Identify equations of parent functions

Unit 12 Conics

73 Identify a conic from graph
74 Identify a conic from equation

Unit 13 Variations

75 Write equation for direct, inverse and joint variation problems
76 Find the constant of variation

Unit 14 Sequences/Series

77 Write n terms of an arithmetic sequence
78 Find the sum of a finite arithmetic series
79 Write n terms of geometric sequence
80 Find sum of geometric series
81 Use formulas to find nth term
82 Identify sequence/series as arithmetic, geometric or neither

Unit 15  Statistics

83 Determine probabilities associated with areas under the normal crve
84  Compute permutations and combinations

 
If you made it this far, here's my call for help:  Anyone have advice/suggestions for how to make this work and/or a better way to organize the information into cohesive units that seem to occur in a somewhat logical order?  There is and will continue to be an emphasis on function families and transformations (as there should be).  I find it difficult to express on paper how each function category needs to be a resting place, but they are all connected in the ways that transformations apply.  Any ideas?
 
...oh...and I'm going to be teaching one section of deaf students and one section of blind students...in case that makes a difference

**edit:  I've added links to the old and new Virgina SOLs for Algebra 2 if anyone's interested**

Simplifying Expressions, Inequalities

Sequences & Series

A sequence is a function whose domain is only natural numbers.

In the general formula, it is common to use n instead of x.

  • Sequences can be infinite, so
    Sometimes, an extra term is needed, so
    ! precedes

Summation Notation:
n=> upper limit


i=> index of summation

1=>lower limit

Geometric Progressions or geometric sequences:
  • consecutive terms have a common ratio (r)

Methods of Representation:

1. Sequence: (list of numb! ers)
2. n-th term: (formulas)
3. Recursion: (using past terms)

Practice Word Problem:
A man wishes to save money by setting aside one cent the 1st, two cents the 2nd day, four cents the 3rd day and so on, doubling the amount each day. Assuming he does not run out of money, what is the total amount of money he would have saved at the end of 30 days?


  • First, you would recognize this as a geometric sequence. Using the equation, , you would plug in to solve for r.

  • Then with the given r value, which should be calculated as 2, you would then use the Geometric Sum formula, to find what the sum of the money would be.
  • With correct substitution of values, the answer comes out to be $3.00



How to find sequence/sum of series on calculators:
LIST MENU (2nd STAT) =>OPS=>seq(formula, variable, lower, upper)=>MATH sum(seq(...))


FORMULAS:
General Sequence:

General Series:

Arithemic Sequence:
nth term of an arithemic sequence:

Finding d:
Arithmetic Sum:
geometric sequence: Recursive Definition:

nth term of a geometric sequence:

Finding r:

Geometric Sum:

Infinite Series:




Practice Problems:

1. Find a formula for the nth term of the sequence below.

2. Find the 15th term of the geometric progression below.
2, 6, 18, 54,...

3. How many terms are in the sequence below?
4,12,36,108,...708588

4. The sum of the first n positive odd integers is 1521. Find n.

5. Insert 3 arithmetic means between 19 and 32.

6. The 7th and 10t! h terms of a geometric sequence are 821 and 6568. Find the 11th term.

7. The seats in a lecture room increase in each row from front to back. The first row has 10 seats. The second row has 11 seats, etc. Find the number of seats in the twelfth row.

8. Using the given information in problem 7, find the number of seats in the room if the twelfth row is the last row. 9. How many terms are in the sequence

10. For the sequence below, determine the next two terms:

1,5,13,29,61,...






Solutions to practice problems

1.

2. 9,565,938

3. 12 terms

4. n=39

5. 22.25, 25.5, 28.75

6. 13,136

7. 21 seats

8. 186 seats

9. 24 terms

10. 125, 253


geometric sequence

Rules for Radicals: How to Begin Taking Back Our Government

I am disgusted and fed up with campaign coverage. I don't give a crap about Hilary 'tearing up' or Obama wearing or not wearing a flag pin of any sort! I am not impressed with idiots who find patriotism in a flag pin like Bush finds courage at the bottom of a bottle! I care even less about how McCain --an idiot --is doing!

The debates might as well be about how many angels can dance on the head of a flag pin. Everything is eyewash until the treasonous criminals who seized the White House are brought to justice before a hangin' judge! Until someone addresses that issue, everything else is just meaningless polemics, a sop, bread! and circuses to let the 'people' believe that they actually count. Since 911, you don't count!

I am not a 'Kumbayah Liberal'. I am a roll up your sleeves and carry a tire iron radical! I am not gentile when someone like Bush --a prissy, prancy, snot-nosed, gay boy cheerleader --tries to bullshit me while scrapping the Constitution and threatening the rest of the world with nukes! Bush's co-conspirators, the GOP, the MIC and certain well-heeled individuals have much to answer for. With any luck at all, they will! In a dock! Charged with a panoply of crimes for which there is abundant probable cause now to try their sorry asses! Don't waste time calling me a 'conspiracy theorist'; I'm not talking theories --I'm talking indictments!

The American left used to be tough. Throughout the American left were found tough minded organizers and radicals like Saul Alinsky who did not mi! nce words.
"Liberals in their meetings utter bold ! works; t hey strut, grimace belligerently, and then issue a weasel-worded statement 'which has tremendous implications, if read between the lines.' They sit calmly, dispassionately, studying the issue; judging both sides; they sit and still sit.

The Radical does not sit frozen by cold objectivity. He sees injustice and strikes at it with hot passion. He is a man of decision and action. There is a saying that the Liberal is one who walks out of the room when the argument turns into a fight.

Society has good reason to fear the Radical. Every shaking advance of mankind toward equality and justice has come from the Radical. He hits, he hurts, he is dangerous. Conservative interests know that while Liberals are most adept at breaking their own necks with their tongues, Radicals are most adept at breaking the necks of Conservatives.

Radicals precipitate the social crisis by action - by using power. Liberals may then timidly follow along or else, as in most cases, be swept! forward along the course set by Radicals, but all because of forces unloosed by Radical action. They are forced to positive action only in spite of their desires ...

--Saul Alinsky: The American Radical
The American left was, in fact, so tough that a shocked and awed GOP decided that if they could not come up with their own strategies they would revert to form and steal those of the 'organizers' that represented America's left wing throughout the 20s, 30s and 40s. Though they will not admit it, the GOP was as impressed as it was frightened with Saul Alinsky. He had, after all, organized the tough Chicago neighborhoods made famous by Upton Sinclair in his novel: The Jungle.
There's another reason for working inside the system. Dostoevsky said that taking a new step is what people fear most. Any re! volutionary change must be preceded by a passive, affirmative,! non-cha llenging attitude toward change among the mass of our people. They must feel so frustrated, so defeated, so lost, so futureless in the prevailing system that they are willing to let go of the past and change the future.

This acceptance is the reformation essential to any revolution. To bring on this reformation requires that the organizer work inside the system, among not only the middle class but the 40 per cent of American families - more than seventy million people - whose income range from $5,000 to $10,000 a year [in 1971]. They cannot be dismissed by labeling them blue collar or hard hat. They will not continue to be relatively passive and slightly challenging. If we fail to communicate with them, if we don't encourage them to form alliances with us, they will move to the right. Maybe they will anyway, but let's not let it happen by default.."[2]

--Saul Alinsky, Organizer
So impressed was the GOP that throughout the '80s --the decade that saw t! he rise of Tom DeLay --GOP consultants would include Alinsky's 'rules for radicals' as the cornerstone of the various GOP 'Campaign Manuals' that they put together. It was a GOP manual, in fact, that was my introduction to Alinsky. I think it's time the 'left' reclaimed Alinsky. He is, after all, one of our own. It's time the 'left' dust off his 'rules for radicals', reclaim them, and put them to work in service to a higher call than that of Bush self-aggrandizement, bullying, and outright theft of the world's resources.
RULE 1: "Power is not only what you have, but what the enemy thinks you have."

Power is derived from 2 main sources - money and people. "Have-Nots" must build power from flesh and blood. (These are two things of which there is a plentiful supply. Government and corporations always have a difficult time appea! ling to people, and usually do so almost exclusively with econ! omic arg uments.)

RULE 2: "Never go outside the expertise of your people."

It results in confusion, fear and retreat.

Feeling secure adds to the backbone of anyone. (Organizations under attack wonder why radicals don't address the "real" issues. This is why. They avoid things with which they have no knowledge.)

RULE 3: "Whenever possible, go outside the expertise of the enemy."

Look for ways to increase insecurity, anxiety and uncertainty. (This happens all the time. Watch how many organizations under attack are blind-sided by seemingly irrelevant arguments that they are then forced to address.)

RULE 4: "Make the enemy live up to its own book of rules."

If the rule is that every letter gets a reply, send 30,000 letters. You can kill them with this because no one can possibly obey all of their own rules. (This is a serious rule. The besieged entity's very credibility and reputa! tion is at stake, because if activists catch it lying or not living up to its commitments, they can continue to chip away at the damage.)

RULE 5: "Ridicule is man's most potent weapon."

There is no defense. It's irrational. It's infuriating. It also works as a key pressure point to force the enemy into concessions. (Pretty crude, rude and mean, huh? They want to create anger and fear.)

RULE 6: "A good tactic is one your people enjoy."

They'll keep doing it without urging and come back to do more. They're doing their thing, and will even suggest better ones. (Radical activists, in this sense, are no different that any other human being. We all avoid "un-fun" activities, and but we revel at and enjoy the ones that work and bring results.)

RULE 7: "A tactic that drags on too long becomes a drag."

Don't become old news. (Even radical activists get bored. So to keep them excited a! nd involved, organizers are constantly coming up with new tact! ics.)

RULE 8: "Keep the pressure on. Never let up."

Keep trying new things to keep the opposition off balance. As the opposition masters one approach, hit them from the flank with something new. (Attack, attack, attack from all sides, never giving the reeling organization a chance to rest, regroup, recover and re-strategize.)

RULE 9: "The threat is usually more terrifying than the thing itself."

Imagination and ego can dream up many more consequences than any activist. (Perception is reality. Large organizations always prepare a worst-case scenario, something that may be furthest from the activists' minds. The upshot is that the organization will expend enormous time and energy, creating in its own collective mind the direst of conclusions. The possibilities can easily poison the mind and result in demoralization.)

RULE 10: "If you push a negative hard enough, it will push through and become a positi! ve."

Violence from the other side can win the public to your side because the public sympathizes with the underdog. (Unions used this tactic. Peaceful [albeit loud] demonstrations during the heyday of unions in the early to mid-20th Century incurred management's wrath, often in the form of violence that eventually brought public sympathy to their side.)

RULE 11: "The price of a successful attack is a constructive alternative."

Never let the enemy score points because you're caught without a solution to the problem. (Old saw: If you're not part of the solution, you're part of the problem. Activist organizations have an agenda, and their strategy is to hold a place at the table, to be given a forum to wield their power. So, they have to have a compromise solution.)

RULE 12: Pick the target, freeze it, personalize it, and polarize it."

Cut off the support network and isolate the target from sym! pathy. Go after people and not institutions; people hurt faste! r than i nstitutions. (This is cruel, but very effective. Direct, personalized criticism and ridicule works.)

--Saul Alinsky, rules for radicals
Even now, Alinsky is quoted more often by the 'right' than the 'left' who should be studying him. I found the following comment on the 'Free Republic':
"Hillary!" Rodham (Pre-Clinton), while at Wellesley, studied Saul Alinsky, whose ideas provided the organizing thesis for her (mysteriously unavailable) Senior Honors Paper.(!)

This is the absolute truth!

Heads up!
My response to the 'wing nut' who posted this is: so what! I advocate taking Alinsky back. He's the genie in the lamp. He served the left well until, somewhere, sometime, he was hijacked. The right wing rubbed the la! mp and his 'rules for radicals' became the object of right wing study, application and practice.

The right wing, however, misunderstood and misapplied Alinsky. The right wing organizes from the top down; Alinsky from people to people, block by block! The right wing is ideologically constipated. Alinsky believed in what works for the people.

I say: reclaim Alinksy, the Genie! Let him out of the lamp and put him back to work for greater and better causes than the enrichment of some one percent of the population who didn't work for it and doesn't deserve it. Class warfare? You bet your sweet ass, it is! Bring it on! Put Alinsky to work for peace and people --not guns and phony aristocrats!

Put Alinsky to work organizing 'committees' that will track down war criminals (we know who they are) when they are out of office and on the lamb. Put Alinsky to work organizing research teams tha! t will support numerous capital crimes cases. Put Alinsky's pr! inciples to work getting the goods on the 'real killers' of 911! And we know who they are as well! Some good starts have been made. But a revolution is won, like chess, in the end game with checkmate. In this case, we start with Rule 12: "Pick the target, freeze it, personalize it, and polarize it."

Additional resource:


SPECIAL COMMENT

Keith Olbermann - 'Countdown'

Olbermann To Bush: "This War Is Not About You...Shut The Hell Up!"


Bill 0'Reilly's 19th Nervous Break Down Rapped (What an Idiot!!)

Subscribe



GoogleYahoo!AOLBloglines

Add to Technorati Favorites

, , ,

Spread the word

yahoo icerocket pubsub newsvine

rules for radicals