12

My boss introduced a new design pattern at work. I couldn't find this design pattern anywhere else, and I don't find it useful at all. I'm the only one using it, but my coworkers seem confused by it as well when they look at my code or have my boss explain the pattern to them. I have serious concerns about this design pattern making our code difficult to maintain. I have a solution to the same problem that I think is much simpler, but I don't know how to start the conversation about it with my boss.

I've completed each task she's assigned me to do with this pattern for about a month, and she has explained the pattern to me several times. I still think there's a significantly better way to do things.

I don't want to work with this design pattern again, so what can I do?

  • 3
    1) What's the pattern? (The fact that you haven't encountered it doesn't mean it's invalid.) 2) Who's the architect for your portion of the code? 3) did the architect select this pattern? If so, ask them why. If not, ask them whether it makes sense in the larger context of the code. If it does, learn to like it, or at least tolerate it. If it doesn't, they're in a better position to recommend alternatives than you are. – keshlam Jul 29 '15 at 2:19
  • @keshlam 1) The same form has a lot of different access points on our site. We use the page object pattern to test these forms. The pattern is called "Bridge", but it is completely different than the Bridge pattern you'll find from a Google search. The pattern is this: have several constructors in the bridge class, which make it easy to reach the form from different access points. The bridge class will create the form page object, and it also gives you access to it. – michaelsnowden Jul 29 '15 at 2:31
  • @keshlam 1 continued) The problem is that this causes a lot of middleman code when we want to use the form because we have to rewrite each method from the form in the bridge class. In my opinion, it would be much easier to have a form factory, and then we wouldn't have any middleman code, but we could still reach the form from any access point. 2 and 3) There is no architect--it's just my boss. – michaelsnowden Jul 29 '15 at 2:32
  • 1
    Sounds like a sort of factory pattern - take a look at "abstract factory". Interface your factories and then you can add / remove different factories to create your concrete object(s) in different ways. – James Jul 29 '15 at 11:53
  • 1
    TELL HIM TO CODE IT HIMSELF (or not, if you wanna keep your job) – SE13013 Aug 18 '15 at 18:40
18

If you don't like what's being proposed you need to draw up precisely what the alternative would be., then ask "I'm confused. I presume there's a usage pattern or efficiency concern that I'm missing, because I would have expected this to be easier to write, use, and maintain. Can you help me understand why it isn't?"

You may learn that there was indeed something you're missing -- which may be as arbitrary as following the style previously established by something similar.

Or, seeing the alternatives, folks may decide you've got a valid point.

Or the answer may be that you've got a valid point but after consideration the decision remains unchanged. At which point your choices are to code to the spec, try to get assigned to something else, or quit. Part of coding as a team is learning that, in the end, some of it isn't going to match your preferences and you sometimes need to just hold your nose and deal with that or the product never gets out the door.

1

Since no one else is using it, why should you? Having just a basic understanding is no reason to put it into production code. See if the team prefers your solution and go with it.

Patterns can be a dangerous thing if they're not used properly and the only way to use them properly is to understand them. With so many questions being asked by all the devs and only one (you) being able to apply the pattern, it seems obvious the understanding is limited. Your boss should be aware of this.

You should be concerned that other developers won't be able to maintain this code. If you don't know why this pattern is being used (And why didn't you ask that when you were shown how to use it?), it may be difficult to maintain and expand.

0

I've worked at a company where the boss frequently changed design patterns or allowed people to use their own "design pattern" without ever consulting anyone or having a team meeting. This person would go out to conferences and come back with the idea and try to make it their own "idea" to promote and gain approval from upper management that they're using the "latest and greatest" development and that they're the "experts" of this.

It sounds like you're at the company I was at. Everyone is working differently then suddenly you have to share the code and maintain something else in a completely different "pattern."

In the end the code was a mess. New people could barely understand what is going on because there's two, three different pattern in a pattern and none of it is the same.

My thought is this: if you are constantly doing this, I would seriously consider a new job.

Not the answer you're looking for? Browse other questions tagged or ask your own question.