need help on refactoring/design dilenma

G

GS

I am still a novice in vb .net 2. actually in vb.net period. please bear
with me.

Problem:
I often found myself refereeing to common utility like setStatus and logs on
the form, and the application title in some messages.


Question. how should I best avoid that ?
my kludge is using fully qualified name My.Forms.myformname.whatever

also, I found myself with some rather large sub(procedure) dealing with
specific spreadsheet. When I tried breaking it down I found myself faced
with either
- passing row and column numbers, and the performance hit of creating /
releasing extra com objects to deal with excel objects or
-used non cls compliant parameter passing


Your input will be much appreciated


Background Info :

I am dealing with an application that has a main form with a few tab pages.
I am trying to partition the code so I can have more manageable smaller
modules or classes.

I expect there will be in excess of 10,000 lines of the code in the version
1. in version 2 probably 20,000..

for the full blown version, I expect around 40,000. the application is
basically a tracking, analysis, and reporting system that also interfaces
with a number of external web No they are not soap based. some are heavily
dependent on jscript for formatting html. worse, the application also have
to load saved html pages, historical spreadsheets for extraction

The application is to extract information from a number of external
website, store result in database and format spreadsheets, charts for
reporting.

Ideally I would like classes or modules dealing with different object

..
 
C

Cor Ligthert [MVP]

GS,

If I understand you well, than is my advice, make classes and instance
objects from it for your data.

Than you have only to pass that object through all the methods.

If you want follow up, than tell that, I am sure I am not the only one who
can help you with this. (As most things).

Cor
 
G

GS

delighted to hear from you Cor. thank you,

Yes I do need more help

I can pass webbrowser cotnrol on the main form by value around as object. is
that an example of instance of data object?



I still fail to see how I can apply the idea of classes and instance object
for some excel automation.


for example I have setup a module for creating excel application, handling
basic initialization, com object release, etc.

however I still have procedure that does basically 3 things,
- copy and paste from webrowser to excel
- searching and adjust the pasted spreadsheet for processing below
- loop through the range found in previous step to
a) make appropriate changes and calculating subtotals, grand totals,
extract to arrays
here I can see data object instances being used here for
updating the database
b) make adjustment to the range as required during the process of
deleting unwanted columns and rows
- from the array of web links
.....
just the step 2 and 3 above without the database code already contain about
200 lines of code. I would love to break that down.

however that would mean I would
either pay the performance hit of creating/releasing excel com objects
or
being non cls compliant
 
C

Cor Ligthert [MVP]

I was thinking about something like this, you pass everytime only the small
reference of the object.

\\\
'Simple routine to start as console program
'And all on one page
'Need some references
Module First
Public Sub Main()
Dim myRunner As New Runner
myRunner.StartMyRunner()

End Sub
End Module

'This is what I want to show
Public Class Runner
Public Sub StartMyRunner()
Dim MyData As New DataHolder("Francis", "Hollywood")
DoConnectionToExcel(MyData)
End Sub

Public Sub DoConnectionToExcel(ByVal TheDate As DataHolder)
'do the connection to excel and use theData
'when it comes back
TheDate.Age = 21 'of course from Excel
ShowTheDate(TheDate)
End Sub
Private Sub ShowTheDate(ByVal Information As DataHolder)
MessageBox.Show("The data is " & Information.Name _
& " " & Information.Age.ToString)
'Here goes the object out of scope and will be done by the GC
End Sub

End Class
Public Class DataHolder
Public Sub New(ByVal Name As String, ByVal City As String)
mName = Name
mCity = City
End Sub
Private mName As String
Private mCity As String
Private mAge As Integer
Public ReadOnly Property Name() As String
Get
Return mName
End Get
End Property
Public Property Age() As Integer
Get
Return mAge
End Get
Set(ByVal Value As Integer)
mAge = Value
End Set
End Property
End Class
////
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top