I am amazed to share the First apex class I wrote back in 10/17/2014.
Apex class used to upload an attachment referencing Parent Id in the Visualforce Page.
Salesforce attachment represents a file that a User has uploaded and attached to a parent standard or custom object record. If the user has created permission on a parent object, then only he/she can able to attach an attachment to the parent object.
You can have a look at the amazing video by Jeff Douglas
When Did you code first time and which functionality was that?
When you declare a method or variable as static, it's initialized only once when a class is loaded. All static member variables in a class are initialized before any object of the class is created. Indeed they aren't transmitted as part of the view state for a Visualforce page.
Using static variables will cause only one instance of the variable to be loaded when the application loads and that variable will not go out of memory until the app is closed. It holds information that is common to all instances on a class and It is shared between them instead of being created a new with each instance.
while
Transient keyword to declare instance variable that can not be saved and should not be transmitted as part of view state for visual force page.
Basically, View State is an encrypted, hidden field on a Visualforce page that keeps track of Apex controller state & Visualforce page state between server requests. This field is only generated when there is a tag present on a page.
ViewState is only used on a single page that handles postbacks. Once you redirect to the new page, the ViewState is lost.
The Whole Process of Calling is like this :
A. URL Requested
B. Apex Controller Instantiated on Server
C. Controller State Serialized & Encrypted to View State
D. Page Markup Sent to Browser & Rendered
E. View State Decrypted & Deserialized (for Postbacks)
View State Automatically keeps track of field values for you and Allows for easy AJAX functionality. In order to remove View State Error, we use 4 methods.
A. Reduce Number of Components
B. Use the transient Keyword
C. Use JavaScript Remoting
D. Use the Streaming API
References: https://developer.salesforce.com/docs/atlas.en-us.apexcode.meta/apexcode/apex_classes_keywords_transient.htm