Hi kotliners, I’m going to model permission rules....
# announcements
f
Hi kotliners, I’m going to model permission rules. Nothing difficult per-se but since the “source of truth” is a spreadheet with rows “object status” and columns “user role” and cells “grant/deny” I was wondering if I should build a representation close to this so it is easier to visually compare with that spreadsheet source of truth. Anything better suited in kotlin than having and array of arrays for this? It is all static and only a 5x8 table.
m
depends on how readable you'd want it. What does permissionRules[1][2] say? (That's access to one cell) What are the different object statusses? What are the different User Roles?
b
Represent a row as object and store it as
List<RowClass>
. Or if you want header colomn
Map<String, RowClassForNonHeaderColumns>
This way you can use type safe representations of your columns. e.g.
String
,
Int
,
Enum
f
(sorry for the delay. work..)
depends on how readable you’d want it.
What does permissionRules[1][2] say? (That’s access to one cell)
It would say granted true/false
Ok, I see some kind of array of array or array of list is the best to try. the type-safe builder look like more suitable for tree models.
j
Use data classes so that you have typesafe immutable representations with significant names for the underlying data, and then design your interface based on your lookup needs. For such a small table, you can get away with a List and just do a linear search. If it gets any bigger, put it into a Map with your search criteria as the key. Do not model it as a table, create a domain model and override toString() to spit out a table representation