Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. The Lounge
  3. Encapsulation, is it so hard?

Encapsulation, is it so hard?

Scheduled Pinned Locked Moved The Lounge
jsonasp-netdata-structuresregexoop
14 Posts 7 Posters 1 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • honey the codewitchH honey the codewitch

    Please when you write parsers, separate your parsing logic from the rest of your app's logic so the app's main code isn't actually tied directly to your parser's grammar! I mean, I get there's going to be some intermingling between different areas of your code but when I crack open a project, and I find a codebase where every section of the app is intimately tied to every other section of the app it's really frustrating. For example, the parser in this case returns LexSpan classes which hold a text buffer, and start and end positions within that buffer. Great for parsing, so you know where your fragments of text are. But then when you build say, your Regex syntax tree with it, DO NOT use LexSpans as your member fields! unpack the values therein for witch's sake! Now if i want to implement a different parser i have to completely tear apart the app's core logic. Lovely.

    Real programmers use butterflies

    R Offline
    R Offline
    RugbyLeague
    wrote on last edited by
    #3

    I don't think I have ever seen lexer/parser code which wouldn't struggle to pass most code reviews.

    L 1 Reply Last reply
    0
    • honey the codewitchH honey the codewitch

      Please when you write parsers, separate your parsing logic from the rest of your app's logic so the app's main code isn't actually tied directly to your parser's grammar! I mean, I get there's going to be some intermingling between different areas of your code but when I crack open a project, and I find a codebase where every section of the app is intimately tied to every other section of the app it's really frustrating. For example, the parser in this case returns LexSpan classes which hold a text buffer, and start and end positions within that buffer. Great for parsing, so you know where your fragments of text are. But then when you build say, your Regex syntax tree with it, DO NOT use LexSpans as your member fields! unpack the values therein for witch's sake! Now if i want to implement a different parser i have to completely tear apart the app's core logic. Lovely.

      Real programmers use butterflies

      G Offline
      G Offline
      GuyThiebaut
      wrote on last edited by
      #4

      Sounds like you need to send Uncle Bob around to visit them...

      “That which can be asserted without evidence, can be dismissed without evidence.”

      ― Christopher Hitchens

      1 Reply Last reply
      0
      • R RugbyLeague

        I don't think I have ever seen lexer/parser code which wouldn't struggle to pass most code reviews.

        L Offline
        L Offline
        Lost User
        wrote on last edited by
        #5

        Mine got a commendation ... :-\

        1 Reply Last reply
        0
        • OriginalGriffO OriginalGriff

          Take yourself to QA, and peruse a few dozen questions before you ask that. Most of 'em can't spell "Emcapsull..." "Encapcalation" "Encrapsilating" "Encapsuoolasion" the word let alone use it!

          "I have no idea what I did, but I'm taking full credit for it." - ThisOldTony AntiTwitter: @DalekDave is now a follower!

          L Offline
          L Offline
          Lost User
          wrote on last edited by
          #6

          OriginalGriff wrote:

          Most of 'em can't spell "Emcapsull..." "Encapcalation" "Encrapsilating" "Encapsuoolasion" the word let alone use it!

          can be a bit tricky, so I do the other ting thng one.

          after many otherwise intelligent sounding suggestions that achieved nothing the nice folks at Technet said the only solution was to low level format my hard disk then reinstall my signature. Sadly, this still didn't fix the issue!

          1 Reply Last reply
          0
          • honey the codewitchH honey the codewitch

            Please when you write parsers, separate your parsing logic from the rest of your app's logic so the app's main code isn't actually tied directly to your parser's grammar! I mean, I get there's going to be some intermingling between different areas of your code but when I crack open a project, and I find a codebase where every section of the app is intimately tied to every other section of the app it's really frustrating. For example, the parser in this case returns LexSpan classes which hold a text buffer, and start and end positions within that buffer. Great for parsing, so you know where your fragments of text are. But then when you build say, your Regex syntax tree with it, DO NOT use LexSpans as your member fields! unpack the values therein for witch's sake! Now if i want to implement a different parser i have to completely tear apart the app's core logic. Lovely.

            Real programmers use butterflies

            Richard DeemingR Offline
            Richard DeemingR Offline
            Richard Deeming
            wrote on last edited by
            #7

            honey the codewitch wrote:

            LexSpan classes which hold a text buffer, and start and end positions within that buffer

            So, a ReadOnlySpan<char>[^], but not as efficient? :)


            "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

            "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

            honey the codewitchH 1 Reply Last reply
            0
            • Richard DeemingR Richard Deeming

              honey the codewitch wrote:

              LexSpan classes which hold a text buffer, and start and end positions within that buffer

              So, a ReadOnlySpan<char>[^], but not as efficient? :)


              "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

              honey the codewitchH Offline
              honey the codewitchH Offline
              honey the codewitch
              wrote on last edited by
              #8

              Well in this I will defend them, as ReadOnlySpan is only available on the latest non-DNF framework

              Real programmers use butterflies

              Richard DeemingR 1 Reply Last reply
              0
              • honey the codewitchH honey the codewitch

                Well in this I will defend them, as ReadOnlySpan is only available on the latest non-DNF framework

                Real programmers use butterflies

                Richard DeemingR Offline
                Richard DeemingR Offline
                Richard Deeming
                wrote on last edited by
                #9

                It's available in DNF 4.5 or later via a NuGet package: NuGet Gallery | System.Memory 4.5.3[^] The DNC version has slightly better performance, because some of the BCL methods have been updated to use it. But the DNF version should be at least as good as rolling your own. :)


                "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                "These people looked deep within my soul and assigned me a number based on the order in which I joined" - Homer

                honey the codewitchH 1 Reply Last reply
                0
                • honey the codewitchH honey the codewitch

                  Please when you write parsers, separate your parsing logic from the rest of your app's logic so the app's main code isn't actually tied directly to your parser's grammar! I mean, I get there's going to be some intermingling between different areas of your code but when I crack open a project, and I find a codebase where every section of the app is intimately tied to every other section of the app it's really frustrating. For example, the parser in this case returns LexSpan classes which hold a text buffer, and start and end positions within that buffer. Great for parsing, so you know where your fragments of text are. But then when you build say, your Regex syntax tree with it, DO NOT use LexSpans as your member fields! unpack the values therein for witch's sake! Now if i want to implement a different parser i have to completely tear apart the app's core logic. Lovely.

                  Real programmers use butterflies

                  L Offline
                  L Offline
                  Lost User
                  wrote on last edited by
                  #10

                  Some patterns don't become obvious until later on. If you're not into constant refactoring (due to fatigue or whatever), things stay.

                  It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

                  honey the codewitchH 1 Reply Last reply
                  0
                  • honey the codewitchH honey the codewitch

                    Please when you write parsers, separate your parsing logic from the rest of your app's logic so the app's main code isn't actually tied directly to your parser's grammar! I mean, I get there's going to be some intermingling between different areas of your code but when I crack open a project, and I find a codebase where every section of the app is intimately tied to every other section of the app it's really frustrating. For example, the parser in this case returns LexSpan classes which hold a text buffer, and start and end positions within that buffer. Great for parsing, so you know where your fragments of text are. But then when you build say, your Regex syntax tree with it, DO NOT use LexSpans as your member fields! unpack the values therein for witch's sake! Now if i want to implement a different parser i have to completely tear apart the app's core logic. Lovely.

                    Real programmers use butterflies

                    D Offline
                    D Offline
                    dandy72
                    wrote on last edited by
                    #11

                    honey the codewitch wrote:

                    Please when you write parsers,

                    That's all I needed to read. You can take comfort in the fact that I've somehow managed to make it thus far in my programming career without ever having to write any sort of parser. Well, certainly not at the level you're dealing with.

                    honey the codewitchH 1 Reply Last reply
                    0
                    • Richard DeemingR Richard Deeming

                      It's available in DNF 4.5 or later via a NuGet package: NuGet Gallery | System.Memory 4.5.3[^] The DNC version has slightly better performance, because some of the BCL methods have been updated to use it. But the DNF version should be at least as good as rolling your own. :)


                      "These people looked deep within my soul and assigned me a number based on the order in which I joined." - Homer

                      honey the codewitchH Offline
                      honey the codewitchH Offline
                      honey the codewitch
                      wrote on last edited by
                      #12

                      That's interesting. At one point i heard the DNF couldn't support stack alloc'd ref types the way DNC could but maybe I heard wrong. Adding, the author intends to target .NET 2.0+ although i think that's a little silly.

                      Real programmers use butterflies

                      1 Reply Last reply
                      0
                      • L Lost User

                        Some patterns don't become obvious until later on. If you're not into constant refactoring (due to fatigue or whatever), things stay.

                        It was only in wine that he laid down no limit for himself, but he did not allow himself to be confused by it. ― Confucian Analects: Rules of Confucius about his food

                        honey the codewitchH Offline
                        honey the codewitchH Offline
                        honey the codewitch
                        wrote on last edited by
                        #13

                        i don't think this code was all that factored to begin with. I think was just intended to be a quick and dirty port of lex basically, but then grew from there

                        Real programmers use butterflies

                        1 Reply Last reply
                        0
                        • D dandy72

                          honey the codewitch wrote:

                          Please when you write parsers,

                          That's all I needed to read. You can take comfort in the fact that I've somehow managed to make it thus far in my programming career without ever having to write any sort of parser. Well, certainly not at the level you're dealing with.

                          honey the codewitchH Offline
                          honey the codewitchH Offline
                          honey the codewitch
                          wrote on last edited by
                          #14

                          I mean, aside from the regex the parsing isn't even that complicated, but the way it was built into the project just stinks.

                          Real programmers use butterflies

                          1 Reply Last reply
                          0
                          Reply
                          • Reply as topic
                          Log in to reply
                          • Oldest to Newest
                          • Newest to Oldest
                          • Most Votes


                          • Login

                          • Don't have an account? Register

                          • Login or register to search.
                          • First post
                            Last post
                          0
                          • Categories
                          • Recent
                          • Tags
                          • Popular
                          • World
                          • Users
                          • Groups