Live data from Hacker News

Objectify: A Better Way to Build Rails Applications

jamesgolick.com

61–70 of 72 posts

Re: Objectify: A Better Way to Build Rails Applications

#61

Earlier quoted context omitted.

Do you really think the OP had SEO as a priority? Likewise I disagree with the idea that these two projects share the same space. A Java ORM and a Rails metaframework for avoiding ORM are not things which have a lot in common. I think the last time I observed a Rails hacker saying anything about AppEngine was 2007 or something.

It will certainly cause confusion. This is just decidedly uncool. As the lead developer of the Objectify project, and someone who makes a living through consulting related to Objectify, I am highly annoyed. I'm also talking to a trademark attorney to find out my options.

Jesus, dude, why not just talk to OP instead? Any lawyer will tell you that if you can resolve your differences peacefully out of court, you should. This seems to be some kind of hair-trigger litigiousness thing you've got on going here.

Re: Objectify: A Better Way to Build Rails Applications

#62

Earlier quoted context omitted.

judofyr is about as credible about Ruby as they come.

If that's the case, why does he need to start a discussion with that kind of statement?

Because maybe it's fucking ridiculous?

You'll have to decide if he made his case or not, but if that's what he thinks then better he just come right out with it instead of dancing around.

Note that he did not call James ridiculous, he criticized the idea. Which is how it should go (if there's going to be criticism).

You can debate whether his assertion is justified, but some (many, perhaps) ideas really are fucking ridiculous and it's better to just cut to the chase.

Re: Objectify: A Better Way to Build Rails Applications

#63

Earlier quoted context omitted.

It will certainly cause confusion. This is just decidedly uncool. As the lead developer of the Objectify project, and someone who makes a living through consulting related to Objectify, I am highly annoyed. I'm also talking to a trademark attorney to find out my options.

Jesus, dude, why not just talk to OP instead? Any lawyer will tell you that if you can resolve your differences peacefully out of court, you should. This seems to be some kind of hair-trigger litigiousness thing you've got on going here.

Relax, it's not like I'm setting a court date. I just prefer to know where I stand before I open my mouth, and I happen to work with lawyers who specialize in this kind of thing. Research before action, no?

Re: Objectify: A Better Way to Build Rails Applications

#64
post #49

Earlier quoted context omitted.

I worked in Rails for the last 6 years professionally, and for the last 4 years on a single application. There are lots of ways to tackle this problem, but it really depends what precisely you have inside those models and there are certainly no universal silver bullets. Lots of people who complain about this underuse Rails features, external plugins etc. I think two good ways to deal with the problem are: - Splitting…

hey man, re: "If you look at Rails itself (it's great Ruby code, I highly recommend really reading it)" I've worked with a member of Rails core, and frequent committers. I've spoken at 10 Ruby conferences at least, maybe 20. I'm familiar with the Rails code base. I once rewrote a few small pieces of ActiveRecord from memory for a stupid project because my wifi was dead. I agree about it being worth reading, I just wa…

When I say "If you look at Rails itself" I do not mean you in particular, I mean in general for people wondering about the problem a good lesson is checking out the Rails code, similarly "a new skill to be learned" in the sense that it is different from traditional OO modelling most people come from. I know your blog and I've seen you discussing concerns in some other place, so I do appreciate your background. Maybe being irritated about bad ideas makes me come up more abrasive than usual.

Anyway, the whole discussion so far was about dealing with the problem of large (in terms of code size) models, so I assumed by "scalability" you mean scalability in terms of being able to handle very large code bases, not performance issues. I do not understand how the approach presented here would result in performance improvements? I've commented elsewhere on the problems associated with it, others did as well in a fairly convincing way I think. I do not deny that problems with scaling both in the performance sense and in the code size sense do exist, I just do not see how Objectify solves any of them and I do see how many problems it introduces.

As for breaking your app down into separate HTTP services, I agree this can be useful in some situations, but it is completely different from the approach outlined in Objectify, for one you still get a chance to do (almost) normal OO modelling and structure the code in a reasonable way, even if the message passing is done via HTTP and not simply via Ruby method calls.

Re: Objectify: A Better Way to Build Rails Applications

#65
post #25

This is not object-oriented at all, unless you learned about object-orientation from Java and its monster frameworks, this is basically a form of data-flow programming. OO is about message passing, here the "objects" do not pass any messages at all, the supposed "objects" _are_ the messages, and the routing of those messages takes place in the configuration in routes.rb, so the objects do almost no message-passing be…

I've read at least a dozen papers on the history of OO, not to mention books and papers on current practices. This is what I came up with. I made what I think is a pretty coherent argument for why in the article. I'd love to hear your refutation of the points I made in there.

I think what the GP might be trying to get at is this: you've reinvented partial function application and first-class functions. An instance of a class can be regarded as a bundle of functions which all have the constructor's parameters partially applied. If your instance only has one method, it's equivalent to a single, partially applied function. In that sense, what you've done is found a way to reorganise a Rails app in a very functional way - and, if you want to do that, given that Ruby doesn't have first-class functions or partial application (well, without proc hack, anyway), this may be the best way to do it.

It may work very well, but it's at least as functional as it is OO.

Re: Objectify: A Better Way to Build Rails Applications

#66

Earlier quoted context omitted.

I've read at least a dozen papers on the history of OO, not to mention books and papers on current practices. This is what I came up with. I made what I think is a pretty coherent argument for why in the article. I'd love to hear your refutation of the points I made in there.

I think what the GP might be trying to get at is this: you've reinvented partial function application and first-class functions. An instance of a class can be regarded as a bundle of functions which all have the constructor's parameters partially applied. If your instance only has one method, it's equivalent to a single, partially applied function. In that sense, what you've done is found a way to reorganise a Rails…

From the examples it doesn't even look like a _partial_ function application since it is not clear whether you can control how those services/policies/responders are initialized. Also I think it would be quite awkward for one service to initialize another and call it, so it is not really functional programming either, since there are no direct function calls. Since all the flow of the data is described in the routes file, it isn't OO at all and mostly reassembles dataflow programming as I said:

http://en.wikipedia.org/wiki/Dataflow_programming

Parts of this approach might be valuable, as I tried to emphasize, but as a whole this doesn't look good for plenty of reasons mentioned in the thread.

Re: Objectify: A Better Way to Build Rails Applications

#67
post #66

Earlier quoted context omitted.

I think what the GP might be trying to get at is this: you've reinvented partial function application and first-class functions. An instance of a class can be regarded as a bundle of functions which all have the constructor's parameters partially applied. If your instance only has one method, it's equivalent to a single, partially applied function. In that sense, what you've done is found a way to reorganise a Rails…

From the examples it doesn't even look like a _partial_ function application since it is not clear whether you can control how those services/policies/responders are initialized. Also I think it would be quite awkward for one service to initialize another and call it, so it is not really functional programming either, since there are no direct function calls. Since all the flow of the data is described in the routes…

The CurrentUserResolver example in the README shows that some initialisation control is possible here.

> it is not really functional programming either, since there are no direct function calls.

There don't have to be. The classes and instances are being referred to by the developer in the same way as any first-class functions defined elsewhere would be - they're actually resolved and called by the framework.

> Since all the flow of the data is described in the routes file, it isn't OO at all and mostly reassembles dataflow programming as I said

It certainly is OO. There are instances, and they receive and act on messages. Yes, there's a dataflow-like DSL for routing, but that's not to the exclusion of other paradigms.

Re: Objectify: A Better Way to Build Rails Applications

#68
post #66

Earlier quoted context omitted.

From the examples it doesn't even look like a _partial_ function application since it is not clear whether you can control how those services/policies/responders are initialized. Also I think it would be quite awkward for one service to initialize another and call it, so it is not really functional programming either, since there are no direct function calls. Since all the flow of the data is described in the routes…

The CurrentUserResolver example in the README shows that some initialisation control is possible here. > it is not really functional programming either, since there are no direct function calls. There don't have to be. The classes and instances are being referred to by the developer in the same way as any first-class functions defined elsewhere would be - they're actually resolved and called by the framework. > Since…

The CurrentUserResolver example in the README shows that some initialisation control is possible here.

This is the dependency injection part, not the policy/service/responder core of the framework I am talking about.

There don't have to be. The classes and instances are being referred to by the developer in the same way as any first-class functions defined elsewhere would be - they're actually resolved and called by the framework.

I am not talking about what happens on the level of Ruby, I am talking about what happens logically at the level of the framework. The classes represent functions, sure, but they do not call other functions (services/policies/responders), the only "function-calling" is done by the router. Yes, this too is a form of functional programming, the form known as dataflow programming where the flow of the data is described explicitly.

It certainly is OO. There are instances, and they receive and act on messages. Yes, there's a dataflow-like DSL for routing, but that's not to the exclusion of other paradigms.

It isn't OO at the level of the framework. Yes, Ruby is underneath, there are classes, there are instances, and the thin ORM layer is object oriented, but the objects within the framework do not exchange messages, the only object doing all the message dispatch is the router. This is not OO, just look at the traits listed here: http://en.wikipedia.org/wiki/Object-oriented_programming

The framework basically forces you to abandon messaging (since there is no exchange of messages, just single directional messages flow from the router), abandon encapsulation (since the services have to access the data of the domain objects and hence the domain objects must make their data available to everyone) and abandon polymorphism (since the services are statically dispatched by the router). How can this be object oriented?

Re: Objectify: A Better Way to Build Rails Applications

#69
post #68

Earlier quoted context omitted.

The CurrentUserResolver example in the README shows that some initialisation control is possible here. > it is not really functional programming either, since there are no direct function calls. There don't have to be. The classes and instances are being referred to by the developer in the same way as any first-class functions defined elsewhere would be - they're actually resolved and called by the framework. > Since…

The CurrentUserResolver example in the README shows that some initialisation control is possible here. This is the dependency injection part, not the policy/service/responder core of the framework I am talking about. There don't have to be. The classes and instances are being referred to by the developer in the same way as any first-class functions defined elsewhere would be - they're actually resolved and called by…

> The framework basically forces you to abandon messaging (since there is no exchange of messages, just single directional messages flow from the router),

The services receive messages from the router, then send messages to whatever they need to call to get the job done. Being sent messages by the framework is what makes it a framework and not a library; I don't get your objection here.

> abandon encapsulation (since the services have to access the data of the domain objects and hence the domain objects must make their data available to everyone)

Only if you're conflating domain objects with persistence objects.

> and abandon polymorphism (since the services are statically dispatched by the router).

They're statically dispatched on a constant name, not on a class. If you need polymorphism at that point, it's trivial to define a dynamic service resolver - all you need is something with a #new method assigned to the constant to do whatever late binding you want.

Re: Objectify: A Better Way to Build Rails Applications

#70
post #68

Earlier quoted context omitted.

The CurrentUserResolver example in the README shows that some initialisation control is possible here. This is the dependency injection part, not the policy/service/responder core of the framework I am talking about. There don't have to be. The classes and instances are being referred to by the developer in the same way as any first-class functions defined elsewhere would be - they're actually resolved and called by…

> The framework basically forces you to abandon messaging (since there is no exchange of messages, just single directional messages flow from the router), The services receive messages from the router, then send messages to whatever they need to call to get the job done. Being sent messages by the framework is what makes it a framework and not a library; I don't get your objection here. > abandon encapsulation (since…

The services receive messages from the router, then send messages to whatever they need to call to get the job done. Being sent messages by the framework is what makes it a framework and not a library; I don't get your objection here.

If it was a framework modelled in an object oriented way it would itself be built of classes exchanging messages, but it isn't. It encourages you to also structure your code in a non object oriented way by creating hundreds of little services which are basically procedure calls instead of making your model accept a wider variety of messages or instead of building classes with more than just a "call" method. Most of the code is supposed to go directly into the services, that's the whole point of the framework, remember it is a solution to the "fat model" problem:

One in particular is something I've been thinking about and refining for a while now [3]. In this approach, persistence objects remain extremely thin, and business logic is encapsulated in lots of very simple objects known as “services” and “policies”.

Also, keep in mind that the services do not normally call each other (they could in theory, but that would be even more awkward), so instead of having message exchange between models you have duplicated code in services or have to use inheritance. Ruby is object oriented so sure there are message calls further down, it doesn't make the framework object oriented on the logical level.

Only if you're conflating domain objects with persistence objects.

Must you go as far as to refer to a hypothetical reality just to win an argument ;) ? That's how Rails works, that's what the examples show, I am not referring to what is possible in theory, but to what the framework does and the most reasonable possible way of using it. Honestly one more level of indirection would make this look completely ridiculous.

They're statically dispatched on a constant name, not on a class. If you need polymorphism at that point, it's trivial to define a dynamic service resolver - all you need is something with a #new method assigned to the constant to do whatever late binding you want.

Ehm, no? You cannot just define a "new" method returning whatever you want neither in a module nor in a class in Ruby. You would have to overwrite the initialization methods that are usually hidden from the user. Passing a constant name is almost equivalent to passing a class.

  module Foo
    def new
      5
    end
  end

  puts Foo.new.inspect
  # undefined method `new' for Foo:Module (NoMethodError)

  class Bar
    def new
      5
    end
  end

  puts Bar.new.inspect
  # #
Post reply on HN