|
-
Oct 6th, 2018, 07:44 AM
#1
Thread Starter
Fanatic Member
New VB6 IDE prototype with Backporter for use with the upcoming VB6Namespaces release
In order to back-port VB.NET code to VB6 with the new VB6Namespaces, I needed to create a new IDE.
At the moment, the VB6 IDE is a just a prototype that can open VB6 projects, edit, save and compile executable files.
- It has a "New Project" dialog window, that has templates inside to choose from, and the VB6Namespaces template as the default.
- The VB6 IDE will be able to automatically remove unused classes at compile time, from the VB6Namespaces collection.
- A class builder is included to help you nest classes efficiently.
- Also featuring "Add module", "Add form", "Add Class", and "Add User Control" options. References and components can be added as well, but needs some work.
- There is also a properties toolbox window for these module level objects, though not hooked up fully yet, awaiting form designer. Unfortunately, there is no object browser.
- Most importantly, it has a prototype back-porter that allows you to import VB.NET project files (or copy/paste code), and convert them as close as possible to VB6. The classes included in the VB6Namespaces template help in the process, since these classes are already available by defaut in a standard exe. Most code can be copied and pasted after back-porting it. Some code will need edits though, depending on the scope and various writing styles etc.
Interestingly, this serves a hybrid between the two variations of the Visual Basic language. For example, the IDE can accept code into the window that normally would not be understood by VB6, but at compilation time that this hybrid can generate the raw code auto-magically to do something new, ie accept new keywords like AndAlso, and OrElse etc., or it can accept and convert python code to vb6 in the newly compiled application etc.
VB6Namespaces
I have made a lot more progress on the VB6Namespaces collection, and I have included color coded treeview control to show the approximate completion level of the classes.
Here is a preview of the new VB6 IDE prototype (proof of concept). The prototype is written in VB.NET 2005. I used VB.NET because it allows me to develop this kind of product rapidly. Although once the project is finished, I can use the backporter to help make a clean VB6 version. Still, the VB.NET version may retain certain abilities that can help port additional namespaces in the future. VB6 can't do that without some kind of redundant interop, although it's totally possible.
Video: https://www.youtube.com/watch?v=Gr18G_-zRzo
If anyone would like to write classes I am trying to map out some standards that I use.
I will reference MS press whenever I can, but some things learned here are through experience. Here are just a few ideas.
Practical Standards for Visual Basic.
Microsoft Press, 2000
Chapter 3. Page 25.
"...Modules and procedures are the framework for the code of your application, and building this framework requires careful consideration...and you should use these techniques when developing your project."
For project templates
Explicit scope definition
Always define the scope of your variables, function, subs, and properties etc.
Strong cohesion
A class module is not simply a container of a bunch of procedures.
Class modules should be used to organize sets of related procedures. Generally one should minimize the number of related procedures in a module. If the number of procedures has become cumbersome then simply organize those the procedures into several modules to be more easily maintained and debugged.
Encapsulation
The ability to expose only certain content to the client, and hide the rest of the procedures from external processes.
C++ 6.0 lacked this ability at the process level, since it's procedures were still exposed to external applications using the "New" keyword.
Private modules
Create private modules whenever possible.
This avoids naming conflicts and executes code faster since the information is not exposed to the whole public scope.
It also avoids other applications from causing external issues with your code flow. This means that one should stay away from public solutions like ActiveX, DLL, or TLB's. In order to expose your functions to the rest of the application, you would use the Friend keyword. That way it doesn't expose the functions to external applications, and is encapsulated.
Self-contained
Create self-contained modules whenever possible. A self-contained module means that the module does not rely on other modules
to function properly. This also avoids dependency issues when the unused modules are to be removed before compilation. It is usually best to have a second copy of the code rather than have a class call another class. That may depend on the size and scope of course.
Loosely coupled vs Tightly coupled
Tightly coupled means that the procedure is tightly coupled to the other functions that it relies on to function properly. Just as modules are self-contained, you should try to create procedures that are also self-contained and do not rely on other functions to function. This is not always possible but try to follow the practice.
Specialized procedures subs/functions
Create only specialized function procedures in your modules. Avoid creating procedures that perform many different tasks. This will make it easier to maintain and manage over time.
Parameters
Always use the correct keywords to pass data ByRef or ByVal explicitly. This makes the code easier to read with blue keyword, but more importantly, it makes the code forward compatible to copy paste into a .NET IDE window. By default, a missing ByRef will be converted to ByVal in .NET, as the default. This will cause the code to fail if the parameter is modified inside the procedure. These keywords need to be written specifically for good compatibility practice.
Miscellaneous
Use public properties rather than Public variables.
Use the Call keyword for procedures.
Declare only one variable per line.
There are plenty more, but you get the point.
Hope this is something useful, and I am always open to suggestions, criticisms, and requests.
I have set the initial release date of V1 for October 31st of this year. I'm not sure how complete it will be, but I hope to create a stable foundation to start with. Feedback and requests will be welcomed after that.
Last edited by Shaggy Hiker; Nov 26th, 2018 at 11:24 AM.
Reason: Removed link.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|