You are viewing a read-only archive of the Blogs.Harvard network. Learn more.

SVN vs Git

SVN is a minor improvement on the CVS design. A linear, central repository. To their credit, the developers of SVN acknowledge this, from the Red Book:

Subversion was designed to be a successor to CVS, and its originators set out to win the hearts of CVS users in two ways—by creating an open source system with a design (and “look and feel”) similar to CVS, and by attempting to avoid most of CVS’s noticeable flaws. While the result wasn’t—and isn’t—the next great evolution in version control design, Subversion is very powerful, very usable, and very flexible.

Git is a Distributed Version Control System (DVCS). It’s important to distinguish it as “decentralized”. What that means is that each user creates a literal “fork” of the project.

What Git offers that’s important is lightweight branching and significantly better merging. These are what make advanced workflows (feature branches) possible. See Git Flow.

Branching by itself isn’t where the magic is. What makes Git bounds above SVN is actually the merging. What makes the merging so much better is actually how the history of commits is kept. Git is a Directed Acyclic Graph (DAG) and SVN is done linearly.

What this means is the SVN merge doesn’t take into account previous merges of the branch, it merges the files directly. They’re both doing 3-way merges, but the 3rd that is used (the common ancestor) isn’t the same because the linear history of SVN isn’t taking into account previous merges. So basically SVN goes back way further because it doesn’t know where the last merge between branches was. The result is a lot more conflicts that have to be manually resolved.

The above is outdated. As of SVN version 1.5, (2008), SVN includes meta data on merge histories, so it uses the 3-way merge to similar effect as Git now. I’m going to have to write a new one of these after more research.

https://git.wiki.kernel.org/index.php/GitSvnComparsion
http://stackoverflow.com/questions/871/why-is-git-better-than-subversion/873#873
http://blog.evanweaver.com/2007/08/15/svn-branching-best-practices-in-practice/
http://stackoverflow.com/questions/2471606/how-and-or-why-is-merging-in-git-better-than-in-svn

Posted in Git, SVN, Uncategorized, Version Control. Tags: , , . Comments Off on SVN vs Git »

Version Control and Sensitive Data

Don’t put passwords in your repositories.

 

https://help.github.com/articles/remove-sensitive-data

Posted in Uncategorized. Tags: , , . Comments Off on Version Control and Sensitive Data »

Web Accessibility Under the Law for Harvard

What is required? Harvard is required to adhere to Section 508 of the Rehabilitation Act of 1973 (The most important Section of which is 504, but that doesn’t directly apply to web development).

The best way to understand the requirements of Section 508 is to read through the text of it. Specifically 1194.22 and by proxy, 1194.21. It should only take a few minutes. It’s not as bad to read through as the W3C’s Web Content Accessibility Guidelines (WCAG). And, more importantly it’s not as comprehensive.

Once you get the highlights, WebAIM has provided a handy checklist. WebAIM is an open consortium that exists just for discussions such as this, similar to what OWASP is for Security. From the spec, (a) through (j) are reasonably straightforward. (k) needs to be understood, as “text only versions” seems to be a common accessibility misconception and isn’t necessary if all of the other items are taken care of.

(l) is a biggie because it requires a different approach to javascript than 99% of js writers do. What it means is to make all interfaces possible to navigate without a mouse, in a way that’s readable to screen readers. That just means following the spirit of (a) through (j) as it pertains to your interface. This seems borderline impossible when you look at things you’ve built and try to add it in after the fact, but is much more reasonable when you design it from the start with this in mind.

Which seems to be a recurring theme when it comes to best practices. These things need to be thought about from the start, not thrown in last minute. So I think the solution for this is to spread information around. Not try to force this into existing projects, but bring them up as new projects / rewrites begin. It’s a lot to think about, I think the trick is to introduce the topics slowly but consistently into our culture until it becomes something we all know and just do without having to be told.

Is Harvard Required by Law to Comply to Accessibility Standards?

Simple answer: Yes.

I have been looking all over for an answer to this. Is there actually a law that defines what we (Harvard University) need to follow in terms of web accessibility? If you search for accessibility law (in the US), you’re basically only going to find references to Section 504 and Section 508.

These are “sections” of the Rehabilitation Act of 1973. So all sections (amendments) are equally applicable.

From the Office of Civil Rights (OCR) Brochure:

The Office for Civil Rights in the U.S. Department of Education enforces regulations implementing Section 504 with respect to programs and activities that receive funding from the Department. The Section 504 regulation applies to all recipients of this funding, including colleges, universities, and postsecondary vocational education and adult education programs. Failure by these higher education schools to provide auxiliary aids to students with disabilities that results in a denial of a program benefit is discriminatory and prohibited by Section 504.

This brochure is linked from the Accessible Education Office’s page on student’s rights.

What this means as far as what is required is a bigger question, and not one I want to write up right now.

Posted in Uncategorized. Tags: , , , . Comments Off on Is Harvard Required by Law to Comply to Accessibility Standards? »

Online Learning About Learning Online

As I continue to tentatively wade back into development waters, I’ve started taking advantage of the many online learning opportunities that are out there. The reasoning is two-fold: (1) The obvious reason is that I want to learn (or, as the case may be, re-learn) some new languages and frameworks, and (2) as someone who works as an educational technologist, I ought to be current on these online opportunities, anyways.

In particular, I’ve been refreshing myself on JavaScript, teaching myself Python, becoming more familiar with Joomla!, and I’m also interested in getting some game development underway with HTML5. For my refresher on JavaScript and my dive into Python, I’ve been using Codeacademy; for Joomla, I’ve been taking advantage of lynda.com; and for game development in HTML5, I attempted participating in a Udacity MOOC. I’ve summarized my (ongoing) experiences below:

Codeacademy

This is a fantastic (and free!) resource for both beginner and advanced programmers, though advanced programmers may find the hand-holding approach a tad slow. Clearly aimed at introducing the newbie into the world of programming, each course re-introduces the fundamentals (syntax, variable assignment, conditionals and control flow, functions, objects, etc.). Each course is divided into sections, and each section into a series of lessons. Lessons build upon themselves, as do sections, and most importantly, several sections are reserved for implementing a simple application based on the concepts learned (I especially enjoyed “Pyglatin:” implementing a pig latin generator in Python).

The interface consists of panel on the left that introduces a particular concept, and then instructs the user to write some code based on the concept. Therein lies the genius of Codeacademy–unlike a book, you are not only forced to read about a subject, you are forced to actually sit down and implement it before moving on. And so far, I’ve discovered their console works amazingly well at detecting errors, giving hints if things don’t go well, and just generally getting things right.

In essence, Codeacademy was designed to teach code and coding practices–nothing else. It does so with simplicity–no fancy videos or multimedia, just well-written text and a console–which is what coding should be all about. Currently it offers courses in JavaScript, Python, HTML/CSS, PHP, Ruby, and APIs. It also offers Codeacademy labs where you can experiment with some of the new languages that you have learned.

Lynda.com

The amount of subject matter on lynda.com is staggering. From project management to 3D modeling, lynda.com offers courses on just about any popular technical concept out there. I typed in “Joomla” and received no less than 13 tutorials (granted, only three pertained to the most recent version of the system). I’m about a quarter way through “Joomla! 3 Essentials” and thus far, my experience has been a positive one.

The course on Joomla! 3 takes what I consider to be the “traditional” approach to online learning: Divide a course into a series of sections, divide each section into a series of lessons, with each lesson consisting of a video and downloadable content to perform the described exercises. Like Codeacademy, lynda.com understands that for most users, learning is the equivalent of doing. This particular course hand-holds the user through downloading and installing Joomla on one’s laptop, then stepping through a series of exercises based on downloadable material. The course sometimes encourages “homework” in between its lessons–that is, if you don’t complete the exercises after a lesson has finished, the next lesson will be tougher, if not impossible, to follow.

The videos for this particular course are professional and well-paced, though, again, for advanced users, the hand-holding might be a tad slow. Nevertheless, with just a quarter of the course behind me, I feel confident enough to go into any Joomla! environment and be able to decipher the basic structure of the site.

Perhaps the only downside to lynda.com is that it’s not free. Although you can get buy with paying $25/month, you really need to download the exercise files to fully experience a course, which ups the price to about $40/month. I’m fortunate that my institution offers lynda.com as a perk; if your institution doesn’t, I strongly encourage you to encourage them to invest in it.

Udacity

I won’t dwell too much on my first experience with MOOCs; suffice to say, I wasn’t impressed. I eagerly signed up for “HTML5 Game Development” when it started being offered, but gave up after the first lesson or two.

Like most MOOCs that I have seen, the course was divided up into a series of lessons, each lesson a series of videos, with each video followed by a “quiz” that could be automatically graded. This is where everything fell apart. The quizzes expected code to be inputted (in this case, Ajax code), and this code would then be “graded” as either correct or incorrect. The problem is that the Udacity grading engine (or whatever they were using behind the scenes) wasn’t able to grasp the concept that with coding, “there is more than one way to do it”.  Although a user could enter code that gave the correct result, the engine seemed to require that the code follow an exact syntax. And in following the discussion forums of each quiz (and some of the apologetic emails I received from instructors), it was clear I wasn’t the only one having difficulties. As I said, I gave up after a bit. Perhaps I’ll return some day.

Maybe I chose the wrong course, or maybe I was wrong in choosing Udacity; regardless, the experience seemed less professional and less reliable than either Codeacadmy or lynda.com. Maybe it’s because MOOCs are in their infancy. . . or perhaps it’s because they’re being run by academics rather than solid business professionals. Regardless, if the experience I had is any indication of how MOOCs are, in general, being run, I don’t see them as viable competitors to other online learning platforms.

 

 

Posted in Development, Javascript, MOOCs, Online Learning, Python. Tags: , , , , , , . Comments Off on Online Learning About Learning Online »

Documenting Documentation

I recently waded back into simple web application development (more on how that feels later), and one of the many aspects of coding that I’ve been refreshing myself on is how to best document what I’ve written so my future self doesn’t get too confused over what I implemented or why I implemented it in the way I did. The application is deadly simple, so simple that I hesitate to call it an application. The web page contacts a PHP script via an Ajax call, and the PHP script does its thing, sending back a JSON-encoded object. The client subsequently uses the object to display a message of success or failure.

As I said, deadly simple.

Nevertheless, as simple as the application is, I’ve been researching how best to document PHP and JavaScript. For PHP, the definitive answer appears to be phpDocumentor 2. For JavaScript, there is JSDoc. Here are some additional links that I found useful:

phpDocumentor

JSDOC

Note that I haven’t actually tried generating documentation with either toolset; that’s a completely different challenge. I’ve mostly been following the format so that my documentation can be printed/generated if somebody (aka me!) wishes. And what I’ve come to understand is that learning how to document a language feels almost as complicated as learning the language itself.

 

Posted in Development, Javascript, PHP, Uncategorized. Tags: , , , . Comments Off on Documenting Documentation »

Javascript Callback Scope

I ran into an annoying issue with js callback scope recently and wanted to document it for myself somewhere. Callbacks are super simple at the core — passing a function as a parameter to another function.

callbackFn =  function(){
  alert("bam");
}
firstFn = function(callback){
  callback();
}
firstFn(callbackFn);

That’s all well and good so long as everything is in the global scope. But that’s just bad practice.

So in OO js, you’d have something like this:

Obj = {
  callbackFn: function(){
    alert("bam");
  },
  firstFn: function(callback){
    callback();
  },
  secondFn: function(){
    this.firstFn(this.callbackFn);
  }
}
Obj.secondFn();

This will actually be executing callbackFn in the global scope. The ‘this’ just gets lost. Note that you may only notice this if you’re expecting the this of callbackFn to find what’s in your obj (the above sample will probably work just fine).

Obj = {
  myalert: function(){
    alert("bam!");
  },
  callbackFn: function(){
    this.myalert();
  },
  firstFn: function(callback){
    callback();
  },
  secondFn: function(){
    this.firstFn(this.callbackFn);
  }
}
Obj.secondFn();

There, that one will fail.

The solution is to use the apply() function.
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Function/apply

Obj = {
  myalert: function(){
    alert("bam!");
  },
  callbackFn: function(){
    this.myalert();
  },
  firstFn: function(callback, callbackObj){
    callback.apply(callbackObj);
  },
  secondFn: function(){
    this.firstFn(this.callbackFn, this);
  }
}
Obj.secondFn();

And that will work as intended.

Django Formsets, the worst thing ever?

This kind of thing really attracted me to django, but then the usability of it goes entirely out the window when you take a closer look.

Formsets are basically a container for an arbitrary collection of forms. A form is a abstraction layer for UI, but I’ve seen they (or rather ModelForms) can be somewhat helpful as a funnel for POST vars and validation of the model. Maybe my issue is that the use I’ve found for them is not the primary concern people have.

from https://docs.djangoproject.com/en/dev/topics/forms/formsets/

>>> ArticleFormSet = formset_factory(ArticleForm, formset=BaseArticleFormSet)
>>> data = {
...     'form-TOTAL_FORMS': u'2',
...     'form-INITIAL_FORMS': u'0',
...     'form-MAX_NUM_FORMS': u'',
...     'form-0-title': u'Test',
...     'form-0-pub_date': u'1904-06-16',
...     'form-1-title': u'Test',
...     'form-1-pub_date': u'1912-06-23',
... }
>>> formset = ArticleFormSet(data)
>>> formset.is_valid()

See, how you would expect something like this to work is it would take in a list, or at least a dict with a list. But no, they have you cat “form-n-” to the field name. This is just so sloppy I have to point it out.

They spent so much time figuring out how to take away customizability from the front end, they weren’t paying attention to the backend.

Django nonrel (noSQL) (app engine)

I’ve been working with this for the last couple weeks. I have been doing this for a couple reasons.
1) I wanted to play with noSQL
2) I’m developing and deploying with the google app engine — the app engine does have a mySQL option (Cloud SQL), but they have no free version of this — so to do a GAE app (entirely (including data) in GAE), you have to use the google data store or pay for SQL.

Now doing the design in a key-value noSQL wasn’t too bad. I just had a design that had each object containing the ids of the other objects that were associated with it both ways. This was somewhat redundant she thinking about it in a relational way, but it made queries simple and fast. The overhead is making sure the software keeps the ids updated in all related objects I.e. if something is deleted.

That wasn’t so bad. It was a fun to design things differently than I’m used to. Then I fleshed out the models in django.

The issue I ran into was django-nonrel. This is the project that converts django to be able to deal with non relational DBs. This changes core django abstraction models and consists of apps that can be installed locally or globally. So I installed them locally because I don’t like the idea of altering the framework globally.

It did not work with the latest version of django.

So I read through the docs a little more carefully to discover the core team quit this project over a year ago. Because noSQL wasn’t right for their projects and Cloud SQL was now available for app engine. The guy who took it over isn’t keeping it up to date with django. He’s about a year behind. It’s working with django 1.3. Current version right now is 1.5.1. That is enough to throw errors.

If django is making changes in point releases that cause the django-nonrel to become out of date, either django isn’t doing a good job at maintaining backwards compatability or (much more likely) django-nonrel project isn’t doing a good job keeping away from hacky implementations that rely on very specific django references.

I don’t have the time to debug django-nonrel. It’s like 4 apps that go in your django project.

Additionally I worked out what the cost of Cloud SQL would be for development and I can deal with less than $2 a month. When it goes production I can worry about dealing with my teams extremely poor mysql management or get my group to pay for a more substantial Cloud SQL instance.

Posted in ATG, Flashcards. Tags: , , , , , , , . Comments Off on Django nonrel (noSQL) (app engine) »

noSQL vs Relational DB

There are a billion articles on this, but having read half of them, I’d like to vomit what I’ve taken away as important from them.

Relational databases are integral to any software developer. We’ve been working with them since day 1 of our career. Now comes mongoDB and the appengine Datastore, and there is a ton of hype behind it. But what are the actual benefits?

The big thing you lose with noSQL is joins. If you’re not doing joins noSQL will probably outperform a relational db. So if you don’t need reporting, if there’s no complexity needed for the data, noSQL is actually a fine solution. That’s not to say you can’t do joins. They’re just different and much slower to perform. So you end up with a bunch of data redundancy, which makes changes to that redundant data much more difficult, but eh, if that data barely ever changes, it ain’t no thang.

Another thing you lose that are the constraints on data, foreign keys, data type constraints. All of that has to be handled in the application layer. Which it should be anyway, but having a second line of defense for validation is nice. We all tend to think in terms of objects. Set objects with clear constraints, so having things set from the get go is understandable. The gain of data amorphism, I haven’t really been able to imagine a real world situation where that’s an actual plus.. which could be due to lack of imagination because that’s what I’ve done forever.

The big thing you gain with noSQL is ‘elastic scaling’. When a relational db starts to get huge, the db gets bigger. The single server that’s running the db has to be bigger and badder, and all replication has to be just as big. With noSQL, you can break up the data between servers. This is especially useful in the cloud, and when trying to cut costs in general. 5 small-medium servers can be dirt cheap compared to 1 huge server.