3 ms·
Virtual attributes are perfectly fine, as long as they can be translated back and forth to real attributes with no information loss. Not each "reflection" of th
by derefr 17y ago
Virtual attributes are perfectly fine, as long as they can be translated back and forth to real attributes with no information loss. Not each "reflection" of the model (e.g. in-memory object, database record) needs to expose the same interface, only to be theoretically capable of exposing it because it "knows" the same underlying data. Views, on the other hand, are lossy, and so you can't guarantee that you can regenerate the original record from a view of it, only from a given reflection of its model.
You're right, though: Rails is practical code that takes practical considerations before theoretical ones (and has been basically bottom-up designed from the start without any regard for what the commonalities between applications "mean," only what they can help achieve.) Still, it's good to understand the theory of MVC-type apps in general, as you can then see how far away a given framework starts you off from "pure MVC," and can then measure drift from there (i.e. it's probably a bad idea if you code such that you're not obeying MVC even as well as the framework will let you.)