You need to sign in to do that
Don't have an account?
csfdc
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:
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
}
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?
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
Alain, I'm curious why you've added the while loop. Can you explain that to me?
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.
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.
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?
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).
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.