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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. The Lounge
  3. I have a horrible feeling I've been using a pattern for years...

I have a horrible feeling I've been using a pattern for years...

Scheduled Pinned Locked Moved The Lounge
comregextutorialquestionlearning
43 Posts 20 Posters 3 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.
  • L Lost User

    killbot5000 wrote:

    understandable by a college freshman in less than 2 weeks.

    If you can't explain your pattern in 5 minutes time, then you probably don't understand it. That is assuming that your freshman knows how to code :)

    killbot5000 wrote:

    Also, if anyone knows of a must-read regarding the use of factory-pattern, please share.

    That's the pattern I'm opening the article with. May take another day or two.

    killbot5000 wrote:

    I really hate it

    Yah, then you had the wrong explanation. Most important question to answer is always "what's in it for me?", and a factory has an easy to explain benefit :thumbsup:

    Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

    K Offline
    K Offline
    killbot5000
    wrote on last edited by
    #41

    If you can't explain your pattern in 5 minutes time, then you probably don't understand it.

    True enough. I was only trying to explain our somewhat informal guideline at work; a junior should be able to master any one of our projects in a maximum of 2 weeks time, without any help from a senior. In general, we don't trust juniors to correctly identify or implement various patterns, so we don't approach our code as such. But, of course, we do want juniors to be able to work for clients almost instantly. *grin* It's mostly an effort of gathering/vetting the right tools; ones that are easy to use, easy to test, and with a low code footprint. Around 90% of our R&D is spend on simplifying the way we do things. But, to come back to factory pattern: I hate it because it often seems the right choice, but, for me, it has never panned out. Every time I try it out, I end up over-designing my data models and adding an abstraction layer I don't really need. In the end, I usually remove it and end up with (almost embarrassingly..) simple classes with distinct data. It can be infuriating. I try to come up with a clever looking data structure, hope factory pattern fits the bill, and *boom* suddenly I see there's no need for abstraction whatsoever, vastly reducing my test code and simplifying my DB design. :(

    L 1 Reply Last reply
    0
    • K killbot5000

      If you can't explain your pattern in 5 minutes time, then you probably don't understand it.

      True enough. I was only trying to explain our somewhat informal guideline at work; a junior should be able to master any one of our projects in a maximum of 2 weeks time, without any help from a senior. In general, we don't trust juniors to correctly identify or implement various patterns, so we don't approach our code as such. But, of course, we do want juniors to be able to work for clients almost instantly. *grin* It's mostly an effort of gathering/vetting the right tools; ones that are easy to use, easy to test, and with a low code footprint. Around 90% of our R&D is spend on simplifying the way we do things. But, to come back to factory pattern: I hate it because it often seems the right choice, but, for me, it has never panned out. Every time I try it out, I end up over-designing my data models and adding an abstraction layer I don't really need. In the end, I usually remove it and end up with (almost embarrassingly..) simple classes with distinct data. It can be infuriating. I try to come up with a clever looking data structure, hope factory pattern fits the bill, and *boom* suddenly I see there's no need for abstraction whatsoever, vastly reducing my test code and simplifying my DB design. :(

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

      killbot5000 wrote:

      Every time I try it out, I end up over-designing my data models and adding an abstraction layer I don't really need.

      Might be easier to not try it until you need one. To find a scenario where the use of it would be beneficial, you'd need some decent example. The abstract examples didn't help me much.

      killbot5000 wrote:

      *boom* suddenly I see there's no need for abstraction whatsoever, vastly reducing my test code and simplifying my DB design. :(

      KISS is always the best choice. Someone else will inderstand it better when reading, updates are easier and less complicated, and less code in general means fewer bugs. I'll give you a ping when I'm done and posted it :)

      Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

      1 Reply Last reply
      0
      • K killbot5000

        I don't care for patterns in my code and I definitely don't care for vague terms like "clean" code. I only care for code that's short, safe to fail, easy to test, and understandable by a college freshman in less than 2 weeks. Nevertheless, please write about the patterns you think are worthwhile; preferably with a not-too-generic example. You might teach us something worthwhile. Also, if anyone knows of a must-read regarding the use of factory-pattern, please share. I really hate it and I'm looking for material to nuance my feelings towards it.

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

        As promised[^], with a not-too-generic example :)

        Bastard Programmer from Hell :suss: If you can't read my code, try converting it here[^]

        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