Functional Layouts, the best layout for functions

Functional Positioning

Let’s talk about Functions again, when I am looking through code, I find it extremely frustrating that I have to roam all throughout the class or file for every couple of minutes and that there is no logical flow or position of the position of the different functions.

There are two general types of functions, the¬†Graphical User Interface (GUI) Functions and the Non-GUI Functions. The GUI Functions are those that are initiated from an action the user does, such as the Form events or controls like buttons and tool bars, these functions should be extremely small containing a Try…Catch block and the Non-GUI Layer Function Call or sometimes laundry list of calls. The Non-GUI Layer Functions are everything else…

Let’s first talk about Non-GUI Layer functions, typically, Non-GUI Layer Functions should be categorized with other similar Non-GUI Layer Functions and supporting functions under the same class, allowing the easy access and finding of what you are trying to do. For instance, any process that interacts with disk management (i.e. managing files, directories, etc), or configuration settings should be under a class object with each other. Each Entry Point into that class should be organized either as a Alphabetical, as a Most Expected to be Managed prospect or as an Usability Process (this works extremely well within the constructs of events, where the form load event is the first thing, then the toolbar function clicks, in the order that the menu options are presented to the user, etc). Personally, I prefer the later of the three, this allows me to look at the GUI interface and then quickly guesstimate whereabouts in the code I am expecting to find it. Personally, I also find that I like to have the Shared (or Static) Private Variables then Shared Methods located at the top of the class, and then the Instantiated Private Variables, Properties and Methods underneath that.

I have heard from two different camps on the usage of regions and how they flow within the code, and arguably, I can see some benefit and some detriment. For instance, with Regions, you are confined to a certain area and if there are to many regions it makes it extremely difficult to locate what you are looking for, especially when the region is closed. While on the other hand, if the regions are limited and are presented as “categories” of the type of code that is expected, it allows the developer an easy way to jump directly to what type of code they are looking for.

Each supporting function should be presented below the last function that uses it in the order that it is used… for instance lets assume that I have a function that calls three other functions (not used in any other function), I would expect that the first function that is called be directly underneath the calling function, kind of like a book sections, chapters, topics, sub-topics, points, etc. If that function is used by multiple functions, I would expect it to be underneath that last function that called it.

Now, lets talk about the GUI Layer Functions, these are the form events, control events that are generated for when the user does something. These should be laid out in a manner as the controls are laid out, these functions shouldn’t really be calling anything within the same form; however, there are times when it is appropriate and then it should be that they are also laid out as directly underneath the calling function in the order called.

In essence, the main goal of organizing our functions is to make it easier to determine where it is for future readers of our code. If there is some logic behind it, then it is more likely that the next person won’t be screaming your name and punching the voodoo doll that has a piece of your hair on it. This also makes it so much easier for debugging purposes as we aren’t racing from one end of the class to the next trying to figure out what is going on.

Until next time, Happy Coding and may you be blessed!

15 comments

  1. A lot of thanks for your own effort on this site. My mom take interest in carrying out research and it’s really easy to see why. My partner and i know all relating to the dynamic way you convey worthwhile guidelines through the blog and even attract participation from website visitors about this concern while our daughter is truly learning a lot of things. Take advantage of the remaining portion of the new year. You are always doing a first class job.

  2. I simply wished to appreciate you all over again. I am not sure the things I would have handled without the actual tips and hints documented by you on such situation. It seemed to be an absolute scary concern in my position, nevertheless being able to see the very specialized way you handled the issue made me to leap with fulfillment. I’m just thankful for the work and expect you realize what a powerful job you are doing teaching the rest through the use of a blog. Probably you have never met any of us.

  3. My wife and i ended up being absolutely joyous Raymond managed to round up his preliminary research from the precious recommendations he got when using the web page. It’s not at all simplistic just to be releasing tactics other people could have been trying to sell. And we know we need the website owner to be grateful to for that. These explanations you have made, the simple web site navigation, the relationships your site help to foster – it’s got most exceptional, and it’s really assisting our son in addition to our family imagine that the concept is brilliant, which is certainly extremely vital. Many thanks for the whole thing!

  4. Thank you for all your work on this web site. My mum loves working on investigation and it’s really simple to grasp why. My partner and i hear all of the compelling method you produce invaluable guidance on the website and even attract contribution from other ones on the subject then our own princess is without a doubt becoming educated a lot. Take pleasure in the rest of the year. You have been doing a terrific job.

  5. I simply wished to thank you very much again. I do not know the things I would have handled without the type of methods revealed by you about this question. It was before an absolute frustrating setting for me, but spending time with a well-written fashion you processed that took me to leap over fulfillment. I am just thankful for the guidance and then hope that you are aware of a powerful job you happen to be carrying out instructing other individuals all through your web site. I know that you’ve never come across any of us.

  6. My spouse and i were so comfortable that Louis could do his studies by way of the precious recommendations he came across out of the web pages. It is now and again perplexing just to always be offering facts which usually other folks could have been trying to sell. Therefore we grasp we have the website owner to thank for that. All the illustrations you have made, the simple blog menu, the friendships you can give support to create – it is mostly great, and it’s really facilitating our son and the family consider that this article is amusing, which is pretty indispensable. Thank you for everything!

  7. I precisely wished to say thanks all over again. I do not know what I might have accomplished in the absence of those information contributed by you regarding that subject matter. It was before the daunting difficulty in my circumstances, however , witnessing the skilled avenue you solved it took me to weep with delight. Now i am thankful for the advice and thus sincerely hope you comprehend what an amazing job you are accomplishing training others with the aid of your website. Probably you have never come across all of us.

  8. I in addition to my guys came examining the excellent advice located on your web page and instantly got an awful feeling I never thanked you for those secrets. Those ladies were definitely consequently joyful to learn them and have in effect pretty much been enjoying them. Appreciation for turning out to be so accommodating as well as for selecting varieties of important information millions of individuals are really wanting to learn about. My honest apologies for not expressing appreciation to you earlier.

  9. I am glad for commenting to make you be aware of of the brilliant discovery my wife’s daughter enjoyed visiting the blog. She discovered several details, which include how it is like to have a very effective giving mindset to get other folks just learn a variety of impossible matters. You truly exceeded our own expected results. I appreciate you for presenting such effective, trusted, edifying and in addition cool thoughts on this topic to Kate.

  10. My husband and i have been absolutely joyful that Chris could carry out his research through your precious recommendations he obtained out of your blog. It is now and again perplexing to simply be giving away facts which usually many people may have been selling. Therefore we understand we’ve got the blog owner to give thanks to for this. The specific explanations you made, the simple web site navigation, the relationships you help to instill – it’s got many incredible, and it’s really helping our son and the family reckon that the situation is cool, and that’s unbelievably important. Many thanks for the whole thing!

  11. I precisely needed to appreciate you all over again. I am not sure the things I would’ve worked on without those recommendations contributed by you about this field. It actually was a real intimidating issue in my position, however , seeing your specialised technique you processed it took me to weep with gladness. I’m just happier for this support and even sincerely hope you know what a great job that you are carrying out educating people today all through your blog. Probably you’ve never come across any of us.

  12. I and also my pals happened to be viewing the good tactics on your site then suddenly developed an awful suspicion I had not expressed respect to the website owner for those techniques. Those men became consequently thrilled to read them and have surely been having fun with them. Appreciation for genuinely quite thoughtful as well as for figuring out this sort of nice issues most people are really wanting to discover. My sincere regret for not expressing gratitude to you earlier.

  13. Thank you for all of the labor on this web page. My mom take interest in participating in investigation and it’s really obvious why. A number of us know all about the compelling mode you convey effective things on this web site and as well increase participation from other ones on that idea then our simple princess is always becoming educated so much. Take advantage of the remaining portion of the year. You are conducting a first class job.

  14. I simply had to thank you so much once again. I am not sure the things that I would’ve done in the absence of the actual advice contributed by you directly on such question. Previously it was a troublesome matter for me, nevertheless discovering the very specialized way you handled the issue made me to cry over fulfillment. I will be thankful for the work and expect you know what a powerful job that you are providing educating people today via a web site. Probably you’ve never come across all of us.

  15. I simply wished to appreciate you all over again. I am not sure what I might have undertaken without the entire concepts documented by you relating to that field. It has been a very troublesome setting in my position, but being able to view a new professional style you treated the issue made me to leap for delight. Now i am grateful for your advice and then wish you really know what a great job you have been putting in instructing the rest through the use of your web page. Most probably you’ve never come across all of us.

Leave a Reply

Your email address will not be published. Required fields are marked *