Home > Software engineering >  Ever study function decomposition tool automatically
Ever study function decomposition tool automatically

Time:09-16

Ever study function decomposition tool automatically? The multiple modules in a programming project with every process of the function code "decomposition" extracted, the form, the module decomposition, and came to
Goal is like doing a phone circuit board of the CPU, memory and other automatic screen and dismantling of intelligent robot,
To carry out the basis of programming elements, and then do highly integration, improve the reusability of the code, forms, modules do write once a permanent use, the purpose of reach 1 + 1=2, 2 + 2=4100 times after that will be infinite, 1 + 1 + 1 + * *, is only 100 times 100. If your salary this month 10000, 20000 over the next month, the * * * *

CodePudding user response:

English proverb says that the No Silver Bullet, there is a book called the, translated into Chinese is called "No Silver Bullet"
The "silver bullet" can mean many things, including the lz said,

CodePudding user response:

You open a pile of old iphone 5, these parts can be combined one can use the iphone 5,
You open a pile of scrap note2, these parts can be combined out of a can use note2,
You put the iphone 4 and note2 parts heap together, you in addition to the iphone 5 and note2 doesn't spell out a new aircraft, because of their internal interfaces, holes, size is not standardized, in addition to a pile of own, and others are not compatible, unless you modify these modules and, of course, does not rule out some of the same chip can be used interchangeably, because they have the same input and output, the same internal logic, appearance is the same size...
The same to our program, you put your function exactly copy to other project can immediately use in it? Public functions, in addition to some standard API can be replaced, such as but the chip could replace the code unless function version, or we have what good replacement,

CodePudding user response:

Dismantle the iphone 5 cannot be used for IHPONE8, it is like a VB6 code cannot be used for VB.NET,
But VB6 is equivalent to the iphone 5, all of the code are interchangeable, 20 years and the products have been alive,
Of course can also be directly up to VB.NET, on the same principle,
Write a code analysis tool, the module disassembly, and dismantling function again, end each line of variable, string universal recognition,
Just want to find a code tools, some of the online download the dismantling of the construction, the useful function to use, but in general, copied out by hand also enough,
Want to save

CodePudding user response:

Such as the following function, how did it come apart analysis,
FUNCTION types, SUB or FUNCTION
There are a few parameters, each parameter type, if there is a default value, function used several variables
The function into the standard of writing format, put all of the variables defined in the function of the front,
How to write a code to achieve the function?

 Private _ 
The Function jia2 (a As Long, _
ByVal b As Long As the Integer 'addition function
Jia=a + b: Dim k As Long: k=3
Dim S: S='88382' "Chinese", "
End _
The Function

CodePudding user response:

Advance the dim, wrote you a try,
Later don't think is too early, give you the format indentation also made a sample, just a example, the inside of the key column is not complete, needed to add,
Suppose you input is the function or sub ha, other you add code,
As to extract parameter number, too lazy to write the code, is the first line to take () in the middle of the part with a comma split, and then go over it one by one analysis,


 
Option Explicit

Private Sub Command1_Click ()
Dim strTest As String
StrTest=strTest & amp; "Private _" & amp; VbCrLf
StrTest=strTest & amp; "The Function jia2 (a As Long, _" & amp; VbCrLf
StrTest=strTest & amp; "ByVal b As Long As an Integer) 'addition function" & amp; VbCrLf
StrTest=strTest & amp; "Jia=a + b: Dim k As Long: k=3" & amp; VbCrLf
StrTest=strTest & amp; "Dim S: S=" "Chinese" "' 88382 ':" & amp; VbCrLf
StrTest=strTest & amp; "If 1=1 then" & amp; VbCrLf
StrTest=strTest & amp; "For I=1 to 100" & amp; VbCrLf
StrTest=strTest & amp; "Doevents: debug. Print" I & amp; VbCrLf
StrTest=strTest & amp; "Next" & amp; VbCrLf
StrTest=strTest & amp; "Then elseif 1=2" & amp; VbCrLf
StrTest=strTest & amp; "Doevents: debug. Print" I & amp; VbCrLf
StrTest=strTest & amp; "Else" & amp; VbCrLf
StrTest=strTest & amp; "Doevents: debug. Print" I & amp; VbCrLf
StrTest=strTest & amp; "End if" & amp; VbCrLf
StrTest=strTest & amp; "End _" & amp; VbCrLf
StrTest=strTest & amp; "Function"

The Debug. Print strTest
The Debug. Print vbCrLf & amp; "Separation line -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- -- --" & amp; VbCrLf
The Debug. Print formatVBcode (strTest)
End Sub
Private Function formatVBcode (ByVal strin As String) As String

Dim strTmp As String
Dim aryTmp () As String
Dim colcode As New Collection
Dim As Long, I j As Long
Dim lngDimRow As Long, lngTabCnt As Long
Dim strTab As String
'fuck all line connection
StrTmp=Replace (strin, "_" & amp; VbCrLf, "")
'fuck the colon in parallel, of course, this may be the string on the inside of the colon is fold line, improved by oneself,
StrTmp=Replace (strTmp, ":", vbCrLf)
'according to the split line
AryTmp=Split (strTmp, vbCrLf)
'go blank lines, a space before and after, and then into my personal favorite collection
For I=LBound (aryTmp) To UBound (aryTmp)
If aryTmp (I) & lt;> "" Then
Colcode. Add Trim (aryTmp (I))
End the If
Next

LngDimRow=2


For I=2 To colcode. Count - 1 'first and second lines too lazy To deal with,
If GetKeyWord (colcode (I))="DIM" Then 'DIM, and moved to the front to
Colcode. Add colcode (I), and lngDimRow
Colcode. Remove the I + 1
End the If
Next

'add indentation, output
LngTabCnt=1
FormatVBcode=formatVBcode & amp; Trim (colcode (1)) & amp; VbCrLf
For I=2 To colcode. Count - 1 'first and second lines too lazy To deal with,
StrTab=Replace (Space (lngTabCnt * 4), "", vbTab) 'need to indent the TAB
If GetKeyWord (colcode (I))="If" Or GetKeyWord (colcode (I))="FOR" Then 'experts who met the If and the FOR the subsequent one indentation, of course, there are other keywords, add, too lazy to write the
FormatVBcode=formatVBcode & amp; StrTab & amp; Colcode (I) & amp; VbCrLf 'plus bank indentation
LngTabCnt=lngTabCnt + 1
ElseIf GetKeyWord (colcode (I))="NEXT" Or GetKeyWord (colcode (I))='END' Then 'bank and subsequent forward one
LngTabCnt=lngTabCnt - 1
StrTab=Replace (Space (lngTabCnt * 4), "", vbTab)
FormatVBcode=formatVBcode & amp; StrTab & amp; Colcode (I) & amp; VbCrLf
ElseIf GetKeyWord (colcode (I))="ElseIf" Or GetKeyWord (colcode (I))="ELSE" Then 'and subsequent indent the same bank
StrTab=Replace (Space ((lngTabCnt - 1) * 4), "", vbTab)
FormatVBcode=formatVBcode & amp; StrTab & amp; Colcode (I) & amp; VbCrLf
The Else
FormatVBcode=formatVBcode & amp; StrTab & amp; Colcode (I) & amp; VbCrLf
End the If
Next
FormatVBcode=formatVBcode & amp; Trim (colcode (colcode. Count - 1))

End the Function

nullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnullnull
  • Related