Futurescale, Inc.
PureMVC Home
The PureMVC Framework
Code at the Speed of Thought
Over 10 years of community discussion and knowledge are maintained here as a read-only archive.
New discussions should be taken up in issues on the appropriate projects at
https://github.com/PureMVC
PureMVC Architects Lounge
Announcements and General Discussion
Architecture
Data formatting
Pages: [
1
]
« previous
next »
Author
Topic: Data formatting (Read 9778 times)
Roustalski
Jr. Member
Posts: 13
Data formatting
«
on:
March 17, 2009, 06:27:40 »
Where should things like number formatters happen?
I would assume the proxy, but what about the case of an item renderer formatting an epoch number into a date?
Or maybe you have a total price label and the proxy has the variable stored as a string. Should the proxy format the string, or store it as a number and let whoever cares deal with it? (in this view's case: $123,456,789).
Thanks.
Logged
Jason MacDonald
Sr. Member
Posts: 243
Re: Data formatting
«
Reply #1 on:
March 17, 2009, 09:42:41 »
I like to keep things simple and have my Proxys store information in a universally usable format so any actor can use the "raw" data and do what they want with it from there.
The likely scenario for the money example is to have the Proxy ensure the type is a Number or int and pass that on to the view (also the Proxy should only receive Numbers or ints for saving). In the view have your formatter utility take a Number input and spit out a formatted String for display. An item Renderer is a good example of this. The underlying dataProvider is a Number but the display is formatted however the item renderer dictates.
I often find it helps to look at Proxy's as if they were DB tables when trying to decide how to store info (probably cuase a lot of my data comes directly from a row into my proxy's as VO's). You would store a date in a DB as an epoch number usually and let whatever uses the data format it.
«
Last Edit: March 17, 2009, 09:49:15 by Jason MacDonald
»
Logged
Roustalski
Jr. Member
Posts: 13
Re: Data formatting
«
Reply #2 on:
March 23, 2009, 05:28:09 »
What about multiple "tables" who need to be grouped together?
Do you have some sort of intermediate step in the model that formats (e.g. groups into a hierarchy), but still left in the raw format before passing off to another actor?
What is grouping/data structuring classified as?
Should there be a proxy for each table, and then another proxy that does the management of each grouping or structure for the data?
Logged
Jason MacDonald
Sr. Member
Posts: 243
Re: Data formatting
«
Reply #3 on:
March 23, 2009, 06:17:34 »
That sounds like the realm of a Command. Have a command grab the "raw" data from the Proxy, or Proxies, and group it together the way you need and then send it back to the view. The view can then handle any further item rendering for formatting of each item (dates, number etc).
For example, a data grid might need the data structured a certain way. So the command groups the data into a ArrayCollection and sends the array back to the data grid where the Item Renderer formats each cell of the data.
Logged
Pages: [
1
]
« previous
next »
Stack Overflow
GitHub
Linked In
Google Plus
Twitter
Powered by SMF 2.0.15
|
SMF © 2006-2007, Simple Machines LLC
|
Content © 2006-2018, Futurescale, Inc.
Loading...