Other Parts of This Series: Part 2: Becoming a Pragmatic (Better) Programmer - Part 2 (Design, Implement, Debug) Pragmatic Programmer (Photo Credit: Unsplash)
Story Remember the guy Ismael from the previous part? He was good at broad-level thinking while coding and efficiently designing software. Today he shares some tips and tricks for making code decoupled and concurrent.
Decouple and Concurrent Coding Tips Maintain SRP (single responsibility principle) and reduce inter-component dependency, because decoupled code is easier to change. Depend on internal state, not external, which means call some component, and this will tell something. But donât ask external components for internal decision-making. Donât chain method calls to do something; instead, create a pipeline based on data. Avoid global data; if itâs extremely important, then wrap global data into an API. Use well-designed patterns and programming paradigms according to business needs. Donât pay inheritance tax, which means avoid inheritance as much as possible. Use interfaces to achieve polymorphism. Prefer composition over inheritance, meaning create Has-A relationships, not Is-A, whenever possible. Frequently changed values should be parameterized using an external configuration service. Analyze workflow to improve concurrency. Use an activity diagram for better understanding of concurrent workflow. Be very aware of the shared states, and remember random failures are often concurrency issues. Use blackboards and pen and paper for high-level analysis of workflow. Story Osama is an experienced software developer currently playing the team lead role. But despite being a team lead, he is actively coding regularly. Because he loves coding. He has a very good track record of following good coding practices and is also known as a âpro-coderâ in his colleaguesâ circle.
...