Why use value objects?

I am trying to delve a little deeper into Flex and have come across discussions about using value objects. My question is why would you use them?
I have an application that stores records in a database using ColdFusion as a backend. Currently I use an HTTPService to call a coldfusion page that returns XML that gets put in a XMLListCollection. This is then used to populate a datagrid and form details when the datagrid item is clicked on. This all works fine and is very easy (if not very elegant, it was one of my first applications)
I have another that uses a remote object to a coldfusion cfc. This cfc returns a query based on verious parameters. This result is then put in an ArrayCollection and used various ways.
What is wrong with doing things this way and why/how would value objects help?
Thanks.
Matt

Your example has nothing to do with value objects.
Value objects are useful in a number of situations such as:
1. They can efficiently represent a limited number of values. Say you have a size field with only four possible values: small, medium, large and extra large. You can use value objects and store the ordinal value (1 to 4) in a single byte instead of needing an 11 byte string. The set of value objects can be used as a white list for validating or constraining user input.
2. You can attach other information to a value object (within reason). Say your app allows users to select from a list of colors. You can store the RGB color information in the value object for each color.
There are probably other uses such as with strategy patterns (http://en.wikipedia.org/wiki/Strategy_pattern) as well.

Similar Messages

  • Shall I use Value Objects???

    Hi,
    I am creating a web app with approx 25 web pages with not much business logic.
    I plan to use struts framework.
    What I wanted to know was, shall I use value object pattern for my web page?
    Is there some kind of questionaire which I can take to decide whether I should use VO or not?
    Thanks,
    KS

    What's the difference between DTO and VO? Both are
    little more than C structs for ferrying data between
    layers. No functionality whatsoever.Value Object was the name used in the first editions of the Applied Java Patterns & Core J2ee Pattern books from Sun. These are called Data Transfer Objects in the later issues of these books.
    The Value Object name also caused some confusion because the term has previously been used to refer to language specific ideoms of wrapping primative types in Object.

  • Why use smart objects

    Been away from photoshop since early days of CS6. At that time I did not use smart objects. Now I see many tutorials using smart objects and smart filters. Is the use of smart objects in the mainstream now? Reasons for and against using them.

    Smart Objects are a very good thing!
    Photoshop Help | Work with Smart Objects
    "Smart Object are layers that contain image data from raster or vector images, such as Photoshop or Illustrator files. Smart Objects preserve an image’s source content with all its original characteristics, enabling you to perform nondestructive editing to the layer."
    I can't think of reasons NOT to use them.
    Nancy O.

  • Design patterns,about value object ,how?why?could you give me a soluttion

    design patterns,about value object ,how?why?could you give me a soluttion
    use value object in ejb,thanks
    i want not set/get the value in ejb,find the method to solve it ,use value
    object ?
    how? thanks.

    Hai
    Enter your telephone number here, at the top it will say your Exchange, Phone and cabient number. If it doesn't mention cabinet that means you are directly connected to the exchange and not via PCP.
    If you are connected to a cabinet and it doesn't say FTTC is available, ask your neighbor to-do the same test (they have 2 be infinity connected). If they are, then proceed to contact the moderators here. Though it could not be showing because all the ports have been used up in the FTTC Cabinet.
    If this helped you please click the Star beside my name.
    If this answered your question please click "Mark as Accepted Solution" below.

  • Need help regarding Value Object Concept in flex/java

    I need to map the java objects to flex use value objects in flex.
    The problem is I have a class in java which is referring to another class and again that class referring another class.
    For instance
    Class A
         protected User user;
    Class User
         protected Address address;
    Now I need to map class A to the flex using value object concept and I have to display the user info in the grid as well.
    Need some help to get started.

    You need to set the "scope" property in your remoting destination definition to "session" or "application".

  • Value Objects still  relevant in EJB 2.0?

    I came across the concept of using Value Objects to get better performance from EJBs as they reduce the number of remote calls to invoke to retrieve object property values.
    However, with the introduction of LocalHome and Local interfaces for EJB 2.0, is it still useful to have value objects to pass data around, typically between EJBs and the Controller (typically servlets/JSPs or session beans that implement business logic)?

    Not so fast.
    I wouldn't be so quick to get rid of VOs simply because local interfaces exist now. Keep in mind that using local interfaces is not always the right answer to your problem (since there are still situations where the client and server are not co-located within a given VM).
    Also, there are times when the brittleness of your API should be considered. If a method takes many parameters, it is often benificial to pass a single VO as a paramater rather than multiple individual parameters. This really comes into play when methods are modified to take different arguments (e.g. adding a new argument).
    Consider a method on a bean used to update a student's records for example.public StudentVO update(String firstName, String middleInitial, String lastName, int age, String ssn, String status) throws UpdateException; is much more brittle than public StudentVO update(StudentVO student) throws UpdateException;Consider what would happen if a design change makes GPA and gradeLevel part of a student's profile.
    The second method's signature would remain the same. The signature of the first method however would now read public StudentVO update(String firstName, String middleInitial, String lastName, int age, String ssn, String status, float gpa, int gradeLevel) throws UpdateException; This change would "break" the calls made by any callers of this method. While there are pros and cons to this (as well as other ways to solve this issue, such as method overloading, etc.), it is something to consider when deciding whether a value object should be used in certain situations.
    Hope this adds another point of view to the discussion.
    Note: I'm using Value Object (VO), Data Transfer Object (DTO) and Transfer Object (TO) to me the same thing here.

  • A sample Value Object code.

    I understand it is a type of collection to exchange data with enterprise beans.
    Am I right?
    If I use value object, how can I make it?
    can I get a sample?
    in my understanding, I might have to make many VOs for each biz entity.
    can I make a common VO( like a common dao ) to make it simple?

    a value object is usually just a wrapper class that has no business or persistence logic- it's just a container for data, e.g.:
    public class UserKey {
    private String name;
    private String userID;
    //getter and setters
    }

  • What is Value object?

    Hi there,
    What is Value object in EJB?
    TQ
    Neo

    The main idea of a value object is to group information into chunks to minimize the chattiness of a distributed system.
    For example if you had a EJB that represented a user you might have methods called getFirstName, getLastName, getPhone, etc. Each time you call one of those methods from a remote context, you have to make a separate remote call. Each remote call involves a bunch or IP and ethernat headers that you never see but must be transfered across the network. So if you are getting two bytes of data you are really sending several hundreds or thousands of bytes of data. It's inefficient. If you were using value objects you would create a call called UserValueObject that would contain all the info about that user. Then you would have a method called getUser on your bean that would fill up the value object and return it. Then you have all the data you need about the user without making umpteen remote calls. The same thing goes for updates.

  • Setting the default value to taxonomy column in sharepoint 2010 using client object model

    I am creating a metadata column and I want to set its default value in sharepoint 2010 using client object model. Can anyone help me?
    My code for creating metadata column is as below:
                ClientContext clientContext = new ClientContext(siteUrl);
                Web site = clientContext.Web;
                List list = site.Lists.GetByTitle("LibraryName");
                FieldCollection collField = list.Fields;
                string fieldSchema = "<Field Type='TaxonomyFieldType' DisplayName='SoftwareColumn' Name='SoftwareColumn' />";
                collField.AddFieldAsXml(fieldSchema, true, AddFieldOptions.DefaultValue);
                //oneField.DefaultValue = "ASP.NET|4c984b91-b308-4884-b1f1-aee5d7ed58b2"; // wssId[0].ToString() + ";#" + term.Name + "|" + term.Id.ToString().ToLower();
                clientContext.Load(collField);           
                clientContext.ExecuteQuery();

    Hi,
    Please try the code like this:
    ClientContext clientContext = new ClientContext("http://yoursite/");
    List list = clientContext.Web.Lists.GetByTitle("List1_mmsfield");
    clientContext.Load(list);
    clientContext.ExecuteQuery();
    FieldCollection fields = list.Fields;
    clientContext.Load(fields);
    clientContext.ExecuteQuery();
    Field f = fields.GetByTitle("mms");
    clientContext.Load(f);
    clientContext.ExecuteQuery();
    Console.WriteLine(f.Title + "---" + f.DefaultValue);
    //2;#A2|a0a95267-b758-4e4d-8c39-067069fd2eef
    //1;#A1|641f5726-992c-41c8-9ddc-204a60b88584
    f.DefaultValue = "1;#A1|641f5726-992c-41c8-9ddc-204a60b88584";
    f.Update();
    clientContext.Load(f);
    clientContext.ExecuteQuery();
    Console.WriteLine(f.Title + "---" + f.DefaultValue);
    Best regards
    Patrick Liang
    TechNet Community Support

  • How to upload a document with values related to document properties in to document set at same time using Javascript object model

    Hi,
          Problem Description: Need to upload a document with values related to document properties using custom form in to document set using JavaScript Object Model.
        Kindly let me know any solutions.
    Thanks
    Razvi444

    The following code shows how to use REST/Ajax to upload a document to a document set.
    function uploadToDocumentSet(filename, content) {
    appweburl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));
    hostweburl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
    var restSource = appweburl +
    "/_api/SP.AppContextSite(@target)/web/GetFolderByServerRelativeUrl('/restdocuments/testds')/files/add(url='" + filename + "',overwrite=true)?@target='" + hostweburl + "'";
    var dfd = $.Deferred();
    $.ajax(
    'url': restSource,
    'method': 'POST',
    'data': content,
    processData: false,
    timeout:1000000,
    'headers': {
    'accept': 'application/json;odata=verbose',
    'X-RequestDigest': $('#__REQUESTDIGEST').val(),
    "content-length": content.byteLength
    'success': function (data) {
    var d = data;
    dfd.resolve(d);
    'error': function (err,textStatus,errorThrown) {
    dfd.reject(err);
    return dfd;
    Then when this code returns you can use the following to update the metadata of the new document.
    function updateMetadataNoVersion(fileUrl) {
    appweburl = decodeURIComponent(getQueryStringParameter('SPAppWebUrl'));
    hostweburl = decodeURIComponent(getQueryStringParameter('SPHostUrl'));
    var restSource = appweburl +
    "/_api/SP.AppContextSite(@target)/web/GetFolderByServerRelativeUrl('/restdocuments/testds')/files/getbyurl(url='" + fileUrl + "')/listitemallfields/validateupdatelistitem?@target='" + hostweburl + "'";
    var dfd = $.Deferred();
    $.ajax(
    'url': restSource,
    'method': 'POST',
    'data': JSON.stringify({
    'formValues': [
    '__metadata': { 'type': 'SP.ListItemFormUpdateValue' },
    'FieldName': 'Title',
    'FieldValue': 'My Title2'
    'bNewDocumentUpdate': true,
    'checkInComment': ''
    'headers': {
    'accept': 'application/json;odata=verbose',
    'content-type': 'application/json;odata=verbose',
    'X-RequestDigest': $('#__REQUESTDIGEST').val()
    'success': function (data) {
    var d = data;
    dfd.resolve(d);
    'error': function (err) {
    dfd.reject(err);
    return dfd;
    Blog | SharePoint Field Notes Dev Tools |
    SPFastDeploy | SPRemoteAPIExplorer

  • Why use “synchronized” to decorate an object which its type is Vector

    Hello,guys.
    Recently,I readed the source code of java.util.Observable.Unfortunately,I encounted some problems&#12290;In the source code ,there is an object named “obs”.Its type is Vector. As we all know,Vector is thread-safe.why use “synchronized” in below code?
        public synchronized void deleteObservers() {
         obs.removeAllElements();
        }thanks.
    Edited by: qiao123 on Dec 21, 2009 7:07 PM

    My " NewBie" Definition of Thread Safe :Is of no interest. It already has a definition and that isn't it.I wanted to make clear what my definition is.
    The [JLS DEF FOR COLLECTION|http://java.sun.com/j2se/1.4.2/docs/api/java/util/Collections.html] says:
    That is the Javadoc for Collections actually, nothing to do with the JLS or Collection.They are authoritative links for Java Language and the discussion in hand, not Fantasies of Lucy Aunty.
    So,how do we draw any inference(s) here?Yes, that you have selectively quoted the Javadoc, which goes on to talk about how you have to use it when iterating.Still not answering my question,Sir.
    ejp,you seem to have knowledge but you don't have the attitude to forward the same to others or bear what others say,even when initiative has been taken by others to put forward a problem.
    P.S : Not all hackers are arrogant and not all arrogant are hackers.
    Another P.S : Waste of my time really !!!
    Edited by: punter on Dec 22, 2009 1:09 AM

  • How to change 'Modified By' column value when a new file is uploaded in SharePoint 2013 using Client Object Model?

    I want to change 'Modified By' column value of a file that is being uploaded using Client Object Model in SharePoint 2013. The problem is that the version of the file is changing. Kindly help me. The code that I am using is:
    using (System.IO.Stream fileStream = System.IO.File.OpenRead(m_strFilePath))
        Microsoft.SharePoint.Client.File.SaveBinaryDirect(m_clientContext, str_URLOfFile, fileStream, true);
        Microsoft.SharePoint.Client.File fileUploaded = m_List.RootFolder.Files.GetByUrl(str_URLOfFile);
        m_clientContext.Load(fileUploaded);
        m_clientContext.ExecuteQuery();
        User user1 = m_Web.EnsureUser("User1");
        User user2 = m_Web.EnsureUser("User2");
        ListItem item = fileUploaded.ListItemAllFields;
        fileUploaded.CheckOut();
        item["UserDefinedColumn"] = "UserDefinedValue1";
        item["Title"] = "UserDefinedValue2";
        item["Editor"] = user1;
        item["Author"] = user2;
        item.Update();
        fileUploaded.CheckIn(string.Empty, CheckinType.OverwriteCheckIn);
        m_clientContext.ExecuteQuery();

    Hi talib2608,
    Chris is correct for this issue, when calling update using ListItem.update method, it will increase item versions, using SystemUpdate and UpdateOverwriteVersion will update the list item overwrite version.
    these two methods are not available in CSOM/REST, only server object model is available for this.
    Thanks,
    Qiao Wei
    TechNet Community Support

  • Mapping an object using values from multiple tables

    Is it possible to use values looked up in other tables when mapping an object?
    For example: I have three tables. In table 1, I have fields for 'cityCode' and 'stateCode'. Table 2 is a state table which contains a list of stateCodes and corresponding stateIds. Table 3 is a city table with cityCodes listed by stateId (the city code is unique within the stateId but can be duplicated under other stateIds). Table 3 also contains the cityName for the matching cityCode/stateId pair.
    I am ultimately trying to match a cityName to a cityCode. I can't figure out how to tell toplink use the stateId returned when mapping Table 1 to Table 2 via stateCode when mapping cityCode in Table 1 to Table 3.
    Any help is greatly appreciated
    --matt                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                               

    What does your object model look like, do you have a single object with data from all three tables in it?
    <p>
    In general because the cardinality of the tables and usage does not match, I would not recommend using multiple tables to map this. Instead define a CityNameManager class that preloads and stores all of the city names for each state, (possible lazy initializing each set of cities per state). Your getCityName() method in your class would then just use this manager.
    <p>
    You could map the multiple tables but it may be difficult, and would most likely need to be read-only because I don't think you want to insert into the table2 or 3. You basically have a foreign key table1.stateCode => table2.stateCode, (table1.cityCode, table2.stateId) => (table3.cityCode, table3.stateId). You probably cannot define this in the Mapping Workbench, so would need to use the ClassDescriptor code API and an amendment method. If you can't get the foreign keys to work you can always use the descriptor multipleTableJoinExpression and define the join directly.
    <p>
    You could also define a OneToOneMapping to the CityName from your object using the cityCode and using a selectionCriteria() on your mapping to provide an expression that uses the getTable() method to join to the intermediate table.
    <p>
    <p>---
    <p>James Sutherland

  • Read records from VALUES OBJECT using the INTERATOR

    Hi
    I'm trying to read records from my value object with interator these way:
    ValidaUsu usuVO = new ValidaUsu();
    for (Iterator it = usuVO it.hasNext(); ) {
    System.out.println(" User from VO: " + usuVO.getUsuario());
    But i don't know what i`m doing wrong ?
    Could help me?
    Thanks

    Hi Gajendra,
    You can mainly read records from MDM (in a DDIC structure) using ABAP API's using the following function modules/methods:
    1. RETRIEVE: This is used to generically retrieve records from tables. Attributes and Values can also be retrieved.
    2. RETRIEVE SIMPLE: Retrieve records from MDM in a simple way.( simple data types).
    3. RETRIEVE CHECKOUT: Retrieves all checked out ID's.
    4. RETRIEVE ATTRIBUTES: Retrieves attribute(s) from a Taxanomy table.
    You will find all these methods in the following interface
    Interface : IF_MDM_CORE_SERVICES
    Hope it helps.
    *Please reward points if found useful.
    Thanks and Regards
    Nitin Jain

  • For the Attribute Movement type(BWA) we use Value " 201" and not "101" why?

    Hello Experts,
    We are in SRM 7.0 classic scenario,
    For the Attribute Movement type(BWA) we use Value " 201" and not "101" and provide the Source syst(backend R/3)
    Can you all plz help me understand what is the difference if use value "101" for the  Attribute Movement type(BWA)
    Also,can you all plz help me understand if we shd use value "101" or "201" for the  Attribute Movement type(BWA) and under what scenario.
    Any pointers will be highly appreciated.
    Thanks & Regards,
    RKS

    Hi,
    Movment type " 201 maintained for the Classic scenario only.
    It is necessary to maintain the attribute if the default material group for a given user (or) sit is set to a backend logical system. The EBP system knows that if the user is set for backend procurement ,that there might be a possibility for a reservation to be generated therefore it checks to see that a value for this attribute is  maintained. The BWA value should be defined  for the  as 201 preceeded by the logical system and a backslash.
    101 should not be used. This isfor the Good receipt.
    In the extended classic scenario when you do the confirmations in SRM the movement type 101 will be created in the
    backend system (R/3 or ECC6.0)
    Regards
    Ganesh Kumar .G

Maybe you are looking for

  • Bex reports in non english language

    What setting required to get the Bex reports in Japanese language. Provide more inputs..

  • Looking for best practice on showing data inside a TableView

    I have an app, that can retrieve one ore more than 300,000 rows as the result of a query and i am displaying them into a TableView.. i am using a mechanism to bring the data "on parts", when i do the query an object with the ids of the rows is set in

  • Animations in a java App

    Hi people :) I'm just trying to make animated graphics : translations, and all animated stuff that we can see in an applet, but in a java application ( not applet ). Could someone give me a direction, a solution, or the URL of a tutorial ? Thanks a l

  • Airport in iMac versus iBook G4

    it's creazy, my airport internetconnection is doing great with my iBook G4 the signal is strong (3 tot 4 bars) and than my iMac ... that is a disaster sometimess a connection is just not possible and when it works I'am happy to have '1' bar saying th

  • Error Installing ruby with RVM Single User mode

    I've just installed RVM on ArchLinux x64 in single user mode via the recommended install script curl -L https://get.rvm.io | bash -s stable I've also installed all the requirements listed in rvm requirements However, I'm having trouble actually insta