function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
drbooleandrboolean 

M in MVC

Hey everyone.  This must be a redundant question, but it's a hard thread to search for.  I'm coming from rails and the 'active record' pattern so forgive me if this is ignorant.

 

How on earth do i extend an SObject with my own functionality?  Or where does my logic 'live'?

 

Should i make a wrapper object with an Apex Class?

 

I'm aware of formula's, but it's slightly limited for what i'm going for.

 

Thanks for your help in advance!

 

- Brian 

 

 

Example:

 

  So i have a visual force view.  I also have this extension.  So how can i implement roadRage()

 

 

public class MileageExtension {

private final Mileage__c mileageObj;

 

    public MileageExtension(ApexPages.StandardController controller) {

this.mileageObj = (Mileage__c)controller.getSubject();

    }

    

        // where do i put all the methods?

        public void roadRage() {

        Car car = mileageObj.getCar();

        Person driver = mileageObj.getDriver();

        car.honk();

        driver.giveFinger();

        car.swerve();

                driver.slowDownInEmbarrassment();

        }

} 

 

Message Edited by drboolean on 08-22-2009 08:39 PM

Message Edited by drboolean on 08-22-2009 08:40 PM
Best Answer chosen by Admin (Salesforce Developers) 
harryZharryZ

My simplest understanding about MVC

 

M -- sObject, wrapper object will needed if the page need a more complex object other than sObject;

V -- vf page

C -- controller, your logic is actully apex functions.

 

 

All Answers

harryZharryZ

My simplest understanding about MVC

 

M -- sObject, wrapper object will needed if the page need a more complex object other than sObject;

V -- vf page

C -- controller, your logic is actully apex functions.

 

 

This was selected as the best answer
drbooleandrboolean

Thanks for the reply!

 

Now I won't always second guess myself when wrapping.