The user settings are a powerful tool for overriding some of Sublime’s default settings with ones that make it easier for you to work.
When we’re on boarding new programmers we always institute a code review process where at least one programmer experienced with the project reviews the work of the new programmer. We use GitHub’s Pull Request feature to help us do this. Most of the changes are easy for us to review and then approve or tell the programmer they need to make changes. Every so often we run into a file where GitHub lets us down (really I don’t know what else they would do here :-)):
The issue was that this particular file had it’s line endings changes on the master branch but not the pull request branch it was messing up the whole system. To try and make sense of all the changes we had to resort to using the command line:
git diff "pr/#" master -w -- file\path\here > temp.txt
This command is calculating the differences in the file (“file\path\here”) between the pull request branch (“pr/#”) and the master branch but it’s ignore all whitespace when comparing the two (“-w”).
This produced a much shorter (20 lines) list of changes which we then had to manually merge in but at least the programmer didn’t loose all their work.
This Programming Thing is a labor of love but it costs money to host the site. If you would like to help us offset some of our costs and you need a virtual server from DigitalOcean please use the link below.
I know what you’re thinking. How can right clicking make me more efficient in Sublime Text.
As knowledge workers, there’s a huge benefit to us knowing how to do things are quickly as possible in our environments of choice. It doesn’t mater if that’s an IDE or Excel every second saved can really add up.
I use Sublime Text every day at work and some days when I’m not working (today I’m off work but I’m working on this post using Sublime Text) so I thought it would be a good place to start. The goal is to release short posts every week so instead of having to digest a HUGE article with tips you can learn a few and them apply those to your daily work. Some of my examples will be geared towards PHP developers specifically but I think most will be applicable to anyone using Sublime Text.
If you feel like I’ve forgotten something or want something added please feel free to leave a comment on this page and we’ll add it.
My noteable links for July.
We recently hired in a new Junior Developer and it’s been interesting to see how well they understand the basic PHP functions but get a little lost when they use some of our more advanced OOP classes. If feels like forever ago I went off on a rant about how we teach programming in what feel like a backwards way to the way I work every day:
When I learned to program in an academic setting (over a decade ago), we learned the basics of programming first (if block, for loop, functions, etc.) and then object oriented programming. This makes sense because it allows you to quickly write programs that do something but I think it teaches you the “wrong” way to structure your code. I think because of this some of the programmers I’ve worked with have been really good at writing code that can be used in one place (and can be copied and pasted into others :-)) but haven’t always been good at writing code that can be unit tested and reused without duplication.
It’s caused me to think about learning PHP using TDD and what that would look like.
Return to Coding 101
When I learned how to program using C++ all those years ago I was given an example like the following (my guess is that this won’t compile so don’t even try it):
If I recall correctly, the author of the book I was learning from then went into detail about what each line did but the amazing thing was that I was able to type this into an editor and it would compile. That’s all it took to get a program up and running.
After this we started learning about variables, control statements, and functions. It was only later that we learned about classes, inheritance, and polymorphism.
Only now I realize we learned about the very basic statements, then functions and how they’re composed of multiple statements, and finally classes which are composed of multiple functions. Small pieces build up to larger pieces. From a learning stand point this makes sense. It’s easier to get going quickly and maximize the “wow” of programming so we didn’t lose interest.
For a long time I really didn’t “get” how classes could make my life easier.
Inverting the Learning
So let’s look at what would be involved in learning PHP if we taught everything TDD first. We would have to invert the learning process of statements > functions > classes to classes > functions > statements. Practically, it would flatten our learning process from learn statements, then functions, then classes to just learn all three in one go.
Programming languages like C# force this concept on us because everything must be a class so I wonder if this is even a problem.
Comparing Hello Worlds
I think the most interesting part of any programming language is the “Hello World!” example. The basic PHP version is simple:
Hard to get simpler than that.
Now let’s look at a classed version:
This is the simplist version of this I could create. If we were doing it the best practice way we would move the class into it’s own file, use an autoloader, setup DocBlocks, and the biggest problem with this is that it’s not easily testable.
Let’s think about this some more. We could use the code above as our learning application and build on it. By doing so we can teach best practices:
- Install composer and use it’s autoloader
- Break the entry point and the class into separate files
- Rewrite the hello world example to use unit tests
It makes our hello world example MUCH longer and harder to understand but I almost wonder if it’s worth it.
When I work on my site I start jekyll using the following command line:
I like this because it shows me what I’m working on and regenerates the files as things are updated:
The downside to this is that if I’m quickly switching between proof reading a post and editing a post it gets a little slow waiting 5+ seconds for the page to regenerate (you should try it). I started looking into the documentation for
jekyll serveand there’s an option that allows you to limit how many posts it uses:
This cuts down the time required to see my changes:
That 4 seconds makes a huge difference.
I’m writing this post for two reasons:
- So others can learn from my mistakes
- So I have this documented somewhere other than my laptop
This post is almost completely a copy and paste job of the notes I created while I was building my last project using Symfony 2.7.
subscribe via RSS