サクサク読めて、アプリ限定の機能も多数!
トップへ戻る
買ってよかったもの
blog.jayfields.com
Every developer, at some point in their career, will find themselves looking for some information on a Linux* box. I don't claim to be an expert, in fact, I claim to be very under-skilled when it comes to linux command line mastery. However, with the following 8 commands I can get pretty much anything I need, done. note: There are extensive documents on each of the following commands. This blog po
I listen to audio books while I work out. I've been known to leave earworms 'Rapid Italian' on while trying to go to sleep. I read books on trains. I answer emails while eating dinner. I clear out my Google Reader while watching TV with my wife. I wanted to learn Ruby and Blackjack perfect strategy, so I wrote a perfect strategy simulator in Ruby. I'm a multi-tasking machine. I am the world's most
Inside the body of defmacro you can call &env and &form to get a bit of interesting information that may or may not be helpful. Here's a few examples that demonstrate how &env and &form can be used. (note: I'm using Clojure 1.2) &env By default &env is nil.user=> (defmacro show-env [] (println &env)) #'user/show-env user=> (show-env) nilHowever, if any bindings exist, &env gives you the names of t
Once upon a time I wrote Expectations for Ruby. I wanted a simple testing framework that allowed me to specify my test with the least amount of code. Now that I'm spending the majority of my time in Clojure, I decided to create a version of Expectations for Clojure. At first it started as a learning project, but I kept adding productivity enhancements. Pretty soon, it became annoying when I wasn't
I'll admit it, the first thing I like to do when learning a new language is fire up a REPL. However, I'm usually ready for the next step after typing in a few numbers, strings and defining a function or two. What feels like centuries ago, Mike Clark wrote an article about using unit testing to learn a new language. Mike was ahead of his time. This blog entry should help you if you want to follow M
In The Joy of Clojure (TJoC) destructuring is described as a mini-language within Clojure. It's not essential to learn this mini-language; however, as the authors of TJoC point out, destructuring facilitates concise, elegant code. What is destructuring?Clojure supports abstract structural binding, often called destructuring, in let binding lists, fn parameter lists, and any macro that expands into
This morning I read Joel: From Podcast 38 and it reminded me how immature developers are when it comes to testing. In the entry Joel says:a lot of people write to me, after reading The Joel Test, to say, "You should have a 13th thing on here: Unit Testing, 100% unit tests of all your code."At that point my interest is already piqued. Unit Testing 100% of your code is a terrible goal and I'm wonder
Most Java unit tests consist of a Class Under Test (CUT), and possibly dependencies or collaborators. The CUT, dependencies and collaborators need to be created somewhere. Some people create each object using 'new' (vanilla construction), others use patterns such as Test Data Builders or Object Mother. Sometimes dependencies and collaborators are instances of concrete classes and sometimes it make
Jason Rudolph recently wrote about Testing Private Methods in Ruby. Before I continue, it's probably a good idea to note that I rarely test private methods. I prefer to test through the public API. However, there are times when life is easier if you write a few tests for a private method or two. The solution highlighted by Jason (original implementation from Evan Phoenix) is nice from a maintainab
The Ruby Core Library documentation is very similar for Kernel.system, Kernel.exec and %x[..]. Recently I needed to kick off a system process, so I spent some time working with all 3 options. Kernel.exec does exactly what the documentation states:Replaces the current process by running the given external command. If exec is given a single argument, that argument is taken as a line that is subject
How is it we keep falling for the same trick? Why is it so hard to remember: there is no silver bullet. I've spent a significant amount of my time for the past 3 years focusing on testing. I've learned several lessons.Setup methods are evilOne assertion or expectation per testDuplicate code in tests can be a good thingTest names aren't always requiredReplacing mocks with stubs can improve essence
In the entry Replace method_missing with dynamic method definitions I have the following example code. class Decorator def initialize(subject) subject.public_methods(false).each do |meth| (class << self; self; end).class_eval do define_method meth do |*args| subject.send meth, *args end end end end end The context of the example can be summarized as, you want to delegate from the instance all the
I love inject. To be more specific, I love Enumerable#inject. I find it easy to read and easy to use. It's powerful and it lets me be more concise. Enumerable#inject is a good thing. Of course, I didn't always love it. When I was new to Ruby I didn't understand what it was, so I found it hard to follow. However, finding it hard to understand didn't make me run from it, instead I wanted to know wha
On Christmas Day 2007 I released the 0.0.1 version of expectations. Expectations is the result of several months of designing what I wanted the Domain Specific Language (DSL) to look like, and a few days of making it executable. To design the DSL, I created what I was looking for without worrying about implementation. This entry is going to focus on what it took to take the DSL from looking good t
Defining Methods Dynamically You have methods that can be defined more concisely if defined dynamically. def failure self.state = :failure end def error self.state = :error end becomes def_each :failure, :error do |method_name| self.state = method_name end Motivation I use Dynamically Define Method quite frequently. Of course, I default to defining methods explicitly, but at the point when duplica
The default architecture for Ruby on Rails, Model View Controller, can begin to break down as Controllers become bloated and logic begins to creep into view templates. The Presenter pattern addresses this problem by adding another layer of abstraction: a class representation of the state of the view. Presenter was inspired by the various GUI patterns documented by Martin Fowler. How It Works The P
Updated following multiple comments requesting examples and questions on where to put AR::Base subclass tests. Everyone (who reads this blog anyway) knows that you should not cross boundaries while unit testing. Unfortunately, Ruby on Rails seems to believe otherwise. This is evident by the fact that the test:units rake task has the pre-requisite db:test:prepare. Additionally, if you use script/ge
このページを最初にブックマークしてみませんか?
『Jay Fields' Thoughts』の新着エントリーを見る
j次のブックマーク
k前のブックマーク
lあとで読む
eコメント一覧を開く
oページを開く