Click here to Skip to main content
15,881,866 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi,

I'm making what has begun to be quite a large class in VB.NET 2010 Express Edition. It is getting difficult to find Subs and Functions so I wanted to sort the code order.

I've done some searching on here and Google and have found Regionerate and Resharper but these are for C# or Visual Studio Full. Cut and Paste is slow but could sort it eventually I guess.

Anyone know of an easy way to sort code in Visual Basic 2010 Express?

Thanks !
Posted
Comments
Philippe Mori 1-Sep-11 20:02pm    
A good habit is that when you add functions, you add them in a consistent order. Typically since generated code is added at the end, I would only order my code. For things like a button handler, if there are a lot of events, it is often simpler to double-clicks on the button in the designr to go to the appropriate code.
codetowns 2-Sep-11 4:13am    
Thanks Philippe. A good idea as currently mine are all over the place. Thanks for the links below too.

The only way I know of is manually. You could make it a partial class, and break your file up that way. Any file over 1000 lines long is TOO long.
 
Share this answer
 
Comments
codetowns 1-Sep-11 10:45am    
Many thanks John! I'm self-taught (from scratch) over the last 6 months and I guess I have been putting off rationalising the code which is currently way over 1000 lines. I guess I'll have to read up on Partial Classes.
fjdiewornncalwe 1-Sep-11 14:14pm    
It would be wiser to look at your class and see how you can break out functionality into separate classes. For a class, you really shouldn't need partials. If you feel you do, then the logical breakdown of your partial files is likely a good starting point for breaking the class up into sub classes.
#realJSOP 2-Sep-11 5:55am    
I think making it a partial class would serve two purposes, make the file smaller and more maintainable, and not cause refactoring problems with abstracting code out into smaller, more targeted classes. Without seeing his code, I couldn't really suggest that myself.
codetowns 2-Sep-11 4:12am    
Thanks Marcus. I will work out how I can subdivide into separate classes.
codetowns 2-Sep-11 11:28am    
Well I think you are all correct but looking at what I have now, it is very difficult to factor stuff out without causing a lot of problems. In the future I plan to design more classes but may put up with what I have done so far - Partial Classes and a Module may help I guess.

Strangely, although the problem isn't particularly unusual (large image editing and vector capture program), I find it very difficult to imagine how to use Class-based objects over Subs and Functions. Perhaps that is the danger of being self taught !?
As mentionned in solution 1, your class try to doi way too much. It lead to unmaintanable code.

This anti-pattern is known as God's class as the class known everything... This is a bad programming pratice.

God object[^]

Code smell[^]

Principles, Patterns, and Practices of Mediocre Programming[^]

Agile Processes in Software Engineering and Extreme Programming[^]

Reasons Why Object Oriented Programming Can Fail[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900