How to analyze and decide whether used or not in sfdc.com? - apex

I am on-boarded into a project where there are existing Apex Class, Apex Trigger, Aura Component Bundle, Custom Object, Lightning Component, Visualforce Component, and Visualforce Pages.
I am given a task to find out which of there components are currently being used in the sfdc.com system.
Should I start to go through the functional requirement documents first and understand how the system is and then check the code?
Or is there any tool which will help me in showing which sfdc.com components are being used and which are not being used?
Does show dependencies button help in this regard?
Also, for the apex class components which are being used how do I decided from where to start writing the test classes?

Interesting question but might be better for https://salesforce.stackexchange.com/, your problem isn't really a specific coding issue...
Start with running built-in tools that should give you some degree of overview:
Setup -> Storage Usage (so you'll see which objects have 0 records)
Setup -> Optimizer (produces a massive PDF but good overview of over-configured areas which might be maintenance pain, users who don't log in too often, unused reports...)
(At end of Optimizer report you should have bunch of resources / links for example to tool that analyses usage of custom fields, how many % are actually populated)
Setup -> Lightning Experience Transition Assistant -> Get Started -> Discover Phase -> Evaluate... -> Check Readiness. Horrible, I know. But will tell you which Visualforce pages were accessed most recently. Or which buttons aren't on page layouts so if people can't click to get to a VF page - they probably can't run it and could be deleted.
These aren't pixel-perfect, SF confirmed to me that Optimizer looks only at certain standard objects & custom ones but not all (I had significant problems hidden in std object that isn't checked, had to pull info from SF backend manually) but it's a start.
In another question you wrote you don't have any developer tools (Eclipse IDE, VScode etc), just dev console. This will limit your ability to just search the project for references to class X... On VF pages "Where is this used" should help you a bit. There are some browser plugins you might want to check out (https://chrome.google.com/webstore/detail/salesforce-advanced-code/lnkgcmpjkkkeffambkllliefdpjdklmi) or there might be some SF plugins on AppExchange...
Where to start writing unit tests? Heh :) Ideally business would be able to point you in general direction of functionality that most often changes / breaks / is most critical and therefore would benefit from nice harness of tests so maintenance developer won't break functionality.
Failing that you can choose to focus on top 10 classes that have most non-covered lines (attacking them should give you quickest coverage % gains). What I'm trying to say if you have class that has 60 / 100 lines covered by test and another that has 2 / 4 covered - it's better to attack the 1st one, even though it has higher coverage %.
After running all tests in go to Developer Console -> Query Editor. On the bottom tick the checkbox for Tooling API. Query similar to this should be a good start:
SELECT ApexClassorTrigger.Name, NumLinesCovered, NumLinesUncovered
FROM ApexCodeCoverageAggregate
ORDER BY NumLinesUncovered DESC
LIMIT 10

Related

Delphi: How to structure multi-device application with native controls?

or "How to decouple UI from business logic in Delphi?"
Each target platform has its own set of native firemonkey controls (Windows=VCL, MacOS=TMS mCL, Android=D.P.F, iOS=TMS iCL and D.P.F). The new FireUI (multi-device form designer) is a great solution for styled components, but not for native components because it still requires the same component on the master pane to support all platforms. As you cannot mix them on the same form, it completely breaks the whole idea with Delphi.
A lot of developers would say that Delphi is the broken approach, see "Why FireMonkey is so fundamentally wrong in every aspect". However, the premise for this question is NOT to argue against Delphi, but to get the best results out of what it does offer.
The conclusion is then that for each form in your application you have to make a separate form for each target platform. This leads to these questions:
Challenge 1: How to include different form files in your project depending on your target platform?
Solution 1: include all of them, i.e. MainForm_IOS.pas, MainForm_Android.pas, MainForm_Win, MainForm_OSX.pas, and then use compiler directives inside the files, so only the content of one of the files is active. Disadvantage: a large application can have many forms (we have around 40), so we are talking about a large number of included files.
Solution 2: Do not include them in the project, but instead just place them in seperate folders. Then you can add the matching folder to the search path for each target platform. Disadvantage: They will not show up in the Project Manager, so it will slow down the workflow every time you need to find a file.
Solution 3: Create a project for each target platform. Disadvantage: Every time you add new units or change common project settings you have to (remember to) apply it to all projects.
Update: As suggested in the Malcom Groves video, placing all the business logic in a package will remove the disadvantage from Solution 3. So I consider solution 3 as the best approach.
Challenge 2: How to connect the different device forms to the (same) business logic?
Possible solution: Create a "Helper" class that contains all the code you would normally have in the form unit.
Update: This "Helper class" is actually what the MVVM calls a ViewModel. What I need seem to be a MVVM framework that can support the databinding. I have made another question about that.
Any input and suggestions about best practice are welcome.
For challenge 1:
You can conditionally link in your FireMonkey form resources depending on the compile target:
{$R *.Windows.fmx MSWINDOWS}
{$R *.Macintosh.fmx _MACOS}
etc.
This is excatly what the XE7 Multiview designer does, but I see nothing against using this mechanism to link whole form files conditionally in to your executable. Of course you might also want to ifdef the corresponding units in your project file.
For challenge 2: Just use some form of Model View Controler logic. So your platform dependant forms will talk to a platform independant controler.

UI Automation Verify v/s UISpy - The way they find UI elements

I am trying to automate UI interactions for a C++ MFC application. I tried to find elements' automation ID using UISpy and UIAVerify tools. I am on win2k3.
There is a tab control, the automation ID of which is visible to UISpy but not to UIAVerify.
The issue is - it is not visible even to the C# code that I write using Project White framework or ui automation framework of .net 3.0.
I want to get handle to this control the way UISpy gets it. Is there any way I can find out how UISpy does it?
Thanks!!!
UISpy is likely using Microsoft UI Automation under the covers. You can see how this works from this example*. There are all kinds of conditions on AutomationElement which you can use to locate them.
I've only worked with WPF tabs, but found it really, really hard to locate them by Automation Id. Instead I've been using the AutomationName property, with the title on the tab as the value. Not sure if White supports this, but I'm pretty sure you can get the original AutomationElement out and use it as per the example.
You'll also probably be looking for something supporting the SelectionItemPattern (there's a SelectionItemIsSupportedProperty), and you'll need to use the pattern to select the tab and make it active before you can see anything in it.
Please comment if you need any more info. It might help to know what the structure of your container with tabs in is.
*Declaration of interest since I wrote this.

Rehosted Workflow Designer and ToolBox double click

1 . I have Toolbox for Activity where I have Activities listed and on right side I have designer where Workflow designer is placed. From my Toolbox I can drag and drop Activites into designer It works fine. Now to increase the usability experience I want to double click on Activity in toolbox and it should be added automatically into desinger within specified "Sequence" activity as the second last activity in sequence workflow ? How can I do this ?
I have long running workflow which runs for 3-5 minutes; I want to give flexibility to end user to Cancel/Stop/Abort workflow while workflow is in execution. How can I do this ?
I am using Toolbox where I have listed down activities; at top of Toolbox it gives Searchbox; This search box gives search based on first letter; now I want to search for anywhere in the text...
I am using workflow designer as hosting Workflow and I use WorkflowInvoker to invoke my workflow; so what is best practice to Cancel/Stop executing workflow ?
To enable double clicking in the ToolboxControl, set the AssociatedDesigner property to the live instance of the WorkflowDesigner.
Might work better if you asked one question per posting...
As for your question on cancel/stop/abort your host application can do this (depending on how you host the workflow).

GWT Lazy Loading

I want to develop a GWT application. The application contains 8 modules and all the modules run in a single page.
I have links for all the 7 options on the top.
When the page loads I want only the home content to be loaded and displayed.
Only when the user clicks the menu options, the menu content should load.
Can anyone suggest the best way to achieve this.
This has been addressed in GWT 2.0... First you'll remove the separate entry points you have for each module - since they're all on the same page, you only need one entry point per page.
Then you can use the GWT.runAsync() method at each point that you feel can be a split... it automatically cuts up the code into chunks that are downloaded as and when necessary.
Look here for the docs.
AFAIK, lazily loaded (or pluggable) modules can't be done in GWT. Partly this is due to the way the GWT compiler works - it likes to import all the code that it is ever going to see and then optimises and prunes it as viciously as possible (to make the resulting JS files as small and lead as possible). If it doesn't have access to all the source code up front, it might make optimisations that will break the pluggable modules (especially since nothing in the "core" application may reference the classes that the lazily-loaded modules need to work properly - the GWT compiler would prune those "unused" classes in the core module).
This stackoverflow question from May 09 asks the same thing and has the same answer - it can't be done.
I searched high and low about six months ago for an answer to this problem, because I really wanted to do what I believe you're asking for. Never found a solution.
(I haven't used GWT 2.0 - it might have addressed the issue)
Thank you for your answer. You are right that the whole Javascript code gets downloaded.
But there must be a way like say on of module is View Profile. Only when the user clicks the view Profile link, the widgets related to displaying my profile needs to be created. is this not possible.

Developing a GUI Builder Application

I am looking for a nice framework for developing a GUI builder Application. We have an application where 100Os of custom data entry forms and their print formats are required and each client will need some modifications on these. We have a developed a product using java based open source templatnig frameworks so that the layout and field definition are stored in database and rendered dynamically to the user. We also have an appication to design these forms but cannot do visual design.
Now I am trying to make a Visual Form Designer application for generating these forms. Can any one suggest some open source frameworks than can be used? Can I use Eclipse Visual Editor? Or is it better to develop some kind of parser for HTML using AntLR and then parse the HTML output from already existing GUI builders like Dreamweaver to get the desired output?
Thanks and Regards,
-- Kannan
Oooh, great question!
I wouldn't know any readily availble framework that you can use. Depending on your needs however, I think rolling your own shouldn't be too hard.
First of all, you probably wouldn't want to give the users too much freedom. Freedom only gives them the opportunity to mess things up and make the resultant forms hard to use. I think from your description that the fields are pre-defined, so that the user only needs to customize which fields appear on a given form, and in what order. Order can be a simple thing like top-to-bottom. Some semi-intelligent automatic layouting could be used to conserve screen space. Adding a feature to group fields together would probably also be useful, and grouping would lead to some kind of standard "group" widget.
Accepting simplified functionality like this, you don't really need the flexibility of a full gui editor. A couple of listviews, maybe a property sheet and a preview window will be enough to give your users the functionality they need.
Of course, this only holds for screen forms. Print forms may be trickier to layout, as people may want to cram as many fields as possible into very little space so the entire form can fit on a single page or something. I really don't have any suggestions for you there, but maybe a similar "simplified" approach with some intelligent auto-layouting could work.
Overall, my advice would be: Keep It Simple! (S... ;)