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
ManvithaManvitha 

Method splitting doubts and PMD issues

Hi All , 

I am new to apex ,working on one apex class where it contains many pmd issue including NcssMethod count to  reduce it i am splitting methods , where i got into some trouble ...let me explain this.
 public static void method1 () {
for(case c : caselist ){

if(condition satisfy){

///my other lines of code which i am going to split & and make another method (lengthy code )
}}
}
so my question is in the sub method is it requeired to check for & if condtion and call that after this method1's if condition ?

am i doing wrng by checking two time for condtion?

please somebody help to get clarity on this 

Thanks in Advnc!! : )

SubratSubrat (Salesforce Developers) 
Hello Manvitha ,

Basically you should write your code so you would be able to test each method individually.

So if there is a requirement to test the sub method individualy , check for both the conditions.

Please refer this discussion and apex guide too -> https://salesforce.stackexchange.com/questions/332978/usage-of-independant-blocks-inside-of-a-method

-> https://resources.docs.salesforce.com/latest/latest/en-us/sfdc/pdf/salesforce_apex_developer_guide.pdf


If it helps please mark this as Best Answer !
Thank you.