rex
rex

Reputation: 3183

VB: Writing whole program in form module bad practice?

I'm trying to get an idea of when it is worth developing classes for a program in VB.

Assuming that you have a a single form program that's not too big, is it bad practice to write the whole thing in that form's module in VB?

To give an idea of program size, say it includes two timer objects, subroutines functions and form control methods all in this single module, that instantiate various objects including HTTP request calls. [Timer tick intervals at around 5 seconds doing http request calls]

Upvotes: 0

Views: 116

Answers (2)

Silvio Marcovic
Silvio Marcovic

Reputation: 503

I think there is nothing wrong with using no design patterns for a small program.

However I always try to implement design patterns, even for small projects. the reason is, even small projects can be a chance to advance your skills. If I have a time limit I cast this reasoning aside. So I guess its up to you. It will definitely take you more time to develop a small program with design patterns, but as I mentioned you are discarding potential practice time (:

and who knows what your so called small project will look like in one year. Maybe you want to make it bigger. So you can plan in advance or refactor the whole thing when you realize it is time for it. I guess both ways are fine, but I definitely prefer more complex architecture from the beginning

Upvotes: 1

rory.ap
rory.ap

Reputation: 35270

There is no real right or wrong answer. For small programs like yours, I would say it's probably not worth it to get too elaborate, so yes, I think it's OK to put all your code in the form class. For larger applications, you should definitely consider using one of the well-thought-out and proven design patterns such as MVP, MVC, Presentation Model, etc. There are a lot of resources out there on the web that cover these, but the fundamental idea is that you can gain a lot of benefits by separating your UI from your presentation logic code and your domain logic code.

Upvotes: 1

Related Questions