Even in an object-oriented language such as Ruby, there are many ways to write code. Some code styles are more in the spirit of OO than others. In this talk, veteran Ruby developer Jim Gay describes his theory of OO programming, in which we issue commands, rather than querying objects about their state. This leads, Gay says, to code that is easier to understand, debug, and maintain. If you’re looking for ways to make your Ruby (or other OO) code clearer and more obviously intentioned, this code will likely give you some insights.
Functional programming is a well-known programming technique in which we treat functions as first-class objects, and all (or many) objects as immutable. In this talk, Jessica Kerr shows how even when we’re working in an object-oriented language, functional programming techniques can help to make our code tighter, more elegant, and easier to understand — as well as more reliable.
Python is an object-oriented language, meaning that nearly everything in the language is an object. You can (and are encouraged to) create your own classes. But what are the best ways to create classes? And what tools does Python provide for us to create classes as easily and well as possible? In this talk, Raymond Hettinger shows us how to create Python classes, starting with the basics and working up to testing and user feedback. Even if you have written many Python classes before, you’re likely to learn something from this talk.
If you are working with objects in Python, and you want to create attributes that behave in new and unusual ways, then you might well want to use “descriptors.” In this talk, Simeon Franklin describes what descriptors are, how they work, and how you might want to use them in your own programs.
Would you describe your code as “confident” or “timid”? That’s not a question I had really ever considered before watching this talk by Avdi Grimm, which shows how we can write code which doesn’t have to second-guess itself or its inputs. The code becomes easier to read and more maintainable. The examples all use Ruby, but can apply to many different languages, and particularly dynamic object-oriented languages.
Python is famous for making it easy to get into programming: The syntax is simple, the constructs readable, and the data structures rich. Python also makes it easy to create new classes and work with objects.
In some ways, though, Python makes it too easy to create and work with objects. Python, unlike some other programming languages, doesn’t require that you use classes, but makes that possible. This means that developers wills sometimes create new classes when it is unnecessary — when functions and Python’s built-in data structures more than suffice.
In this talk, Python core committer Jack Diederich describes and demonstrates many cases in which Python developers went overboard, creating and using classes when there was no good reason to do so. Using classes made the resulting code slower and more complex than as otherwise necessary.
We all talk about “object-oriented programming,” but what do we mean by that? In this talk, veteran developer Josh Susser describes what an object is, and what object-oriented development means.
Rubyists need to know about the method cache, because it determines the speed of the rest of the system. In this talk, Sheena McCoy and Rachel Myers describe how Ruby caches methods, and thus makes our method calls faster than would otherwise be the case.
How should you write tests? What should you test? Sandi Metz presents ideas for how you should think about testing.