Java Script Design Pattern

  • Module
  • Prototype
  • Observer
  • Singleton
https://scotch.io/bar-talk/4-javascript-design-patterns-you-should-know

Locality of reference

In computer sciencelocality of reference, also known as the principle of locality,[1] is a term for the phenomenon in which the same values, or related storage locations, are frequently accessed, depending on the memory access pattern. There are two basic types of reference locality – temporal and spatial locality. Temporal locality refers to the reuse of specific data, and/or resources, within a relatively small time duration. Spatial locality refers to the use of data elements within relatively close storage locations. Sequential locality, a special case of spatial locality, occurs when data elements are arranged and accessed linearly, such as, traversing the elements in a one-dimensional array.
Locality is merely one type of predictable behavior that occurs in computer systems. Systems that exhibit strong locality of reference are great candidates for performance optimization through the use of techniques such as the cachingprefetching for memory and advanced branch predictors at the pipelining stage of a processor core.

HTML and XHTML

HTML is HTML written as XML.

What Is XHTML?

  • XHTML stands for EXtensible HyperText Markup Language
  • XHTML is almost identical to HTML
  • XHTML is stricter than HTML
  • XHTML is HTML defined as an XML application
  • XHTML is supported by all major browsers

Why XHTML?

Many pages on the internet contain "bad" HTML.
This HTML code works fine in most browsers (even if it does not follow the HTML rules):
<html>
<head>
  <title>This is bad HTML</title>

<body>
  <h1>Bad HTML
  <p>This is a paragraph
</body>
Today's market consists of different browser technologies. Some browsers run on computers, and some browsers run on mobile phones or other small devices. Smaller devices often lack the resources or power to interpret "bad" markup.
XML is a markup language where documents must be marked up correctly (be "well-formed").
If you want to study XML, please read our XML tutorial.
XHTML was developed by combining the strengths of HTML and XML.
XHTML is HTML redesigned as XML.

The Most Important Differences from HTML:

Document Structure

  • XHTML DOCTYPE is mandatory
  • The xmlns attribute in <html> is mandatory
  • <html>, <head>, <title>, and <body> are mandatory

XHTML Elements

  • XHTML elements must be properly nested
  • XHTML elements must always be closed
  • XHTML elements must be in lowercase
  • XHTML documents must have one root element

XHTML Attributes

  • Attribute names must be in lower case
  • Attribute values must be quoted
  • Attribute minimization is forbidden

Modifying DOM Elements Managed by the Lightning Component Framework

The framework creates and manages the DOM elements owned by a component. If you want to modify these DOM elements created by the framework, modify the DOM elements in the handler for the component’s render event or in a custom renderer. Otherwise, the framework will override your changes when the component is rerendered.
For example, if you modify DOM elements directly from a client-side controller, the changes may be overwritten when the component is rendered.
You can read from the DOM outside a render event handler or a custom renderer.
The simplest approach is to leave DOM updates to the framework. Update a component’s attribute and use an expression in the markup. The framework’s rendering service takes care of the DOM updates.
You can modify CSS classes for a component outside a renderer by using the $A.util.addClass()$A.util.removeClass(), and $A.util.toggleClass() methods.
There are some use cases where you want to perform post-processing on the DOM or react to rendering or rerendering of a component. For these use cases, there are a few options.

DOM: Document Object Model

The DOM is a W3C (World Wide Web Consortium) standard.
The DOM defines a standard for accessing documents:
"The W3C Document Object Model (DOM) is a platform and language-neutral interface that allows programs and scripts to dynamically access and update the content, structure, and style of a document."
The W3C DOM standard is separated into 3 different parts:
  • Core DOM - standard model for all document types
  • XML DOM - standard model for XML documents
  • HTML DOM - standard model for HTML documents

I


  1. Itna na mujhse tu pyar badha
  2. Is kadar pyar he tumse ye Humsafar 
  3. Ik Kone Mein Tha Baitha Jab Mujhe Woh Dikhi Thi
  4. is ishq-o-muhobbat ki, kuchh hain ajeeb rasmein
  5. Is Deewane Ladke Ko, Koi Samjhaye
  6. ishq aur pyaar kaa mazaa lijiye
  7. Ishq hota nahi he sabhi ke liye

Standard Fields that can be encrypted using Shield Encryption

Account
Contact
Lead
Opportunity
Case
Case Comment
Activity (Task & Event)
Contract
List Email
List Email Sent Result

Java Design Patterns


Create Trigger and Class using Rest API

public class CreateClassAndTrigger{

public static void CreateTrigger(){
  Httprequest req = new HttpRequest();
            req.setEndpoint(URL.getSalesforceBaseUrl().toExternalForm()+'/services/data/v27.0/sobjects/ApexTrigger');
            req.setMethod('POST');
            req.setHeader('Content-Type','application/json');
            req.setHeader('Authorization','Bearer '+UserInfo.getSessionID());
           String json = '{ "Name" : "NewTrigger", "TableEnumOrId" : "Account","Body" : "trigger NewTrigger on Account (after insert) {  }" }'; 
           req.setBody(json);

         http httpReq = new http();
         HttpResponse res = httpReq.send(req); 
}

public static void CreateClass(){
 Httprequest req = new HttpRequest();
            req.setEndpoint(URL.getSalesforceBaseUrl().toExternalForm()+'/services/data/v27.0/sobjects/ApexClass');
            req.setMethod('POST');
            req.setHeader('Content-Type','application/json');
            req.setHeader('Authorization','Bearer '+UserInfo.getSessionID());
           String json = '{ "Name" : "NewApexClass", "Body" : "public class NewApexClass{  }" }'; 
           req.setBody(json);

         http httpReq = new http();
         HttpResponse res = httpReq.send(req); 
      }

}

Add a Report Chart to a Console Component

To add a report chart to the sidebars of a Salesforce console, edit the page layout of the records from which to display the chart.

User Permissions Needed
To add custom console components:“Customize Application”
Before you add a report chart component, make sure that the source report:
  1. Is in a folder that’s shared with users who need access.
  2. Is a summary or matrix report.
  3. Contains a chart.
  4. Don't store reports in your My Personal Custom Reports folder.
  1. Go to the page layout editor for the object you’re adding the report component to.
    • For a standard object, from Setup, click Customize | Object | Page Layouts.
    • For a custom object, from Setup, click Create | Objects, and then choose the object.
  2. Click Edit next to the layout.
  3. Click Custom Console Components.
  4. Next to the sidebar in which you want to add your component, choose how to display and organize your components. See Sidebar Styles for Console Components.
  5. Specify the size of the sidebar in the console. When the height or width of the sidebar is below 150 pixels, report charts automatically hide because they become too difficult to read.
  6. Under Type, specify Report Chart.
  7. Choose a report chart that’s been added to the page layout.
    Since page layouts are limited to two report charts, you can add up to two report charts to a sidebar. You can add up to five components to a sidebar and a maximum of eight components to a page layout. You can also hide report charts from pages where they appear as components to prevent duplicate information from showing.
  8. Under Label, type the name for your component as it should display to console users from the sidebar. If you don’t type a label for a report chart, the report chart’s name is used.
  9. Specify the size of the component in the sidebar by selecting height or width, and typing its percentage or number of pixels. If you don’t specify a height or width, the component is automatically sized to appear correctly in a console.
  10. Click Save.

Concept of Person Accout and Business Account in Salesforce.com

Salesforce.com has of two types of Accounts :-

  1. Business Account or normally termed as an Account 
  2. Person Account
The basic difference between these two types of accounts is the business model on which they are based. One needs to understand the business model of the Organization and decide which type of account will meets it requirements. Business Account will work in the B2B Industry i.e. Business to Business whereas Person Account will work in the B2C Industry i.e. Business to Consumer.
 
In Person Account i.e. Business to Consumer Industry there is no concept of Contacts as you are dealing with one individual who is termed as an Account. Example of B2C is loan taken by an individual from a company. 
 
For enabling person accounts, a feature request needs to be raised with salesforce.com and they do the need full. Please remember Person Account once enabled can not be disabled, but they can be used in parallel with the Business Accounts. 
 
The change that happens in your Organization on the enabling of person account is that a new record type is created on account with the name as person account. In Person account record type contacts related list on account will be missing whereas in case of business account record type contacts related list will be present.
 
For both scenarios the contacts and accounts will be saved as two different records in the database. For Person Accounts the contact information will come from the standard account fields which are internally holding the contact information. This is the reason person account record still occupies 4 KB of data; 2 KB of space for account and 2 KB of space for the contact record. For business Account we have no such issues as two separate placeholders for keeping the account and contact information.

Counters