HACKER Q&A
📣 leobg

How to get good at separation of concerns?


Any resources that help me build a better intuition for this? Also, any personal aha-moments you had in this regard?

Thanks.


  👤 dtagames Accepted Answer ✓
Sure. I'd say be aware of code smell as you write and read your own code. Look out for functions that have too many parameters.as they're probably doing too much. Avoid passing data to a function that it doesn't absolutely need. Be careful about returning complex variables. Don't write functions that do more than one thing. Avoid globals and closures. In general, functional style programming will naturally lead to better separation of concerns.

👤 aristofun
You can not get good at an abstract matter.

It just doesn’t work this way.

You get good at some specific activities and then maybe generalize the experience to the point where you’re able tov extrapolate it to something else.

In other words — first you need to answer what do ypu need this abstract skill for, what exact goal and then go get good at that specific thing.


👤 vivegi
If you are using a class based programming language, determining what must be a class member function versus a pure function helps with separation of concerns at the interface design stage.

An example of the above with C# might be determining what is a class member function versus an extension method.


👤 NicoJuicy
Perhaps a different perspective that could help.

The parameters that are used in the method are the only ones that are logical.

Eg. Looking up a car owner by license plate in a SaaS.

Yes for: license plate number, on ( datetime) and country code.

No for tenant ( eg. should be injected by Tenancy service).


👤 inphovore
Due to the critical nature of our minds, it is often easier to critique the code of others.

Take time to do some refactoring if you can.

Gradually you will impress upon yourself to take the initiative and do things right the first time (aka “the hard way”.)


👤 tomohawk
Tell others that you are particularly insterested in growing in this area before they review your code when you submit it, or ask someone to review code you have already written with this in mind.

👤 arunnanda
Mentally summarize the old context in 1-2 mins and then completely forget the old topic and focus 100% on the new one.

👤 bot41
Think in extremes and then dial it back to what is reasonable