Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.programming > #5987
| From | Victor Porton <porton@narod.ru> |
|---|---|
| Newsgroups | comp.programming |
| Subject | Re: Deviating from "standard" active record concept? |
| Date | 2015-11-26 22:03 +0200 |
| Organization | Aioe.org NNTP Server |
| Message-ID | <n37oho$nhq$1@speranza.aioe.org> (permalink) |
| References | <n37nrd$koj$1@speranza.aioe.org> |
Victor Porton wrote:
> I was assigned to write a lightweight ORM in Perl. This includes writing
> an active record.
>
> Classic active record pattern implies assignments to fields of a model and
> after this a save operation. What about using
>
> model->save({Passport=>123456789, FullName=>"Ivan Grotter"})
> (pseudocode)
>
> instead (that it passing all parameters in one hash, instead of assigning
> one by one)?
>
> I prefer my variant of active record because it a little simplifies Model
> class. What are other advantages and disadvantages of leaving classic
> active record and using my method?
Hm, now I have realized that save() for a newly created object should assign
its identifier.
It would be inconsistent to assign the identifier but not to assign other
fields. This is an argument toward classic active record (rather than my
variation).
However, alternatively we can make save() to just return the identifier of
the saved object.
--
Victor Porton - http://portonvictor.org
Back to comp.programming | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
Deviating from "standard" active record concept? Victor Porton <porton@narod.ru> - 2015-11-26 21:51 +0200 Re: Deviating from "standard" active record concept? Victor Porton <porton@narod.ru> - 2015-11-26 22:03 +0200 Re: Deviating from "standard" active record concept? Julio Di Egidio <julio@diegidio.name> - 2015-11-26 13:26 -0800
csiph-web