http://qs321.pair.com?node_id=642143


in reply to Re^4: Hide Data based on account
in thread Hide Data based on account

It is clear you need to define some form of permission map and decide how to implement it. The problem is; what strategy to use.

Ask ten developers and get ten answers, most of which won't apply to your specific situation. It really boils down to what you are willing and capable of doing with the resources you have. If you find that the components you have don't supply enough information to make a decision in every case, then you are going to have to develop that yourself. If you do have all the information, but don't have a strategy to implement the decisions, START SIMPLE.

It is not a sin to have your entire logic tied to an IF logic tree, especially initially. Don't over-complicate your solution just because you are looking for elegance. If elegance comes to you, and it provides the solution you are looking for, well... excellent!

A strategy that is useful is compartmentalizing. If you have this THING that needs to only show when a set of values align. Go for it. Make it a TRUE/FALSE subroutine, and then move on. Solve each situation similarly. You are bound to find some overlap. When it is natural, combine or re-use. As you go along, some patterns may emerge that speaks to you of a clear and elegant solution to large portions of your already written logic. Good for you.

The sin will be worrying about optimizations and elegance too early. Don't do that. It will drive you insane. Start simply, make sure it completely works for the situation it was designed for and move on. If you write readable code, comment where necessary, and don't sweat the beauty of it all, you may find you have created a completely suitable solution after all.