Preface – This post is part of the Object Oriented Thinking series.
“In my 20 years in this industry, I have never seen a revolution as profound as this.”
— Steve Jobs, on object-oriented programming
So what is object-oriented programming (OOP) and why was Steve Jobs so passionate about it?
I’ll tell you, but to be honest, the late Steve Jobs said it best:
Here’s an example: If I’m your laundry object, you can give me your dirty clothes and send me a message that says, “Can you get my clothes laundered, please.” I happen to know where the best laundry place in San Francisco is. And I speak English, and I have dollars in my pockets. So I go out and hail a taxicab and tell the driver to take me to this place in San Francisco. I go get your clothes laundered, I jump back in the cab, I get back here. I give you your clean clothes and say, “Here are your clean clothes.”
You have no idea how I did that. You have no knowledge of the laundry place. Maybe you speak French, and you can’t even hail a taxi. You can’t pay for one, you don’t have dollars in your pocket. Yet I knew how to do all of that. And you didn’t have to know any of it. All that complexity was hidden inside of me, and we were able to interact at a very high level of abstraction. That’s what objects are. They encapsulate complexity, and the interfaces to that complexity are high level.”
Steve somehow knew that object-oriented programming would revolutionize coding, long before the world realized this. What a brilliant man!
Don’t worry if the concept of OOP hasn’t sunk in your head yet – it takes time to understand it. But fear not students: we’re going to spend this entire chapter digging deeper into OOP, how it applies to Salesforce, and how it’ll help you to write bigger and better codebases.
Next post: What are objects and classes?
Hello Community,
I’m attempting to use one SOQL query to get many data point that can be displayed on a Visualforce page. My query returns the expected results but I am not sure of how to parse through the query results and assign them to variables. My thought was that I could simply loop through the results and, based on the conditions, assign them to variables with getters. This does not generate an error, but my page will not return anything when calling {!MembershipsYTD}. if someone could help point me in the right direction it would be greatly appreciated.
public class MDEventResults
{
// Properties
public integer ThisMonth = date.today().month();
public integer MembershipsYTD {get; set;}
public integer MembershipsMTD {get; set;}
// Query Event Data
List EventAgg = [SELECT Sum(Total_Memberships__c) MembershipSum, count(ID) CNT, Calendar_month(Event_Date__c) Month, Facilitated_by_MD__c FacilitatedBy, Booked_By__c BookedBy,
GROUPING (Facilitated_by_MD__C) FacilGroup, GROUPING (Booked_By__c) BookedGroup, GROUPING (Event_Date__c) monthGroup
FROM Campaign
// WHERE Booked_by__r.id = :UserInfo.getUserid()//
WHERE End_Date_Time__c = This_Year
// AND Status = ‘Completed’ //
GROUP BY ROLLUP (Facilitated_by_MD__c , Booked_By__c, Event_Date__c)];
// method to parse results
public void MembershipsYTD() {
for (AggregateResult ar : EventAgg) {
if (integer.valueOf(ar.get(‘monthGroup’ )) == ThisMonth &&
integer.valueOf(ar.get(‘BookedGroup’)) == 1 &&
integer.valueOf(ar.get(‘FacilGroup’ )) == 1)
{
MembershipsYTD = integer.valueOf(ar.get(‘MembershipSum’));
system.debug(‘MembershipsYTD’ + MembershipsYTD);
}
}
}
}
updated question: Any help would be greatly appreciated
https://developer.salesforce.com/forums/ForumsMain?id=906F0000000MMZaIAO
Hi David,
Thank you for your tutorials, I am learning a lot from them. could you please let me know when are you going to release more sessions on your website?
Thank you,
Sinan
Hi David,
Greetings!!
Glad to know the site which helps to learn salesforce coding…
I would like to know where to start apex….I am struggling to write code……..Dont know where to start ….how to learn basics of apex programming……
I want to be good programmer…..Any help on this please….Please guide me….I am losing confidence because of not having coding skills…..
What’s wrong with my site? =)
LOL… Good one
Jose – you need to load every Eric Thomas motivational speech to your iPod, and listed to it every day. Listen to this one in the morning, while getting ready for the day. http://youtu.be/_jHeqfZO69o
You need to want it… Time to Rise and Grind my brother.
This video was so good I made a post on it – thank you David for you inspiration to me and others!!
looking forward to watch it/..
Looking forward for this exciting chapter…..!!!
OOP is very interesting and can empower so many novice programmers….I wish I had more time to learn!!
Im thinking of going full time study, 6 months of intense Java learning and Apex, then start an exciting job.
Who dares wins!
Jose, I was in your exact position not long ago. Quit, and learn to code, or stay on the job, and potentially lose out on the opportunity to do something I loved.
Ultimately, I decided that I did not want to grow old and one day ask “what if?” I wanted to learn badly enough that I would have no regrets even if I failed.
I learned though that the two things, your job and learning Apex, are not opposite tracks. You can still work a 40-50 hour a week job AND learn to code enough that you can get a dedicated job as a coder. Even if you have no freedom in your job to practice any code, you can still learn quickly enough at home and on weekends. 10 hours a week for six months is all it takes!
So – definitely don’t feel like you have to quit your day job to follow a passion! Learning is much easier than you think – consistent practice, no matter how little each time, will get you there!
Hi Dave!
I wish I had your energy! But yeah, for sure, sometimes you need to really dig deep and strive for your dreams.
Something that sets me back is me having to practice SF admin and customization in my spare time rather than on live projects…grrrr. I was hired to implement SF for the company’s Sales team, but in the end, they went cold turkey and chose another CRM. So here I am, one year later, doing SAP and Ariba ERP administration and support (yuck) and leaving SF behind.
Ive had some very juicy SF job offers thrown at me (based in England) and Ive had to turn them down due to my SF skills being a little rusty!
Im in a dilema: to quit and go full SF and Apex VS staying and putting in the extra hours and effort…..I will follow my heart and also, take note of your advice :)
Thank you once again for inspiring me to go forward and do my best!
Oh man Jose, sounds like your job is pushing you away from Salesforce instead of the other way around!
If you don’t choose to take time off or accept a Salesforce job offer, one thing you can also do is volunteer to do admin work for a Salesforce non-profit a few hours a week. A lot of my co-workers broke into the Salesforce industry this way!
Best of luck and let me know what you decide!
David