DEV Community

Cover image for Essential Senior Dev Skill: Solving Problems With Patterns

Essential Senior Dev Skill: Solving Problems With Patterns

James Hickey on July 02, 2019

Let's continue with the "Stages Of Your Software Development Career" series! I find the senior developer career stage one of the most interesting ...
Collapse
 
skyjur profile image
Ski • Edited

In most scenarios I would rather modify config adding threads/processes and/oo add servers than take risk and waste my time heavily modifying legacy code such as converting to async unless there is plenty of time planned and it's worth to pursue this undertaking. Computers are not people like chefs in kitchen they don't cost a lot.

Collapse
 
jamesmh profile image
James Hickey

Actually, it wouldn't be hard at all. I actually had already changed TONS of other places in the same codebase to use async. It's just an unfortunate reality that sometimes people jump the gun without considering what the root cause of an issue is and how that can be solved well - and that other people have the knowledge to make the right change.

In web apps, you usually cannot simply add "more threads" since the thread pool is a static size. If you have to add more (some pools allow that), then something more fundamental is probably very wrong with the app in question.

There's also the issue of improving code quality overall (which, for most legacy systems, in particular, I would say is a win).

So I guess I disagree πŸ˜‹

Collapse
 
skyjur profile image
Ski • Edited

I don't disagree with your. I'm sure having details of situation you made correct decision. You mentioned it was legacy application but from your comment it sounds like it's actually actively maintained application without too many problems I wonder makes it "legacy". Upgrading some old applications to async can be very painful. For example it might require upgrading legacy libraries to more modern ones that will have radically different interfaces (http, database drivers, ORMs, etc). If thread locals were in use this will need to be upgraded to different approach. If transactions are in use then db connection needs to be locked to async context. If code is littered with long-spanning transactions then this first needs to be broken down before considering upgrade to async flow otherwise async will bring no benefits. These are just some things I would expect to find in legacy application.

In web apps, you usually cannot simply add "more threads" since the thread pool is a static size

Static pool size is usually configured through config that what I meant by saying "adding more threads" sorry if didn't made it clear.

Thread Thread
 
jamesmh profile image
James Hickey

I think you've made a lot of good points there. Some legacy apps are really messy, tangled and use some poor practices.

I suppose it would also depend on how central such a system is to a business. Does it represent the "core" of the business?

If so, I would think it's worth more to invest time into improving the quality.

If not, or it's just not being maintained, etc... then perhaps not so much, as you said

I would agree, that in the cases you described it's really hard to add async stuff 😜.

I think perhaps where we disagree is about how often these near un-maintainable applications appear? I really wouldn't know what the overall percentage is...

And in some cases, we aren't talking about adding async, but just code quality in general.

I guess it's all about trade-offs. Is there a real benefit that will save the company money long-term?

I'd say we're both right - it just depends!

Thanks for the comments! πŸ‘Œ

Collapse
 
radumg profile image
Radu Gidei

Always enjoy your well-written posts James.
For the real-world references/analogies, it might be useful to reference that design patterns actually came from the architectural field, coined by Christopher Alexander in his "A Pattern Language" book. Things like "Facade" patterns suddenly start making sense :)

en.wikipedia.org/wiki/A_Pattern_La...

Collapse
 
raminahmadi1986 profile image
Ramin Ahmadi

Thank you for your post, it is brilliant. I really enjoyed reading your series.

Collapse
 
jamesmh profile image
James Hickey

Thanks for the kind words Ramin! πŸ™‚

Collapse
 
victorhazbun profile image
Victor Hazbun

Fantastic blog post, I like how you compared software to physical world stuff (makes it very simple to understand when to use patterns). Thanks for sharing.

Collapse
 
jamesmh profile image
James Hickey

Thanks for the kind words Victor! πŸ‘

Collapse
 
kyleuk profile image
Kyle-uk • Edited

Thanks, I am getting closer to senior dev and really enjoying design patterns and the benefits they bring. I would recommend "Clean code" to anyone researching this topic.

Collapse
 
jamesmh profile image
James Hickey

Welcome!

Collapse
 
anduser96 profile image
Andrei Gatej

Even though I’ve read this article from a β€œjunior” dev’s perspective, I enjoyed it very much!
I’ll reread this article in different stages of my career.

Thanks for sharing!

Collapse
 
jamesmh profile image
James Hickey

You're welcome!

Collapse
 
jamesmh profile image
James Hickey

You're welcome Dave! Glad you found this helpful πŸ‘