Subs and Functions
Subs and Functions
Subs and Functions
Subs and Functions
Subs and Functions
Subs and Functions Subs and Functions Subs and Functions Subs and Functions Subs and Functions Subs and Functions Subs and Functions Subs and Functions
Subs and Functions Subs and Functions
Subs and Functions
Go Back  Xtreme Visual Basic Talk > > > Subs and Functions


Reply
 
Thread Tools Display Modes
  #1  
Old 09-10-2014, 10:56 AM
Fat_Lip's Avatar
Fat_Lip Fat_Lip is offline
Centurion
 
Join Date: Feb 2005
Posts: 123
Default Subs and Functions


I'm just wondering, is it bad practice to call a sub or function and then call a second one from within the first one that was called? I always try to avoid doing this but sometimes it would really shorten things up for me.
Reply With Quote
  #2  
Old 09-10-2014, 07:03 PM
PlausiblyDamp's Avatar
PlausiblyDampSubs and Functions PlausiblyDamp is offline
Ultimate Contributor

Forum Leader
* Expert *
 
Join Date: Nov 2003
Location: Newport, Wales
Posts: 2,058
Default

If anything that is generally a good practice and how you should do things.

Part of writing understandable and maintainable software is by breaking complex and difficult tasks down into smaller and therefore more understandable pieces. Functions and Subs are the essential building blocks you are working with, these are combined into other functions and subs as well as higher level objects such as classes and structures.

There are no hard and fast rules on this but if doing something makes the code easier to maintain and read then it is probably something you should do, if it seems to be adding complexity and making things difficult to read and maintain then your should probably avoid doing it.
__________________
Intellectuals solve problems; geniuses prevent them.
-- Albert Einstein

Posting Guidelines Forum Rules Use the code tags

Last edited by passel; 09-14-2014 at 08:30 PM. Reason: changed braking to breaking
Reply With Quote
  #3  
Old 09-10-2014, 07:58 PM
Fat_Lip's Avatar
Fat_Lip Fat_Lip is offline
Centurion
 
Join Date: Feb 2005
Posts: 123
Default

Thanks, I was always wondering that.
Reply With Quote
  #4  
Old 09-11-2014, 09:23 AM
Gruff's Avatar
GruffSubs and Functions Gruff is offline
Bald Mountain Survivor

Retired Moderator
* Expert *
 
Join Date: Aug 2003
Location: Oregon, USA - deceased
Posts: 6,440
Default

A general rule of thumb is that if any sub is larger than your screen it is too big and should be broken into smaller procedures. Like anything though there are exceptions.

A complementing rule is that if your code can be reused then make a procedure out of it.
If it fits into a suite of concepts then a class is a better place for it.

Just sayin...
__________________
Burn the land and boil the sea
You can't take the sky from me


~T
Reply With Quote
Reply


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Subs and Functions
Subs and Functions
Subs and Functions Subs and Functions
Subs and Functions
Subs and Functions
Subs and Functions Subs and Functions Subs and Functions Subs and Functions Subs and Functions Subs and Functions Subs and Functions
Subs and Functions
Subs and Functions
 
Subs and Functions
Subs and Functions
 
-->