Best way to get rid of hungarian notation?

前端 未结 20 1345
萌比男神i
萌比男神i 2021-01-18 20:52

Let\'s say you\'ve inherited a C# codebase that uses one class with 200 static methods to provide core functionality (such as database lookups). Of the many nightmares in th

20条回答
  •  执笔经年
    2021-01-18 21:27

    I am actually doing the same thing here for an application extension. My approach has been to use VIM mappings to search for specific Hungarian notation prefixes and then delete them and fix capitalization as appropriate.

    Examples (goes in vimrc):

    "" Hungarian notation conversion helpers
    "" get rid of str prefixes and fix caps e.g. strName -> name
    map ,bs /\Wstr[A-Z]^Ml3x~
    map ,bi /\Wint[A-Z]^Ml3x~
    "" little more complex to clean up m_p type class variables
    map ,bm /\Wm_p\?[A-Z]^M:.s/\(\W\)m_p\?/\1_/^M/\W_[A-Z]^Mll~
    map ,bp /\Wp[A-Z]^Mlx~
    

提交回复
热议问题