vb.net - When to create a procedure(sub, function) -
i'm creating application , i'd write understandable code. i'd know when create procedure. if affects performance of application if created much.
here sample:
sample code:
with sub
private sub form1_load(sender object, e eventargs) handles mybase.load greetings() end sub private sub greetings() messagebox.show("hello!") messagebox.show("to") messagebox.show("my") messagebox.show("world") end in example above, assume sub called 1 - 2 times in whole application. understand code.
versus
without sub
private sub form1_load(sender object, e eventargs) handles mybase.load messagebox.show("hello!") messagebox.show("to") messagebox.show("my") messagebox.show("world") end sub in example above, piece of code time understand.
in general, should create subroutines when logic going used multiple times, if it's being used in multiple places.
if ever have change code, want change once.
performance running basic code or calling functions non-issue. not consider it.
Comments
Post a Comment