Recently, I have been working on moving some processes from the request-response web cycle to a MongoMapper-backed Delayed::Job. Everything seem to go smoothly, but it seemed that there was some slowness actually queuing the jobs. Here is how I got to the bottom of it.
During the interview, she mentioned some rules that she had come up with to give when asked about design guidelines. She was clear that the rules could be broken, but once you understand why the rules are there in the first place.
Without further ado:
- Your class can be no longer than 100 lines of code
- Your methods can be no longer than 5 lines of code
- You can pass no more than 4 parameters, and you can’t just make it one big hash
- Your controller can only instantiate 1 object to do what needs to be done
- Your view can only know about 1 instance variable
Do you want to have a shortcut that takes you from a method call to it’s definition, wherever that may be in your code? How about another shortcut to jump back to your previous position. Here is how to do it in Sublime Text 2
In the UNIX paradigm, everything is a file system. So, it makes sense that there is a utility to work with open files.
A common use case is to try to eject a mounted drive or clear the trash and get a warning about a locked file. What process has this file or folder open?
1 2 3
Since everything is a file, it works just as well with ports:
1 2 3
Or you can check the files for a specific program:
1 2 3 4 5 6 7 8 9 10 11
lsof supports many, many options, read the man pages for more information.
If you call yourself a ruby programmer, you should read this book.
Sandi Metz has done a great job explaining how to write maintainable applications, in a way that is accessible to programmers at any skill level. Her book is concise (less than 250 pages, including the index), but jam-packed with great nuggets of practical advice and coding techniques that you can start applying immediately in your projects. Her style is easy to read, with many code examples that show you the evolution of code, as an application changes and is refactored.
Among the techniques discussed:
- Use dependency injection to avoid coupling between objects. (Makes them easier to test too)
- To write great APIs, focus on the messages being sent between objects. (She shows why you would actually want to use a UML diagram)
- By creating role tests and applying them to test doubles, you can avoid the ‘leaving the dream’ problem, where stubs in tests obscure the fact that objects interfaces have changed.