Where communities thrive


  • Join over 1.5M+ people
  • Join over 100K+ communities
  • Free without limits
  • Create your own community
People
Activity
Tim Riley
@timriley
@nepalez Congrats on the first dry-initializer release :) Would you like to pen a little blog post for the dry-rb site announcing it?
Tim Riley
@timriley
@coop thinking I could maybe add a little parenthetical aside explaining the difference between entities and value objects – do you reckon that’d help?
Tim Cooper
@coop
I think it would help.
Tim Riley
@timriley

@coop How’s this read?

(Technically, these examples are entities rather than strict value types, because we include the record IDs in their attributes, which you'd expect to be the key indicator of equality. However, in practice, Dry::Types::Struct instances still check for equality across all attributes, and in our apps we only ever instantiate these objects from known-good database data, which means they still behave effectively as value objects. So let's continue!)

Tim Cooper
@coop
That clears it up.
Tim Riley
@timriley
Cool, and thanks for the discussion!
Tim Cooper
@coop
@timriley do you ever mutate these and write them back to the database? And when I say “mutate” I’m talking about returning a new value object with the changed attributes.
Tim Riley
@timriley
Nope, we just work with hashes when we’re persisting changes. Get a params hash from a form, adjust as necessary in an “operation” object, run it through validation schema, pass it to a ROM command.
Tim Cooper
@coop
From your example I could imagine something: changed_article = article.with_title(“my new title”) and then pass changed_article to the DB.
Ah ok.
Tim Riley
@timriley
Yeah. I think a lot of this will be clearer once I can start to piece a few things together.
But I’m trying to avoid 6,000 word articles ;)
Tim Cooper
@coop
:P
The idea of hashes is fine, we do something similar for event sourcing, each aggregate keeps list of events to persist to the database which are effectively an array of hashes.
We wrote so much code that is similar to dry-types.
Tim Riley
@timriley
heh
Tim Cooper
@coop
All of our events are typed… We enforce types when constructing events. I’ve tried substituting for dry-t and dry-v but it’s quite a lot of work. It will be worth it because dry-t and dry-v integrate so nicely, we’ll be able to delete a lot of code at the end.
Tim Riley
@timriley
Cool, that’ll be nice to get in place :)
Andy Holland
@AMHOL
hanami/validations#98
Fran Worley
@fran-worley
@AMHOL Some sound arguments, it's just a shame that there can't be some kind of consensus amongst rails alternative ruby 'frameworks'.
Andy Holland
@AMHOL
@fran-worley Yeah, the point about not being able to wrap the API was the only real valid argument IMO, but each to their own I guess
Fran Worley
@fran-worley
@AMHOL I can kind of see the argument for having lots of dependencies but if it keeps code DRYer then why wouldn't you...
Andy Holland
@AMHOL
Yeah, I think the adding more gems argument is a non-issue
Fran Worley
@fran-worley
I'd rather have 30 small dependencies that use each other than 5 large ones that have to re-implement common functionality. I just appreciate that others don't agree.
Andy Holland
@AMHOL
Unless those gems make changes to the runtime environment
:+1: * :100:
Fran Worley
@fran-worley
Yeah. Also the point about the wrapable API, isn't this being addressed to some degree by the discussions on custom input processors and Error handlers
and surely there is nothing to stop you writing your own macros to reintroduce the validates :title, :presence type syntax ?
Simon Schmid
@sled
I'm currently working on something like dry-activemodels, basically composes the errors and output of a schema to an activemodel
(error messages, output hash) => activemodel and (full type) => activemodel
some simple delegations
but getting attribute translations and form builder compatibility :)
Andy Holland
@AMHOL
Well you could build an entirely custom API and make use of the AST in theory, but I think Luca would rather spend the time implementing a similar validation library from scratch, rather than go to that effort and have the underlying dependencies too
Be interesting to see what Piotr thinks when he gets back though, I'm not all that familiar with dry-validation myself
Simon Schmid
@sled
I think the only external gem dependency of dry-* is the Kleisli gem
Andy Holland
@AMHOL
Also concurrent-ruby
Simon Schmid
@sled
yep concurrent-ruby is a beast ;)
Andy Holland
@AMHOL
It is indeed, I preferred thread-safe TBH
But again, people don't want too many dependencies, so lets have a gem for utitility classes, a gem for managing concurrency and a gem for active anything
I can't wait to see what Tim does with https://github.com/icelab/dry-web-skeleton tho, hopefully will be able to get the full stack running on top of dry and rom soon
Fran Worley
@fran-worley
It would be good to hear Piotr's opinion but I remember him saying a while ago that his vision for Macros was to enable people to build their own. I know that there was talk a while ago of building something into Reform to make the migration to Dry-V easier.
Andy Holland
@AMHOL
Oh cool, I guess I missed that
Fran Worley
@fran-worley
I could be wrong and I know that at this stage it's not been explored to its full potential but that combined with custom processors for inputs and errors would in theory allow you to 'wrap' the library.
Tim Riley
@timriley
I think Piotr and Luca may have different opinions on the importance of validation.
I can see Luca's opinion on the API stability front. It's something he's decided to take on, with hanami being a "one stop shop"/all-encompassing solution for developers, something they can rely on above all else.
I guess it's a bit different to how an app using e.g. dry-web or other non-frameworks is put together, where you decide to use whichever gems you want, and then learn/use them directly and keep on top of any API changes they may (or may not) ever need.
(I know that's possible with hanami too, but in offering a full range of functionality as an in-house option, I'd imagine the majority of hanami users would follow that path)
Tim Riley
@timriley
Anyway, the improvements to their validation system look nice! Even if they cover similar ground to dry-v.
I'll release a dry-web gem release today and try to get some minimal docs in our icelab skeleton, @AMHOL :)
I also want to think about what constitutes a viable minimum skeleton too, something perhaps less opinionated than ours (which comes out of the box with things like a background job runner, etc., things that people might not necessarily want).