Results 1 to 20 of 20

Thread: In a very large project, how to deal with thousands of interface classes?

  1. #1

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,447

    In a very large project, how to deal with thousands of interface classes?

    I'm doing some extreme tests on the VB6 project. In the test, a VBP project contains thousands of classes and thousands of Interface (classes). In the process of loading VBP, the prompt "Out of memory" appears. So I decide to split this VBP project.

    One of the solutions is to put all the interface files (interface classes) into a separate VBP project, and compile this project into an Active-DLL for the main VBP project to call. I'd like to know whether this solution is feasible, and is there a better solution?

    Another solution is to put these thousands of interface files (interface classes) in a TLB. I have never created a TLB myself, and I don't know anything about TLB. I don't know if this solution is better.

    Any suggestions and hints would be greatly appreciated.
    Last edited by SearchingDataOnly; Apr 5th, 2021 at 11:16 AM.

  2. #2
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,910

    Re: In a very large project, how to deal with thousands of interface classes?

    Thousands of classes and interfaces?
    What kind of project is this?

    I would normally put classes which are related in a single DLL and in the main project only reference what’s needed.
    Why do you want everything in a single project?

  3. #3
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,543

    Re: In a very large project, how to deal with thousands of interface classes?

    Yeah, I'd break things up based on functionality or domain (business) ... Let's say you have a program that represents a car. Rather than have it all crammed into one app, break it up... Electronics.DLL, Fuel.DLL, Exhaust.DLL, etc... The Engine.dll would use the other DLLs as needed as well as providing it's own interface and functionality and so on.
    Just be wary of circular references.


    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  4. #4

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,447

    Re: In a very large project, how to deal with thousands of interface classes?

    Quote Originally Posted by Arnoutdv View Post
    Thousands of classes and interfaces?
    What kind of project is this?

    I would normally put classes which are related in a single DLL and in the main project only reference what’s needed.
    Why do you want everything in a single project?
    The above project with thousands of classes is one of dozens of DLLs in a huge project. If each VB6-DLL-project can only contain a few hundred class files, then the entire huge project will need(produce) hundreds of DLL files.

  5. #5

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,447

    Re: In a very large project, how to deal with thousands of interface classes?

    Quote Originally Posted by techgnome View Post
    Yeah, I'd break things up based on functionality or domain (business) ... Let's say you have a program that represents a car. Rather than have it all crammed into one app, break it up... Electronics.DLL, Fuel.DLL, Exhaust.DLL, etc... The Engine.dll would use the other DLLs as needed as well as providing it's own interface and functionality and so on.
    Just be wary of circular references.


    -tg
    Yes, we can take this approach for cars. But if it's a 10,000-ton-class or 30,000-ton-class ship, maybe we need to think about other better ways, such as building a giant ship in sections (each section is huge).
    Last edited by SearchingDataOnly; Apr 6th, 2021 at 06:58 AM.

  6. #6

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,447

    Re: In a very large project, how to deal with thousands of interface classes?

    After testing, I found that the total number of module files and class files that each single VB6 project can hold is less than 1050 (approximate number), otherwise VB6-IDE will prompt "Out of memory" and stop loading the remaining files.

    This limitation has caused me a big trouble. I need a single VB6 project to hold at least 3000 class files and module files.

  7. #7
    Smooth Moperator techgnome's Avatar
    Join Date
    May 2002
    Posts
    34,543

    Re: In a very large project, how to deal with thousands of interface classes?

    Waht kind of project is this for? I can't even imagine needing more than a few dozen classes, let alone a 1000, and there shouldn't even be a need for 3000 classes in anything... Wot in the heck are you building?

    -tg
    * I don't respond to private (PM) requests for help. It's not conducive to the general learning of others.*
    * I also don't respond to friend requests. Save a few bits and don't bother. I'll just end up rejecting anyways.*
    * How to get EFFECTIVE help: The Hitchhiker's Guide to Getting Help at VBF - Removing eels from your hovercraft *
    * How to Use Parameters * Create Disconnected ADO Recordset Clones * Set your VB6 ActiveX Compatibility * Get rid of those pesky VB Line Numbers * I swear I saved my data, where'd it run off to??? *

  8. #8
    The Idiot
    Join Date
    Dec 2014
    Posts
    2,731

    Re: In a very large project, how to deal with thousands of interface classes?

    yeah, why do you need all those 3000 classes in the same time (real-time)?
    better split them in sections.
    if you really need 3000 classes operating at the same time, I wonder if you are not doing something wrongly. nothing need that much, well, maybe an AI?
    if each class stores data, and you want it to be active, maybe you need to re-think how to store data in another way, this so you don't need the class alive.
    if its information or data calling or operation calling, all that can be changed into database and DLL.

    another method is to create multiple exe's and you have some kind of communication between them.

  9. #9
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,749

    Re: In a very large project, how to deal with thousands of interface classes?

    you can make 10 or 100 dll,and load them

  10. #10

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,447

    Re: In a very large project, how to deal with thousands of interface classes?

    Quote Originally Posted by techgnome View Post
    Waht kind of project is this for? I can't even imagine needing more than a few dozen classes, let alone a 1000, and there shouldn't even be a need for 3000 classes in anything... Wot in the heck are you building?

    -tg
    Quote Originally Posted by baka View Post
    yeah, why do you need all those 3000 classes in the same time (real-time)?
    better split them in sections.
    if you really need 3000 classes operating at the same time, I wonder if you are not doing something wrongly. nothing need that much, well, maybe an AI?
    if each class stores data, and you want it to be active, maybe you need to re-think how to store data in another way, this so you don't need the class alive.
    if its information or data calling or operation calling, all that can be changed into database and DLL.

    another method is to create multiple exe's and you have some kind of communication between them.
    I'm doing some extreme tests (stress tests) to explore new possibilities for VB6.

    No one seems to have a good solution, maybe we should focus the discussion on TLB.

  11. #11
    PowerPoster Arnoutdv's Avatar
    Join Date
    Oct 2013
    Posts
    5,910

    Re: In a very large project, how to deal with thousands of interface classes?

    But in real life you would only include the libraries you need.
    Not one big huge library which contains all you will ever need, at least what you can think of right now.

    You would have a math library, a graphics library, a font library etc etc.
    Not everything in a single library.

  12. #12
    PowerPoster PlausiblyDamp's Avatar
    Join Date
    Dec 2016
    Location
    Pontypool, Wales
    Posts
    2,474

    Re: In a very large project, how to deal with thousands of interface classes?

    Quote Originally Posted by SearchingDataOnly View Post
    I'm doing some extreme tests (stress tests) to explore new possibilities for VB6.

    No one seems to have a good solution, maybe we should focus the discussion on TLB.
    According to http://codebetter.com/patricksmacchi...net-framework/ it looks like the entire .Net 3.5 framework only had about 1,700 public interfaces - I suspect needing anything like that amount in an application is highly unlikely.
    Last edited by PlausiblyDamp; Apr 6th, 2021 at 04:34 PM.

  13. #13
    PowerPoster
    Join Date
    Jun 2012
    Posts
    2,395

    Re: In a very large project, how to deal with thousands of interface classes?

    What about "lightweight COM" classes via bas module?

  14. #14
    PowerPoster
    Join Date
    Feb 2006
    Posts
    24,482

    Re: In a very large project, how to deal with thousands of interface classes?

    .Net has the advantage of overloaded methods. So an interface might have "one method" that is really 8 or 9. Not sure whether that figures into the issue for VB6.

  15. #15
    PowerPoster
    Join Date
    Jan 2020
    Posts
    3,749

    Re: In a very large project, how to deal with thousands of interface classes?

    If you need to develop an operating system, sorry, please do not use VB 6.
    vb.net It suits you.or vc++

  16. #16

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,447

    Re: In a very large project, how to deal with thousands of interface classes?

    @Arnoutdv, @PlausiblyDamp, @Krool, @dilettante, @xiaoyao:

    I'm trying to convert some TypeScript interfaces into VB6 code, there are thousands of such interfaces.

    https://www.vbforums.com/showthread....=1#post5396553
    Code:
    /*---------------------------------------------------------
     * Copyright (C) Microsoft Corporation. All rights reserved.
     *--------------------------------------------------------*/
    'use strict';
    
    // -- raw grammar typings
    
    export interface ILocation {
    	readonly filename: string;
    	readonly line: number;
    	readonly char: number;
    }
    
    export interface ILocatable {
    	readonly $vscodeTextmateLocation?: ILocation;
    }
    
    export interface IRawGrammar extends ILocatable {
    	repository: IRawRepository;
    	readonly scopeName: string;
    	readonly patterns: IRawRule[];
    	readonly injections?: { [expression: string]: IRawRule };
    	readonly injectionSelector?: string;
    
    	readonly fileTypes?: string[];
    	readonly name?: string;
    	readonly firstLineMatch?: string;
    }
    
    export interface IRawRepositoryMap {
    	[name: string]: IRawRule;
    	$self: IRawRule;
    	$base: IRawRule;
    }
    
    export type IRawRepository = IRawRepositoryMap & ILocatable;
    
    export interface IRawRule extends ILocatable {
    	id?: number;
    
    	readonly include?: string;
    
    	readonly name?: string;
    	readonly contentName?: string;
    
    	readonly match?: string;
    	readonly captures?: IRawCaptures;
    	readonly begin?: string;
    	readonly beginCaptures?: IRawCaptures;
    	readonly end?: string;
    	readonly endCaptures?: IRawCaptures;
    	readonly while?: string;
    	readonly whileCaptures?: IRawCaptures;
    	readonly patterns?: IRawRule[];
    
    	readonly repository?: IRawRepository;
    
    	readonly applyEndPatternLast?: boolean;
    }
    
    export interface IRawCapturesMap {
    	[captureId: string]: IRawRule;
    }
    
    export type IRawCaptures = IRawCapturesMap & ILocatable;
    
    
    export interface IOnigLib {
    	createOnigScanner(sources: string[]): OnigScanner;
    	createOnigString(sources: string): OnigString;
    }
    
    export interface IOnigCaptureIndex {
    	start: number;
    	end: number;
    	length: number;
    }
    
    export interface IOnigMatch {
        index: number;
        captureIndices: IOnigCaptureIndex[];
        scanner: OnigScanner;
    }
    
    export interface OnigScanner {
    	findNextMatchSync(string: string | OnigString, startPosition: number): IOnigMatch;
    }
    
    export interface OnigString {
    	readonly content: string;
    	readonly dispose?: () => void;
    }
    Last edited by SearchingDataOnly; Apr 7th, 2021 at 05:08 AM.

  17. #17

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,447

    Re: In a very large project, how to deal with thousands of interface classes?

    Quote Originally Posted by Krool View Post
    What about "lightweight COM" classes via bas module?
    Hi Krool, thanks for your suggestion.

    I re-studied Olaf's tutorial "VB6 LightWeight COM and vbFriendly-BaseInterfaces". IMO, LightWeight COM seems to only play a role in reducing the memory occupied by the created objects and speeding up the release of the objects(class instances). But it does not help VB6-IDE to load thousands of class files.

    However, Olaf mentioned the concept of "class factory" in the example that seems to help me solve some problems. For example, I can merge many classes into the "class factory", but this doesn't seem to work for interface classes. Maybe we should still consider how to use TLB to define a large number of interfaces and classes.

  18. #18

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,447

    Re: In a very large project, how to deal with thousands of interface classes?

    Below is the code to generate a huge project (in a module file):
    Code:
    Public Sub CreateHugeProject()
        Dim i As Long:
        Dim sPath  As String
        Dim sClassName As String
        Dim sFileName As String
        
        sPath = "C:\MyHugeProject\"
        New_c.FSO.EnsurePath sPath
        
        With New_c.StringBuilder
            .AppendNL "Type=Exe"
            .AppendNL "Reference=*\G{00020430-0000-0000-C000-000000000046}#2.0#0#C:\Windows\System32\stdole2.tlb#OLE Automation"
                    
            For i = 1 To 3000
                sClassName = "Class" & i
                sFileName = sPath & sClassName & ".cls"
                CreateHugeProject_Class sClassName, sFileName
                .AppendNL "Class=" & sClassName & "; " & sClassName & ".cls"
            Next i
            
            .AppendNL "Startup=""Sub Main"""
            .AppendNL "HelpFile="""""
            .AppendNL "Command32="""""
            .AppendNL "Name=""MyHugeProject"""
            .AppendNL "HelpContextID=""0"""
            .AppendNL "CompatibleMode=""0"""
            .AppendNL "MajorVer=1"
            .AppendNL "MinorVer=0"
            .AppendNL "RevisionVer=0"
            .AppendNL "AutoIncrementVer=0"
            .AppendNL "ServerSupportFiles=0"
            .AppendNL "VersionCompanyName=""TEST"""
            .AppendNL "CompilationType=0"
            .AppendNL "OptimizationType=0"
            .AppendNL "FavorPentiumPro(tm)=0"
            .AppendNL "CodeViewDebugInfo=0"
            .AppendNL "NoAliasing=0"
            .AppendNL "BoundsCheck=0"
            .AppendNL "OverflowCheck=0"
            .AppendNL "FlPointCheck=0"
            .AppendNL "FDIVCheck=0"
            .AppendNL "UnroundedFP=0"
            .AppendNL "StartMode=0"
            .AppendNL "Unattended=0"
            .AppendNL "Retained=0"
            .AppendNL "ThreadPerObject=0"
            .AppendNL "MaxNumberOfThreads=1"
            
            sFileName = sPath & "MyHugeProject.vbp"
            New_c.FSO.WriteTextContent sFileName, .ToString()
        End With
        
    End Sub
    
    Private Sub CreateHugeProject_Class(ByVal sClassName, ByVal sFileName As String)
    
        With New_c.StringBuilder
            .AppendNL "VERSION 1.0 CLASS"
            .AppendNL "BEGIN"
            .AppendNL "  MultiUse = -1  'True"
            .AppendNL "  Persistable = 0  'NotPersistable"
            .AppendNL "  DataBindingBehavior = 0  'vbNone"
            .AppendNL "  DataSourceBehavior  = 0  'vbNone"
            .AppendNL "  MTSTransactionMode  = 0  'NotAnMTSObject"
            .AppendNL "END"
            .AppendNL "Attribute VB_Name = """ & sClassName & """"
            .AppendNL "Attribute VB_GlobalNameSpace = False"
            .AppendNL "Attribute VB_Creatable = True"
            .AppendNL "Attribute VB_PredeclaredId = False"
            .AppendNL "Attribute VB_Exposed = False"
            .AppendNL "Option Explicit"
            '.AppendNL STR_NULL
                
            New_c.FSO.WriteTextContent sFileName, .ToString(), True
            
        End With
        
    End Sub
    Last edited by SearchingDataOnly; Apr 7th, 2021 at 07:28 AM.

  19. #19
    PowerPoster wqweto's Avatar
    Join Date
    May 2011
    Location
    Sofia, Bulgaria
    Posts
    5,169

    Re: In a very large project, how to deal with thousands of interface classes?

    Quote Originally Posted by SearchingDataOnly View Post
    For example, I can merge many classes into the "class factory"
    Merge several coclasses implementation into a single .bas module, not a class factory.

    Quote Originally Posted by SearchingDataOnly View Post
    . . . but this doesn't seem to work for interface classes. Maybe we should still consider how to use TLB to define a large number of interfaces and classes.
    A typelib shoud be ok declaring thousands of interfaces that could be implemented in some hundreds of .bas modules only.

    cheers,
    </wqw>

  20. #20

    Thread Starter
    Frenzied Member
    Join Date
    Aug 2020
    Posts
    1,447

    Re: In a very large project, how to deal with thousands of interface classes?

    Quote Originally Posted by wqweto View Post
    Merge several coclasses implementation into a single .bas module, not a class factory.
    Thank you for your correction, wqweto.

    Quote Originally Posted by wqweto View Post
    A typelib shoud be ok declaring thousands of interfaces that could be implemented in some hundreds of .bas modules only.
    It's a good idea. It seems that I have to learn how to use VTable and how to create TLBs (I've been avoiding these Windows proprietary technologies). This can solve the problem of thousands of interface classes. For ordinary vb-classes, besides merging them into bas modules, is there any other better way? Thanks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width