The Phractalattice

...a rabbit hole...

Thoughts on graduate school, the GREs and homogenous academic environments

A couple of weeks ago now I managed to break my foot playing ultimate frisbee at a friend's bachelor party. The joke still hasn't quite grown old is that the strippers got a little too rowdy. In all truth though, it was the bachelorette party that had the strippers, and from what I hear it was pretty funny. Fortunately, the break is pretty minor and I was doing something a least somewhat cool when it happened. Last year I hurt my back pretty badly getting into the shower. That's how old people get hurt. I had to lie and say that I was rock climbing. I mean, I was rock climbing really...

Anyway, whilst cooped up with my swollen foot above my heart I began to wonder whether my body was trying to tell me something. I roughly sketched out (after some serious leaps of logic) that maybe it is that I need to go back to school. This may be a silly conclusion, and while I'm not sold on it, I have decided that having to stay off my foot is an excellent excuse and opportunity to bone up on the mathematics GRE subject test (not to be confused with the math section of the general GRE exam - the math subject test is for potential mathematics grad students) and get serious about grad school. So that's what I'm doing.

However, as I may or may not have stated in previous posts, I have a real problem with GREs and other standardized tests in general. I think that they make it very easy for admissions departments to exclude people off of very limited criteria. Some of the most brilliant mathematical minds that I know simply do not test well, or more pointedly, don't test well in the kind of situations imposed upon mathematicians-to-be at these testing centers. There can be a lot of reasons for this, but the bottom line is that everyone's brain really is quite unique, and there are so many ways that individuals can contribute greatly to mathematical knowledge.

One of the best examples that comes to mind of an individual who would likely not have fit well into the conventional test mold is the algebraist J.J. Sylvester. One of the books I've been reviewing, Contemporary Abstract Algebra by Joseph Gallian, is made lovely in part by the end of chapter sections discussing various influential algebraists. One of these sections accounts for the work of Sylvester, calling him "the most influential mathematician in America in the 19th century... His writings and lectures - flowery and eloquent, pervaded with poetic flights, emotional expressions, bizarre utterances, and paradoxes - reflected the personality of this sensitive excitable and enthusiastic man."

One of Sylvester's students, W.P. Dufree, had this to say about the man - "He seldom remembered theorems, propositions, etc., but had always to deduce them when he wishes to use them... I remember once submitting to Sylvester some investigations that I had been engaged onm and he immediately denied my first statement, saying that such a proposition had never been heard of, let alone proved. To his astonishment, I showed him a paper of his own in which he had proved the proposition; in fact, I believe the object of his paper had been the very proof which was so strange to him."

It is this type of character which I feel is pushed to the side due to standardized testing. Perhaps Sylvester's reconstructive abilities were potent enough that he would have done fine on such a test, but as I study for the GRE math subject test myself, what I am noticing is that the test is really geared to test your quickness and rapid facility with all that you are imagined to have learned or studied as an undergraduate math student. Someone who has to reconstruct (as Sylvester does, and as I often choose to do) is most likely slowed down by this greatly and may do very poorly.

Another mathematician who is worth mentioning is Joseph Fourier, who invested/discovered what we now call Fourier transforms. These mathematical transforms are now a vital part of signal processing theory, acoustical mathematics and functional analysis. Rudolph Langer had to say of the man, "It was, no doubt, partially because of his very disregard for rigor that he was able to take conceptual steps which were inherently impossible to men of more critical genius."

Yutaka Taniyama, of the Taniyama Shimura conjecture (or Modularity Theorem, which inspired Andrew Wiles's proof of Fermat's Last Theorem) was another such individual. Shimura, who worked closely with Taniyama, had to say of him that he "was not a very careful person as a mathematician. He made a lot of mistakes, but made mistakes in a good direction.. I tried to imitate him, but I found out it is very difficult to make good mistakes." It was this ability to make "good mistakes" that enabled Taniyama to discover deep and beautiful mathematical connections linking seemingly very disparate areas of mathematics in a beautiful conjecture with deep number theoretic implications.

It is my fear that in today's age we are sacrificing some of our most brilliant mathematical minds, individuals who color the mathematical community with a precious quirkiness and different perspectives, all for ease of evaluation. In doing so, we may be contributing to more homogeneous academic environments which lead to less creativity. As it stands, there is little I can do now to change this. My hope is that after getting a graduate degree and establishing myself as a mathematician I can do something to either make academia more widely accepting of such individuals or establish communities which are more accepting of these colorful individuals of less critical genius. In the mean time, I am bowing to the system as it stands, and in all truth having fun committing myself towards this preparation, concentrating all of the math that I have studied in to the tips of my fingers.

EDITS

8/10 - Corrected a mistake; Wiles did not prove the Tamiyana-Shimura conjecture, but did the part of the proof which would give him FLT. Later, his work was used to complete a full proof of the conjecture, however.

iPhone email swipe behaviour modifications

With iOS4, Apple made some nice changes to the mail application. The thread functionality in particular is great. One thing that I don't like though is that now when swiping a message in the inbox, instead of showing a delete button, it shows an archive button. Perhaps this is something that folks prefer and were asking for, but I find that it has disrupted my iPhone mail work-flow quite a bit.

I get a lot of mail, and there is a lot of it that I simply don't need to see and a lot that once seen I don't need to keep (facebook updates, urgent action updates from environmental//humanitarian organizations and the like) and liked that in the old interface I could easily swipe and delete these. It made this task almost easier on my phone than it was when logged into gmail. I certainly archive plenty of mail, but really miss the ability to easily delete mail also.

Thinking about it, it occurred to me that it might be possible to have the best of both worlds - wouldn't it be great if swiping left let you delete and swiping right let you archive (or vice versa)? If you like this idea and would like to see it on your phone, get noisy about it - spread the word. Post something on an apple forum. My hope is that other folks will hop on board with this idea and that it will eventually be integrated in some future version of iOS.

Filed under  //   iPhone  

The future of human computer interactions

A couple weeks ago I caught this TED video

 

I knew that scientists had successfully used cranial electrodes measuring brain patterns to control computer cursors and such, but last time I heard about it it was all pretty rudimentary. The technical advances that this group has made, both in hardware and software (significantly cheaper electrode headsets which don't require intensive preparation and algorithms mapping the folded brain surface structure to a flatter surface), have made some very exciting things possible.

What we are looking at here is very possibly going to become a standard component of human-computer interface. From punch cards to keyboard terminals to the first mice computers have become more and more user friendly. However, mouse and keyboard have been the standard means of interaction for decades now. Only very recently have touch screens (mostly in smaller mobile devices) made their way into the mainstream and are proliferating through the electronic markets. This technology of course was also presented in a TED talk just as it began finding integration in the mainstream of Apples phones and iPods.

 

 

We have also seen devices like the Nintendo Wii with their revolutionary motion sensing game controllers follow a somewhat similar trend. Now motion sensors are also being integrated into phones and mobile devices. Another interesting paradigm is that of room motion sensing, as in Minority Report -

 

 

What these developments have in common is that in some way or another each of these interfaces makes the way we interact with computers more natural. Touch screens allow us remove the separation between the device we use for clicking on things and visual representations of those things. Instead of pointing a mouse towards an icon or button and clicking, we touch what we can actually see as the icon or button. It also makes more natural many other interactions such as zooming. Motion sensors make it so that the motions we make in the space we actually live in can be used instead of virtualized button clicks. But what could be more natural than simply thinking open, move, zoom move or hide? If the advances of these other technologies serve as any sort of preclusion for what we can expect to see in the coming years, these brain scanning devices and room sensing technology are likely to proliferate very soon.

What is interesting to consider with all of this is that while designing revolutionary apps for these new interface technologies is fairly straightforward once they hit the scene, something more significant is looming. After coming out of decades of standard interface technologies consisting essentially of the mouse and keyboard only to witness these many advancements find their way into our sphere so quickly, we find ourselves in a period where things are going to soon start shifting more and more rapidly.

We've already seen this in the small mobile device market, but laptops are still laptops and desktop computers are still desktops. What I'm on the edge of my seat for is to see how these new technologies are going to integrate themselves into the well established traditional computing devices or how they begin to replace them. It's easy to make touch screens the new standard for a mobile device when the technology is still in it's infancy and no one is too attached to anything yet. The realm is fluid, cutting edge and welcomes change. Changing anything in the realm of laptops or desktops upsets a very established domain.

At the moment, iPads and the like have some potential for grabbing some of the market for traditional laptop and desktop computing, but they are really very different beasts. What is important to note with them is that Apple had a specific vision when they were created. The envisioned a device that didn't try to replace the new iPhone/iPod technology or the existing laptop/desktop technology. They envisioned a device complementary to the devices in it's neighboring realms. This means that there is still room for revolution in the realm of laptop/desktop interface.

The recent advent of the iPad also illustrates another key point. If we look at the months before the iPad was released, there were scores of other companies that were marketing some sort of touch tablet or another. But no one cared. No one bought one. It was only once Apple released theirs that it was clear what the vision was for these new things and what they ought to be. This highlight's the importance of a cohesive vision for the implementation of something new of this sort.

To further illustrate this point, I had a chance to set up someone's new HP Touchsmart computer for them and play around with the interface a bit several months ago. It was cool but it wasn't revolutionary. Basically, it was windows with a little HP application that you could open which gave you a more touch friendly interface to various applications. The problem is that it was ad hoc. It was not an integration, it was a plugin, just like all of the touch tablets that no one sold. There was no cohesive vision and as a result the technology is not meeting it's potential.

So the question, once again, is when do we see these new technologies not just being plugged into the existing desktop/laptop paradigms, but revolutionizing them? When are the traditional operating systems going to bow to these new interface technologies and re-envision themselves from the ground up?

That this is going to happen is not the question (save global catastrophe, thermonuclear war or complete economic collapse). The question is what will the vision look like and who is going to envision it? Will it be Apple? Could it be one of these groups that we've looked at who have designed these new technologies? Will it be Google or some other organization committed to establishing the technology in a relatively open fashion? Will Microsoft redeem themselves by revolutionizing their operating system (see relevant xkcd strips 350, 528, 272, 612 - hope I'm not offending anyone here, but seriously, between Linux and Mac, what is the point of Windows)?

At this point these are hard questions to answer, but I'll bet my pinky toe that development is already under way. I would expect that Apple has a good chance of setting the precedent. Their history bears witness to their facility with that. It seems very unlikely that Microsoft has what it takes to rise to this challenge. It's certainly possible, but the problem (aside from the fact that they already do what they are doing now badly) is that they don't have the kind of full control over hardware and software that Apple has, so it is more difficult for them to make complete revolutions as quickly; they're still too married to the status quo to rock the boat.

My hope is that the open source community hits this one on the head first. Though Apple beat Google on groovy phone operating system, Google showed with the Droid and the Android operating system that open source has the ability to team up with device manufacturers to prototype a vision which is inherently modular with respect to hardware and leaves infinite room for flexibility, customization, hackabillity and all around openness in the operating system and software. You get something less cohesive than what you get when you have Apple creating the sole device and operating system which are wed to each other, but the open source community is I believe entirely fluid enough to craft a cohesive enough vision in this realm.

The time is nigh to begin thinking about the possible applications of these technologies and how they will shape our future. With this kind of power comes great moral responsibility. I hope that those with compasses embrace the tools as means to better the world and that we all remain careful and vigilant in our technological travels.

Ipad
(EDIT 08/13/10) I had to throw the above in here.

Filed under  //   computers   iPhone  

Miscellaneous updates and thoughts on the future

Life has been amazingly full for me of late. I am now running a programming business called Sharp Logic and have been doing a fair bit of private tutoring and music teaching (at least until the school year let out). I have also been very active with my band (Enso, which just started work on our first full length album) and am on the board of our island's new and expanding food coop. And best of all I get to do all of this in one of the most beautiful places on Earth.

(download)

Wonderful as things are, I continue to feel the calling of mathematics. With every thought of Galois Theory, large cardinals or the Euler identity I feel the floor falling out from under my feet, the space between the atoms of my body exploding into infinity. It's a magical sensation which I treasure but rarely get to share with others. I do find occasion to impart bits and pieces with bright students and curious friends, but often wish that there was a stronger community of individuals around me with the same level of passion and/or depth of understanding. Consequently, I at times have felt torn between my little island shire and the great mathematical adventure that I feel lies on the horizons.

This conflict was not new for me - I have always had such a wide range of passions and interests. Things took a twist though when I saw a TED video of Steve Jobs speaking at a Standford graduation ceremony. He spoke of following your heart, finding what you love and of using the knowledge of your death as a tool in living life to it's fullest. In particular, he conveyed that death ensures that nothing is permanent - we all loose everything eventually, so why hold back in life out of fear of loosing something? The truth is, we have nothing to loose that isn't destined to be lost to us eventually. For a moment I found my conflict dissolve and realized that significantly furthering my knowledge of mathematics is something that definitely I want to do before I die.

With all of this in mind I started thinking again about graduate school. The difficulty here is that I am greatly displeased with much of the academy. I dislike the egotism, the hoops, the weeding out and the transmutation of humans into academic cogs, machines designed for the function of paper writing. Furthermore, all of this has been accentuated in light of the current economic situation. Not only has funding been cut, thereby reducing the number of available positions, but there are more applicants now that the financial sector has released it's quants from their employment. This has exacerbated the competition and made entry more difficult than ever.

Wondering whether or not there might be an alternative I imagined myself working to attain PhD level mastery of mathematics in all the spare time that I don't have between the zillion things I have going on in my life. I also began to imagine the lack of other individuals who I could work with in achieving my goals who lived on the island. Graduate school, at least for mathematics and science PhD students, is effectively paid for and puts you in direct contact with a large community of individuals who share your passions.

Questioning all of these matters segued into conversations with a good friend of mine named Paul Lessard, another mathematics student who at the time was working on getting into graduate school (he has since been accepted to a graduate program in Vermont). His similar distaste for the negative aspects of the academy were coupled with deep convictions about how these negative aspects cater and are endemic to more deeply rooted social issues. We began to dream of another way of supporting individuals who wish to pursue knowledge, one that has the potential to counteract the downfalls of the academy and promote the kind of consciousness necessary to heal the planet. We agreed that if we did go through the academy that we would only do so en route to meeting the challenge of reshaping the world into a more positive and healthy place.

Inspiration further peaked when I came across Antony Garrett Lisi, a sort of renegade physicist who, disillusioned with the overemphasis of String Theory in theoretical physics research opted after receiving his PhD not to remain in the academy but to live in Hawaii in his van, surf, engage in adventure sports and research theoretical physics independently. The product of this decision and the awarding of a FQXi grant to pursue his studies was his paper, An Exceptionally Simple Theory of Everything. The title of this paper is a play on the approach taken towards his crafting of a GUT - the theory considers elementary particles as the symmetries of the E8 lie group, which is one of several exceptional simple Lie groups and is considered one of the most beautiful structures in the entirety of mathematics - certainly, it would be fitting if such an aesthetically pleasing structure turned out to be intimately related to the very structure of the universe. Through his renegade lifestyle Lisi has developed the notion of a "science hostel", a place where scientists and mathematicians could live closer to nature and remain active in their research passions.

Though I sense that Lisi's vision has a somewhat different scope than that which Pual and I have developed, it was a clear indication that we are not alone in the general direction of our goals and that there are individuals who are able to make significant contributions to the fields of math and science from outside of the academy.

Possible as it may be right now to establish the sort of organization or network which Paul and I have envisioned, it is almost certain that it would take a significant amount of time to do so, further postponing the actual research and studies which I seek. It will also most likely be easier to carry out such an establishment with the clout of a PhD in tow. This means leaving my shire, my band and the community which I have come to love.

Adventure awaits..

Filed under  //   education   mathematics   phsyics   science  

Uploading PDF docs to iPhone without emailing them to yourself

I just upgraded to iOS 4 on my iPhone 3G and was happy to find the iBooks application on my iPhone, less because I thought myself likely to be buying lots of ebooks, but more because I've wanted an easy way to carry around PDF documents on my phone. However, the only way I could figure to upload the files to iBooks was to email them to myself, open up the documents in Mail and then transfer them to iBooks from the Mail app. Clearly, this isn't an ideal solution - I sought to find a better one.

The first thing I tried was to connect my phone to my computer and seeing if I could do something easily through iTunes. Once synced, I clicked the little dropdown for my phone on the iTunes sidebar and then clicked on books

Tendril_on_itunes_sidebar
When I did this I saw a list of the free Whinnie the Pooh Book that came with iBooks and a PDF that I had downloaded from Mail. I went for the obvious tactic of trying to drag some PDF files into this list. It was a no go.

I spent some time on google trying to figure out if there was some easy way to do what I was looking for. I could find just about next to nothing other than to use some other third party PDF viewing program.

Finally, I tried messing around a bit more and found that if instead of going to Books I went to Purchased I could drag PDF files into that list. Once I synced the phone, the PDFs found themselves nicely on my bookshelf.

I'm wondering why the more intuitive process of dragging into the books folder isn't supported. In any case, I'm easily able to do what I want and happy enough with that.

One quick note though to those who want to do the same thing I did - you have to make sure the files have a .pdf extension. I found that they won't load into the Purchased folder if you don't.

Happy iPhone PDFing.

 

Update (07/27/2010)

As pointed out in the comments below, you can also drag into the Library section within your iTunes sidebar. I'm not sure if this is a feature update or if, as the the commenter suggests, this is only possible once you already have uploaded PDFs into your library. Any feedback on this in the comments would be greatly appreciated.

Itunes_sidebar

 

Filed under  //   iPhone  

General Approach - Lessons with J

Is I described in a recent blog post, I have been working with a fourth grader named J and introducing him to a very different mathematical education than most students ever receive. This is the culmination of a great deal of thought into what could be done to make mathematics education more effective and more reflective of what mathematics actually is.

As I currently see it, there are two fundamental aspects of this which stand out. The first is the subject matter itself - I have been exploring everything from combinatorics to group theory to fractals with him, subjects many students never get into until they are in upper division college mathematics courses. The second is in the approach, an aspect which has been evolving, and I imagine will continue to. This approach has of late though been taking influence from Math Circles, which I shall describe further. So far, the results from this have been really stunning, and have been exciting for both me and J.

Let me describe the first meeting we ever had together. J and I sat down at a big table. I asked him if he had any homework. He did - simple multiplication stuff. I picked his brain on a few problems to get a guage for where he was at. He didn't have too much difficulty. I started asking him about the tricks for multiplying by 5, by 9, by 6 and so on. He knew it all already. So I dropped the gauntlet - "Do you want to learn about fractals?" From there we explored one of the simplest fractals to understand - the Koch fractal. We looked at how it is defined and also added up the total length of the shape through the first few iterations of the fractal. This gave some good contextual exercise in adding fractions. But more importantly it was going somewhere conceptually significant - by looking at how the first few lengths grow in size, we see that it would appear that the length continues to grow through the interactions in an unbounded fashion. This illustrates (without rigorous proof) the fact that the actual fractal, the result of iteration ad infinitum, produces a shape which is infinitely long but contained in a finite amount a space, a pretty weird but significant feature of what it is to be a fractal. After going through that process we played around a bit with a computer program that let us navigate through the Mandelbrot set, which he absolutely loved. Through this we were able to exercise some practical skills (adding fractions - we stopped through this to talk about why adding fractions works the way it does thinking about pies), were able to illustrate some pretty weird and fascinating concepts and were able to engage with a really beautiful and stunning fractal through a computer application (we used one that I wrote, but for those of you interested, I would recommend Xaos - free, open source and multi-platform). This is something that is certainly going to stick with him for the rest of his life and ensure that his view of mathematics won't be restricted but will encompass a sense of beauty and wonder and richness.

Another sort of "unit" that developed through our work focused on group theory and combinatorics. We looked at the permutations of sets in relation to translations of squares, triangles, tetrahedrons and other shapes in connection with counting the combinations of such permutations and translation. We looked at how these translations can be non-commutative. Though I don't believe that a student of his age is capable of appreciating the full abstractness of of modern algebra, I do believe that by hinting at some of the content of that subject you open up some very fundamental neural pathways that open the student up to that sort of thinking so that in later years they can grasp that sort of subject more naturally.

The last thing that I will comment on for now that we looked at was some simple geometry stuff. We took a big step back and looked at what numbers are. How they can be used to count as well as how they can be applied towards geometry. We looked at how multiplication being thought of in terms of n sets of m objects relates to the area of an n by m rectangle by breaking up the rectangle into 1 by 1 squares and counting the n groups of m squares. From there (the area of rectangles) we looked at the area of triangles. Here it is less obvious to see how you would think about area. What I did then (in inspiration from the approach taken in Math Circles) was to - in a very natural and explorative fashion - try to get J to figure out how to come up with the area of a triangle all on his own. One of the key techniques which I implemented was to not tell him flat out if he was going in the wrong direction with his thinking about the problem. Instead, I let him follow his intuition and then by asking him question help him to see when an approach wasn't general enough to always work, or even when it just didn't work. This is extremely important I've realized. Those who are successful with upper division mathematics typically have an ability to tool around and explore things. They may not always head in the right direction. They may take wrong turns, but the process of proving something doesn't have a predetermined formula. It requires a sense of fearlessness and exploration. When you tell someone that they are wrong in their approach flat out, it instills a sense that there is a right way and they are not on it. When you let them explore various paths and in a very natural manner through that exploration help them see why one path might not work, it lets students fall in the groove of the creative and explorative process that is such a valuable aspect of mathematics. Doing this, over the course of an hour, J was able to figure out (with my gentle nudges) how to find the area of the triangle by taking the triangle, creating a copy of it, making a rhombus with the two and then making the rhombus into a rectangle by cutting off one triangle from one side of the rombus and gluing it onto the other. You then end up with a rectangle with twice the area of the triangle, one side of which is the triangle's height, the other being the triangle's base width. You find the rectangle's area using those measurements and then divide by two. AND HE DID THIS MOSTLY BY HIMSELF!!!!!

I was so excited by this last lesson I could have peed myself! We haven't had much time together since this lesson (I was in New Mexico with my family for the holidays) - just one this last week in which we reviewed the ideas that we had already explored and started venturing a little bit into other regular polygons. He got the idea pretty quickly to break them up into triangles radiating out from the center of the polygon (bright kid). He got really interested right away with the way that you could take a compass, make a circle, then make a circle center on some spot on the circumference of the circle, then make another circle centering itself on the intersection of those two circles, and so on. What intrigued him was that in going around the original circle doing this you end up back at the very first circle. This is actually a sacred geometry shape called the seed of life. We talked about that for a while and started looking at why there end up being six circles circling the perimeter when doing this. We didn't quite finish exploring this, and will probably pick up from there the next time.

There are lots of conclusions to be drawn from all of this work. Not all of them are easily capitulizable. Really, this has been a great playground for me to experiment with different ways of opening up this kid's mind to all sorts of great mathematics. We have been able to approach mathematics in a creative, explorative manner, have seen some beautiful and intriguing things, have broadened his view of mathematics and have been able to work on practical skills in the context of pursuing interesting aspects of mathematics. For me this has really nailed home that in a one on one basis, it IS possible to broaden the typically narrow confines of early mathematics education. There is still much to do here, and there is still lots of time to see how J develops as a student. I can only hope that he ends up studying mathematics or a related subject so that the effect of my work with him can be more deeply evaluated - obviously though, I respect this kid's intelligence and natural drive and want to see him engage in that which most engages him. I hope that others can engage in these kinds of teaching/tutoring techniques so that a bit broader base of experience can be explored with this sort of approach.

The question of how possible it is to implement this sort of flexibility in the classroom is a good one. There are a lot of inhibiting factors. For one thing, part of what makes the magic happen in these cases is the one on one time we are able to have with each other. Another important factor is the fact that I am a very experienced mathematics tutor/teacher but also have a really strong understanding of the broader picture of what mathematics is and what its foundations are. This is not typically the case with your average early education mathematics teacher. Could more money for mathematics education provide funding for strong mathematicians/teachers to come into early education classrooms once or twice a month and explore fascinating subjects with students in a larger class setting to good effect? Would any attempt to this end be plagued with the inflexibilities of trying to implement such activities on a broad scale? Could giving more flexibility to teachers for doing this sort of thing coupled with reducing the importance we place on "teaching to the test" allow for teachers to implement their own ideas in cooperation with mathematician consultants who would come by, do fun lessons with the whole class and then give the teacher perspective on ways to continue pushing the limits of the subjects? Could having more in class session where students help each other (pairing of strong students who get the ideas with weaker one's who need more one on one attention) help issues associated with modern education teaching too much to the lowest common denominator and not allowing students who are capable to soar do just that? Could encouraging parents to get involved with their kids by solving puzzles and playing games and doing fun math related activities help provide the sort of individual attention that kids need to develop the critical and conceptual thinking skills that are so valuable in mathematics and other areas of study and life (thank you Stanislav for your post on this)?

There are a lot of questions here, and the only way to answer them is to try things out and do research. I hope that my experiences will inspire others to do so. My personal motive here is my love for mathematics and my disappointment that many people are afraid of or feel negatively toward math without really even having an understanding of what mathematics is and what it can be. Mathematics is definitely hard and not for everyone, but I think that we can do a better job of teaching students about what mathematics really is and make that teaching more productive along the way. If students understand what mathematics is, they can at least make an informed decision about whether or not it is worth it for them to get into it (or related subjects) academically.

Filed under  //   education   mathematics  

Validating model instances from related model views in rails

Have you ever had a rails project where you have a form for instances of one model being presented in the view for some other model? For example, you might have a project management application where you have projects whcih have many tasks. When on the project page, it would be natural to want to see the tasks associated with that project, and also to be able to create a new task that belongs to that project right from that same page and have it redirect to that page when the task is successfully created. The trick is that it makes sense to also want to redirect to that same page when the task fails in validation. The question is, how do you implement this so that the validation errors display on that same page?

This is the problem that I just recently encountered, and at first I thought that it would be no problem, but I just couldn't figure out how to get the errors to show up. After a bit of tooling around, I figured out a solution.

The crux of the problem is that if you redirect to the project show action from within the task's create action, you loose access to the same new_task instance that you were working with, and so with the errors associated with it. The solution I cam up with is to store the working instance of the task model in the session hash if there is an error, and erase it from the hash as soon as the creation action is called successfully. Then just access the working instance from the sessions hash within the view in order to display the error messages.

The controller code then implements as follows -

Then in the show.html.whatever view use error_messages_for("new_task") to display the task errors.

I hope that this will help someone who is in a similar situation as I am. If there is a better way to do this though, please let me know in the comments. Also, if anything here is unclear, please ask for clearification.

Filed under  //   forms   rails   ruby  

Cucumber and Rubular - a match made in heaven...

I have resisted writing tests in all but really hairy cases now for quite some time, much less approaching my projects from a TDD or BDD perspective. It's not that I haven't wanted to. I've understood the value of it, but have been turned off from having to take the extra effort to first pick a testing framework (or frameworks) and then to get comfortable using them. Inevitably, I would get anxious and want to dive right in to coding and say to hell with it. Often though, later in development I would encounter a bug, complexity level or tricky problem and wish that I had just spent the extra time figuring it all out. I am now happy to say that I have had enough and am finally taking the time to orient myself to these development paradigms.

The first thing I had to do was sort through all of the framework options. After much thought and reading, I eventually decided to use Rspec to spec out models and helpers and Cucumber to spec out the behaviour of the whole stack. I realized that the advantage from a business standpoint of specifying behaviour in Cucumber features was well worth giving it a try. Since Cucumber uses Rspec by default, it made sense to also use that for specing out the finer graned behaviour of my models and helpers.

Once I had decided on a set of tools, it was time to dig in and start getting comfortable with them. The first thing that I realized is that Cucumber was bound to put my regular expression skills to the test. Sure I've had to use regular expressions before, but never intensively enough to get to the point where I could just dig in and start writing them without having to go and find a reference sheet first. My saving grace in this has been the discovery of rubular, an amazing online tool which allows you to test regular expressions as you type. It even has a nifty little reference card right beneath the tester. So cool!

Now that I have been digging in for a while, I can say that I am very happy that I have. I'm finding that on the two or three projects which I have just started, I'm already really appreciating what BDD is doing for my clearity of thinking and planning of the project. This has been especially true of Cucumber. The plain english specifications make it so easy to just start writing out behaviour without having to think about code. I'm also definitely digging the bonus of beefing up my regexp chops.

For anyone interested in getting into Cucumber, consider checking out Ryan Bate's intro screencast. Very good stuff.

Broadening the Scope of Early Mathematics Education

This is a subject that I have thought much on. One of the things that I get time and time again from people who I talk to about math is that there is a real misunderstanding of what math really is and how beautiful it can be. The picture most have (I sense) is one of a closed book of algorithms, rules and procedures for doing things with numbers and sometimes shapes. When I share with people the vision that I have of mathematics, the creative side, the beautiful side and the limitlessness of it, it usually comes as news. Why is this? Because mathematics I fear is all too often taught as though such is the case.

The question then stands, why is mathematics taught this way? This is not an easy question to answer as there are many facets to the situation. We have teachers throwing out creativity so that thay can focus on teaching to the test. We have teachers who don't really have a big picture understanding of mathematics themselves and are largely faking their way through text books. We also have pressure from society to produce machines for the economic engines, not explorers of uncharted realms. There are certainly other factors, but lets leave it there for now. What I want to talk about is how and what we could be teaching children.

For a while now I have spouted about how I think that doing this or that could help the situation and give kids a better more wholistic view of mathematics. But this has till now consisted of lots of speculation. I have never had opportunity to test my ideas and explore the possibilities with real people. Till now.

A couple of months ago, I was talking to a friend about mathematics and he asked me if I would work with his son, J. J, he told me, is a very bright kid who did well in mathematics but was not being engaged with the standard coursework. He wanted to see if I could help keep him actively learning mathematics at his own level and go beyond what was happening in his fourth grade class.

Now let me explain something. I love mathematics. If you get me started, I could talk all day about it. Heck, I could talk for days straight about it. I've learned to sense when people have had enough, but I can almost always go on. Now I also love tutoring and have done tons of it, but you generally have stay within the dotted lines of the subject that is at hand. There is less freedom to roam around. So imagine my excitement at being able to step outside of those lines and really get to explore what math is with someone, and in doing so also test my theories and hypothesis about what is possible in mathematics education. Astounding!

Since this time J and I have had many sessions together and I have really started to get a sense of what is and is not possible with a student his age. I've also been looking into other teaching styles and methodologies for inspiration and guidance. This has given me a lot to think about and a lot to share. Over several of the next blog posts here I want to share more about the work that J ad I have been doing together and how my thoughts on this subject have evolved. If you are interested, I hope you will tune in.

Filed under  //   education   mathematics  

Polymorphic models in Rails 1.9 - a tale of belonging

A while back I created a rails app that used the attribute fu plugin to do nested forms. This was very groovy stuff and I was happy to come across the plugin, but there were some issues - I needed the nesting to work for the belongs_to side of a polymorphic relationship. This turned out to be not possible - or at least very difficult - using the plugin. As it turned out, I was able to create a stage 1 version that met all of the needs without using this, but it was clear that to take the app to it's full potential I would need this functionality. The time has now come for me to see if I can't figure the problem out.

Suppose that we have the following quirky model structure -

The basic idea here is that we wan to make these cakes that have manny different kinds of layers, and for whatever kooky reason, our technology crazed bakers want to bake each layer seperately and slap them together. But, they also want to be able record very specific baking settings depending on what kind of layer they are dealing with - phyllo dough settings are clearly going to be different from ice cream layers, chocolate cake layers and so on. And, they want to enter all of the information for a given cake in one form. This somewhat silly example models the situation quite well.

At the time that I had been working on this before, I was running Rails 2.2. I decided to upgrade to Rails 2.3.3 in order to gain access to the built in nested model functionality. I figured that even if it didn't work any better, it would probably be better to hack something up with it than with a plugin which was looking not too supported in light of the new built in functionality. Unfortunately, the transition was not as smooth as it could have been.

For one thing, there was a comments model also being used which was in a polymorphic threesome with both layers and cakes - "My, this was a fantastic layer!" or "Boy, what a splendid cake!". With attribute-fu, this worked great, pretty much right out of the package since it was nesting through the has_many side of the relationship. As it turned out, this didn't work so well for the new built in functionality. So I went about figuring out what was going on.

Hmm, it doesn't know that it has those attributes. I also checked out what happens with the creation_setting, just for shits and giggles.

Hmm, another problem entirely. Well, I looked into this one first, since I figure if all else failed I could get the comments back up and running with attribute-fu (not the ideal way to do it obviously, but as far as priorities go, that was that). What I ended up finding (about all I ended up finding) was this post by Travis Dunn. He had a very simple solution - create the missing method by scratch. Cake, huh? So I added this method definition to my Layers model.

Great! Should work right? Nope, I end up getting another UnknownAttributeError. At this point I start wondering why this appeared to work so well for Travis and not for me. I do a little more digging and find this ticket wherein Mike down below describes a similar workaround that seems to work just fine for him. So, it would seem as though something is a little quirky for me, but I figured that I would try essentially the same idea on the attributes as for the build methods - make it myself! So I added the following to my Layers model

and lo and behold, it works!

So, the models are working now, but I'm getting the feeling that I really shouldn't have had to do the attribute fussing. If anyone is able to confirm that either they did or did not have these problems with the UnknownAttributeError (or ideas on why I might be getting em), please post a comment - I would really like to know.  For now, I'm going to focus on getting the views and controllers working. The biggest challenge here (I think) will be getting the fancy javascript stuff to insert the right template depending on which kind of cake layer is needed. If I find anything interesting I'll post it.

I hope that this will help someone down the road : )

Filed under  //   complex forms   programming   rails   ruby