Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

VB.NET best practices and designing classes [closed]

Tags:

vb.net

I am busy writing a program in Visual Basic .NET and I have a few questions regarding best practices. I know it is a bit open ended, but just a few guidelines/ideas or even links would be appreciated.

Firstly, the code in the main form is getting a bit long (about 1000 lines). What is an acceptable number of lines of code for the main form or any other form for that matter? I have divided the program into classes as far is it makes logically sense to me. What are some good guidelines to what should be added together in a class? Should I add functions in classes as shared function rather than putting the code in the main form? Also, should I refrain from adding code in modules?

On a similar note, I am looking for information about how to design a large software project. I know the language pretty well now, but how does one actually plan how to create a large program or does that only come with experience?

like image 836
Kritz Avatar asked May 14 '11 18:05

Kritz


People also ask

Will VB.NET be phased out?

Visual Basic (VB.NET) will continue to be supported by Microsoft. (It's not dead.) The language will no longer have new features added to it.

Does VB.NET have classes?

Class Members In VB.NET, class modules can contain the following types of members: Data members. This includes member variables (also called fields) and constants. Event members.

What are the three ways to run a Visual Basic application?

There are several ways to run your program: Press the F5 key. On the VB menu bar, Run > Start. On the VB toolbar, click the VB Run icon (the arrow)

Is VB.NET back end?

Net comprises both frontend and backend languages. As for example, ASP.NET is used as backend and C# & VB.NET are used for frontend development.


2 Answers

It sounds like you are not creating distinct layers in your application. If your main form has 1,000 lines of code, you are probably putting business logic or even data access code in the form itself. You really need to separate out your layers (at least presentation layer, business logic layer, and data access layer). This will help you better follow good OO principles. In relation to VB.NET specifically, here are a few articles that might help:

http://www.asp.net/data-access/tutorials/creating-a-business-logic-layer-vb

http://www.vbdotnetheaven.com/UploadFile/akrao/PracticesofCodingInVB11162005001109AM/PracticesofCodingInVB.aspx

http://www.codeproject.com/KB/vb/N-Tier_Application_VB.aspx

These will help you with layers and how to implement them in VB.NET. The ASP.NET article will work fine because the actual ASP.NET is the Presentation Layer, which you would replace with Winforms.

If you want to watch videos on OO design principles, here is a good site to do so (it isn't free but it is very cheap):

http://www.learnvisualstudio.net/content/series/Visual_Basic_201_Object_Oriented_Programming_and_Design_Patterns.aspx

A great book for helping you understand OO design is Head First Object-Oriented Analysis & Design.

like image 106
IAmTimCorey Avatar answered Nov 07 '22 13:11

IAmTimCorey


Read Clean Code and about SOLID principles. This will be a great place to start.

like image 32
Kevin LaBranche Avatar answered Nov 07 '22 13:11

Kevin LaBranche