Design Patterns in Salesforce (Ep. 1) – What Are Design Patterns?

When Should You Learn About Design Patterns?

When you first start learning about software development, I’d recommend against beginning with design patterns. Why? If you start with design patterns, you might be misled and start thinking that all of your code must conform to a design pattern, which isn’t the case and makes the process of learning how to code even more complicated. You’ll end up confused and overwhelmed, and your code could end up overengineered and wonky.

Instead, I encourage you to start with the basic building blocks of code, and design a few applications without using any design patterns, and that can serve as a foundation for more advanced functions, such as design patterns, later on. After you’ve mastered the basics of coding, and experienced a handful of difficult development situations, you’ll be ready to go back and learn about design patterns, and use them to solve tricky and difficult problems or situations in the code you develop.

Also, I recommend you learn more about design principles before getting into design patterns since those principles guide the design patterns. Design patterns will make much more sense once you’ve got a handle on the underlying design principles. To learn more about design principles, you can also check out the book Clean Code by Robert Martin, a fantastic resource for any budding code writer.

What Are Design Patterns?

Once you’re comfortable with the basics of coding and design principles, it’s time for the third step: understanding design patterns! True to their name, design patterns are coding patterns that can help you fix tricky situations you’ll find yourself in while coding, but that’s just the start. Design patterns can also make your code more flexible and easier to read, and be more performant when you’re done writing it.

Suppose you wrote something, and it always takes 2-3 minutes to load. You might be able to use the Singleton pattern to only load something that is very time-consuming once, which will likely cut down on the page-load time. And that’s just one example. Design patterns use their patterns to fix practically any problem or mess you’ve got in your software, and certain design patterns can be prescribed for certain coding issues.

You can think of them as medicine for your code, such as a doctor prescribing either Advil, Tylenol, or Ibuprofin for your headache. Any three of those would work 90% of the time for your headache, and in the other 10%, you may need to try something else. It’s the same with design patterns; none of them is a guaranteed miracle fix for a coding issue, but they generally work, and a skilled developer can prescribe one for a development problem.

Which Design Patterns Should You Learn?

Make no bones about it: there are a lot of design patterns out there! I couldn’t possibly list them all. For now, though, we can narrow the field down to 23 particular design patterns that are best learned first, and they are widely used, too (and they’re well-regarded, too). They are described as the “gang of four” design patterns since they were designed by a quartet of people calling themselves the gang of four. They even wrote a book together on this topic titled Design Patterns: Elements of Reusable Object-Oriented Software. You can check it out to get plenty of in-depth information.

These 23 design patterns are sorted into three categories: behavioral design patterns, creational design patterns, and structural design patterns. These include design patterns that you’ve probably heard of before, such as the Singleton pattern or the Observer pattern. Remarkably, these design patterns are almost 30 years old, but are still in use today, proving just how well-designed and universal in usage they are.

Later in my series, we will review all 23 of those design patterns and how to implement them in your own code. We will also go over some basic areas of object-oriented programming, just in case you’re not familiar with that topic, along with inheritance, encapsulation, and polymorphism.

That’s all for now. I hope that in the future, you’ll master all 23 design patterns and put them to work in your own development tasks and see for yourself just how handy they can really be! Until next time!

Get Coding With The Force Merch!!

We now have a tee spring store setup so you can buy cool Coding With The Force merchandise! Please check it out! Every purchase goes to supporting the blog and YouTube channel.

Get Coding With The Force Merch Here!


Check Out More Coding With The Force Stuff!

If you liked this post make sure to follow us on all our social media outlets to stay as up to date as possible with everything!

Youtube
Patreon
Github
Facebook
Twitter
Instagram


Salesforce Development Books I Recommend

Advanced Apex Programming
Salesforce Lightning Platform Enterprise Architecture
Mastering Salesforce DevOps
Apex Design Patterns Book

Good Non-SF Specific Development Books:

Clean Code
Clean Architecture
Design Patterns: Elements of Reusable Object-Oriented Software Book

Salesforce Apex Master Class (Ep. 4) – What is an IDE?

What is an IDE?

Let’s review what an IDE is and why it’s so incredibly helpful to you as a developer in Salesforce and beyond. As a developer, you’re encouraged to use an IDE, since it can make your work so much easier.

An IDE is an integrated development environment, where you can combine a wide variety of development tools to do your work much faster and more efficiently every day. Now, let’s check out an example (below) of an IDE at work. This particular IDE is IntelliJ, and I’m using a plug-in that allows me to do Salesforce development called the Illuminated Cloud 2 plug-in.

Demoing the Benefits of Using an IDE

An IDE like IntelliJ here will make your life, and the lives of your developer teammates, so much easier. In this interface, I have my code editor so I can write Apex code or a lightning web component, among other things. I can also analyze debug logs here in this IDE, or even run anonymous Apex. But why should you use an IDE and not just a developer console? An IDE like IntelliJ has many features that developer consoles don’t.

The first major benefit is if you want to know everywhere that a class is used in your codebase, you can simply copy the name of the class, then press CTRL-shift-F, and then the IDE searches for the class in all of the code in your Salesforce environment. There are also a litany of other hotkeys that will make traversal through your code base considerably easier. Shortcuts like that aren’t available in the developer console.

Autocomplete is another major advantage in using an IDE like IntelliJ with Illuminated Cloud 2. You can type “system.” and the IDE knows methods are available for that system class in the Apex language. So, you it will present to you a list of autocompleted methods that you can select from and have your code auto-completed for you. By contrast, the Salesforce developer console’s auto-complete features struggle and sometimes just outright do not work. This makes it easy for programmers, like you, to know all your options without having to look them up elsewhere in documentation.

There’s even more an IDE can do for you. For example, you can enable version control, allowing you to create local backups of your code, so you can revert back if something goes wrong. You sure can’t do that in a developer console! Meanwhile, you can find more useful stuff in the settings menu too, such as setting all the defaults for code style for a specified language, such as Apex or Javascript. All that will be automatically formatted for you. You can export all this to other developers on your team too, and make everyone’s code consistent. That’s an example of the convenient, time-saving efficiency of an IDE.

Another option is to run your Apex tests in the IDE, and it will display coverage next to the classes that it tests. Yes, you can do that in developer consoles too, but an IDE like IntelliJ will conveniently show you which classes the test covered, and even break down what happened in those tests, such as line coverage. Pretty cool, huh? And this is just the start; an IDE can do a whole lot more!

To recap, an IDE like IntelliJ will make your life as a programmer faster, more convenient, more direct, more consistent, and more intuitive than ever before, acting like a souped-up developer console with more options so you can get more work done. Give it a try, and see what you can accomplish with the power of an IDE! Until next time!


Get Coding With The Force Merch!!

We now have a tee spring store setup so you can buy cool Coding With The Force merchandise! Please check it out! Every purchase goes to supporting the blog and YouTube channel.

Get Coding With The Force Merch Here!


Check Out More Coding With The Force Stuff!

If you liked this post make sure to follow us on all our social media outlets to stay as up to date as possible with everything!

Youtube
Patreon
Github
Facebook
Twitter
Instagram


Salesforce Development Books I Recommend

Advanced Apex Programming
Salesforce Lightning Platform Enterprise Architecture
Mastering Salesforce DevOps
Apex Design Patterns Book

Good Non-SF Specific Development Books:

Clean Code
Clean Architecture
Design Patterns: Elements of Reusable Object-Oriented Software Book

Salesforce Apex Master Class (Ep. 3) – What is the Apex Programming Langage?

The Salesforce Definition of What the Apex Language is

Let’s go over what Apex actually is, and when you, as a developer or administrator, should use it when creating custom functionality in your Salesforce orgs.

Apex is a proprietary development language created specifically for Salesforce’s own platform. Apex looks and feels similar to Java (not Javascript) or C#. The Apex language allows you to build custom functionality that Salesforce’s point-and-click tools can’t support or do on their own. This means that with Apex, you can expand Salesforce’s functionality and build absolutely anything that you or your users can dream up for your Salesforce instance. The sky is the limit with the power of Apex! Go ahead and give it a try, and see what you can do with it.

A Simpler Explanation of What the Apex Language Is

Apex is a strongly typed object-oriented programming language, but what does that really mean? Let’s look at an example.

public class OpportunityCalculator {
    
    Integer numberValue = 1;
    String oppName = 'Cool Opp';
    
    
    public Integer addOpportunityValues(Integer oppValueOne, Integer oppValueTwo){
        Integer oppValuesCombined = oppValueOne + oppValueTwo;
        return oppValuesCombined;
    }
    
    public Integer substractOpportunityValues(Integer oppValueOne, Integer oppValueTwo){
        Integer oppValuesCombined = oppValueOne - oppValueTwo;
        return oppValuesCombined;
    }

This example is a representation of a calculator for opportunities in our org. Like a real, physical calculator, this code calculator could potentially have the ability to add, subtract, multiply, and divide value. My opportunity calculator class above uses methods to add and subtract values, all while creating a representation of an object and the many ways in which that object can interface with its users (such as pressing a calculator’s buttons to do some math). There’s much more I could say about object-oriented programming, but that can should probably wait for a future blog post. It’s too much to unpack here, but eventually, we’ll check it out together!

There are four key things you need to know about object-oriented programming: encapsulation, abstraction, inheritance, and polymorphism. If you’d like to know more about those four in greater detail, check out my video over OOP in Apex here!


What is a Strongly Typed OOP Language?

public class OpportunityCalculator {

Integer numberValue = 1;
String oppName = 'Cool Opp';


public Integer addOpportunityValues(Integer oppValueOne, Integer oppValueTwo){
Integer oppValuesCombined = oppValueOne + oppValueTwo;
return oppValuesCombined;
}

public Integer substractOpportunityValues(Integer oppValueOne, Integer oppValueTwo){
Integer oppValuesCombined = oppValueOne - oppValueTwo;
return oppValuesCombined;
}



At a very high-level, object-oriented programming (OOP) is the representation of an object and its functionality in code. Now, what is a strongly typed language? First, consider variables, or a way to represent a value. When I create a variable called numberValue and I set it equal to 1, I’m declaring that variable as an integer, or a way to declare a number in Apex (among many other development languages). I’m declaring it as type Integer, but note that if I just declared that 1 as a number value without “Integer,” Apex wouldn’t accept it, nor would Apex allow me to save it like that. In short, Apex needs me to specify the type of value I’m trying to store: Integer. I must also specify what kind of value I want to return from those methods if I want to return something.

So, when I declare my method, I’m saying that when my method is done executing, it will return an integer. In programming languages that aren’t strongly typed, you don’t have to declare variables as a specific type (like Integer). Javascript is an example, where you can simply say that the variable you’re declaring equals 1 or Cool or whatever you can think up, and you don’t define a type for those variable.

In short, strongly typed OOP language means you’ve got to tell the code what it’s supposed to return and what your variable types are.


When Should You Actually Choose to Use Apex?

When exactly should you use the Apex development language? It’s a bit subjective, but also not. Often, you’ll find that out-of-the-box, point-and-click Salesforce stuff doesn’t work well with what your users actually need so they can do their job, and that’s when you use Apex. As a Salesforce user or admin, you must know all the administrative capabilities and know how to create new objects with their own fields, among other things. This is so you know when it’s proper to use administrative tools, or when you should use custom development instead.

Usually, you’ll need to use Apex development in one of two different scenarios. The first is, as mentioned earlier, when your out-of-the-box, point-and-click tools aren’t enough to build what you’re trying to make for your users. The second is when your org scales up to a huge size with lots of users (such as the 500-user mark), where your point-and-click tools can’t handle the sheer volume of daily transactions your users are making. When you reach that point, it’s time for Apex code to take over and work its magic!


Get Coding With The Force Merch!!

We now have a tee spring store setup so you can buy cool Coding With The Force merchandise! Please check it out! Every purchase goes to supporting the blog and YouTube channel.

Get Coding With The Force Merch Here!


Check Out More Coding With The Force Stuff!

If you liked this post make sure to follow us on all our social media outlets to stay as up to date as possible with everything!

Youtube
Patreon
Github
Facebook
Twitter
Instagram


Salesforce Development Books I Recommend

Advanced Apex Programming
Salesforce Lightning Platform Enterprise Architecture
Mastering Salesforce DevOps
Apex Design Patterns Book

Good Non-SF Specific Development Books:

Clean Code
Clean Architecture
Design Patterns: Elements of Reusable Object-Oriented Software Book

Salesforce Apex Master Class (Ep. 2): How to Set Up a Free Salesforce Developer Org

Welcome to the second episode of my Salesforce Apex Master Class! Today, I’ll show you how to set up your own Salesforce developer org!

How to Set Up a Free Dev Org!

It’s easy to set up your own Salesforce developer org, even if it’s your first time using the Salesforce platform. First, you’ll visit developer.salesforce.com/signup, then fill in your information and dive right in. It’s quick and easy, but take note that with Salesforce, you’re living in “the cloud” (aka sharing space on a server with other businesses), and there are limits imposed on your orgs because of that! Limits are imposed on things like, the amount of data you can store in your org or the number of queries you can do in your org in a single execution context.

In your developer org, those numbers tend to be pretty low compared to what you’d experience when using regular organizations. I’ve found some ways to bypass those limits, such as with “big objects”, but I probably should not suggest them as they certainly aren’t “best practice” and I’m not sure Salesforce would condone them!

One note when signing up for Salesforce: if you’ve ever created a Salesforce org or if you’ve been placed in a Salesforce org before, and you used your email address as a username in those orgs anywhere at all, you can’t reuse that email address (usernames must be unique across ALL instances of Salesforce in existence, not just your own org). Instead, you’ll make up something new, or a least revise your email address when using it as a username. Such as adding a few letters or numbers at the end.

Once all that’s done, you’ll receive an email that will inform you that your Salesforce org has been created for you! It’ll take a few minutes to get that email, though, so be patient. Next up, you’ll verify your new account via that email you just received. You’ll click “Verify my account” and set up your password. Once all that’s done, you’ll be looking at your very own Salesforce org, and you’re ready for work! It’s quick, easy, and doesn’t cost you a dime.

That’s all for now. Thanks for reading, and happy coding!


Get Coding With The Force Merch!!

We now have a tee spring store setup so you can buy cool Coding With The Force merchandise! Please check it out! Every purchase goes to supporting the blog and YouTube channel.

Get Coding With The Force Merch Here!


Check Out More Coding With The Force Stuff!

If you liked this post make sure to follow us on all our social media outlets to stay as up to date as possible with everything!

Youtube
Patreon
Github
Facebook
Twitter
Instagram


Salesforce Development Books I Recommend

Advanced Apex Programming
Salesforce Lightning Platform Enterprise Architecture
Mastering Salesforce DevOps
Apex Design Patterns Book

Good Non-SF Specific Development Books:

Clean Code
Clean Architecture
Design Patterns: Elements of Reusable Object-Oriented Software Book

Salesforce Apex Master Class (Ep.1): What to Expect to Do as a Salesforce Developer

What is Salesforce?

You may have heard of Salesforce before, and that developers on this platform get paid good money, but what exactly is Salesforce, anyway? No matter how much you earn, your work will suffer unless you actually enjoy what you’re doing. So before you dive into this career, let’s discover what Salesforce is and what you can expect to do as a developer on the platform!

Salesforce is a customer relationship management (CRM) platform, a vital tool for marketing sales, commerce, service, and IT teams to work in unison and be of service to their customers anywhere and everywhere. As of this writing, Salesforce stands as the #1 CRM platform available, overtaking competing platforms such as Siebel, Oracle, and SAP, among others. For context, CRM’s market share in 2015 was 19.7%, and as of today, it rose only slightly to 19.8%, with minor fluctuations. Meaning, CRM and Salesforce are probably going to remain steady for the foreseeable future, though there’s no guarantee of that. If you’re entering the Salesforce Ecosystem just because it’s the #1 CRM platform, don’t bank on that, even though it hasn’t for awhile, it could shift at any time. At one point (not long ago) Siebel was the #1 CRM platform, now you rarely hear of them.

That said, whether or not Salesforce stays at #1, it’s an outstanding platform that can do you a lot of good, and if you know your stuff, it could pay off handsomely. Now let’s go into more detail.


What You Will Likely Build as an SF Dev

As mentioned above, you’ll most likely use Salesforce for work in IT, marketing sales, commerce, services (such as help desk services), and a few others. IT, marketing sales, commerce, and services are probably going to be the central core of your work, with a few exceptions, so those are a good starting point for your use of Salesforce. Personally, I worked on 50 projects for 20 different clients using Salesforce, nearly all of them involving IT, marketing sales, commerce, and services.

So, what can you expect to build? You could build configuration point-and-click administration stuff and custom development in those areas described above, for example. I built extremely customized sales cloud instances and very large custom marketing applications that can sit on top of Salesforce or to be within a particular organization’s instance, just to name two examples.

Your overall goal: to take a client’s older or underperforming platform and upgrade it with Salesforce. This work can be done pretty quickly, too, and Salesforce’s brand prides itself on that fact. Once your work is done, any team working in IT, marketing sales, commerce, and services can coordinate their work and do it faster, more easily, and with better analytics with their daily work.

With that in mind, you might expect to move into Salesforce pretty quickly for two reasons: one, because of Salesforce’s reputation for speed, and two, because Salesforce offers a huge shell for making it easy for devs to get their work done faster than ever. Along the way, you’ll also want to understand Salesforce’s administrative side, through which you will build database tables, and set up anything else you’d have to develop on your own. When you use Salesforce, a lot of the work is already done for you.

In short, it’s incredibly important for you to get a handle on all this admin work with Salesforce. Some might disagree, which is fine, but having worked as a Java and PHP developer myself, Salesforce’s admin features can cut out a lot of clutter for developer work so I can focus on what matters most: writing code. I greatly enjoy Salesforce’s streamlined feel for my development work, and it was an easy and enjoyable transition to this platform while cutting out time-consuming remedial work. Perhaps the same will be true for you, too!


De-Mystifying Some SF Dev Misconceptions

You might have heard some misconceptions online about Salesforce, such as people saying that you don’t have to write much code with Salesforce, or that outdated languages are being used with it, or that there are few customization options with this platform, among other issues. Those were somewhat true in the past (and still a bit true today), but Salesforce is stronger and more effective than these rumors would suggest. Let’s review.

Salesforce didn’t have much IDE support early on (I have a separate video on the topic), but fortunately, IDE support is everywhere today. Meanwhile, maybe you’ve heard that you can’t do source-driven development in Salesforce, which would be a serious issue. Good news: you absolutely can use source-driven development with Salesforce, such as with scratch orgs, if a developer wants to.

As for outdated programming languages: yes, you’ll use the slightly dated language Apex, which can be compared to what Java was like 6-7 years ago. But don’t let that discourage you! No matter its age, Apex provides nearly everything you need for work in Salesforce, just lacking a few of the most advanced capabilities of coding languages. If that’s ever a concern for you, try using open source repos to fill in the gaps.

Another rumor says that with Salesforce, you can’t work with modern front-end technologies. Up until two years ago, that was true, but with today’s lightning web components, you can pretty much perform whatever modern UI front-end development you need.

The only caveat to working with Lightning Web Component’s within Salesforce is lightning locker service, among a few other issues. Locker Service, which is due for an update soon which might render this sentence incorrect, makes it challenging to use outside JavaScript Libraries. Many JS Libraries that you could easily import into a Node JS project (or equivalent) would require you to re-write some of its code (or a lot of its code) just to get it to function inside of an LWC due to Locker Service restrictions.

Typescript also won’t work out very well in Salesforce, for example, being hampered by a variety of problems. While it can be done there is just so much out-of-the-box Salesforce stuff that it won’t cooperate with that it renders it fairly useless.

As a developer, you’ll have endless options with Salesforce, and I myself have made hundreds of custom applications with Salesforce. You’ll simply have to keep those limitations in mind and plan accordingly. Once in a while, for example, you might build an application elsewhere, such as with AWS, then pipe it into Salesforce. Anything you can’t make in Salesforce, you can just slot right in.

On a final note, some folks might think that anyone who’s using Salesforce is mostly an admin, just doing point-and-click stuff instead of coding. This is simply not true, as a developer on the platform you’ll be expected to do development every single day. I’ve been a developer on the Salesforce platform for the past seven years, I’ve done development work every single day. Coding comes first and foremost with Salesforce as a developer on the platform, I can assure you, and it’s simply a pleasure for any developer like me to use.

Salesforce, in short, isn’t for everyone, but for the right developers, it’s a dream come true. Give it a try, and see what you can create! Until next time!


Get Coding With The Force Merch!!

We now have a tee spring store setup so you can buy cool Coding With The Force merchandise! Please check it out! Every purchase goes to supporting the blog and YouTube channel.

Get Coding With The Force Merch Here!


Check Out More Coding With The Force Stuff!

If you liked this post make sure to follow us on all our social media outlets to stay as up to date as possible with everything!

Youtube
Patreon
Github
Facebook
Twitter
Instagram


Salesforce Development Books I Recommend

Advanced Apex Programming
Salesforce Lightning Platform Enterprise Architecture
Mastering Salesforce DevOps
Apex Design Patterns Book

Good Non-SF Specific Development Books:

Clean Code
Clean Architecture
Design Patterns: Elements of Reusable Object-Oriented Software Book