function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
csfdccsfdc 

SFDC developer interview tech assessment question on pseudocode function

I want to put this out to the sfdc developer community to see if anyone has some feedback on a question I've received as part of a technical assessment for a Salesforce developer role. 

Specifically, a hiring manager has asked me the following:
 
Given the following 2 classes:
Class Folder
name: string
parent: Folder
 
Class File
name: string
parent: Folder
 
Complete the following function in pseudocode to return the full string path of a file.
 
function getFullFilePath(file: File): string {
         …
return path
}
My question is can someone please explain to me how you would respond to this? Also, what is your interpretation of what is being asked?

 
Chandra ViswanathChandra Viswanath
My interpretation here is : how will one get the Full path of a given file (the file itself will be the parameter here), additionally, since this can be nested several layers deep, you will have Folder inside Folder... all the way to File.
Alain CabonAlain Cabon
It is just for writing pseudo code and it is not related with Salesforce.
Nor is it a question related with a "real life" language where you get getFullFilePath(file: File) directly without writing a single line of code.

It is a theoretical exercise How to get all the parents with a loop?

From File file, you get the first parent (folder) and from this first parent, you get its own parent and so on up to the root.

/folder1/folder2/file.txt : File file: name: file.txt;  parent: folder2 > Folder: name: folder2 , parent: folder1 > Folder: name : folder1, parent : null

you should return: /folder1/folder2/file.txt 

function getFullFilePath(file: File): string {
    string  fileDelimiter = system.file.delimiter;   //   / or \
    string path = file.name;       // file.txt
    Folder folder = file.parent;  // folder2
    while ( folder != null ) {    
           path = folder.name + fileDelimiter + path;   // folder2/file.txt then folder1/folder2/file.txt    
           folder = folder.parent;     // folder1  then null
      }    
   path = fileDelimiter + path;   //  /folder1/folder2/file.txt
   return path

 
csfdccsfdc
Thank you Chandra, thank you Alain.

Alain, I'm curious why you've added the while loop. Can you explain that to me? 
Alain CabonAlain Cabon
 in reality, we never get  getFullFilePath(file: File) , like that.

We just use a predefined functon in java or Apex but here it is pseudo code with very simple objects and functions.

It is a simple procedural solution with objets (OO) but you can imagine a function writen for a functional language or a recursive function, is that your question?   They didin't ask for a recursive function but you can also write a recursive one as a solution but there is problem because the parameter of getFullFilePath is File and not a folder. File should extend Folder for a recursive solution excepted if you use an internal function.

It is not java, javascript or Apex here.

The closest syntax is typescript but it is not that language that must be used for the solution, it is pseudo code.

In java, you just write that.
File file = new File("yourfileName");
String path = file.getAbsolutePath();

They imagined "fictive" limited classes for an object oriented program in pseudo code.

folder.name + fileDelimiter + path;   should be wrtiten: concatenate ( folder.name , fileDelimiter , path ) also perhaps

But pseudo code is a free syntax. You can find some tries of standardization but the only goal with pseudo code is to be understood properly without a specify language.

They just test if you answer : string path = file.getAbsolutePath();  direct and bad solution just because you have used it in java.

 
csfdccsfdc
Alain, Java's getAbsolutePath() is exactly where my head was at. 

My question is actually really simple. Why did you include a Control Flow Statement (the while loop) in your pseudocode? I had imagined that you did so for the purpose of error handling (my frame of reference was avoiding a Null Pointer exception in Salesforce). Did you include it in your pseudocode for that purpose or for something else?
Joy BingJoy Bing
If you have just bought a Canon product you must be looking out for easy ways to complete your Canon Printer Setup. We bring for you the simplified procedure of Canon Printer Setup via Canon.com/ijsetup. You can read the step by step guide that we bring for you and then easily do your Canon Printer Setup on your own. 
 
Alain CabonAlain Cabon
Show us your solution ( String path = file.getAbsolutePath();  bad , it is not java for the solution but pseudo-code based on very simple objects )

You must not write a solution with functions specific to a language here.

For example, if the question was "write a sort algorithm for a list", you could also write all the time just: mylist.sort();   ( because you know that this function exists in another language) but that doesn't prove that you know how to write a sort algorithm (you just know how to call a algorithm via a function, it is very different ).

If the question was "how can you sort the list mylist in Apex?" you could write "mylist.sort();" for the solution (language specified in the question).
 
David Mark 11David Mark 11
AOL Mail is well known for its fully secure, reliable and lightning-fast email services. It gives you some of the best features, excellent tools and user-friendly interface that the latest technology can afford. In order to experience the performance of this outstanding mailing service, you can opt for the convenient AOL Mail services.  
 
sukha kalasukha kala
Nowadays, downloading the Alexa app for Windows PC has become easier than before. You can download the Alexa app for PC (https://downloadechodotsetup.com/download-alexa-app-for-pc/), iPhone, Mac, Windows 10, Android phones, etc and connect it with your Echo device very easily. There are two methods of downloading the Alexa app for PC. First, You can simply go to the Microsoft store located in the taskbar of almost all windows 10 computers.
There you can search for the Alexa app and download it by clicking on the get button. You can log in to it and get it working by following some on-screen instructions to set it up. Second, You can also go to Alexa.Amazon.com by entering it into the address bar of your web browser and login into it with the help of your Amazon Account’s login credentials. That is the method in which you can set up your Echo device without actually installing or downloading the Alexa app for your devices.
Sandy MaxSandy Max
Canon printers are one of the essentials in every office as well as households. To start using your Canon product you can read all required information at Ij.Start.Cannon. The process of the setup of printers is available at Canon.com/ijsetup. Of you are still confused about something, then quickly get in touch with the experts here.