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
Om PrakashOm Prakash 

Apex class variable best practice

Hello,
Which is best practice from memory allocation view of point , if I have to show three or four fields on visualforce page :
1. 
public MyCustomObject__c oMyCustomObject{get;set;}

or.

2.
public String sNotes{get;set;}
public String sStatus{get;set;}
public datetime dClosedDate{get;set;}
Best Answer chosen by Om Prakash
Vijay NagarathinamVijay Nagarathinam
Hi,

I think the first one is the best practice for accessing the variable in your visualforce page and also reduce the memory allocation.

For example: Public MyCustomObject__c customObj{get;set;}

you can access all the fields with the help of customObj instance

I think it will be helpful for you.