I have a complete and functional app which I developed in salesforce, I have a simple visualforce page and its correspondent controller and of course its correspondent tab.

I have heard about packages [in salesforce] and many other things that may help, but it seems I have to modify the 75% of my code... making a static testMethod which means a lot of work and more.

How can I simple encrypt, hide or call by a simple link the controller in visualforce page?

Is there any way to make this possible? If it is how could I encrypt it or hide it without having to modify all my code?

  • Why would you want to hide the code? You will need to have 75% of your code covered by unit tests - no matter if the code is encrypted or hidden. This also applies if you want to deploy your code to a production environment. – 0ff Jan 22 '16 at 16:12
  • Because the app is for external customers. I don't want that they can be able to see my code. So what should I do to make my 2000 lines of code and 300 methods in [unit tests]? – Rodolfo Lanshore Jan 22 '16 at 16:14
  • why do you think that they can see your code? code is visible to admin only – Himanshu Jan 22 '16 at 16:59
  • Exactly. Let me show you the scenario. The app I developed is gonna be for external customers as I said. So, my customers will provide me the credentials to get into their accounts, I'll create the tab, visualforce page and only paste the code in a new visualforce page and controller. – Rodolfo Lanshore Jan 22 '16 at 19:39
  • 1
    The right way to develop a Salesforce App this way is a managed package. This way, your code stays with you and no customer can see it. You will, however, need test coverage. Note that 2000 LoC can be tested in way, way less than 300 methods. This is not how coverage works. It means that the 2k LoC must be run (and results should be asserted!). Complex test may lead to more code, of course. – 0ff Jan 22 '16 at 20:45

You can get intellectual property protecting using a Managed Package (https://help.salesforce.com/apex/HTViewHelpDoc?id=sharing_apps.htm). Note that you will have to use custom settings to capture application customization for your end users since any packaged apex is hidden and any packaged visualforce is not editable. Your customers than then use a url to install or upgrade your application.

  • It says I need to have 75% of my code in unit test. Does it mean I have to re-write all my code again?? – Rodolfo Lanshore Jan 26 '16 at 15:49
  • You do not need 75% of your code IN unit tests. You need at least 75% of your code COVERED by unit tests. This means that if you have 100 lines of Apex Code (excluding comments and test methods), your apex unit tests must test 75 lines of that code. Salesforce has lots of good resources on unit testing, but I suggest you start with developer.salesforce.com/page/How_to_Write_Good_Unit_Tests. – dsharrison Jan 26 '16 at 18:02

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.