You’re Doing it Wrong If
postal-code.com
postal-code.com
I've been doing web apps programming for a few years now, and I do admit there are better technologies out there. That's why I've been dipping my feet in lisp for the past year, and lately spending my nights with Clojure. But what he's advocating isn't good programming, it's sheep mentality, and I'm disapointed to see it here.
But since it's not nice to just be a critic:
* You’re not building atop an open-source framework
* You’re writing your own framework upon which to build
I have open source above, open source below and open source in the database. But holding it all together is a thin layer written by me, simply because I want to be able to adjust it as much and as often as I feel like. * You’re not using an ORM layer
* You’re writing your own ORM layer
I actually played with writing my own a few year back. In the meantime I thought a lot of times about its benefits and I ultimately decided against using one. Why? Because I only ever use one database engine, and if I change it it will definitely happen on a new app. Also I value too much development speed and flexibility. I saw code developed with ORM, and I still have see xml in my nightmares. Granted, it will probably work in many contexts, and if/when I switch to lisp I will probably use a persistance engine instead of a database, but now and for me it's definitely not an advantage. * You believe you can write it faster or better or more efficiently than any available library
You can, always. It's only a matter of effort invested. In most cases, the years necessary are not worth it, but very ocasionaly it pays. * You have more than one developer on your project and no written coding style guidelines
I usually poke them on the head when they forget spaces. I most certainly don't waste time with written specs. * Your bug tracker serves as your functional scope or your development roadmap
Actually it does. Took it from google: the best project management tool is a queue. Put stuff at one end, solve at the other. And also, we don't believe in deadlines. * You aren’t using source control
We are and like it. * You comment the what but not the why
We never comment. Ever. We spend lunch breakes thinking up intelligent variable names. * You tend to pass properties instead of instances to functions
No idea what this is, but we probably do it. * Your “deployment procedure” involves any combination of FTP and/or drag n’ drop
More like scripting and ssh. This one's ok. * You write code in a manner that cannot be unit tested
We don't unit test. True, it hurts ocasionaly, but at the amount of new (good) code we write, it's not really necessary. What we do (well, I at least and I'm evangelical about it) is read and re-read code, preferably before compiling. * Your primary method of code reuse is copy/paste
No comment. * You don’t read any development blogs focused on your primary and secondary languages or technologies
LOL * You haven’t been to a conference or birds-of-a-feather meeting in the past year
Really lol'ed this time. * The only code you read at work is your own
And my coworkers. True. * You worry that some day someone else will read your code and know it was written by you
Don't. True.If your data is not organized relationally, why are you using a relational database?
Edit: I also question the necessity or even the marginal utility of conferences.
We can both reel of lists of great frameworks, but that's survivor bias at work, because we remember the winners. For every Rails, there are hundreds or even thousands of terrible in-house frameworks all competing to be the subject of a DailyWTF post.
Of course, this leads to an age-old debating point, namely if you can find a few exceptions to a rule, should you toss the rule out? Add a lot of fine print disclaimers? Or keep the rule and trust that anyone who knowingly violates it has a good reason in mind?
At my own company, we had our founder and a director present at a recent conference, and the contacts and credibility they gained there will probably directly contribute to doubling our revenue over the next 2 or 3 years.
Unless you're right.
Take memcpy, for example; a while back I noticed that the win32 memcpy was atrociously slow for small blocks, significantly increasing runtime (since our program, x264, did loads of small memcpys). So I wrote my own; it was almost 10 times faster. And that isn't bragging--the function itself was utterly trivial--it just goes to show that system libraries are not always well-optimized.
Blindly using rails or even merb or any other framework will only get you so far. To truly transcend, you must build your own or heavily alter an existing framework.
This is hacker news right? Go out and build your own framework already dammit!
# You’re writing your own framework upon which to build
# You’re not using an ORM layer
# You’re writing your own ORM layer
I'm glad DHH and the boys over at django did it wrong, to be honest.
They're smart cookies, and but so are many web devs. While I agree that we should benefit from their labours, if there are times when we are confronted with the problems they had, we should be as bold as they were.
But if you're setting to build a web app chances are it's folly to build your own "framework" and ORM and libraries first (note for the absolutists in the crowd: that is purposely _not_ an absolute statement; we can all come up with suitably contrarian one-off edge cases).
What does this mean?
ira_account.register_with_irs(customer.get_ssn())
He suggests: ira_account.register_with_irs(customer)
Which I think is a roundabout way of getting at looser coupling and working at a higher level of abstraction.(update: obviously, I cast this in OO rather than functional terms. I suspect the point is isomorphic to FP).
In one case we're arguing that the registration code shouldn't have to know how to work with a customer. In the other case we're arguing that code initiating a registration shouldn't have to know what the IRS wants from a customer.
Seems like there's room for reasonable people to empty a bottle of single malt while debating the alternates.
'Course unless you're building a framework or library coupling should probably not be your main priority when building a web site.
As for the Law of Demeter, like my list that too is a rule of thumb and not an absolute, requiring judgement calls.
I wonder if he's talking about some problem that happens with people who've converted from other languages, and that's why I don't understand it.
I suspect the issue here is making good decisions about which entities/modules/functions/objects/thingummies should know a, which should know b, and which should know c.
The observation stems from seeing reams of web app code that take in form data (or raw database data) and then proceed to move it around the app without encapsulating it in any way. The result is functions like:
function display_user( user_first_name, user_last_name...user_valid)
Look at twenty or thirty functions like that in an app and one starts to think "perhaps you need a user object?"
I certainly didn't mean to suggest we should all start tightly coupling all our classes together willy-nilly.
vs.
func(PersonInstance);
The first one is more tightly coupled. But there are no hard and fast rules in good design.
That means you'd better think critically about the ORM/Framework/Fairyland you're using to build things.